From 395aa665d7783dd937c9c7dbcb94e8b97d66cbdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 9 Mar 2023 16:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=9C=A8=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=A1=B5=E9=9D=A2=E4=B8=AD=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=85=B3=E9=94=AE=E8=AF=8D=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E7=9A=84=E8=BF=90=E8=A1=8C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/clusters/logs/deleteAll.go | 60 +++++++++++++++++++ .../actions/default/clusters/logs/index.go | 3 + .../web/actions/default/clusters/logs/init.go | 1 + web/views/@default/clusters/logs/index.css | 7 +++ .../@default/clusters/logs/index.css.map | 2 +- web/views/@default/clusters/logs/index.html | 4 ++ web/views/@default/clusters/logs/index.js | 19 ++++++ web/views/@default/clusters/logs/index.less | 13 +++- 8 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 internal/web/actions/default/clusters/logs/deleteAll.go diff --git a/internal/web/actions/default/clusters/logs/deleteAll.go b/internal/web/actions/default/clusters/logs/deleteAll.go new file mode 100644 index 00000000..e1c121f2 --- /dev/null +++ b/internal/web/actions/default/clusters/logs/deleteAll.go @@ -0,0 +1,60 @@ +// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package logs + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" +) + +type DeleteAllAction struct { + actionutils.ParentAction +} + +func (this *DeleteAllAction) RunPost(params struct { + DayFrom string + DayTo string + Keyword string + Level string + Type string // unread, needFix + Tag string + ClusterId int64 + NodeId int64 +}) { + defer this.CreateLogInfo("批量删除节点运行日志") + + // 目前仅允许通过关键词删除,防止误删 + if len(params.Keyword) == 0 { + this.Fail("目前仅允许通过关键词删除") + return + } + + var fixedState configutils.BoolState = 0 + var allServers = false + if params.Type == "needFix" { + fixedState = configutils.BoolStateNo + allServers = true + } + + _, err := this.RPC().NodeLogRPC().DeleteNodeLogs(this.AdminContext(), &pb.DeleteNodeLogsRequest{ + NodeClusterId: params.ClusterId, + NodeId: params.NodeId, + Role: nodeconfigs.NodeRoleNode, + DayFrom: params.DayFrom, + DayTo: params.DayTo, + Keyword: params.Keyword, + Level: params.Level, + IsUnread: params.Type == "unread", + Tag: params.Tag, + FixedState: int32(fixedState), + AllServers: allServers, + }) + if err != nil { + this.ErrorPage(err) + return + } + + this.Success() +} diff --git a/internal/web/actions/default/clusters/logs/index.go b/internal/web/actions/default/clusters/logs/index.go index 872661c4..03772bd3 100644 --- a/internal/web/actions/default/clusters/logs/index.go +++ b/internal/web/actions/default/clusters/logs/index.go @@ -39,6 +39,7 @@ func (this *IndexAction) RunGet(params struct { this.Data["dayFrom"] = params.DayFrom this.Data["dayTo"] = params.DayTo this.Data["keyword"] = params.Keyword + this.Data["searchedKeyword"] = params.Keyword this.Data["level"] = params.Level this.Data["type"] = params.Type this.Data["tag"] = params.Tag @@ -97,6 +98,8 @@ func (this *IndexAction) RunGet(params struct { return } var count = countResp.Count + this.Data["countLogs"] = count + var page = this.NewPage(count) this.Data["page"] = page.AsHTML() diff --git a/internal/web/actions/default/clusters/logs/init.go b/internal/web/actions/default/clusters/logs/init.go index 19cc5e54..0a12195f 100644 --- a/internal/web/actions/default/clusters/logs/init.go +++ b/internal/web/actions/default/clusters/logs/init.go @@ -18,6 +18,7 @@ func init() { Post("/readAllLogs", new(ReadAllLogsAction)). Post("/fix", new(FixAction)). Post("/fixAll", new(FixAllAction)). + Post("/deleteAll", new(DeleteAllAction)). EndAll() }) } diff --git a/web/views/@default/clusters/logs/index.css b/web/views/@default/clusters/logs/index.css index e05cd134..1d6b698f 100644 --- a/web/views/@default/clusters/logs/index.css +++ b/web/views/@default/clusters/logs/index.css @@ -2,4 +2,11 @@ pre.log-box { margin: 0; padding: 0; } +.search-keyword-label a { + opacity: 1!important; +} +.search-keyword-label span.small { + font-size: 0.8em; + color: #4183c4 !important; +} /*# sourceMappingURL=index.css.map */ \ No newline at end of file diff --git a/web/views/@default/clusters/logs/index.css.map b/web/views/@default/clusters/logs/index.css.map index 2c0cfd3e..708abd76 100644 --- a/web/views/@default/clusters/logs/index.css.map +++ b/web/views/@default/clusters/logs/index.css.map @@ -1 +1 @@ -{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,GAAG;EACF,SAAA;EACA,UAAA","file":"index.css"} \ No newline at end of file +{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,GAAG;EACF,SAAA;EACA,UAAA;;AAGD,qBACC;EACC,oBAAA;;AAFF,qBAKC,KAAI;EACH,gBAAA;EACA,cAAA","file":"index.css"} \ 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 5a707199..89990c7e 100644 --- a/web/views/@default/clusters/logs/index.html +++ b/web/views/@default/clusters/logs/index.html @@ -68,6 +68,10 @@

暂时还没有未读需修复日志。

+
+
正在搜索关键词"{{searchedKeyword}}",共{{countLogs}}条记录   [清除日志]
+
+ diff --git a/web/views/@default/clusters/logs/index.js b/web/views/@default/clusters/logs/index.js index 8e9ab17f..d77d220e 100644 --- a/web/views/@default/clusters/logs/index.js +++ b/web/views/@default/clusters/logs/index.js @@ -82,4 +82,23 @@ Tea.context(function () { }) }) } + + this.deleteLogs = function () { + teaweb.confirm("确定要删除当前关键词\"" + this.searchedKeyword + "\"匹配的" + this.countLogs + "个运行日志?", function () { + this.$post(".deleteAll") + .params({ + dayFrom: this.dayFrom, + dayTo: this.dayTo, + keyword: this.keyword, + level: this.level, + type: this.type, + tag: this.tag, + clusterId: this.clusterId, + nodeId: this.nodeId + }) + .success(function () { + teaweb.reload() + }) + }) + } }) \ No newline at end of file diff --git a/web/views/@default/clusters/logs/index.less b/web/views/@default/clusters/logs/index.less index 9accd63d..96cb3473 100644 --- a/web/views/@default/clusters/logs/index.less +++ b/web/views/@default/clusters/logs/index.less @@ -1,4 +1,15 @@ pre.log-box { margin: 0; padding: 0; -} \ No newline at end of file +} + +.search-keyword-label { + a { + opacity: 1!important; + } + + span.small { + font-size: 0.8em; + color: #4183c4!important; + } +}