mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 01:10:29 +08:00
运行日志可以使用集群、节点筛选
This commit is contained in:
@@ -21,8 +21,8 @@ func init() {
|
|||||||
EndHelpers().
|
EndHelpers().
|
||||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeCommon)).
|
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeCommon)).
|
||||||
Post("/options", new(OptionsAction)).
|
Post("/options", new(OptionsAction)).
|
||||||
|
Post("/nodeOptions", new(NodeOptionsAction)).
|
||||||
GetPost("/selectPopup", new(SelectPopupAction)).
|
GetPost("/selectPopup", new(SelectPopupAction)).
|
||||||
|
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,14 @@ func (this *IndexAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
DayFrom string
|
DayFrom string
|
||||||
DayTo string
|
DayTo string
|
||||||
Keyword string
|
Keyword string
|
||||||
Level string
|
Level string
|
||||||
Type string
|
Type string
|
||||||
Tag string
|
Tag string
|
||||||
|
ClusterId int64
|
||||||
|
NodeId int64
|
||||||
}) {
|
}) {
|
||||||
this.Data["dayFrom"] = params.DayFrom
|
this.Data["dayFrom"] = params.DayFrom
|
||||||
this.Data["dayTo"] = params.DayTo
|
this.Data["dayTo"] = params.DayTo
|
||||||
@@ -35,6 +37,8 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["level"] = params.Level
|
this.Data["level"] = params.Level
|
||||||
this.Data["type"] = params.Type
|
this.Data["type"] = params.Type
|
||||||
this.Data["tag"] = params.Tag
|
this.Data["tag"] = params.Tag
|
||||||
|
this.Data["clusterId"] = params.ClusterId
|
||||||
|
this.Data["nodeId"] = params.NodeId
|
||||||
|
|
||||||
// 常见标签
|
// 常见标签
|
||||||
this.Data["tags"] = nodelogutils.FindNodeCommonTags()
|
this.Data["tags"] = nodelogutils.FindNodeCommonTags()
|
||||||
@@ -52,14 +56,15 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
|
|
||||||
// 日志数量
|
// 日志数量
|
||||||
countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
||||||
NodeId: 0,
|
NodeClusterId: params.ClusterId,
|
||||||
Role: nodeconfigs.NodeRoleNode,
|
NodeId: params.NodeId,
|
||||||
DayFrom: params.DayFrom,
|
Role: nodeconfigs.NodeRoleNode,
|
||||||
DayTo: params.DayTo,
|
DayFrom: params.DayFrom,
|
||||||
Keyword: params.Keyword,
|
DayTo: params.DayTo,
|
||||||
Level: params.Level,
|
Keyword: params.Keyword,
|
||||||
IsUnread: params.Type == "unread",
|
Level: params.Level,
|
||||||
Tag: params.Tag,
|
IsUnread: params.Type == "unread",
|
||||||
|
Tag: params.Tag,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -70,16 +75,17 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["page"] = page.AsHTML()
|
this.Data["page"] = page.AsHTML()
|
||||||
|
|
||||||
logsResp, err := this.RPC().NodeLogRPC().ListNodeLogs(this.AdminContext(), &pb.ListNodeLogsRequest{
|
logsResp, err := this.RPC().NodeLogRPC().ListNodeLogs(this.AdminContext(), &pb.ListNodeLogsRequest{
|
||||||
NodeId: 0,
|
NodeClusterId: params.ClusterId,
|
||||||
Role: nodeconfigs.NodeRoleNode,
|
NodeId: params.NodeId,
|
||||||
DayFrom: params.DayFrom,
|
Role: nodeconfigs.NodeRoleNode,
|
||||||
DayTo: params.DayTo,
|
DayFrom: params.DayFrom,
|
||||||
Keyword: params.Keyword,
|
DayTo: params.DayTo,
|
||||||
Level: params.Level,
|
Keyword: params.Keyword,
|
||||||
IsUnread: params.Type == "unread",
|
Level: params.Level,
|
||||||
Tag: params.Tag,
|
IsUnread: params.Type == "unread",
|
||||||
Offset: page.Offset,
|
Tag: params.Tag,
|
||||||
Size: page.Size,
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
package logs
|
package clusters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/lists"
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -153,20 +152,5 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
this.Data["regions"] = regionMap
|
this.Data["regions"] = regionMap
|
||||||
|
|
||||||
// 集群列表
|
|
||||||
var clusterMaps = []maps.Map{}
|
|
||||||
clusterResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClusters(this.AdminContext(), &pb.FindAllEnabledNodeClustersRequest{})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, cluster := range clusterResp.NodeClusters {
|
|
||||||
clusterMaps = append(clusterMaps, maps.Map{
|
|
||||||
"id": cluster.Id,
|
|
||||||
"name": cluster.Name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.Data["clusters"] = clusterMaps
|
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ func init() {
|
|||||||
Prefix("/servers/logs").
|
Prefix("/servers/logs").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
GetPost("/settings", new(SettingsAction)).
|
GetPost("/settings", new(SettingsAction)).
|
||||||
Post("/nodeOptions", new(NodeOptionsAction)).
|
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
26
web/public/js/components/cluster/node-cluster-combo-box.js
Normal file
26
web/public/js/components/cluster/node-cluster-combo-box.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
Vue.component("node-cluster-combo-box", {
|
||||||
|
props: ["v-cluster-id"],
|
||||||
|
data: function () {
|
||||||
|
let that = this
|
||||||
|
Tea.action("/clusters/options")
|
||||||
|
.post()
|
||||||
|
.success(function (resp) {
|
||||||
|
that.clusters = resp.data.clusters
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
clusters: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
change: function (item) {
|
||||||
|
if (item == null) {
|
||||||
|
this.$emit("change", 0)
|
||||||
|
} else {
|
||||||
|
this.$emit("change", item.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<div v-if="clusters.length > 0">
|
||||||
|
<combo-box title="集群" placeholder="集群名称" :v-items="clusters" name="clusterId" :v-value="vClusterId" @change="change"></combo-box>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
@@ -112,7 +112,7 @@ Vue.component("combo-box", {
|
|||||||
this.$emit("change", this.selectedItem)
|
this.$emit("change", this.selectedItem)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div style="display: inline">
|
template: `<div style="display: inline; z-index: 10; background: white">
|
||||||
<!-- 搜索框 -->
|
<!-- 搜索框 -->
|
||||||
<div v-if="selectedItem == null">
|
<div v-if="selectedItem == null">
|
||||||
<input type="text" v-model="keyword" :placeholder="placeholder" :size="size" style="width: 11em" @input="changeKeyword" @focus="show" @blur="hide" @keyup.enter="confirm()" @keypress.enter.prevent="1" ref="searchBox" @keyup.down="downItem" @keyup.up="upItem"/>
|
<input type="text" v-model="keyword" :placeholder="placeholder" :size="size" style="width: 11em" @input="changeKeyword" @focus="show" @blur="hide" @keyup.enter="confirm()" @keypress.enter.prevent="1" ref="searchBox" @keyup.down="downItem" @keyup.up="upItem"/>
|
||||||
@@ -128,7 +128,7 @@ Vue.component("combo-box", {
|
|||||||
|
|
||||||
<!-- 菜单 -->
|
<!-- 菜单 -->
|
||||||
<div v-if="selectedItem == null && items.length > 0 && visible">
|
<div v-if="selectedItem == null && items.length > 0 && visible">
|
||||||
<div class="ui menu vertical small narrow-scrollbar" style="width: 11em; max-height: 17em; overflow-y: auto; position: absolute; border: rgba(129, 177, 210, 0.81) 1px solid; border-top: 0">
|
<div class="ui menu vertical small narrow-scrollbar" style="width: 11em; max-height: 17em; overflow-y: auto; position: absolute; border: rgba(129, 177, 210, 0.81) 1px solid; border-top: 0; z-index: 100">
|
||||||
<a href="" v-for="(item, index) in items" ref="itemRef" class="item" :class="{active: index == hoverIndex, blue: index == hoverIndex}" @click.prevent="selectItem(item)" style="line-height: 1.4">{{item.name}}</a>
|
<a href="" v-for="(item, index) in items" ref="itemRef" class="item" :class="{active: index == hoverIndex, blue: index == hoverIndex}" @click.prevent="selectItem(item)" style="line-height: 1.4">{{item.name}}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
20
web/public/js/components/node/node-combo-box.js
Normal file
20
web/public/js/components/node/node-combo-box.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
Vue.component("node-combo-box", {
|
||||||
|
props: ["v-cluster-id", "v-node-id"],
|
||||||
|
data: function () {
|
||||||
|
let that = this
|
||||||
|
Tea.action("/clusters/nodeOptions")
|
||||||
|
.params({
|
||||||
|
clusterId: this.vClusterId
|
||||||
|
})
|
||||||
|
.post()
|
||||||
|
.success(function (resp) {
|
||||||
|
that.nodes = resp.data.nodes
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
nodes: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<div v-if="nodes.length > 0">
|
||||||
|
<combo-box title="节点" placeholder="节点名称" :v-items="nodes" name="nodeId" :v-value="vNodeId"></combo-box>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
@@ -1,13 +1,6 @@
|
|||||||
// 访问日志搜索框
|
// 访问日志搜索框
|
||||||
Vue.component("http-access-log-search-box", {
|
Vue.component("http-access-log-search-box", {
|
||||||
props: ["v-ip", "v-domain", "v-keyword", "v-cluster-id", "v-node-id", "v-clusters"],
|
props: ["v-ip", "v-domain", "v-keyword", "v-cluster-id", "v-node-id"],
|
||||||
mounted: function () {
|
|
||||||
if (this.vClusterId >0) {
|
|
||||||
this.changeCluster({
|
|
||||||
value: this.vClusterId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data: function () {
|
data: function () {
|
||||||
let ip = this.vIp
|
let ip = this.vIp
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
@@ -28,7 +21,7 @@ Vue.component("http-access-log-search-box", {
|
|||||||
ip: ip,
|
ip: ip,
|
||||||
domain: domain,
|
domain: domain,
|
||||||
keyword: keyword,
|
keyword: keyword,
|
||||||
nodes: []
|
clusterId: this.vClusterId
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -61,19 +54,8 @@ Vue.component("http-access-log-search-box", {
|
|||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeCluster: function (item) {
|
changeCluster: function (clusterId) {
|
||||||
this.nodes = []
|
this.clusterId = clusterId
|
||||||
if (item != null) {
|
|
||||||
let that = this
|
|
||||||
Tea.action("/servers/logs/nodeOptions")
|
|
||||||
.params({
|
|
||||||
clusterId: item.value
|
|
||||||
})
|
|
||||||
.post()
|
|
||||||
.success(function (resp) {
|
|
||||||
that.nodes = resp.data.nodes
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div style="z-index: 10">
|
template: `<div style="z-index: 10">
|
||||||
@@ -103,11 +85,11 @@ Vue.component("http-access-log-search-box", {
|
|||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui fields inline" style="margin-top: 0.5em">
|
<div class="ui fields inline" style="margin-top: 0.5em">
|
||||||
<div class="ui field" v-if="vClusters != null && vClusters.length > 0">
|
<div class="ui field">
|
||||||
<combo-box title="集群" name="clusterId" placeholder="集群名称" :v-items="vClusters" :v-value="vClusterId" @change="changeCluster"></combo-box>
|
<node-cluster-combo-box :v-cluster-id="clusterId" @change="changeCluster"></node-cluster-combo-box>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field" v-if="nodes.length > 0">
|
<div class="ui field" v-if="clusterId > 0">
|
||||||
<combo-box title="节点" name="nodeId" placeholder="节点名称" :v-items="nodes" :v-value="vNodeId"></combo-box>
|
<node-combo-box :v-cluster-id="clusterId" :v-node-id="vNodeId"></node-combo-box>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<button class="ui button small" type="submit">搜索日志</button>
|
<button class="ui button small" type="submit">搜索日志</button>
|
||||||
|
|||||||
@@ -31,10 +31,18 @@
|
|||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui fields inline" style="margin-top: 0.5em">
|
||||||
|
<div class="ui field">
|
||||||
|
<node-cluster-combo-box :v-cluster-id="clusterId" @change="changeCluster"></node-cluster-combo-box>
|
||||||
|
</div>
|
||||||
|
<div class="ui field" v-if="clusterId > 0">
|
||||||
|
<node-combo-box :v-cluster-id="clusterId" :v-node-id="nodeId"></node-combo-box>
|
||||||
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<button type="submit" class="ui button">查询</button>
|
<button type="submit" class="ui button">查询</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0 || tag.length > 0">
|
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0 || tag.length > 0 || clusterId > 0 || nodeId > 0">
|
||||||
<a :href="'/clusters/logs?type=' + type">[清除条件]</a>
|
<a :href="'/clusters/logs?type=' + type">[清除条件]</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -38,4 +38,8 @@ Tea.context(function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.changeCluster = function (clusterId) {
|
||||||
|
this.clusterId = clusterId
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<input type="hidden" name="serverId" :value="serverId"/>
|
<input type="hidden" name="serverId" :value="serverId"/>
|
||||||
<input type="hidden" name="hasError" :value="hasError"/>
|
<input type="hidden" name="hasError" :value="hasError"/>
|
||||||
<input type="hidden" name="hasWAF" :value="hasWAF"/>
|
<input type="hidden" name="hasWAF" :value="hasWAF"/>
|
||||||
<http-access-log-search-box :v-clusters="clusters" :v-cluster-id="clusterId" :v-node-id="nodeId" :v-ip="ip" :v-domain="domain" :v-keyword="keyword">
|
<http-access-log-search-box :v-cluster-id="clusterId" :v-node-id="nodeId" :v-ip="ip" :v-domain="domain" :v-keyword="keyword">
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" name="day" maxlength="10" placeholder="选择日期" style="width:7.8em" id="day-input" v-model="day"/>
|
<input type="text" name="day" maxlength="10" placeholder="选择日期" style="width:7.8em" id="day-input" v-model="day"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user