NEZ-3154 fix:修改matrix类型 表格数据
This commit is contained in:
10
nezha-fronted/package-lock.json
generated
10
nezha-fronted/package-lock.json
generated
@@ -14218,7 +14218,7 @@
|
||||
},
|
||||
"node-sass": {
|
||||
"version": "4.14.1",
|
||||
"resolved": "https://registry.npmmirror.com/node-sass/-/node-sass-4.14.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.14.1.tgz",
|
||||
"integrity": "sha512-sjCuOlvGyCJS40R8BscF5vhVlQjNN069NtQ1gSxyK1u9iqvn6tf7O1R4GNowVZfiZUCRt5MmMs1xd+4V/7Yr0g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -17546,7 +17546,7 @@
|
||||
},
|
||||
"showdown": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/showdown/-/showdown-2.1.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/showdown/-/showdown-2.1.0.tgz",
|
||||
"integrity": "sha512-/6NVYu4U819R2pUIk79n67SYgJHWCce0a5xTP979WbNp0FL9MN1I1QK662IDU1b6JzKTvmhgI7T7JYIxBi3kMQ==",
|
||||
"requires": {
|
||||
"commander": "^9.0.0"
|
||||
@@ -17554,7 +17554,7 @@
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "9.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/commander/-/commander-9.5.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
|
||||
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ=="
|
||||
}
|
||||
}
|
||||
@@ -19255,7 +19255,7 @@
|
||||
"tmp": {
|
||||
"version": "0.0.29",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.29.tgz",
|
||||
"integrity": "sha512-89PTqMWGDva+GqClOqBV9s3SMh7MA3Mq0pJUdAoHuF65YoE7O0LermaZkVfT5/Ngfo18H4eYiyG7zKOtnEbxsw==",
|
||||
"integrity": "sha1-8lEl/w3Z2jzLDC3Tce4SiLuRKMA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"os-tmpdir": "~1.0.1"
|
||||
@@ -20614,7 +20614,7 @@
|
||||
},
|
||||
"webpack-bundle-analyzer": {
|
||||
"version": "2.13.1",
|
||||
"resolved": "https://registry.npmmirror.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.13.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.13.1.tgz",
|
||||
"integrity": "sha512-rwxyfecTAxoarCC9VlHlIpfQCmmJ/qWD5bpbjkof+7HrNhTNZIwZITxN6CdlYL2axGmwNUQ+tFgcSOiNXMf/sQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
||||
@@ -200,11 +200,11 @@
|
||||
<span>{{$t('explore.expandResults')}}</span>
|
||||
<el-switch v-model="expandResults" @click.native.stop tabindex="0"></el-switch>
|
||||
</div>
|
||||
<span>{{$t('explore.resultSeries')}}:{{this.results}}</span>
|
||||
<span>{{$t('explore.resultSeries')}}:{{rowData.length}}</span>
|
||||
</div>
|
||||
<div class="nz-table-list explore-table">
|
||||
<ul v-my-loading="tools.loading" class="row-table" :class="{'expand-results-table':expandResults}">
|
||||
<li class="row-table-row" v-for="(row,index) in storedTableData" :key="index">
|
||||
<li class="row-table-row" v-for="(row,index) in rowData" :key="index">
|
||||
<div class="table-row-left">
|
||||
<copy :copyData='row.element' :showInfo='row.element'>
|
||||
<template slot="copy-text">
|
||||
@@ -3618,7 +3618,7 @@ export default {
|
||||
showTopBtn: false, // top按钮
|
||||
scrollbarWrap: null,
|
||||
allMatrix: false, // metric是否全部为matrix类型
|
||||
results: 0 // 结果序列
|
||||
rowData: []
|
||||
}
|
||||
},
|
||||
async created () {
|
||||
@@ -4025,10 +4025,10 @@ export default {
|
||||
let tLabels = []
|
||||
if (res.length > 0) {
|
||||
this.storedTableData = []
|
||||
this.rowData = []
|
||||
this.tableData = []
|
||||
this.tableTitle = []
|
||||
this.tools.customTableTitle = []
|
||||
this.results = 0
|
||||
|
||||
this.allMatrix = res.every(d => d.data.resultType === 'matrix')
|
||||
|
||||
@@ -4045,7 +4045,7 @@ export default {
|
||||
}]
|
||||
}
|
||||
data.forEach((result, i) => {
|
||||
let metrics = Object.assign({}, result.metric)
|
||||
const metrics = Object.assign({}, result.metric)
|
||||
if (response.data.resultType === 'matrix') {
|
||||
this.$set(metrics, 'value#' + index, chartDataFormat.getUnit(this.chartUnit || 2).compute(result.values[0][1], null, 2))
|
||||
this.$set(metrics, 'time', bus.timeFormate(bus.computeTimezone(result.values[0][0] * 1000)))
|
||||
@@ -4066,15 +4066,24 @@ export default {
|
||||
tLabels.push(label)
|
||||
}
|
||||
}
|
||||
if (response.data.resultType === 'matrix') {
|
||||
result.values.forEach(item => {
|
||||
tData.push({
|
||||
...metrics,
|
||||
['value#' + index]: chartDataFormat.getUnit(this.chartUnit || 2).compute(item[1], null, 2),
|
||||
time: bus.timeFormate(bus.computeTimezone(result.values[0][0] * 1000))
|
||||
})
|
||||
})
|
||||
} else {
|
||||
tData.push(metrics)
|
||||
}
|
||||
|
||||
// 处理row模式数据
|
||||
const rowData = this.handlerRowData(result.metric)
|
||||
rowData.value = metrics['value#' + index]
|
||||
metrics = Object.assign(metrics, rowData)
|
||||
// matrix 类型数据
|
||||
if (response.data.resultType === 'matrix') {
|
||||
metrics.valueList = result.values.map((item, index) => {
|
||||
this.results++
|
||||
rowData.valueList = result.values.map((item, index) => {
|
||||
const obj = {}
|
||||
obj.value = chartDataFormat.getUnit(this.chartUnit || 2).compute(item[1], null, 2)
|
||||
obj.timestamp = '@' + item[0]
|
||||
@@ -4085,10 +4094,10 @@ export default {
|
||||
return obj
|
||||
})
|
||||
} else {
|
||||
metrics.timestamp = '@' + result.value[0]
|
||||
this.results++
|
||||
rowData.timestamp = '@' + result.value[0]
|
||||
rowData.time = bus.timeFormate(bus.computeTimezone(result.value[0] * 1000))
|
||||
}
|
||||
tData.push(metrics)
|
||||
this.rowData.push(rowData)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,11 +104,11 @@
|
||||
<span>{{$t('explore.expandResults')}}</span>
|
||||
<el-switch v-model="expandResults" @click.native.stop tabindex="0"></el-switch>
|
||||
</div>
|
||||
<span>{{$t('explore.resultSeries')}}:{{this.results}}</span>
|
||||
<span>{{$t('explore.resultSeries')}}:{{rowData.length}}</span>
|
||||
</div>
|
||||
<div class="nz-table-list explore-table">
|
||||
<ul v-my-loading="tools.loading" class="row-table" :class="{'expand-results-table':expandResults}">
|
||||
<li class="row-table-row" v-for="(row,index) in storedTableData" :key="index">
|
||||
<li class="row-table-row" v-for="(row,index) in rowData" :key="index">
|
||||
<div class="table-row-left">
|
||||
<copy :copyData='row.element' :showInfo='row.element'>
|
||||
<template slot="copy-text">
|
||||
@@ -216,7 +216,7 @@ export default {
|
||||
tableMode: 'table',
|
||||
expandResults: false,
|
||||
allMatrix: false, // metric是否全部为matrix类型
|
||||
results: 0 // 结果序列
|
||||
rowData: []
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
@@ -314,10 +314,10 @@ export default {
|
||||
let tLabels = []
|
||||
if (res.length > 0) {
|
||||
this.storedTableData = []
|
||||
this.rowData = []
|
||||
this.tableData = []
|
||||
this.tableTitle = []
|
||||
this.tools.customTableTitle = []
|
||||
this.results = 0
|
||||
|
||||
this.allMatrix = res.filter((r, i) => r.state).every(d => d.data.resultType === 'matrix' && d.api === 'query')
|
||||
|
||||
@@ -329,7 +329,7 @@ export default {
|
||||
const data = response.data.result
|
||||
if (data) {
|
||||
data.forEach((result, i) => {
|
||||
let metrics = Object.assign({}, result.metric)
|
||||
const metrics = Object.assign({}, result.metric)
|
||||
if (!Array.isArray(result.values)) {
|
||||
const val = result
|
||||
result = {
|
||||
@@ -338,7 +338,6 @@ export default {
|
||||
}
|
||||
this.$set(metrics, 'value#' + index, chartDataFormat.getUnit(this.chartUnitType || 2).compute(result.values[0][1], null, 2))
|
||||
this.$set(metrics, 'time', bus.timeFormate(bus.computeTimezone(result.values[0][0] * 1000)))
|
||||
|
||||
for (const key in metrics) {
|
||||
const label = {
|
||||
label: key,
|
||||
@@ -352,14 +351,24 @@ export default {
|
||||
tLabels.push(label)
|
||||
}
|
||||
}
|
||||
if (response.api === 'query') {
|
||||
result.values.forEach(item => {
|
||||
tData.push({
|
||||
...metrics,
|
||||
['value#' + index]: chartDataFormat.getUnit(this.chartUnit || 2).compute(item[1], null, 2),
|
||||
time: bus.timeFormate(bus.computeTimezone(result.values[0][0] * 1000))
|
||||
})
|
||||
})
|
||||
} else {
|
||||
tData.push(metrics)
|
||||
}
|
||||
|
||||
// 处理row模式数据
|
||||
const rowData = this.handlerRowData(result.metric)
|
||||
rowData.value = metrics['value#' + index]
|
||||
metrics = Object.assign(metrics, rowData)
|
||||
// matrix 类型数据
|
||||
if (response.data.resultType === 'matrix' && response.api === 'query') {
|
||||
metrics.valueList = result.values.map((item, index) => {
|
||||
this.results++
|
||||
rowData.valueList = result.values.map((item, index) => {
|
||||
const obj = {}
|
||||
obj.value = chartDataFormat.getUnit(this.chartUnitType || 2).compute(item[1], null, 2)
|
||||
obj.timestamp = '@' + item[0]
|
||||
@@ -370,10 +379,10 @@ export default {
|
||||
return obj
|
||||
})
|
||||
} else {
|
||||
metrics.timestamp = '@' + result.values[0][0]
|
||||
this.results++
|
||||
rowData.time = bus.timeFormate(bus.computeTimezone(result.values[0][0] * 1000))
|
||||
rowData.timestamp = '@' + result.values[0][0]
|
||||
}
|
||||
tData.push(metrics)
|
||||
this.rowData.push(rowData)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user