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: `
暂时还没有分组。
+| 分组名称 | +操作 | +
|---|---|
| {{group.name}} | ++ 修改 + 删除 + | +
暂时还没有任务。
+ +| 节点 | +IP | +端口 | +综合延时 | +综合级别 | +综合连通率 | +
|---|---|---|---|---|---|
| 
+            {{task.node.name}} | 
+        
+            {{task.ip}} | 
+        + {{task.port}} + - + | ++ {{task.costMs}}ms + - + | ++ {{task.levelName}} + | ++ {{task.connectivity}}% + - + | +
| 名称 * | +终端名称 * | |||||||||
| 所属分组 | +
+                 | 
+        |||||||||
| 
              
+                 
+            {{group.name}} 
+            
+                v{{reporter.status.buildVersion}} -> v{{reporter.newVersion}}
+             
          | 
         
             
 安装信息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 @@
     
     
  | 
|---|---|---|---|---|---|---|---|---|---|---|