mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 09:20:25 +08:00
在服务列表中显示需要修复的错误
This commit is contained in:
24
internal/web/actions/default/servers/fixLog.go
Normal file
24
internal/web/actions/default/servers/fixLog.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package servers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type FixLogAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *FixLogAction) RunPost(params struct {
|
||||
LogId int64
|
||||
}) {
|
||||
_, err := this.RPC().NodeLogRPC().FixNodeLog(this.AdminContext(), &pb.FixNodeLogRequest{NodeLogId: params.LogId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -250,5 +252,48 @@ func (this *IndexAction) RunGet(params struct {
|
||||
// 是否有用户管理权限
|
||||
this.Data["canVisitUser"] = configloaders.AllowModule(this.AdminId(), configloaders.AdminModuleCodeUser)
|
||||
|
||||
// 显示服务相关的日志
|
||||
errorLogsResp, err := this.RPC().NodeLogRPC().ListNodeLogs(this.AdminContext(), &pb.ListNodeLogsRequest{
|
||||
NodeId: 0,
|
||||
Role: "node",
|
||||
Offset: 0,
|
||||
Size: 10,
|
||||
Level: "error",
|
||||
FixedState: int32(configutils.BoolStateNo),
|
||||
AllServers: true,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
errorLogMaps := []maps.Map{}
|
||||
for _, errorLog := range errorLogsResp.NodeLogs {
|
||||
serverResp, err := this.RPC().ServerRPC().FindEnabledUserServerBasic(this.AdminContext(), &pb.FindEnabledUserServerBasicRequest{ServerId: errorLog.ServerId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
server := serverResp.Server
|
||||
if server == nil {
|
||||
// 设置为已修复
|
||||
_, err = this.RPC().NodeLogRPC().FixNodeLog(this.AdminContext(), &pb.FixNodeLogRequest{NodeLogId: errorLog.Id})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
errorLogMaps = append(errorLogMaps, maps.Map{
|
||||
"id": errorLog.Id,
|
||||
"description": errorLog.Description,
|
||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", errorLog.CreatedAt),
|
||||
"serverId": errorLog.ServerId,
|
||||
"serverName": server.Name,
|
||||
})
|
||||
}
|
||||
this.Data["errorLogs"] = errorLogMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ func init() {
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/create", new(CreateAction)).
|
||||
GetPost("/update", new(UpdateAction)).
|
||||
Post("/fixLog", new(FixLogAction)).
|
||||
|
||||
GetPost("/addPortPopup", new(AddPortPopupAction)).
|
||||
GetPost("/addServerNamePopup", new(AddServerNamePopupAction)).
|
||||
|
||||
6
web/views/@default/servers/index.css
Normal file
6
web/views/@default/servers/index.css
Normal file
@@ -0,0 +1,6 @@
|
||||
.ui.message .icon {
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 1.8em;
|
||||
}
|
||||
/*# sourceMappingURL=index.css.map */
|
||||
1
web/views/@default/servers/index.css.map
Normal file
1
web/views/@default/servers/index.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,GAAG,QACF;EACC,kBAAA;EACA,UAAA;EACA,UAAA","file":"index.css"}
|
||||
@@ -1,6 +1,23 @@
|
||||
{$layout}
|
||||
{$template "menu"}
|
||||
|
||||
<!-- 错误日志 -->
|
||||
<div v-if="errorLogs.length > 0">
|
||||
<div class="margin"></div>
|
||||
<div class="ui menu tabular attached">
|
||||
<span class="ui item active"><span class="red">需要修复的错误</span></span>
|
||||
</div>
|
||||
<div class="ui segment attached">
|
||||
<div class="ui message error" v-for="log in errorLogs">
|
||||
[{{log.createdTime}}]
|
||||
<a :href="'/servers/server/settings?serverId=' + log.serverId"><span v-if="log.serverName.length > 0">[{{log.serverName}}]</span><span v-else>[服务]</span></a>
|
||||
{{log.description}}
|
||||
<a href="" title="关闭" @click.prevent="fixLog(log.id)"><i class="ui icon remove small"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
<form method="get" class="ui form" action="/servers">
|
||||
<input type="hidden" name="auditingFlag" :value="auditingFlag"/>
|
||||
<div class="ui margin"></div>
|
||||
|
||||
@@ -46,4 +46,20 @@ Tea.context(function () {
|
||||
this.showLatest = function () {
|
||||
this.latestVisible = !this.latestVisible
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误日志相关
|
||||
*/
|
||||
this.fixLog = function (logId) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要关闭此错误提示吗?", function () {
|
||||
that.$post(".fixLog")
|
||||
.params({
|
||||
logId: logId
|
||||
})
|
||||
.success(function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
7
web/views/@default/servers/index.less
Normal file
7
web/views/@default/servers/index.less
Normal file
@@ -0,0 +1,7 @@
|
||||
.ui.message {
|
||||
.icon {
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 1.8em;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user