mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-05 22:30:28 +08:00
浏览访问日志时自动用点符号标记有数据的分表
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
Vue.component("http-access-log-partitions-box", {
|
||||
props: ["v-partition", "v-day"],
|
||||
props: ["v-partition", "v-day", "v-query"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
Tea.action("/servers/logs/partitionData")
|
||||
@@ -11,13 +11,18 @@ Vue.component("http-access-log-partitions-box", {
|
||||
resp.data.partitions.reverse().forEach(function (v) {
|
||||
that.partitions.push({
|
||||
code: v,
|
||||
isDisabled: false
|
||||
isDisabled: false,
|
||||
hasLogs: false
|
||||
})
|
||||
})
|
||||
if (that.partitions.length > 0) {
|
||||
if (that.vPartition == null || that.vPartition < 0) {
|
||||
that.selectedPartition = that.partitions[0].code
|
||||
}
|
||||
|
||||
if (that.partitions.length > 1) {
|
||||
that.checkLogs()
|
||||
}
|
||||
}
|
||||
})
|
||||
.post()
|
||||
@@ -25,7 +30,8 @@ Vue.component("http-access-log-partitions-box", {
|
||||
data: function () {
|
||||
return {
|
||||
partitions: [],
|
||||
selectedPartition: this.vPartition
|
||||
selectedPartition: this.vPartition,
|
||||
checkingPartition: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -48,12 +54,43 @@ Vue.component("http-access-log-partitions-box", {
|
||||
p.isDisabled = true
|
||||
}
|
||||
})
|
||||
},
|
||||
checkLogs: function () {
|
||||
let that = this
|
||||
let index = this.checkingPartition
|
||||
let params = {
|
||||
partition: index
|
||||
}
|
||||
let query = this.vQuery
|
||||
if (query == null || query.length == 0) {
|
||||
return
|
||||
}
|
||||
query.split("&").forEach(function (v) {
|
||||
let param = v.split("=")
|
||||
params[param[0]] = decodeURIComponent(param[1])
|
||||
})
|
||||
Tea.action("/servers/logs/hasLogs")
|
||||
.params(params)
|
||||
.post()
|
||||
.success(function (response) {
|
||||
if (response.data.hasLogs) {
|
||||
// 因为是倒序,所以这里需要使用总长度减去index
|
||||
that.partitions[that.partitions.length - 1 - index].hasLogs = true
|
||||
}
|
||||
|
||||
index++
|
||||
if (index >= that.partitions.length) {
|
||||
return
|
||||
}
|
||||
that.checkingPartition = index
|
||||
that.checkLogs()
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div v-if="partitions.length > 1">
|
||||
<div class="ui divider" style="margin-bottom: 0"></div>
|
||||
<div class="ui menu text small blue" style="margin-bottom: 0; margin-top: 0">
|
||||
<a v-for="(p, index) in partitions" :href="url(p.code)" class="item" :class="{active: selectedPartition == p.code, disabled: p.isDisabled}">分表{{p.code+1}} <span class="disabled" v-if="index != partitions.length - 1">|</span></a>
|
||||
<a v-for="(p, index) in partitions" :href="url(p.code)" class="item" :class="{active: selectedPartition == p.code, disabled: p.isDisabled}">分表{{p.code+1}} <span v-if="p.hasLogs"> <dot></dot></span> <span class="disabled" v-if="index != partitions.length - 1">|</span></a>
|
||||
</div>
|
||||
<div class="ui divider" style="margin-top: 0"></div>
|
||||
</div>`
|
||||
|
||||
Reference in New Issue
Block a user