From 59564f570250836a888df0d62fcc938cad332813 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 19 May 2021 20:52:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=97=A5=E5=BF=97=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=81=9A=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/clusters/cluster/node/logs.go | 31 ++++++++++---- .../actions/default/clusters/logs/index.go | 1 + .../@default/clusters/cluster/node/logs.html | 41 ++++++++++++++++++- .../@default/clusters/cluster/node/logs.js | 6 +++ web/views/@default/clusters/logs/index.html | 2 +- 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 web/views/@default/clusters/cluster/node/logs.js diff --git a/internal/web/actions/default/clusters/cluster/node/logs.go b/internal/web/actions/default/clusters/cluster/node/logs.go index 22a8870d..09cf715f 100644 --- a/internal/web/actions/default/clusters/cluster/node/logs.go +++ b/internal/web/actions/default/clusters/cluster/node/logs.go @@ -17,13 +17,25 @@ func (this *LogsAction) Init() { } func (this *LogsAction) RunGet(params struct { - NodeId int64 + NodeId int64 + DayFrom string + DayTo string + Keyword string + Level string }) { this.Data["nodeId"] = params.NodeId + this.Data["dayFrom"] = params.DayFrom + this.Data["dayTo"] = params.DayTo + this.Data["keyword"] = params.Keyword + this.Data["level"] = params.Level countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{ - Role: "node", - NodeId: params.NodeId, + Role: "node", + NodeId: params.NodeId, + DayFrom: params.DayFrom, + DayTo: params.DayTo, + Keyword: params.Keyword, + Level: params.Level, }) if err != nil { this.ErrorPage(err) @@ -33,10 +45,14 @@ func (this *LogsAction) RunGet(params struct { page := this.NewPage(count, 20) logsResp, err := this.RPC().NodeLogRPC().ListNodeLogs(this.AdminContext(), &pb.ListNodeLogsRequest{ - NodeId: params.NodeId, - Role: "node", - Offset: page.Offset, - Size: page.Size, + NodeId: params.NodeId, + Role: "node", + DayFrom: params.DayFrom, + DayTo: params.DayTo, + Keyword: params.Keyword, + Level: params.Level, + Offset: page.Offset, + Size: page.Size, }) logs := []maps.Map{} @@ -47,6 +63,7 @@ func (this *LogsAction) RunGet(params struct { "createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt), "level": log.Level, "isToday": timeutil.FormatTime("Y-m-d", log.CreatedAt) == timeutil.Format("Y-m-d"), + "count": log.Count, }) } this.Data["logs"] = logs diff --git a/internal/web/actions/default/clusters/logs/index.go b/internal/web/actions/default/clusters/logs/index.go index 64b0424e..41f0be3d 100644 --- a/internal/web/actions/default/clusters/logs/index.go +++ b/internal/web/actions/default/clusters/logs/index.go @@ -70,6 +70,7 @@ func (this *IndexAction) RunGet(params struct { "createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt), "level": log.Level, "isToday": timeutil.FormatTime("Y-m-d", log.CreatedAt) == timeutil.Format("Y-m-d"), + "count": log.Count, "node": maps.Map{ "id": node.Id, "cluster": maps.Map{ diff --git a/web/views/@default/clusters/cluster/node/logs.html b/web/views/@default/clusters/cluster/node/logs.html index 15f05a88..787dfc71 100644 --- a/web/views/@default/clusters/cluster/node/logs.html +++ b/web/views/@default/clusters/cluster/node/logs.html @@ -1,6 +1,45 @@ {$layout} {$template "node_menu"} +{$var "header"} + + + + + + +{$end} + +
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+

暂时还没有日志。

@@ -11,7 +50,7 @@
-
[{{log.createdTime}}][{{log.createdTime}}][{{log.tag}}]{{log.description}}
+
[{{log.createdTime}}][{{log.createdTime}}][{{log.tag}}]{{log.description}}   共{{log.count}}条
diff --git a/web/views/@default/clusters/cluster/node/logs.js b/web/views/@default/clusters/cluster/node/logs.js new file mode 100644 index 00000000..29a90420 --- /dev/null +++ b/web/views/@default/clusters/cluster/node/logs.js @@ -0,0 +1,6 @@ +Tea.context(function () { + this.$delay(function () { + teaweb.datepicker("day-from-picker") + teaweb.datepicker("day-to-picker") + }) +}) \ No newline at end of file diff --git a/web/views/@default/clusters/logs/index.html b/web/views/@default/clusters/logs/index.html index 77e6d6d1..52d1b9e6 100644 --- a/web/views/@default/clusters/logs/index.html +++ b/web/views/@default/clusters/logs/index.html @@ -54,7 +54,7 @@ {{log.node.cluster.name}} {{log.node.name}} -
[{{log.createdTime}}][{{log.createdTime}}][{{log.tag}}]{{log.description}}
+
[{{log.createdTime}}][{{log.createdTime}}][{{log.tag}}]{{log.description}}   共{{log.count}}条