数据看板和节点看板都改成异步加载

This commit is contained in:
刘祥超
2021-08-30 15:23:31 +08:00
parent 19178f963e
commit 1d9d44ecc3
14 changed files with 188 additions and 99 deletions

View File

@@ -1,11 +1,24 @@
Tea.context(function () {
this.isLoading = true
this.trafficTab = "hourly"
this.metricCharts = []
this.$delay(function () {
this.reloadHourlyTrafficChart()
this.reloadHourlyRequestsChart()
this.reloadTopDomainsChart()
this.reloadTopNodesChart()
this.$post("$")
.success(function (resp) {
for (let k in resp.data) {
this[k] = resp.data[k]
}
this.isLoading = false
this.$delay(function () {
this.reloadHourlyTrafficChart()
this.reloadHourlyRequestsChart()
this.reloadTopDomainsChart()
this.reloadTopNodesChart()
})
})
})
this.selectTrafficTab = function (tab) {
@@ -24,15 +37,15 @@ Tea.context(function () {
this.reloadHourlyTrafficChart = function () {
let stats = this.hourlyTrafficStats
this.reloadTrafficChart("hourly-traffic-chart-box", stats, function (args) {
let index = args.dataIndex
let cachedRatio = 0
let attackRatio = 0
if (stats[index].bytes > 0) {
cachedRatio = Math.round(stats[index].cachedBytes * 10000 / stats[index].bytes) / 100
attackRatio = Math.round(stats[index].attackBytes * 10000 / stats[index].bytes) / 100
}
let index = args.dataIndex
let cachedRatio = 0
let attackRatio = 0
if (stats[index].bytes > 0) {
cachedRatio = Math.round(stats[index].cachedBytes * 10000 / stats[index].bytes) / 100
attackRatio = Math.round(stats[index].attackBytes * 10000 / stats[index].bytes) / 100
}
return stats[index].day + " " + stats[index].hour + "时<br/>总流量:" + teaweb.formatBytes(stats[index].bytes) + "<br/>缓存流量:" + teaweb.formatBytes(stats[index].cachedBytes) + "<br/>缓存命中率:" + cachedRatio + "%<br/>拦截攻击流量:" + teaweb.formatBytes(stats[index].attackBytes) + "<br/>拦截比例:" + attackRatio + "%"
return stats[index].day + " " + stats[index].hour + "时<br/>总流量:" + teaweb.formatBytes(stats[index].bytes) + "<br/>缓存流量:" + teaweb.formatBytes(stats[index].cachedBytes) + "<br/>缓存命中率:" + cachedRatio + "%<br/>拦截攻击流量:" + teaweb.formatBytes(stats[index].attackBytes) + "<br/>拦截比例:" + attackRatio + "%"
})
}