Merge branch 'dev-3.2' of https://git.mesalab.cn/nezha/nezha-fronted into dev-3.3

This commit is contained in:
zhangyu
2022-03-30 15:17:08 +08:00
24 changed files with 175 additions and 97 deletions

View File

@@ -212,7 +212,7 @@ export const alertMessage = {
export const statisticsList = [
{ value: 'min', label: i18n.t('dashboard.panel.chartForm.statisticsVal.min') },
{ value: 'max', label: i18n.t('dashboard.panel.chartForm.statisticsVal.max') },
{ value: 'average', label: i18n.t('dashboard.panel.chartForm.statisticsVal.average') },
{ value: 'avg', label: i18n.t('dashboard.panel.chartForm.statisticsVal.average') },
{ value: 'total', label: i18n.t('dashboard.panel.chartForm.statisticsVal.total') },
{ value: 'first', label: i18n.t('dashboard.panel.chartForm.statisticsVal.first') },
{ value: 'last', label: i18n.t('dashboard.panel.chartForm.statisticsVal.last') },

View File

@@ -13,6 +13,7 @@ export const clickoutside = {
let oldValue
try {
oldValue = JSON.parse(JSON.stringify(binding.value.obj))
el.__newValue__ = oldValue
} catch (e) {
}
@@ -36,8 +37,8 @@ export const clickoutside = {
return false
}
if (oldValue) {
const newValue = JSON.parse(JSON.stringify(binding.value.obj))
if (unsavedChange == 'on' && !isEqual(oldValue, newValue)) {
// const newValue = JSON.parse(JSON.stringify(binding.value.obj))
if (unsavedChange == 'on' && !isEqual(oldValue, el.__newValue__)) {
MessageBox.confirm(i18n.t('tip.confirmCancel'), {
confirmButtonText: i18n.t('tip.yes'),
cancelButtonText: i18n.t('tip.no'),
@@ -66,6 +67,9 @@ export const clickoutside = {
el.__vueClickOutside__ = documentHandler
document.addEventListener('mousedown', documentHandler)
},
update (el, binding, vnode) {
el.__newValue__ = binding.value.obj
},
unbind (el, binding) {
// 解除事件监听
document.removeEventListener('mousedown', el.__vueClickOutside__)
@@ -907,7 +911,7 @@ export function getMetricTypeValue (queryItem, type) {
const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
return max
}
case 'average': {
case 'avg': {
copy = copy.map(t => parseFloat(t[1]))
const sum = eval(copy.join('+'))
const avg = sum / copy.length

View File

@@ -349,7 +349,7 @@ const cn = {
statisticsVal: {
min: 'Min',
max: 'Max',
average: 'Average',
avg: 'Avg',
total: 'Total',
first: 'First',
last: 'Last',

View File

@@ -365,7 +365,7 @@ const en = {
statisticsVal: {
min: 'Min',
max: 'Max',
average: 'Average',
avg: 'Avg',
total: 'Total',
first: 'First',
last: 'Last',

View File

@@ -487,7 +487,7 @@
<span @click="addColumns('')">
<i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i>
</span>
<span class="nz-icon-copy">
<span style="margin-right: 5px">
<i @click="copyColumns(index)" class="nz-icon nz-icon-override"></i>
</span>
<span class="nz-icon-minus-medium">

View File

@@ -1,5 +1,5 @@
<template>
<div v-clickoutside="{obj:editChart, func:clickOutside}" :class="boxClass" class="right-box right-box-chart">
<div v-clickoutside="{obj: editChart, func:clickOutside}" :class="boxClass" class="right-box right-box-chart">
<transition v-if="from !== 'chartTemp'" name="right-box">
<!-- <panel-box v-if="!showPanel.type" ref="panelBox2" :panel="panel" @reload="panelReload"></panel-box>-->
</transition>
@@ -457,42 +457,42 @@ export default {
if (obj.param && !obj.param.thresholds) {
obj.param.thresholds = []
}
this.editChart = obj
if (this.editChart.groupId === -1) {
this.editChart.groupId = ''
if (obj.groupId === -1) {
obj.groupId = ''
}
if (this.editChart.param) {
if (!this.editChart.param.min) {
this.editChart.param.min = 0
if (obj.param) {
if (!obj.param.min) {
obj.param.min = 0
}
if (!this.editChart.param.max) {
this.editChart.param.max = 100
if (!obj.param.max) {
obj.param.max = 100
}
if (!this.editChart.param.link) {
this.$set(this.editChart.param, 'link', '')
if (!obj.param.link) {
this.$set(obj.param, 'link', '')
}
if (!this.editChart.param.enable) {
this.editChart.param.enable = {
if (!obj.param.enable) {
obj.param.enable = {
thresholds: false,
legend: false,
valueMapping: false
}
}
// this.editChart.varType = 1
if (this.editChart.param.enable.legend && !this.editChart.param.legend) {
this.editChart.param.legend = { placement: 'bottom', values: [], show: true }
if (obj.param.enable.legend && !obj.param.legend) {
obj.param.legend = { placement: 'bottom', values: [], show: true }
}
if (this.editChart.param.datasource && !this.editChart.param.datasource[0].legend) {
this.editChart.param.datasource[0].legend = ''
if (obj.param.datasource && !obj.param.datasource[0].legend) {
obj.param.datasource[0].legend = ''
}
if (this.editChart.param.valueMapping) {
this.editChart.param.valueMapping.forEach(item => {
if (obj.param.valueMapping) {
obj.param.valueMapping.forEach(item => {
if (!item.show) {
item.show = false
}
})
}
}
this.editChart = obj
}
},
'editChart.type': {
@@ -501,6 +501,12 @@ export default {
this.editChart.groupId = ''
}
}
},
editChart: {
deep: true,
handler () {
}
}
}
}

View File

@@ -346,6 +346,7 @@ export default {
},
showMapping (index) {
this.chartConfig.param.valueMapping[index].show = !this.chartConfig.param.valueMapping[index].show
this.change()
},
mappingItemChange (index, type) {
const mapping = this.chartConfig.param.valueMapping[index]
@@ -416,6 +417,7 @@ export default {
},
showColumns (index) {
this.chartConfig.param.columns[index].show = !this.chartConfig.param.columns[index].show
this.change()
},
tagsChange (newTags) {
this.chartConfig.param.tags = newTags

View File

@@ -449,7 +449,7 @@
<span @click="addColumns('')">
<i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i>
</span>
<span class="nz-icon-copy">
<span style="margin-right: 5px">
<i @click="copyColumns(index)" class="nz-icon nz-icon-override"></i>
</span>
<span class="nz-icon-minus-medium">