diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go index 497a1f20..c1bf36db 100644 --- a/internal/rpc/rpc_client.go +++ b/internal/rpc/rpc_client.go @@ -304,6 +304,10 @@ func (this *RPCClient) ReportNodeRPC() pb.ReportNodeServiceClient { return pb.NewReportNodeServiceClient(this.pickConn()) } +func (this *RPCClient) ReportNodeGroupRPC() pb.ReportNodeGroupServiceClient { + return pb.NewReportNodeGroupServiceClient(this.pickConn()) +} + func (this *RPCClient) ReportResultRPC() pb.ReportResultServiceClient { return pb.NewReportResultServiceClient(this.pickConn()) } diff --git a/internal/web/actions/default/clusters/monitors/groups/options.go b/internal/web/actions/default/clusters/monitors/groups/options.go new file mode 100644 index 00000000..3a6b70e2 --- /dev/null +++ b/internal/web/actions/default/clusters/monitors/groups/options.go @@ -0,0 +1,32 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package groups + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/maps" +) + +type OptionsAction struct { + actionutils.ParentAction +} + +func (this *OptionsAction) RunPost(params struct{}) { + resp, err := this.RPC().ReportNodeGroupRPC().FindAllEnabledReportNodeGroups(this.AdminContext(), &pb.FindAllEnabledReportNodeGroupsRequest{}) + if err != nil { + this.ErrorPage(err) + return + } + + var groupMaps = []maps.Map{} + for _, group := range resp.ReportNodeGroups { + groupMaps = append(groupMaps, maps.Map{ + "id": group.Id, + "name": group.Name, + }) + } + this.Data["groups"] = groupMaps + + this.Success() +} diff --git a/internal/web/helpers/user_must_auth.go b/internal/web/helpers/user_must_auth.go index 9db6bad3..dbd2e9ec 100644 --- a/internal/web/helpers/user_must_auth.go +++ b/internal/web/helpers/user_must_auth.go @@ -246,12 +246,12 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map { "code": "ipAddr", "isOn": teaconst.IsPlus, }, - /**{ + { "name": "区域监控", "url": "/clusters/monitors", "code": "monitor", "isOn": teaconst.IsPlus, - },**/ + }, { "name": "SSH认证", "url": "/clusters/grants", diff --git a/web/public/js/components/report/report-node-groups-selector.js b/web/public/js/components/report/report-node-groups-selector.js new file mode 100644 index 00000000..f0748011 --- /dev/null +++ b/web/public/js/components/report/report-node-groups-selector.js @@ -0,0 +1,72 @@ +// 监控节点分组选择 +Vue.component("report-node-groups-selector", { + props: ["v-group-ids"], + mounted: function () { + let that = this + Tea.action("/clusters/monitors/groups/options") + .post() + .success(function (resp) { + that.groups = resp.data.groups.map(function (group) { + group.isChecked = that.groupIds.$contains(group.id) + return group + }) + that.isLoaded = true + }) + }, + data: function () { + var groupIds = this.vGroupIds + if (groupIds == null) { + groupIds = [] + } + + return { + groups: [], + groupIds: groupIds, + isLoaded: false, + allGroups: groupIds.length == 0 + } + }, + methods: { + check: function (group) { + group.isChecked = !group.isChecked + this.groupIds = [] + let that = this + this.groups.forEach(function (v) { + if (v.isChecked) { + that.groupIds.push(v.id) + } + }) + } + }, + watch: { + allGroups: function (b) { + if (b) { + this.groupIds = [] + this.groups.forEach(function (v) { + v.isChecked = false + }) + } + } + }, + template: `
+ + 还没有分组。 +
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
` +}) \ No newline at end of file diff --git a/web/views/@default/clusters/monitors/@menu.html b/web/views/@default/clusters/monitors/@menu.html index fdde0cbc..b0009406 100644 --- a/web/views/@default/clusters/monitors/@menu.html +++ b/web/views/@default/clusters/monitors/@menu.html @@ -1,5 +1,6 @@ - 任务 - 日志 + + 终端 + 分组 \ No newline at end of file diff --git a/web/views/@default/clusters/monitors/groups/createPopup.html b/web/views/@default/clusters/monitors/groups/createPopup.html new file mode 100644 index 00000000..d2d7637e --- /dev/null +++ b/web/views/@default/clusters/monitors/groups/createPopup.html @@ -0,0 +1,15 @@ +{$layout "layout_popup"} + +

创建分组

+
+ + + + + + +
分组名称 + +
+ +
\ No newline at end of file diff --git a/web/views/@default/clusters/monitors/groups/group/updatePopup.html b/web/views/@default/clusters/monitors/groups/group/updatePopup.html new file mode 100644 index 00000000..6c52986c --- /dev/null +++ b/web/views/@default/clusters/monitors/groups/group/updatePopup.html @@ -0,0 +1,16 @@ +{$layout "layout_popup"} + +

修改分组

+
+ + + + + + + +
分组名称 + +
+ +
\ No newline at end of file diff --git a/web/views/@default/clusters/monitors/groups/index.html b/web/views/@default/clusters/monitors/groups/index.html new file mode 100644 index 00000000..31020c50 --- /dev/null +++ b/web/views/@default/clusters/monitors/groups/index.html @@ -0,0 +1,23 @@ +{$layout} +{$template "../menu"} + + + [添加分组] + + +

暂时还没有分组。

+ + + + + + + + + + + +
分组名称操作
{{group.name}} + 修改   + 删除 +
\ No newline at end of file diff --git a/web/views/@default/clusters/monitors/groups/index.js b/web/views/@default/clusters/monitors/groups/index.js new file mode 100644 index 00000000..3d9d4052 --- /dev/null +++ b/web/views/@default/clusters/monitors/groups/index.js @@ -0,0 +1,31 @@ +Tea.context(function () { + this.createGroup = function () { + teaweb.popup(".createPopup", { + callback: function () { + teaweb.success("保存成功", function () { + teaweb.reload() + }) + } + }) + } + + this.updateGroup = function (groupId) { + teaweb.popup(".group.updatePopup?groupId=" + groupId, { + callback: function () { + teaweb.success("保存成功", function () { + teaweb.reload() + }) + } + }) + } + + this.deleteGroup = function (groupId) { + teaweb.confirm("确定要删除此分组吗?", function () { + this.$post(".group.delete") + .params({ + groupId: groupId + }) + .refresh() + }) + } +}) \ No newline at end of file diff --git a/web/views/@default/clusters/monitors/index.html b/web/views/@default/clusters/monitors/index.html index e896c845..db995186 100644 --- a/web/views/@default/clusters/monitors/index.html +++ b/web/views/@default/clusters/monitors/index.html @@ -1,2 +1,60 @@ {$layout} -{$template "menu"} \ No newline at end of file +{$template "menu"} + +
+ +
+
+
+ 集群: +
+
+ +
+
+ +
+
+
+ +

暂时还没有任务。

+ + + + + + + + + + + + + + + + + + + + +
节点IP端口综合延时综合级别综合连通率
+ {{task.node.name}} + + {{task.ip}} + + {{task.port}} + - + + {{task.costMs}}ms + - + + {{task.levelName}} + + {{task.connectivity}}% + - +
+ +
\ No newline at end of file diff --git a/web/views/@default/clusters/monitors/index.js b/web/views/@default/clusters/monitors/index.js new file mode 100644 index 00000000..d1d81411 --- /dev/null +++ b/web/views/@default/clusters/monitors/index.js @@ -0,0 +1,18 @@ +Tea.context(function () { + this.tasks.forEach(function (v) { + switch (v.level) { + case "good": + v.color = "green" + break + case "normal": + v.color = "blue" + break + case "bad": + v.color = "orange" + break + case "broken": + v.color = "red" + break + } + }) +}) \ No newline at end of file diff --git a/web/views/@default/clusters/monitors/reporters/createPopup.html b/web/views/@default/clusters/monitors/reporters/createPopup.html index 20ecb7e1..9001f952 100644 --- a/web/views/@default/clusters/monitors/reporters/createPopup.html +++ b/web/views/@default/clusters/monitors/reporters/createPopup.html @@ -5,11 +5,17 @@ - + + + + + diff --git a/web/views/@default/clusters/monitors/reporters/index.html b/web/views/@default/clusters/monitors/reporters/index.html index 00eb2e3a..3f09c9ac 100644 --- a/web/views/@default/clusters/monitors/reporters/index.html +++ b/web/views/@default/clusters/monitors/reporters/index.html @@ -7,11 +7,19 @@
+
+ +
+   + [清除条件]
@@ -33,6 +41,12 @@ - + @@ -33,10 +33,12 @@ + -
名称 *终端名称 *
所属分组 + +
{{reporter.name}} +
+
{{group.name}}
+
+
+ v{{reporter.status.buildVersion}} -> v{{reporter.newVersion}} +
{{reporter.location}} diff --git a/web/views/@default/clusters/monitors/reporters/reporter/index.html b/web/views/@default/clusters/monitors/reporters/reporter/index.html index 3c414840..6b2c8391 100644 --- a/web/views/@default/clusters/monitors/reporters/reporter/index.html +++ b/web/views/@default/clusters/monitors/reporters/reporter/index.html @@ -4,7 +4,7 @@ - + @@ -17,6 +17,15 @@ 在线 + + + + + + + +
名称终端名称 {{reporter.name}}
所属分组 +
+ {{group.name}} +
+ 全部分组 +
区域 @@ -42,6 +51,10 @@ 没有设置
版本号v{{reporter.status.buildVersion}}

安装信息

diff --git a/web/views/@default/clusters/monitors/reporters/reporter/index.js b/web/views/@default/clusters/monitors/reporters/reporter/index.js deleted file mode 100644 index e69de29b..00000000 diff --git a/web/views/@default/clusters/monitors/reporters/reporter/results.html b/web/views/@default/clusters/monitors/reporters/reporter/results.html index 491854b9..bf808346 100644 --- a/web/views/@default/clusters/monitors/reporters/reporter/results.html +++ b/web/views/@default/clusters/monitors/reporters/reporter/results.html @@ -24,7 +24,7 @@
类型 对象结果级别 耗时 错误信息
{{result.typeName}} {{result.targetDesc}} - 成功 - 失败 + {{result.levelName}} + + {{result.costMs}}ms + - {{result.costMs}}ms {{result.error}} - diff --git a/web/views/@default/clusters/monitors/reporters/reporter/results.js b/web/views/@default/clusters/monitors/reporters/reporter/results.js new file mode 100644 index 00000000..41d769d0 --- /dev/null +++ b/web/views/@default/clusters/monitors/reporters/reporter/results.js @@ -0,0 +1,18 @@ +Tea.context(function () { + this.results.forEach(function (v) { + switch (v.level) { + case "good": + v.color = "green" + break + case "normal": + v.color = "blue" + break + case "bad": + v.color = "orange" + break + case "broken": + v.color = "red" + break + } + }) +}) \ No newline at end of file diff --git a/web/views/@default/clusters/monitors/reporters/reporter/update.html b/web/views/@default/clusters/monitors/reporters/reporter/update.html index e7bc01a3..35f84b35 100644 --- a/web/views/@default/clusters/monitors/reporters/reporter/update.html +++ b/web/views/@default/clusters/monitors/reporters/reporter/update.html @@ -6,11 +6,17 @@ - + + + + + diff --git a/web/views/@default/dashboard/boards/index.html b/web/views/@default/dashboard/boards/index.html index acc469d2..3e95ed3c 100644 --- a/web/views/@default/dashboard/boards/index.html +++ b/web/views/@default/dashboard/boards/index.html @@ -35,6 +35,10 @@ 升级提醒:有 {{nsNodeUpgradeInfo.count}} 个DNS节点需要升级到 v{{nsNodeUpgradeInfo.version}} 版本 +
名称 *终端名称 *
所属分组 + +