Merge branch 'dev-3.9' of git.mesalab.cn:nezha/nezha-fronted into dev-3.9
This commit is contained in:
@@ -191,7 +191,6 @@ export default {
|
||||
|
||||
this.legends = []
|
||||
this.series = chartOption.series = this.handleTimeSeries(this.chartInfo, chartOption.series[0], this.chartData) // 生成series和legends
|
||||
|
||||
chartOption.series.forEach(item => {
|
||||
if (item.lineStyle) {
|
||||
item.lineStyle.width = this.lineOption.lineWidth
|
||||
@@ -611,7 +610,10 @@ export default {
|
||||
yAxisLabelFormatter (minValue, maxValue, copies, unit, dot) {
|
||||
const self = this
|
||||
return function (val, index) {
|
||||
const value = formatScientificNotation(val, 6)
|
||||
let value = formatScientificNotation(val, 6)
|
||||
if (!val) {
|
||||
value = 0
|
||||
}
|
||||
return unit.compute(value, index, -1, dot)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -350,7 +350,7 @@ export default {
|
||||
maxValue = Math.abs(minValue)
|
||||
}
|
||||
maxValue = maxValue - minValue
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii)
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii)
|
||||
let oldValue = maxValue
|
||||
if (maxValue < 0) {
|
||||
oldValue = Math.abs(maxValue)
|
||||
|
||||
@@ -2083,7 +2083,7 @@ export default {
|
||||
maxValue = Math.abs(minValue)
|
||||
}
|
||||
maxValue = maxValue - minValue
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii)
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii)
|
||||
let oldValue = maxValue
|
||||
let dot = 0
|
||||
if (maxValue == 1) {
|
||||
|
||||
@@ -73,6 +73,22 @@ function bits (value, index, type = 1, dot = 0) {
|
||||
return asciiCompute(num, 1024, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function bitsSI (value, index, type = 1, dot = 0) {
|
||||
const num = value / 8
|
||||
if (value < 8) {
|
||||
return value + 'b'
|
||||
}
|
||||
if (num < 1000) {
|
||||
return num + 'B'
|
||||
}
|
||||
if (type == 1) {
|
||||
return asciiCompute(num, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(num, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot)
|
||||
} else {
|
||||
return asciiCompute(num, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function bytes (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
@@ -82,6 +98,15 @@ function bytes (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1024, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function bytesSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function kilobytes (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
@@ -91,6 +116,15 @@ function kilobytes (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1024, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function kilobytesSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1000, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1000, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function megabytes (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
@@ -100,6 +134,15 @@ function megabytes (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1024, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function megabytesSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1000, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1000, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function gigabytes (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
@@ -109,6 +152,15 @@ function gigabytes (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1024, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function gigabytesSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1000, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1000, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function terabytes (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
@@ -118,6 +170,15 @@ function terabytes (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1024, ['TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function terabytesSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['TB', 'PB', 'EB', 'ZB', 'YB'], 0)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1000, ['TB', 'PB', 'EB', 'ZB', 'YB'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1000, ['TB', 'PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function petabytes (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 0)
|
||||
@@ -127,6 +188,15 @@ function petabytes (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function petabytesSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 0)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 2)
|
||||
}
|
||||
}
|
||||
function packetsSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['pps', 'Kpps', 'Mpps', 'Gpps', 'Tpps', 'Ppps', 'Epps', 'Zpps', 'Ypps'], 1)
|
||||
@@ -137,6 +207,128 @@ function packetsSec (value, index, type = 1, dot) {
|
||||
}
|
||||
}
|
||||
function bitsSec (value, index, type = 1, dot) {
|
||||
const num = value / 8
|
||||
if (value < 8) {
|
||||
return value + 'b'
|
||||
}
|
||||
if (num < 1024) {
|
||||
return num + 'B'
|
||||
}
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 2)
|
||||
}
|
||||
}
|
||||
function bytesSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function kilobytesSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
}
|
||||
}
|
||||
function kilobitsSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function megabytesSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function megabitsSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function gigabytesSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function gigabitsSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function terabytesSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function terabitsSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function petabytesSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['PBs', 'EBs', 'ZBs', 'YBs'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function petabitsSec (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1024, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
return asciiCompute(value, 1024, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], dot)
|
||||
} else {
|
||||
return asciiCompute(value, 1024, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function bitsSecSI (value, index, type = 1, dot) {
|
||||
const num = value / 8
|
||||
if (value < 8) {
|
||||
return value + 'b'
|
||||
}
|
||||
if (num < 1000) {
|
||||
return num + 'B'
|
||||
}
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -145,7 +337,7 @@ function bitsSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 2)
|
||||
}
|
||||
}
|
||||
function bytesSec (value, index, type = 1, dot) {
|
||||
function bytesSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -154,7 +346,7 @@ function bytesSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function kilobytesSec (value, index, type = 1, dot) {
|
||||
function kilobytesSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -163,7 +355,7 @@ function kilobytesSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
}
|
||||
}
|
||||
function kilobitsSec (value, index, type = 1, dot) {
|
||||
function kilobitsSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -172,7 +364,7 @@ function kilobitsSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function megabytesSec (value, index, type = 1, dot) {
|
||||
function megabytesSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -181,7 +373,7 @@ function megabytesSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function megabitsSec (value, index, type = 1, dot) {
|
||||
function megabitsSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -190,7 +382,7 @@ function megabitsSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function gigabytesSec (value, index, type = 1, dot) {
|
||||
function gigabytesSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -199,7 +391,7 @@ function gigabytesSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function gigabitsSec (value, index, type = 1, dot) {
|
||||
function gigabitsSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -208,7 +400,7 @@ function gigabitsSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function terabytesSec (value, index, type = 1, dot) {
|
||||
function terabytesSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -217,7 +409,7 @@ function terabytesSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function terabitsSec (value, index, type = 1, dot) {
|
||||
function terabitsSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -226,7 +418,7 @@ function terabitsSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
function petabytesSec (value, index, type = 1, dot) {
|
||||
function petabytesSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['PBs', 'EBs', 'ZBs', 'YBs'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -235,7 +427,7 @@ function petabytesSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['PBs', 'EBs', 'ZBs', 'YBs'], 2)
|
||||
}
|
||||
}
|
||||
function petabitsSec (value, index, type = 1, dot) {
|
||||
function petabitsSecSI (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 1)
|
||||
} else if (type == -1) {
|
||||
@@ -244,6 +436,7 @@ function petabitsSec (value, index, type = 1, dot) {
|
||||
return asciiCompute(value, 1000, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 2)
|
||||
}
|
||||
}
|
||||
|
||||
function Hertz (value, index, type = 1, dot) {
|
||||
if (type == 1) {
|
||||
return asciiCompute(value, 1000, ['Hz', 'KHz', 'MHz', 'GHz', 'THz', 'PHz', 'EHz', 'ZHz', 'YHz'], 1)
|
||||
@@ -549,37 +742,86 @@ const unitOptions = [
|
||||
{
|
||||
value: 6,
|
||||
compute: bits,
|
||||
label: 'bits'
|
||||
label: 'bits(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 36,
|
||||
compute: bitsSI,
|
||||
label: 'bits(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 7,
|
||||
compute: bytes,
|
||||
label: 'bytes'
|
||||
label: 'bytes(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 37,
|
||||
compute: bytesSI,
|
||||
label: 'bytes(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 8,
|
||||
compute: kilobytes,
|
||||
label: 'kilobytes'
|
||||
label: 'kilobytes(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 38,
|
||||
compute: kilobytesSI,
|
||||
label: 'kilobytes(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 9,
|
||||
compute: megabytes,
|
||||
label: 'megabytes'
|
||||
label: 'megabytes(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 39,
|
||||
compute: megabytesSI,
|
||||
label: 'megabytes(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 10,
|
||||
compute: gigabytes,
|
||||
label: 'gigabytes'
|
||||
label: 'gigabytes(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 40,
|
||||
compute: gigabytesSI,
|
||||
label: 'gigabytes(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 11,
|
||||
compute: terabytes,
|
||||
label: 'terabytes'
|
||||
label: 'terabytes(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 41,
|
||||
compute: terabytesSI,
|
||||
label: 'terabytes(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 12,
|
||||
compute: petabytes,
|
||||
label: 'petabytes'
|
||||
label: 'petabytes(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 42,
|
||||
compute: petabytesSI,
|
||||
label: 'petabytes(SI)',
|
||||
ascii: 1000
|
||||
}
|
||||
]
|
||||
}, // Data end
|
||||
@@ -590,67 +832,152 @@ const unitOptions = [
|
||||
{
|
||||
value: 13,
|
||||
compute: packetsSec,
|
||||
label: 'packets/sec'
|
||||
label: 'packets/sec',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 14,
|
||||
compute: bitsSec,
|
||||
label: 'bits/sec'
|
||||
label: 'bits/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 43,
|
||||
compute: bitsSecSI,
|
||||
label: 'bits/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 15,
|
||||
compute: bytesSec,
|
||||
label: 'bytes/sec'
|
||||
label: 'bytes/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 44,
|
||||
compute: bytesSecSI,
|
||||
label: 'bytes/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 16,
|
||||
compute: kilobytesSec,
|
||||
label: 'kilobytes/sec'
|
||||
label: 'kilobytes/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 45,
|
||||
compute: kilobytesSecSI,
|
||||
label: 'kilobytes/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 17,
|
||||
compute: kilobitsSec,
|
||||
label: 'kilobits/sec'
|
||||
label: 'kilobits/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 46,
|
||||
compute: kilobitsSecSI,
|
||||
label: 'kilobits/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 18,
|
||||
compute: megabytesSec,
|
||||
label: 'megabytes/sec'
|
||||
label: 'megabytes/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 47,
|
||||
compute: megabytesSecSI,
|
||||
label: 'megabytes/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 19,
|
||||
compute: megabitsSec,
|
||||
label: 'megabits/sec'
|
||||
label: 'megabits/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 48,
|
||||
compute: megabitsSecSI,
|
||||
label: 'megabits/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 20,
|
||||
compute: gigabytesSec,
|
||||
label: 'gigabytes/sec'
|
||||
label: 'gigabytes/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 49,
|
||||
compute: gigabytesSecSI,
|
||||
label: 'gigabytes/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 21,
|
||||
compute: gigabitsSec,
|
||||
label: 'gigabits/sec'
|
||||
label: 'gigabits/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 50,
|
||||
compute: gigabitsSec,
|
||||
label: 'gigabits/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 22,
|
||||
compute: terabytesSec,
|
||||
label: 'terabytes/sec'
|
||||
label: 'terabytes/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 51,
|
||||
compute: terabytesSecSI,
|
||||
label: 'terabytes/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 23,
|
||||
compute: terabitsSec,
|
||||
label: 'terabits/sec'
|
||||
label: 'terabits/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 52,
|
||||
compute: terabitsSecSI,
|
||||
label: 'terabits/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 24,
|
||||
compute: petabytesSec,
|
||||
label: 'petabytes/sec'
|
||||
label: 'petabytes/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 53,
|
||||
compute: petabytesSecSI,
|
||||
label: 'petabytes/sec(SI)',
|
||||
ascii: 1000
|
||||
},
|
||||
{
|
||||
value: 25,
|
||||
compute: petabitsSec,
|
||||
label: 'petabits/sec'
|
||||
label: 'petabits/sec(IEC)',
|
||||
ascii: 1024
|
||||
},
|
||||
{
|
||||
value: 54,
|
||||
compute: petabitsSecSI,
|
||||
label: 'petabits/sec(SI)',
|
||||
ascii: 1000
|
||||
}
|
||||
]
|
||||
}, // DataRate end
|
||||
@@ -739,7 +1066,7 @@ export default {
|
||||
unitOptions: function () {
|
||||
return unitOptions
|
||||
},
|
||||
getUnit: function (index) {
|
||||
getUnit: function (value) {
|
||||
if (units.length < 1) {
|
||||
unitOptions.forEach((item, index) => {
|
||||
item.children.forEach((n, i) => {
|
||||
@@ -747,13 +1074,15 @@ export default {
|
||||
})
|
||||
})
|
||||
}
|
||||
return units[index - 1]
|
||||
return units.find(item => item.value === value)
|
||||
},
|
||||
formatData: function (value, unit) {
|
||||
return this.getUnit(unit).compute(value, null, 2)
|
||||
},
|
||||
formatDatas: function (value, type, flow = 'ceil', ascii) {
|
||||
formatDatas: function (value, unit, flow = 'ceil') {
|
||||
let pow = 0
|
||||
const ascii = unit.ascii || 1000
|
||||
const type = unit.type
|
||||
if (value < 1 && value != 0) {
|
||||
while (value < 1) {
|
||||
pow++
|
||||
@@ -767,19 +1096,19 @@ export default {
|
||||
|
||||
if (type === 'Data') {
|
||||
if (value > 1) {
|
||||
while (value > 1024) {
|
||||
while (value > ascii) {
|
||||
pow++
|
||||
value = value / 1024
|
||||
value = value / ascii
|
||||
}
|
||||
|
||||
if (flow === 'ceil') {
|
||||
const length = JSON.stringify(Math.ceil(value)).length
|
||||
value = value / Math.pow(10, length - 1)
|
||||
return Math.ceil(value) * Math.pow(1024, pow) * Math.pow(10, length - 1)
|
||||
return Math.ceil(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1)
|
||||
} else if (flow === 'floor') {
|
||||
const length = JSON.stringify(Math.floor(value)).length
|
||||
value = value / Math.pow(10, length - 1)
|
||||
return Math.floor(value) * Math.pow(1024, pow) * Math.pow(10, length - 1)
|
||||
return Math.floor(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1)
|
||||
}
|
||||
} else {
|
||||
return value
|
||||
@@ -788,19 +1117,19 @@ export default {
|
||||
|
||||
if (type === 'Misc' || type === 'DataRate') {
|
||||
if (value > 1) {
|
||||
while (value > 1000) {
|
||||
while (value > ascii) {
|
||||
pow++
|
||||
value = value / 1000
|
||||
value = value / ascii
|
||||
}
|
||||
|
||||
if (flow === 'ceil') {
|
||||
const length = JSON.stringify(Math.ceil(value)).length
|
||||
value = value / Math.pow(10, length - 1)
|
||||
return Math.ceil(value) * Math.pow(1000, pow) * Math.pow(10, length - 1)
|
||||
return Math.ceil(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1)
|
||||
} else if (flow === 'floor') {
|
||||
const length = JSON.stringify(Math.floor(value)).length
|
||||
value = value / Math.pow(10, length - 1)
|
||||
return Math.floor(value) * Math.pow(1000, pow) * Math.pow(10, length - 1)
|
||||
return Math.floor(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1)
|
||||
}
|
||||
} else {
|
||||
return value
|
||||
@@ -823,7 +1152,9 @@ export default {
|
||||
case 10: return 5
|
||||
}
|
||||
},
|
||||
Interval: function (value, copies, type, interValType) {
|
||||
Interval: function (value, copies, unit, interValType) {
|
||||
const type = unit.type || unit
|
||||
const ascii = unit.ascii || 1000
|
||||
if (!copies) {
|
||||
copies = 1
|
||||
}
|
||||
@@ -834,12 +1165,12 @@ export default {
|
||||
return value || 1
|
||||
}
|
||||
|
||||
if (value < 1024 && type === 'Data') {
|
||||
if (value < ascii && type === 'Data') {
|
||||
let interVal = value / copies
|
||||
interVal = !isNaN(interVal) ? interVal : 1
|
||||
return interVal
|
||||
}
|
||||
if (value < 1000 && (type === 'DataRate' || type === 'Misc')) {
|
||||
if (value < ascii && (type === 'DataRate' || type === 'Misc')) {
|
||||
let interVal = value / copies
|
||||
interVal = !isNaN(interVal) ? interVal : 1
|
||||
return interVal
|
||||
@@ -848,17 +1179,17 @@ export default {
|
||||
let interVal = value / copies
|
||||
let pow = 0
|
||||
if (interVal) {
|
||||
while (interVal > 1024) {
|
||||
while (interVal > ascii) {
|
||||
pow++
|
||||
interVal = interVal / 1024
|
||||
interVal = interVal / ascii
|
||||
}
|
||||
interVal = Math.ceil(interVal) * Math.pow(1024, pow)
|
||||
interVal = Math.ceil(interVal) * Math.pow(ascii, pow)
|
||||
}
|
||||
interVal = !isNaN(interVal) ? interVal : 1
|
||||
if (interVal >= 1 && interVal <= 512) {
|
||||
interVal = 512
|
||||
} else if (interVal > 512 && interVal <= 1024) {
|
||||
interVal = 1024
|
||||
if (interVal >= 1 && interVal <= ascii / 2) {
|
||||
interVal = ascii / 2
|
||||
} else if (interVal > 512 && interVal <= ascii) {
|
||||
interVal = ascii
|
||||
}
|
||||
return interVal
|
||||
}
|
||||
@@ -866,11 +1197,11 @@ export default {
|
||||
let interVal = value / copies
|
||||
let pow = 0
|
||||
if (interVal) {
|
||||
while (interVal > 1000) {
|
||||
while (interVal > ascii) {
|
||||
pow++
|
||||
interVal = interVal / 1000
|
||||
interVal = interVal / ascii
|
||||
}
|
||||
interVal = Math.ceil(interVal) * Math.pow(1000, pow)
|
||||
interVal = Math.ceil(interVal) * Math.pow(ascii, pow)
|
||||
}
|
||||
interVal = !isNaN(interVal) ? interVal : 1
|
||||
return interVal
|
||||
|
||||
@@ -100,12 +100,12 @@ export default {
|
||||
|
||||
// 设置右y轴
|
||||
if (chartInfo.param.enable.rightYAxis) {
|
||||
s.yAxisIndex = 0
|
||||
chartInfo.param.rightYAxis && chartInfo.param.rightYAxis.elementNames.forEach(item => {
|
||||
if (data.elements.name == item) {
|
||||
if ((data.elements.name == item) && !s.yAxisIndex) {
|
||||
s.yAxisIndex = 1
|
||||
data.yAxisIndex = 1
|
||||
} else {
|
||||
s.yAxisIndex = 0
|
||||
data.yAxisIndex = 0
|
||||
}
|
||||
})
|
||||
@@ -405,7 +405,7 @@ export default {
|
||||
maxValue = Math.abs(minValue)
|
||||
}
|
||||
maxValue = maxValue - minValue
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii)
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii)
|
||||
let oldValue = maxValue
|
||||
if (maxValue < 0) {
|
||||
oldValue = Math.abs(maxValue)
|
||||
|
||||
@@ -437,6 +437,7 @@ export default {
|
||||
if (this.chartInfo.type === 'log') {
|
||||
this.logChartDataFormat()
|
||||
}
|
||||
console.log(this.$lodash.cloneDeep(this.chartData), '123123')
|
||||
}).catch(res => {
|
||||
// console.info(res)
|
||||
}).finally(() => {
|
||||
|
||||
@@ -31,8 +31,8 @@ export default {
|
||||
// 左y轴
|
||||
const leftData = chartData.filter(item => item[0] && !item[0].yAxisIndex)
|
||||
const leftInfo = this.getMinMaxFromData(leftData, chartInfo.unit, chartInfo.param) //
|
||||
chartOption.yAxis[0].minInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit.type, 'min')
|
||||
chartOption.yAxis[0].maxInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit.type, 'max') * Math.ceil(this.series.length / 5)
|
||||
chartOption.yAxis[0].minInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit, 'min')
|
||||
chartOption.yAxis[0].maxInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit, 'max') * Math.ceil(this.series.length / 5)
|
||||
if (chartInfo.param.stack) {
|
||||
chartOption.yAxis[0].maxInterval = chartOption.yAxis[0].maxInterval * (Math.ceil(leftData.length / 5) + 1)
|
||||
}
|
||||
@@ -64,8 +64,8 @@ export default {
|
||||
chartOption.yAxis[1].splitLine.show = allRight
|
||||
const rightData = chartData.filter(item => item[0] && item[0].yAxisIndex)
|
||||
const rightInfo = this.getMinMaxFromData(rightData, lodash.get(chartInfo, 'param.rightYAxis.unit', 2), lodash.get(chartInfo, 'param.rightYAxis', {}))//
|
||||
chartOption.yAxis[1].minInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit.type, 'min')
|
||||
chartOption.yAxis[1].maxInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit.type, 'max') * Math.ceil(this.series.length / 5)
|
||||
chartOption.yAxis[1].minInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit, 'min')
|
||||
chartOption.yAxis[1].maxInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit, 'max') * Math.ceil(this.series.length / 5)
|
||||
if (chartInfo.param.stack) {
|
||||
chartOption.yAxis[1].maxInterval = chartOption.yAxis[1].maxInterval * (Math.ceil(rightData.length / 5) + 1)
|
||||
}
|
||||
@@ -158,7 +158,7 @@ export default {
|
||||
maxValue = Math.abs(minValue)
|
||||
}
|
||||
maxValue = maxValue - minValue
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii) // 取最大值后 需要对其进行取整
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii) // 取最大值后 需要对其进行取整
|
||||
let oldValue = maxValue
|
||||
let dot = 0
|
||||
if (oldValue == 1) {
|
||||
|
||||
@@ -267,7 +267,9 @@ export default {
|
||||
this.object.paramObj.push({ key: '', value: [] })
|
||||
}
|
||||
this.object.assetName = this.object.asset ? this.object.asset.name : ''
|
||||
this.object.softwareAssetName = this.object.softwareAsset ? this.object.softwareAsset.name : ''
|
||||
this.object.assetId = this.object.asset ? this.object.asset.id + '' : ''
|
||||
this.object.softwareAssetId = this.object.softwareAsset ? this.object.softwareAsset.id + '' : ''
|
||||
this.object.projectId = this.object.project.id
|
||||
this.object.moduleId = this.object.module.id
|
||||
this.object.type = this.object.module.type
|
||||
|
||||
@@ -86,6 +86,7 @@ export default {
|
||||
async handler (n) {
|
||||
if (n) {
|
||||
this.searchLabel = {}
|
||||
this.tableData = []
|
||||
this.getTableData()
|
||||
}
|
||||
}
|
||||
@@ -152,6 +153,8 @@ export default {
|
||||
this.toTopBtnHandler(this.scrollbarWrap)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.$message.error(response.msg || response.error)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -83,7 +83,6 @@ export default {
|
||||
momentTz (timestamp, fmt) { // moment 转化时间戳为str
|
||||
const offset = localStorage.getItem('nz-sys-timezone')
|
||||
const format = fmt || localStorage.getItem('nz-default-dateFormat')
|
||||
console.log(timestamp, fmt, offset, localStorage.getItem('nz-default-dateFormat'), format)
|
||||
return moment.tz(timestamp, offset).format(format)
|
||||
},
|
||||
momentStrToTimestamp (str, fmt) {
|
||||
|
||||
@@ -56,9 +56,17 @@
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="item.prop === 'category'">
|
||||
<div>
|
||||
{{scope.row.type ? scope.row.type.category : '-'}}
|
||||
</div>
|
||||
<div>
|
||||
{{scope.row.type ? scope.row.type.category : '-'}}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="item.prop === 'loginlimit'">
|
||||
<div v-if="scope.row.loginlimit">
|
||||
{{scope.row.loginlimit == -1 ? '∞': scope.row.loginlimit}}
|
||||
</div>
|
||||
<div v-else>
|
||||
'-'
|
||||
</div>
|
||||
</template>
|
||||
<span v-else-if="item.prop === 'production_date' || item.prop === 'expiration_date'">{{ scope.row[item.prop] ? momentTz(scope.row[item.prop] * 1000) : '-'}}</span>
|
||||
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
||||
@@ -110,13 +118,13 @@ export default {
|
||||
tableTitle: [ // 原始table列
|
||||
{
|
||||
label: this.$t('licenseMange.product'),
|
||||
prop: 'typename',
|
||||
prop: 'name',
|
||||
show: true,
|
||||
width: 350
|
||||
// sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('licenseMange.keyType'),
|
||||
prop: 'name',
|
||||
prop: 'typename',
|
||||
minWidth: 200,
|
||||
show: true
|
||||
}, {
|
||||
|
||||
@@ -3885,10 +3885,12 @@ export default {
|
||||
this.$refs.logDetail && this.$refs.logDetail.resetOperation()
|
||||
if (this.expressions.length > 0) {
|
||||
const requestArr = []
|
||||
const realArr = [] // 记录原始位置
|
||||
// 过滤掉state为0的元素
|
||||
this.expressions.forEach((item, index) => {
|
||||
if (item != '' && this.promqlKeys[index].state && item) {
|
||||
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[0])) + '&end=' + this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[1])) + '&limit=' + limit))
|
||||
realArr.push(index)
|
||||
}
|
||||
})
|
||||
if (requestArr.length > 0) {
|
||||
@@ -3896,18 +3898,22 @@ export default {
|
||||
this.saveDisabled = false
|
||||
}
|
||||
axios.all(requestArr).then(res => {
|
||||
this.postHistory()
|
||||
console.log(res)
|
||||
this.chartLoading = false
|
||||
const errorRowIndex = []
|
||||
res.forEach((r, i) => {
|
||||
if (typeof r === 'string') {
|
||||
if (r.code !== 200) {
|
||||
errorRowIndex.push(i)
|
||||
this.promqlKeys[realArr[i]].isResError = true
|
||||
} else {
|
||||
this.promqlKeys[realArr[i]].isResError = false
|
||||
}
|
||||
})
|
||||
if (errorRowIndex.length > 0) {
|
||||
this.$message.error(this.$t('tip.errorInRow') + ': ' + errorRowIndex.map(e => e + 1).join(' ,'))
|
||||
res = res.filter((r, i) => errorRowIndex.indexOf(i) === -1)
|
||||
}
|
||||
this.postHistory()
|
||||
if (res.length > 0) {
|
||||
const logData = res.map(r => r.data)
|
||||
if (logData[0].result.length > 0) {
|
||||
@@ -3941,6 +3947,8 @@ export default {
|
||||
this.logData = logData
|
||||
hasGraph && this.loadLogGraph()
|
||||
})
|
||||
} else {
|
||||
this.showIntroduce = true
|
||||
}
|
||||
}).catch(e => {
|
||||
this.chartLoading = false
|
||||
@@ -4370,7 +4378,6 @@ export default {
|
||||
} else {
|
||||
const promiseArr = []
|
||||
this.expressions.forEach((item, index) => {
|
||||
console.log(item)
|
||||
if (item != '' && this.promqlKeys[index].state && item) {
|
||||
promiseArr.push(this.$get('logs/loki/api/v1/format_query', { query: item }))
|
||||
} else {
|
||||
@@ -4386,7 +4393,6 @@ export default {
|
||||
this.updatePath()
|
||||
},
|
||||
initQueryFromPath () {
|
||||
console.log('initQueryFromPath')
|
||||
const param = this.$route.query[this.position]
|
||||
if (param) {
|
||||
const data = JSON.parse(param)
|
||||
@@ -4412,7 +4418,6 @@ export default {
|
||||
this.promqlCount = data.queries.length
|
||||
data.queries.forEach((item, index) => {
|
||||
this.$set(this.expressions, index, item.expr)
|
||||
console.log(item)
|
||||
this.promqlKeys[index] = {
|
||||
...item,
|
||||
id: getUUID(),
|
||||
@@ -4571,7 +4576,7 @@ export default {
|
||||
})
|
||||
this.lastHistory.forEach((item) => {
|
||||
const findItem = arr.find(history => history.id == item.id)
|
||||
if (findItem && findItem.queryValue !== item.value) {
|
||||
if (findItem && findItem.queryValue !== item.value && !findItem.isError && !findItem.isResError) {
|
||||
postArr.push({
|
||||
queryKey,
|
||||
queryValue: findItem.queryValue
|
||||
@@ -4580,7 +4585,7 @@ export default {
|
||||
})
|
||||
arr.forEach(item => {
|
||||
const findItem = this.lastHistory.find(history => history.id == item.id)
|
||||
if (!findItem) {
|
||||
if (!findItem && !item.isResError) {
|
||||
postArr.push({
|
||||
queryKey,
|
||||
queryValue: item.queryValue
|
||||
@@ -4588,8 +4593,8 @@ export default {
|
||||
}
|
||||
})
|
||||
postArr = postArr.filter(item => item.queryValue)
|
||||
console.log(postArr)
|
||||
this.$post('/sys/user/queryHistory', postArr).then(res => {
|
||||
console.log(res)
|
||||
this.lastHistory = this.$lodash.cloneDeep(postArr)
|
||||
})
|
||||
},
|
||||
|
||||
178
nezha-fronted/src/components/page/dashboard/explore/logqlHint.js
Normal file
178
nezha-fronted/src/components/page/dashboard/explore/logqlHint.js
Normal file
@@ -0,0 +1,178 @@
|
||||
const logqlHint = {
|
||||
functions: [{
|
||||
label: 'rate',
|
||||
detail: 'functions',
|
||||
info: 'Calculates the number of entries per second.',
|
||||
type: 'functions'
|
||||
}, {
|
||||
label: 'count_over_time',
|
||||
detail: 'functions',
|
||||
info: 'Counts the entries for each log stream within the given range.',
|
||||
type: 'functions'
|
||||
}, {
|
||||
label: 'bytes_rate',
|
||||
detail: 'functions',
|
||||
info: 'Calculates the number of bytes per second for each stream.',
|
||||
type: 'functions'
|
||||
}, {
|
||||
label: 'bytes_over_time',
|
||||
detail: 'functions',
|
||||
info: 'counts the amount of bytes used by each log stream for a given range.',
|
||||
type: 'functions'
|
||||
}, {
|
||||
label: 'absent_over_time',
|
||||
detail: 'functions',
|
||||
info: 'returns an empty vector if the range vector passed to it has any elements and a 1-element vector with the value 1 if the range vector passed to it has no elements. (absent_over_time is useful for alerting on when no time series and logs stream exist for label combination for a certain amount of time.)',
|
||||
type: 'functions'
|
||||
}
|
||||
],
|
||||
aggregateOp: [{
|
||||
label: 'duration_seconds',
|
||||
detail: 'aggregation',
|
||||
info: 'which will convert the label value in seconds from the go duration format (e.g 5m, 24s30ms).',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'duration',
|
||||
detail: 'aggregation',
|
||||
info: 'which will convert the label value in seconds from the go duration format (e.g 5m, 24s30ms).',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'bytes',
|
||||
detail: 'aggregation',
|
||||
info: 'which will convert the label value to raw bytes applying the bytes unit (e.g. 5 MiB, 3k, 1G).',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'rate',
|
||||
detail: 'aggregation',
|
||||
info: 'calculates per second rate of the sum of all values in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'rate_counter',
|
||||
detail: 'aggregation',
|
||||
info: 'calculates per second rate of the values in the specified interval and treating them as “counter metric”.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'sum_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the sum of all values in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'avg_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the average value of all points in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'max_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the maximum value of all points in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'min_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the minimum value of all points in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'min_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the minimum value of all points in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'first_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the first value of all points in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'last_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the last value of all points in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'stdvar_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the population standard variance of the values in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'stddev_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the population standard deviation of the values in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'quantile_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'the φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval.',
|
||||
type: 'keyword'
|
||||
}, {
|
||||
label: 'absent_over_time',
|
||||
detail: 'aggregation',
|
||||
info: 'returns an empty vector if the range vector passed to it has any elements and a 1-element vector with the value 1 if the range vector passed to it has no elements. (absent_over_time is useful for alerting on when no time series and logs stream exist for label combination for a certain amount of time.)',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'sum',
|
||||
detail: 'aggregation',
|
||||
info: 'Calculate sum over labels',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'avg',
|
||||
detail: 'aggregation',
|
||||
info: 'Calculate the average over labels',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'min',
|
||||
detail: 'aggregation',
|
||||
info: 'Select minimum over labels',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'max',
|
||||
detail: 'aggregation',
|
||||
info: 'Select maximum over labels',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'stddev',
|
||||
detail: 'aggregation',
|
||||
info: 'Calculate the population standard deviation over labels',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'stdvar',
|
||||
detail: 'aggregation',
|
||||
info: 'Calculate the population standard variance over labels',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'count',
|
||||
detail: 'aggregation',
|
||||
info: 'Count number of elements in the vector',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'topk',
|
||||
detail: 'aggregation',
|
||||
info: 'Select largest k elements by sample value',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'bottomk',
|
||||
detail: 'aggregation',
|
||||
info: 'Select smallest k elements by sample value',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'sort',
|
||||
detail: 'aggregation',
|
||||
info: 'returns vector elements sorted by their sample values, in ascending order.',
|
||||
type: 'keyword'
|
||||
},
|
||||
{
|
||||
label: 'sort_desc',
|
||||
detail: 'aggregation',
|
||||
info: 'Same as sort, but sorts in descending order.',
|
||||
type: 'keyword'
|
||||
}
|
||||
]
|
||||
}
|
||||
export default logqlHint
|
||||
@@ -10,30 +10,29 @@
|
||||
@click="dropDownVisible = false"
|
||||
>
|
||||
<div
|
||||
:id="pqid + 'editor'+index"
|
||||
v-if="type !== 'log'"
|
||||
:id="pqid + 'editor'+index + type"
|
||||
class="not-fixed-height no-resize no-close"
|
||||
style="padding-right: 24px;box-sizing: border-box"
|
||||
>
|
||||
</div>
|
||||
<div class="zy" style="position: relative;overflow-x: hidden;display: block;border: 1px solid #dedede;width: 100%" v-if="type == 'log'">
|
||||
<MonacoEditor
|
||||
v-if="type == 'log'"
|
||||
v-model="expressionList[index]"
|
||||
theme="nz"
|
||||
class="not-fixed-height no-resize"
|
||||
ref="monacoEditor"
|
||||
style="width: calc(100% - 24px)"
|
||||
:style="{
|
||||
height: monacoEditorHeight + 'px'
|
||||
}"
|
||||
language="logql"
|
||||
:options="MONACO_EDITOR_OPTIONS"
|
||||
@editorWillMount="handelBeforeMount"
|
||||
@editorDidMount="handleMount"
|
||||
@change="expressionChange"
|
||||
/>
|
||||
</div>
|
||||
<!-- <div class="zy" style="position: relative;overflow-x: hidden;display: block;border: 1px solid #dedede;width: 100%" v-if="type == 'log'">-->
|
||||
<!-- <MonacoEditor-->
|
||||
<!-- v-if="type == 'log'"-->
|
||||
<!-- v-model="expressionList[index]"-->
|
||||
<!-- theme="nz"-->
|
||||
<!-- class="not-fixed-height no-resize"-->
|
||||
<!-- ref="monacoEditor"-->
|
||||
<!-- style="width: calc(100% - 24px)"-->
|
||||
<!-- :style="{-->
|
||||
<!-- height: monacoEditorHeight + 'px'-->
|
||||
<!-- }"-->
|
||||
<!-- language="logql"-->
|
||||
<!-- :options="MONACO_EDITOR_OPTIONS"-->
|
||||
<!-- @editorWillMount="handelBeforeMount"-->
|
||||
<!-- @editorDidMount="handleMount"-->
|
||||
<!-- @change="expressionChange"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div v-if="errorMsg" class="append-msg error" style="position: absolute">
|
||||
<span>{{ errorMsg }}</span>
|
||||
@@ -68,30 +67,29 @@
|
||||
v-if="plugins.indexOf('metric-input') > -1"
|
||||
>
|
||||
<div
|
||||
:id="pqid + 'editor'+index"
|
||||
v-if="type !== 'log'"
|
||||
:id="pqid + 'editor'+index + type"
|
||||
class="not-fixed-height no-resize no-close"
|
||||
style="padding-right: 24px;box-sizing: border-box"
|
||||
>
|
||||
</div>
|
||||
<div class="zy" style="position: relative;overflow-x: hidden;display: block;border: 1px solid #dedede;width: 100%" v-if="type == 'log'">
|
||||
<MonacoEditor
|
||||
v-if="type == 'log'"
|
||||
v-model="expressionList[index]"
|
||||
theme="nz"
|
||||
class="not-fixed-height no-resize"
|
||||
ref="monacoEditor"
|
||||
style="width: calc(100% - 24px)"
|
||||
:style="{
|
||||
height: monacoEditorHeight + 'px'
|
||||
}"
|
||||
language="logql"
|
||||
:options="MONACO_EDITOR_OPTIONS"
|
||||
@editorWillMount="handelBeforeMount"
|
||||
@editorDidMount="handleMount"
|
||||
@change="expressionChange"
|
||||
/>
|
||||
</div>
|
||||
<!-- <div class="zy" style="position: relative;overflow-x: hidden;display: block;border: 1px solid #dedede;width: 100%" v-if="type == 'log'">-->
|
||||
<!-- <MonacoEditor-->
|
||||
<!-- v-if="type == 'log'"-->
|
||||
<!-- v-model="expressionList[index]"-->
|
||||
<!-- theme="nz"-->
|
||||
<!-- class="not-fixed-height no-resize"-->
|
||||
<!-- ref="monacoEditor"-->
|
||||
<!-- style="width: calc(100% - 24px)"-->
|
||||
<!-- :style="{-->
|
||||
<!-- height: monacoEditorHeight + 'px'-->
|
||||
<!-- }"-->
|
||||
<!-- language="logql"-->
|
||||
<!-- :options="MONACO_EDITOR_OPTIONS"-->
|
||||
<!-- @editorWillMount="handelBeforeMount"-->
|
||||
<!-- @editorDidMount="handleMount"-->
|
||||
<!-- @change="expressionChange"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
<div class="append-msg error" v-if="errorMsg">
|
||||
<span>{{ errorMsg }}</span>
|
||||
@@ -254,6 +252,8 @@ import { get } from '@/http'
|
||||
import { PromQLExtension } from '@prometheus-io/codemirror-promql'
|
||||
import { baseTheme, promqlHighlighter, lightTheme } from './CMTheme.tsx'
|
||||
import { newCompleteStrategy } from '@prometheus-io/codemirror-promql/dist/esm/complete'
|
||||
import { analyzeCompletion, computeStartCompletePosition, ContextKind } from '@prometheus-io/codemirror-promql/dist/esm/complete/hybrid'
|
||||
import { aggregateOpModifierTerms, aggregateOpTerms, atModifierTerms, binOpModifierTerms, binOpTerms, durationTerms, functionIdentifierTerms, matchOpTerms, numberTerms } from '@prometheus-io/codemirror-promql/dist/esm/complete/promql.terms'
|
||||
// import {basicSetup} from '@codemirror/basic-setup';
|
||||
import { EditorView, highlightSpecialChars, keymap, ViewUpdate, placeholder } from '@codemirror/view'
|
||||
import { EditorState, Prec, Compartment } from '@codemirror/state'
|
||||
@@ -261,6 +261,7 @@ import { bracketMatching, indentOnInput, syntaxHighlighting, syntaxTree } from '
|
||||
import { defaultKeymap, history, historyKeymap, insertNewlineAndIndent } from '@codemirror/commands'
|
||||
import { highlightSelectionMatches } from '@codemirror/search'
|
||||
import { lintKeymap } from '@codemirror/lint'
|
||||
import logqlHint from './logqlHint'
|
||||
import {
|
||||
autocompletion,
|
||||
completionKeymap,
|
||||
@@ -418,28 +419,143 @@ export default {
|
||||
const defaultHeaders = {
|
||||
Authorization: localStorage.getItem('nz-token')
|
||||
}
|
||||
|
||||
let api = '/prom/'
|
||||
if (this.type === 'log') {
|
||||
api = '/logs/loki/'
|
||||
}
|
||||
const promqlExtension = new PromQLExtension()
|
||||
.activateCompletion(true)
|
||||
.activateLinter(true)
|
||||
.setComplete({
|
||||
completeStrategy: new HistoryCompleteStrategy(
|
||||
newCompleteStrategy({
|
||||
remote: {
|
||||
url: baseUrl + '/prom/',
|
||||
fetchFn: (resource, options = {}) => {
|
||||
const params = options.body?.toString()
|
||||
const search = params ? `?${params}` : ''
|
||||
return fetch(resource + search, {
|
||||
method: 'Get',
|
||||
headers: new Headers(
|
||||
defaultHeaders
|
||||
)
|
||||
})
|
||||
}
|
||||
},
|
||||
maxMetricsMetadata: 99999
|
||||
const completeStrategy = newCompleteStrategy({
|
||||
remote: {
|
||||
url: baseUrl + api,
|
||||
fetchFn: (resource, options = {}) => {
|
||||
const params = options.body?.toString()
|
||||
const search = params ? `?${params}` : ''
|
||||
return fetch(resource + search, {
|
||||
method: 'Get',
|
||||
headers: new Headers(
|
||||
defaultHeaders
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
},
|
||||
maxMetricsMetadata: 99999
|
||||
})
|
||||
if (this.type === 'log') {
|
||||
const autocompleteNodes = {
|
||||
matchOp: matchOpTerms,
|
||||
binOp: binOpTerms,
|
||||
duration: durationTerms,
|
||||
binOpModifier: [],
|
||||
atModifier: [],
|
||||
functionIdentifier: logqlHint.functions,
|
||||
aggregateOp: logqlHint.aggregateOp,
|
||||
aggregateOpModifier: aggregateOpModifierTerms,
|
||||
number: numberTerms
|
||||
}
|
||||
completeStrategy.promQL = function (context) {
|
||||
const { state, pos } = context
|
||||
const tree = syntaxTree(state).resolve(pos, -1)
|
||||
const contexts = analyzeCompletion(state, tree)
|
||||
let asyncResult = Promise.resolve([])
|
||||
let completeSnippet = false
|
||||
const span = true
|
||||
for (const context of contexts) {
|
||||
switch (context.kind) {
|
||||
case ContextKind.Aggregation:
|
||||
completeSnippet = true
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.aggregateOp)
|
||||
})
|
||||
break
|
||||
case ContextKind.Function:
|
||||
completeSnippet = true
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.functionIdentifier)
|
||||
})
|
||||
break
|
||||
case ContextKind.BinOpModifier:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.binOpModifier)
|
||||
})
|
||||
break
|
||||
case ContextKind.BinOp:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.binOp)
|
||||
})
|
||||
break
|
||||
case ContextKind.MatchOp:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.matchOp)
|
||||
})
|
||||
break
|
||||
case ContextKind.AggregateOpModifier:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.aggregateOpModifier)
|
||||
})
|
||||
break
|
||||
case ContextKind.Duration:
|
||||
span = false
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.duration)
|
||||
})
|
||||
break
|
||||
case ContextKind.Offset:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat([{ label: 'offset' }])
|
||||
})
|
||||
break
|
||||
case ContextKind.Bool:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat([{ label: 'bool' }])
|
||||
})
|
||||
break
|
||||
case ContextKind.AtModifiers:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.atModifier)
|
||||
})
|
||||
break
|
||||
case ContextKind.Number:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return result.concat(autocompleteNodes.number)
|
||||
})
|
||||
break
|
||||
case ContextKind.MetricName:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return this.autocompleteMetricName(result, context)
|
||||
})
|
||||
break
|
||||
case ContextKind.LabelName:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return this.autocompleteLabelName(result, context)
|
||||
})
|
||||
break
|
||||
case ContextKind.LabelValue:
|
||||
asyncResult = asyncResult.then((result) => {
|
||||
return this.autocompleteLabelValue(result, context)
|
||||
})
|
||||
}
|
||||
}
|
||||
return asyncResult.then((result) => {
|
||||
return arrayToCompletionResult(result, computeStartCompletePosition(tree, pos), pos, completeSnippet, span)
|
||||
})
|
||||
}
|
||||
}
|
||||
function arrayToCompletionResult (data, from, to, includeSnippet = false, span = true) {
|
||||
const options = data
|
||||
// options.push(...logqlHint);
|
||||
return {
|
||||
from: from,
|
||||
to: to,
|
||||
options: options,
|
||||
validFor: span ? /^[a-zA-Z0-9_:]+$/ : undefined
|
||||
}
|
||||
}
|
||||
// console.log(JSON.stringify(promqlExtension.promQL()))
|
||||
promqlExtension.activateCompletion(true)
|
||||
.activateLinter(!(this.type === 'log'))
|
||||
.setComplete({
|
||||
completeStrategy: new HistoryCompleteStrategy(completeStrategy)
|
||||
|
||||
})
|
||||
function HistoryCompleteStrategy (CompleteStrategy) {
|
||||
@@ -467,6 +583,7 @@ export default {
|
||||
})),
|
||||
span: /^[a-zA-Z0-9_:]+$/
|
||||
}
|
||||
console.log(res.options)
|
||||
// 过滤 非logs的函数
|
||||
if (res !== null) {
|
||||
historyItems.options = historyItems.options.concat(res.options)
|
||||
@@ -485,6 +602,10 @@ export default {
|
||||
lightTheme
|
||||
]
|
||||
if (!this.newView) {
|
||||
let placeholderStr = 'Metrics Expression (press Shift+Enter for newlines)'
|
||||
if (this.type === 'log') {
|
||||
placeholderStr = 'Logs Expression (press Shift+Enter for newlines)'
|
||||
}
|
||||
const EditorViewstate = EditorState.create({
|
||||
doc: self.codeMirrorValue[self.index],
|
||||
extensions: [
|
||||
@@ -500,7 +621,7 @@ export default {
|
||||
highlightSelectionMatches(),
|
||||
EditorView.lineWrapping,
|
||||
keymap.of([...closeBracketsKeymap, ...defaultKeymap, ...historyKeymap, ...completionKeymap, ...lintKeymap]),
|
||||
placeholder('Expression (press Shift+Enter for newlines)'),
|
||||
placeholder(placeholderStr),
|
||||
dynamicConfigCompartment.of(dynamicConfig),
|
||||
keymap.of([
|
||||
{
|
||||
@@ -539,7 +660,7 @@ export default {
|
||||
const view = new EditorView({
|
||||
state: EditorViewstate,
|
||||
// parent: document.getElementById('editor')
|
||||
parent: document.getElementById(this.pqid + 'editor' + self.index)
|
||||
parent: document.getElementById(this.pqid + 'editor' + self.index + this.type)
|
||||
})
|
||||
self.newView = view
|
||||
} else {
|
||||
@@ -1090,14 +1211,35 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
selectLog (str) {
|
||||
if (!str || str.length === 0) return
|
||||
this.expressionList[this.index] = str
|
||||
this.codeMirrorValue[this.index] = str
|
||||
this.dropDownVisible = false
|
||||
this.$emit('change', str)
|
||||
this.$forceUpdate()
|
||||
this.cascaderValue = ''
|
||||
selectLog (item) {
|
||||
if (!item.id) {
|
||||
this.metricChangeNew(item.name)
|
||||
} else if (item.id) {
|
||||
this.dropDownVisible = false
|
||||
this.$get('/expression/tmpl/' + item.id).then(res => {
|
||||
if (res.code === 200) {
|
||||
if (!res.data.vars || !res.data.vars.length) {
|
||||
this.metricChange(item.expression)
|
||||
this.initCodeMirror()
|
||||
return
|
||||
}
|
||||
res.data.vars.forEach(item => {
|
||||
res.data[item] = ''
|
||||
const arr = item.split('.')
|
||||
const keyword = arr[0].toLowerCase()
|
||||
this.getAllOptins(keyword, keyword + 'Option')
|
||||
})
|
||||
this.tempBox = {
|
||||
...this.tempBox,
|
||||
...res.data
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.tempBoxShow = true
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -1150,11 +1292,9 @@ export default {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler (n) {
|
||||
if (n !== 'log') {
|
||||
this.$nextTick(() => {
|
||||
this.initCodeMirror()
|
||||
})
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.initCodeMirror()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -336,7 +336,7 @@ export default {
|
||||
this.hideMe()
|
||||
},
|
||||
selectLog () {
|
||||
this.$emit('selectLog', this.logFinalStr)
|
||||
this.$emit('selectLog', { name: this.logFinalStr })
|
||||
this.hideMe()
|
||||
},
|
||||
copyItem (value) {
|
||||
|
||||
@@ -684,7 +684,7 @@ export default {
|
||||
maxValue = Math.abs(minValue)
|
||||
}
|
||||
maxValue = maxValue - minValue
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii)
|
||||
maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii)
|
||||
let oldValue = maxValue
|
||||
let dot = 0
|
||||
if (maxValue == 1) {
|
||||
|
||||
Reference in New Issue
Block a user