mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 05:00:25 +08:00
可以在运行日志页面中删除使用关键词匹配的运行日志
This commit is contained in:
60
internal/web/actions/default/clusters/logs/deleteAll.go
Normal file
60
internal/web/actions/default/clusters/logs/deleteAll.go
Normal file
@@ -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()
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ func init() {
|
||||
Post("/readAllLogs", new(ReadAllLogsAction)).
|
||||
Post("/fix", new(FixAction)).
|
||||
Post("/fixAll", new(FixAllAction)).
|
||||
Post("/deleteAll", new(DeleteAllAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,GAAG;EACF,SAAA;EACA,UAAA","file":"index.css"}
|
||||
{"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"}
|
||||
@@ -68,6 +68,10 @@
|
||||
|
||||
<p class="comment" v-if="logs.length == 0">暂时还没有<span v-if="type == 'unread'">未读</span><span v-if="type == 'needFix'">需修复</span>日志。</p>
|
||||
|
||||
<div v-if="countLogs > 0 && searchedKeyword.length > 0" class="search-keyword-label">
|
||||
<div class="ui label basic small">正在搜索关键词"{{searchedKeyword}}",共{{countLogs}}条记录 <a href="" @click.prevent="deleteLogs"><span class="small">[清除日志]</span></a> </div>
|
||||
</div>
|
||||
|
||||
<table class="ui table selectable celled" v-if="logs.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -2,3 +2,14 @@ pre.log-box {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.search-keyword-label {
|
||||
a {
|
||||
opacity: 1!important;
|
||||
}
|
||||
|
||||
span.small {
|
||||
font-size: 0.8em;
|
||||
color: #4183c4!important;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user