fix:修复 explore 保存时 legend 以及 step参数未携带的问题

This commit is contained in:
zhangyu
2023-10-23 16:59:34 +08:00
parent b7d44f5c78
commit f8d690fc3e

View File

@@ -3733,7 +3733,7 @@ export default {
logsHistory: [], logsHistory: [],
lastHistory: [], lastHistory: [],
showChart: false, showChart: false,
showTable: false, showTable: false
} }
}, },
async created () { async created () {
@@ -4041,7 +4041,7 @@ export default {
const promqlInputIndexs = [] const promqlInputIndexs = []
const queryExpression = [] const queryExpression = []
// 过滤掉state为0的元素 // 过滤掉state为0的元素
let step = bus.getStep(bus.formateTimeToTime(this.filterTime[0]), bus.formateTimeToTime(this.filterTime[1])) const step = bus.getStep(bus.formateTimeToTime(this.filterTime[0]), bus.formateTimeToTime(this.filterTime[1]))
this.expressions.forEach((item, index) => { this.expressions.forEach((item, index) => {
if (item != '' && this.promqlKeys[index].state && !this.promqlKeys[index].matrix && this.promqlKeys[index].queryType == 1) { if (item != '' && this.promqlKeys[index].state && !this.promqlKeys[index].matrix && this.promqlKeys[index].queryType == 1) {
let queryStep = step let queryStep = step
@@ -4162,6 +4162,7 @@ export default {
}) })
if (requestArr.length > 0) { if (requestArr.length > 0) {
this.showIntroduce = false this.showIntroduce = false
this.saveDisabled = false
} }
const res = await axios.all(requestArr) const res = await axios.all(requestArr)
const tData = [] const tData = []
@@ -4179,7 +4180,7 @@ export default {
if (response.data && response.status === 'success') { if (response.data && response.status === 'success') {
// matrix类型不请求chart接口 只展示表格数据 // matrix类型不请求chart接口 只展示表格数据
this.promqlKeys[index].matrix = response.data.resultType === 'matrix' this.promqlKeys[index].matrix = response.data.resultType === 'matrix'
let data = response.data.result const data = response.data.result
if (data) { if (data) {
data.forEach((result, i) => { data.forEach((result, i) => {
const metrics = Object.assign({}, result.metric) const metrics = Object.assign({}, result.metric)
@@ -4605,30 +4606,28 @@ export default {
param: { param: {
stack: 0, stack: 0,
nullType: 'null', nullType: 'null',
legend: { placement: 'bottom', values: [], show: true }, legend: {
placement: 'bottom',
values: [],
show: true
},
enable: {
legend: true,
valueMapping: false,
thresholds: false,
visibility: false,
rightYAxis: false,
tooltip: true
},
thresholdShow: true, thresholdShow: true,
thresholds: [{ value: undefined, color: '#eeeeeeff' }], thresholds: [{ color: '#31a1f7', id: '1fbdd19f' }],
showHeader: 1, showHeader: 1,
visibility: { visibility: { varName: '', operator: 'equal', varValue: '', result: 'show' },
varName: '', rightYAxis: { elementNames: [], style: 'line', unit: 2, label: '' },
operator: 'equal',
varValue: '',
result: 'show'
},
rightYAxis: {
elementNames: [],
style: 'line',
unit: 2,
label: '',
min: undefined,
max: undefined
},
dataLink: [], dataLink: [],
tooltip: { tooltip: { mode: 'all', sort: 'none' },
mode: 'all', valueMapping: [],
sort: 'none' link: ''
},
option: undefined
}, },
elements: [], elements: [],
panel: '', panel: '',
@@ -4637,7 +4636,16 @@ export default {
groupId: -1 groupId: -1
} }
this.expressions.forEach((exp, index) => { this.expressions.forEach((exp, index) => {
chart.elements.push({ state: this.promqlKeys[index].state, expression: exp, legend: '', type: 'expert', id: '', name: this.transformNumToLetter(index) }) chart.elements.push({
state: this.promqlKeys[index].state,
expression: exp,
legend: this.promqlKeys[index].legend,
step: this.promqlKeys[index].step,
queryType: this.promqlKeys[index].queryType,
type: 'expert',
id: '',
name: this.transformNumToLetter(index)
})
}) })
this.chartData = chart this.chartData = chart
this.rightBox.show = true this.rightBox.show = true
@@ -4674,7 +4682,16 @@ export default {
remark: '' remark: ''
} }
this.expressions.forEach((exp, index) => { this.expressions.forEach((exp, index) => {
chart.elements.push({ state: this.promqlKeys[index].state, expression: exp, legend: '', type: 'expert', id: '', name: this.transformNumToLetter(index) }) chart.elements.push({
state: this.promqlKeys[index].state,
expression: exp,
legend: this.promqlKeys[index].legend,
step: this.promqlKeys[index].step,
queryType: this.promqlKeys[index].queryType,
type: 'expert',
id: '',
name: this.transformNumToLetter(index)
})
}) })
this.chartData = chart this.chartData = chart
this.rightBox.show = true this.rightBox.show = true