运行日志可以使用集群、节点筛选

This commit is contained in:
刘祥超
2022-01-11 14:59:19 +08:00
parent c61381441c
commit 7f8be85116
12 changed files with 102 additions and 73 deletions

View 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>`
})

View File

@@ -112,7 +112,7 @@ Vue.component("combo-box", {
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">
<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 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>
</div>
</div>

View 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>`
})

View File

@@ -1,13 +1,6 @@
// 访问日志搜索框
Vue.component("http-access-log-search-box", {
props: ["v-ip", "v-domain", "v-keyword", "v-cluster-id", "v-node-id", "v-clusters"],
mounted: function () {
if (this.vClusterId >0) {
this.changeCluster({
value: this.vClusterId
})
}
},
props: ["v-ip", "v-domain", "v-keyword", "v-cluster-id", "v-node-id"],
data: function () {
let ip = this.vIp
if (ip == null) {
@@ -28,7 +21,7 @@ Vue.component("http-access-log-search-box", {
ip: ip,
domain: domain,
keyword: keyword,
nodes: []
clusterId: this.vClusterId
}
},
methods: {
@@ -61,19 +54,8 @@ Vue.component("http-access-log-search-box", {
}, 500)
}
},
changeCluster: function (item) {
this.nodes = []
if (item != null) {
let that = this
Tea.action("/servers/logs/nodeOptions")
.params({
clusterId: item.value
})
.post()
.success(function (resp) {
that.nodes = resp.data.nodes
})
}
changeCluster: function (clusterId) {
this.clusterId = clusterId
}
},
template: `<div style="z-index: 10">
@@ -103,11 +85,11 @@ Vue.component("http-access-log-search-box", {
<slot></slot>
</div>
<div class="ui fields inline" style="margin-top: 0.5em">
<div class="ui field" v-if="vClusters != null && vClusters.length > 0">
<combo-box title="集群" name="clusterId" placeholder="集群名称" :v-items="vClusters" :v-value="vClusterId" @change="changeCluster"></combo-box>
<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="nodes.length > 0">
<combo-box title="节点" name="nodeId" placeholder="节点名称" :v-items="nodes" :v-value="vNodeId"></combo-box>
<div class="ui field" v-if="clusterId > 0">
<node-combo-box :v-cluster-id="clusterId" :v-node-id="vNodeId"></node-combo-box>
</div>
<div class="ui field">
<button class="ui button small" type="submit">搜索日志</button>