diff --git a/internal/web/actions/default/clusters/cluster/init.go b/internal/web/actions/default/clusters/cluster/init.go index 86d6407f..75eb756b 100644 --- a/internal/web/actions/default/clusters/cluster/init.go +++ b/internal/web/actions/default/clusters/cluster/init.go @@ -47,6 +47,7 @@ func init() { Get("/thresholds", new(thresholds.IndexAction)). Get("/detail", new(node.DetailAction)). GetPost("/boards", new(nodeboards.IndexAction)). + Post("/boards/data", new(nodeboards.DataAction)). GetPost("/updateDNSPopup", new(node.UpdateDNSPopupAction)). // 分组相关 diff --git a/internal/web/actions/default/clusters/cluster/node/boards/data.go b/internal/web/actions/default/clusters/cluster/node/boards/data.go new file mode 100644 index 00000000..154bb0d3 --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/node/boards/data.go @@ -0,0 +1,41 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package boards + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/maps" +) + +type DataAction struct { + actionutils.ParentAction +} + +func (this *DataAction) RunPost(params struct { + ClusterId int64 + NodeId int64 +}) { + resp, err := this.RPC().ServerStatBoardRPC().ComposeServerStatNodeBoard(this.AdminContext(), &pb.ComposeServerStatNodeBoardRequest{NodeId: params.NodeId}) + if err != nil { + this.ErrorPage(err) + return + } + + this.Data["board"] = maps.Map{ + "isActive": resp.IsActive, + "trafficInBytes": resp.TrafficInBytes, + "trafficOutBytes": resp.TrafficOutBytes, + "countConnections": resp.CountConnections, + "countRequests": resp.CountRequests, + "countAttackRequests": resp.CountAttackRequests, + "cpuUsage": resp.CpuUsage, + "memoryUsage": resp.MemoryUsage, + "memoryTotalSize": resp.MemoryTotalSize, + "load": resp.Load, + "cacheDiskSize": resp.CacheDiskSize, + "cacheMemorySize": resp.CacheMemorySize, + } + + this.Success() +} diff --git a/internal/web/actions/default/clusters/cluster/node/boards/index.go b/internal/web/actions/default/clusters/cluster/node/boards/index.go index 218a4fd0..617b00b3 100644 --- a/internal/web/actions/default/clusters/cluster/node/boards/index.go +++ b/internal/web/actions/default/clusters/cluster/node/boards/index.go @@ -38,7 +38,14 @@ func (this *IndexAction) RunGet(params struct { this.RedirectURL("/clusters/cluster/node?clusterId=" + strconv.FormatInt(params.ClusterId, 10) + "&nodeId=" + strconv.FormatInt(params.NodeId, 10)) return } + + this.Show() +} +func (this *IndexAction) RunPost(params struct { + ClusterId int64 + NodeId int64 +}) { resp, err := this.RPC().ServerStatBoardRPC().ComposeServerStatNodeBoard(this.AdminContext(), &pb.ComposeServerStatNodeBoardRequest{NodeId: params.NodeId}) if err != nil { this.ErrorPage(err) @@ -200,33 +207,5 @@ func (this *IndexAction) RunGet(params struct { this.Data["metricCharts"] = chartMaps } - this.Show() -} - -func (this *IndexAction) RunPost(params struct { - ClusterId int64 - NodeId int64 -}) { - resp, err := this.RPC().ServerStatBoardRPC().ComposeServerStatNodeBoard(this.AdminContext(), &pb.ComposeServerStatNodeBoardRequest{NodeId: params.NodeId}) - if err != nil { - this.ErrorPage(err) - return - } - - this.Data["board"] = maps.Map{ - "isActive": resp.IsActive, - "trafficInBytes": resp.TrafficInBytes, - "trafficOutBytes": resp.TrafficOutBytes, - "countConnections": resp.CountConnections, - "countRequests": resp.CountRequests, - "countAttackRequests": resp.CountAttackRequests, - "cpuUsage": resp.CpuUsage, - "memoryUsage": resp.MemoryUsage, - "memoryTotalSize": resp.MemoryTotalSize, - "load": resp.Load, - "cacheDiskSize": resp.CacheDiskSize, - "cacheMemorySize": resp.CacheMemorySize, - } - this.Success() } diff --git a/internal/web/actions/default/dashboard/boards/index.go b/internal/web/actions/default/dashboard/boards/index.go index e4cf3ac2..cbacf3cd 100644 --- a/internal/web/actions/default/dashboard/boards/index.go +++ b/internal/web/actions/default/dashboard/boards/index.go @@ -40,6 +40,11 @@ func (this *IndexAction) RunGet(params struct{}) { } } + this.Show() +} + +func (this *IndexAction) RunPost(params struct { +}) { // 读取看板数据 resp, err := this.RPC().AdminRPC().ComposeAdminDashboard(this.AdminContext(), &pb.ComposeAdminDashboardRequest{ ApiVersion: teaconst.APINodeVersion, @@ -249,5 +254,5 @@ func (this *IndexAction) RunGet(params struct{}) { this.Data["metricCharts"] = chartMaps } - this.Show() + this.Success() } diff --git a/internal/web/actions/default/dashboard/init.go b/internal/web/actions/default/dashboard/init.go index 9321f294..9e5c87fa 100644 --- a/internal/web/actions/default/dashboard/init.go +++ b/internal/web/actions/default/dashboard/init.go @@ -16,12 +16,11 @@ func init() { // 看板 Prefix("/dashboard/boards"). - Get("", new(boards.IndexAction)). + GetPost("", new(boards.IndexAction)). Get("/waf", new(boards.WafAction)). Post("/wafLogs", new(boards.WafLogsAction)). Get("/dns", new(boards.DnsAction)). Get("/user", new(boards.UserAction)). - EndAll() }) } diff --git a/internal/web/helpers/user_must_auth.go b/internal/web/helpers/user_must_auth.go index 9a01a7e1..7cde11fa 100644 --- a/internal/web/helpers/user_must_auth.go +++ b/internal/web/helpers/user_must_auth.go @@ -240,6 +240,18 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map { "url": "/clusters/logs", "code": "log", }, + /**{ + "name": "IP资源", + "url": "/clusters/ip-addrs", + "code": "ipAddr", + "isOn": teaconst.IsPlus, + }, + { + "name": "监控", + "url": "/clusters/monitors", + "code": "monitor", + "isOn": teaconst.IsPlus, + },**/ { "name": "SSH认证", "url": "/clusters/grants", diff --git a/web/views/@default/clusters/cluster/boards/index.html b/web/views/@default/clusters/cluster/boards/index.html index 5bdeb789..f5ed4648 100644 --- a/web/views/@default/clusters/cluster/boards/index.html +++ b/web/views/@default/clusters/cluster/boards/index.html @@ -2,13 +2,13 @@ {$template "/echarts"} -