From 2f1e5bad437a75194d6857f3537c334ba8db8b7e Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 19 Sep 2021 16:10:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=BA=90=E7=89=88=E6=9C=AC=E4=B9=9F?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=9F=9F=E5=90=8D=E6=8E=92=E8=A1=8C=E3=80=81?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=B5=81=E9=87=8F=E8=B6=8B=E5=8A=BF=E3=80=81?= =?UTF-8?q?=E6=94=BB=E5=87=BB=E6=B5=81=E9=87=8F=E8=B6=8B=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/actions/default/dashboard/index.go | 41 +++- web/views/@default/dashboard/index.html | 23 ++- web/views/@default/dashboard/index.js | 181 +++++++++++------- 3 files changed, 165 insertions(+), 80 deletions(-) diff --git a/internal/web/actions/default/dashboard/index.go b/internal/web/actions/default/dashboard/index.go index f9cde459..3b8187bb 100644 --- a/internal/web/actions/default/dashboard/index.go +++ b/internal/web/actions/default/dashboard/index.go @@ -40,6 +40,10 @@ 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, @@ -50,7 +54,7 @@ func (this *IndexAction) RunGet(params struct{}) { } this.Data["dashboard"] = maps.Map{ "defaultClusterId": resp.DefaultNodeClusterId, - + "countServers": resp.CountServers, "countNodeClusters": resp.CountNodeClusters, "countNodes": resp.CountNodes, @@ -85,8 +89,14 @@ func (this *IndexAction) RunGet(params struct{}) { statMaps := []maps.Map{} for _, stat := range resp.HourlyTrafficStats { statMaps = append(statMaps, maps.Map{ - "bytes": stat.Bytes, - "hour": stat.Hour[8:], + "bytes": stat.Bytes, + "cachedBytes": stat.CachedBytes, + "countRequests": stat.CountRequests, + "countCachedRequests": stat.CountCachedRequests, + "countAttackRequests": stat.CountAttackRequests, + "attackBytes": stat.AttackBytes, + "day": stat.Hour[4:6] + "月" + stat.Hour[6:8] + "日", + "hour": stat.Hour[8:], }) } this.Data["hourlyTrafficStats"] = statMaps @@ -97,8 +107,13 @@ func (this *IndexAction) RunGet(params struct{}) { statMaps := []maps.Map{} for _, stat := range resp.DailyTrafficStats { statMaps = append(statMaps, maps.Map{ - "bytes": stat.Bytes, - "day": stat.Day[4:6] + "月" + stat.Day[6:] + "日", + "bytes": stat.Bytes, + "cachedBytes": stat.CachedBytes, + "countRequests": stat.CountRequests, + "countCachedRequests": stat.CountCachedRequests, + "countAttackRequests": stat.CountAttackRequests, + "attackBytes": stat.AttackBytes, + "day": stat.Day[4:6] + "月" + stat.Day[6:] + "日", }) } this.Data["dailyTrafficStats"] = statMaps @@ -172,6 +187,20 @@ func (this *IndexAction) RunGet(params struct{}) { } } + // 域名排行 + { + var statMaps = []maps.Map{} + for _, stat := range resp.TopDomainStats { + statMaps = append(statMaps, maps.Map{ + "serverId": stat.ServerId, + "domain": stat.Domain, + "countRequests": stat.CountRequests, + "bytes": stat.Bytes, + }) + } + this.Data["topDomainStats"] = statMaps + } + // 指标 { var chartMaps = []maps.Map{} @@ -210,5 +239,5 @@ func (this *IndexAction) RunGet(params struct{}) { this.Data["metricCharts"] = chartMaps } - this.Show() + this.Success() } diff --git a/web/views/@default/dashboard/index.html b/web/views/@default/dashboard/index.html index 4a7cea71..5bd26583 100644 --- a/web/views/@default/dashboard/index.html +++ b/web/views/@default/dashboard/index.html @@ -1,24 +1,31 @@ {$layout} {$template "/echarts"} + +
+
+
  数据加载中... +
+
+ -
+ -
+ -
+ -
+

集群

{{dashboard.countNodeClusters}}
@@ -50,9 +57,9 @@
-
+
-