mirror of https://github.com/bjdgyc/anylink.git
commit
7b3507d962
|
@ -217,50 +217,61 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
formatOnline(data) {
|
formatOnline(data) {
|
||||||
let timeFormat = data.scope == "rt" || data.scope == "1h" || data.scope == "24h" ? "h:i:s" : "m/d h:i:s"
|
let timeFormat = this.getTimeFormat(data.scope)
|
||||||
|
let chartData = this.lineChart[data.action]
|
||||||
let datas = data.datas
|
let datas = data.datas
|
||||||
this.lineChart.online.xname = []
|
chartData.xname = []
|
||||||
this.lineChart.online.xdata["在线人数"] = []
|
chartData.xdata["在线人数"] = []
|
||||||
for(var i=0; i<datas.length;i++){
|
for(var i=0; i<datas.length;i++){
|
||||||
this.lineChart.online.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
chartData.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
||||||
this.lineChart.online.xdata["在线人数"][i] = datas[i].num
|
chartData.xdata["在线人数"][i] = datas[i].num
|
||||||
}
|
}
|
||||||
// 实时更新在线数
|
// 实时更新在线数
|
||||||
if (data.scope == "rt") {
|
if (data.scope == "rt") {
|
||||||
this.counts.online = datas[datas.length - 1].num
|
this.counts.online = datas[datas.length - 1].num
|
||||||
}
|
}
|
||||||
|
this.lineChart[data.action] = chartData
|
||||||
},
|
},
|
||||||
formatNetwork(data) {
|
formatNetwork(data) {
|
||||||
let timeFormat = data.scope == "rt" || data.scope == "1h" || data.scope == "24h" ? "h:i:s" : "m/d h:i:s"
|
let timeFormat = this.getTimeFormat(data.scope)
|
||||||
|
let chartData = this.lineChart[data.action]
|
||||||
let datas = data.datas
|
let datas = data.datas
|
||||||
this.lineChart.network.xname = []
|
chartData.xname = []
|
||||||
this.lineChart.network.xdata["上行流量"] = []
|
chartData.xdata["上行流量"] = []
|
||||||
this.lineChart.network.xdata["下行流量"] = []
|
chartData.xdata["下行流量"] = []
|
||||||
for(var i=0; i<datas.length;i++){
|
for(var i=0; i<datas.length;i++){
|
||||||
this.lineChart.network.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
chartData.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
||||||
this.lineChart.network.xdata["上行流量"][i] = this.toMbps(datas[i].up)
|
chartData.xdata["上行流量"][i] = this.toMbps(datas[i].up)
|
||||||
this.lineChart.network.xdata["下行流量"][i] = this.toMbps(datas[i].down)
|
chartData.xdata["下行流量"][i] = this.toMbps(datas[i].down)
|
||||||
}
|
}
|
||||||
|
this.lineChart[data.action] = chartData
|
||||||
},
|
},
|
||||||
formatCpu(data) {
|
formatCpu(data) {
|
||||||
let timeFormat = data.scope == "rt" || data.scope == "1h" || data.scope == "24h" ? "h:i:s" : "m/d h:i:s"
|
let timeFormat = this.getTimeFormat(data.scope)
|
||||||
|
let chartData = this.lineChart[data.action]
|
||||||
let datas = data.datas
|
let datas = data.datas
|
||||||
this.lineChart.cpu.xname = []
|
chartData.xname = []
|
||||||
this.lineChart.cpu.xdata["CPU"] = []
|
chartData.xdata["CPU"] = []
|
||||||
for(var i=0; i<datas.length;i++){
|
for(var i=0; i<datas.length;i++){
|
||||||
this.lineChart.cpu.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
chartData.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
||||||
this.lineChart.cpu.xdata["CPU"][i] = this.toDecimal(datas[i].percent)
|
chartData.xdata["CPU"][i] = this.toDecimal(datas[i].percent)
|
||||||
}
|
}
|
||||||
|
this.lineChart[data.action] = chartData
|
||||||
},
|
},
|
||||||
formatMem(data) {
|
formatMem(data) {
|
||||||
let timeFormat = data.scope == "rt" || data.scope == "1h" || data.scope == "24h" ? "h:i:s" : "m/d h:i:s"
|
let timeFormat = this.getTimeFormat(data.scope)
|
||||||
|
let chartData = this.lineChart[data.action]
|
||||||
let datas = data.datas
|
let datas = data.datas
|
||||||
this.lineChart.mem.xname = []
|
chartData.xname = []
|
||||||
this.lineChart.mem.xdata["内存"] = []
|
chartData.xdata["内存"] = []
|
||||||
for(var i=0; i<datas.length;i++){
|
for(var i=0; i<datas.length;i++){
|
||||||
this.lineChart.mem.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
chartData.xname[i] = this.dateFormat(datas[i].created_at, timeFormat)
|
||||||
this.lineChart.mem.xdata["内存"][i] = this.toDecimal(datas[i].percent)
|
chartData.xdata["内存"][i] = this.toDecimal(datas[i].percent)
|
||||||
}
|
}
|
||||||
|
this.lineChart[data.action] = chartData
|
||||||
|
},
|
||||||
|
getTimeFormat(scope) {
|
||||||
|
return (scope == "rt" || scope == "1h" || scope == "24h") ? "h:i:s" : "m/d h:i:s"
|
||||||
},
|
},
|
||||||
toMbps(bytes) {
|
toMbps(bytes) {
|
||||||
if (bytes == 0) return 0
|
if (bytes == 0) return 0
|
||||||
|
|
Loading…
Reference in New Issue