mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-23 18:00:27 +08:00
实现节点运行日志上传
This commit is contained in:
@@ -67,6 +67,10 @@ func (this *RPCClient) NodeRPC() pb.NodeServiceClient {
|
|||||||
return pb.NewNodeServiceClient(this.pickConn())
|
return pb.NewNodeServiceClient(this.pickConn())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *RPCClient) NodeLogRPC() pb.NodeLogServiceClient {
|
||||||
|
return pb.NewNodeLogServiceClient(this.pickConn())
|
||||||
|
}
|
||||||
|
|
||||||
func (this *RPCClient) NodeGrantRPC() pb.NodeGrantServiceClient {
|
func (this *RPCClient) NodeGrantRPC() pb.NodeGrantServiceClient {
|
||||||
return pb.NewNodeGrantServiceClient(this.pickConn())
|
return pb.NewNodeGrantServiceClient(this.pickConn())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func init() {
|
|||||||
GetPost("/node/install", new(node.InstallAction)).
|
GetPost("/node/install", new(node.InstallAction)).
|
||||||
Post("/node/updateInstallStatus", new(node.UpdateInstallStatusAction)).
|
Post("/node/updateInstallStatus", new(node.UpdateInstallStatusAction)).
|
||||||
Post("/node/status", new(node.StatusAction)).
|
Post("/node/status", new(node.StatusAction)).
|
||||||
|
Get("/node/logs", new(node.LogsAction)).
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
57
internal/web/actions/default/clusters/cluster/node/logs.go
Normal file
57
internal/web/actions/default/clusters/cluster/node/logs.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package node
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogsAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *LogsAction) Init() {
|
||||||
|
this.Nav("", "node", "log")
|
||||||
|
this.SecondMenu("nodes")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *LogsAction) RunGet(params struct {
|
||||||
|
NodeId int64
|
||||||
|
}) {
|
||||||
|
this.Data["nodeId"] = params.NodeId
|
||||||
|
|
||||||
|
countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
||||||
|
Role: "node",
|
||||||
|
NodeId: params.NodeId,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
count := countResp.Count
|
||||||
|
page := this.NewPage(count)
|
||||||
|
|
||||||
|
logsResp, err := this.RPC().NodeLogRPC().ListNodeLogs(this.AdminContext(), &pb.ListNodeLogsRequest{
|
||||||
|
NodeId: params.NodeId,
|
||||||
|
Role: "node",
|
||||||
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
|
})
|
||||||
|
|
||||||
|
logs := []maps.Map{}
|
||||||
|
for _, log := range logsResp.NodeLogs {
|
||||||
|
logs = append(logs, maps.Map{
|
||||||
|
"tag": log.Tag,
|
||||||
|
"description": log.Description,
|
||||||
|
"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"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.Data["logs"] = logs
|
||||||
|
|
||||||
|
this.Data["page"] = page.AsHTML()
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<second-menu>
|
<second-menu>
|
||||||
<menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + nodeId" code="node">节点详情</menu-item>
|
<menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + nodeId" code="node">节点详情</menu-item>
|
||||||
|
<menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + nodeId" code="log">节点日志</menu-item>
|
||||||
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + nodeId" code="update">修改节点</menu-item>
|
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + nodeId" code="update">修改节点</menu-item>
|
||||||
<menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + nodeId" code="install">安装节点</menu-item>
|
<menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + nodeId" code="install">安装节点</menu-item>
|
||||||
</second-menu>
|
</second-menu>
|
||||||
26
web/views/@default/clusters/cluster/node/logs.html
Normal file
26
web/views/@default/clusters/cluster/node/logs.html
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "/left_menu"}
|
||||||
|
|
||||||
|
<div class="right-box">
|
||||||
|
{$template "node_menu"}
|
||||||
|
|
||||||
|
<p class="comment" v-if="logs.length == 0">暂时还没有日志。</p>
|
||||||
|
|
||||||
|
<table class="ui table selectable" v-if="logs.length > 0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr v-for="log in logs">
|
||||||
|
<td>
|
||||||
|
<span :class="{red:log.level == 'error', yellow:log.level == 'warning'}">
|
||||||
|
<span v-if="!log.isToday">[{{log.createdTime}}]</span>
|
||||||
|
<strong v-if="log.isToday">[{{log.createdTime}}]</strong>
|
||||||
|
[{{log.tag}}]{{log.description}}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="page" v-html="page"></div>
|
||||||
|
</div>
|
||||||
4
web/views/@default/clusters/index.css
Normal file
4
web/views/@default/clusters/index.css
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
table a span {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
/*# sourceMappingURL=index.css.map */
|
||||||
1
web/views/@default/clusters/index.css.map
Normal file
1
web/views/@default/clusters/index.css.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,KAAM,EAAE;EACP,0BAAA","file":"index.css"}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<tr v-for="cluster in clusters">
|
<tr v-for="cluster in clusters">
|
||||||
<td>{{cluster.name}}</td>
|
<td>{{cluster.name}}</td>
|
||||||
<td>
|
<td>
|
||||||
<a :href="'/clusters/cluster?clusterId=' + cluster.id" v-if="cluster.countAllNodes > 0">{{cluster.countAllNodes}}</a>
|
<a :href="'/clusters/cluster?clusterId=' + cluster.id" v-if="cluster.countAllNodes > 0"><span :class="{red:cluster.countAllNodes > cluster.countActiveNodes}">{{cluster.countAllNodes}}</span></a>
|
||||||
<span class="disabled" v-else="">-</span>
|
<span class="disabled" v-else="">-</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
3
web/views/@default/clusters/index.less
Normal file
3
web/views/@default/clusters/index.less
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
table a span {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user