fix: 1. Panel > 编辑图标功能,判断兼容老数据添加默认值

2. 修复 告警等级 Priority select 初始化 color 为 undefined
This commit is contained in:
@changcode
2021-07-07 14:30:27 +08:00
parent 87268e43ff
commit 8a6da26217
5 changed files with 43 additions and 23 deletions

View File

@@ -232,52 +232,52 @@ export default {
label: 'ID', label: 'ID',
prop: 'id', prop: 'id',
show: true, show: true,
width: 80 width: 160,
}, { sortable: 'custom'
},{
label: this.$t('alert.alertName'), label: this.$t('alert.alertName'),
prop: 'alertRule', prop: 'alertRule',
show: true, show: true,
}, /* {
label: this.$t("alert.list.type"),
prop: 'type',
show: true,
width: 100
}, { }, {
label: this.$t("alert.list.linked"),
prop: 'linkObject',
show: true,
width: 140
}, */{
label: this.$t('alert.list.labels'), label: this.$t('alert.list.labels'),
prop: 'labels', prop: 'labels',
show: true, show: true,
width: 300 NotSet: true,
minWidth: 250,
sortable: 'custom'
}, { }, {
label: this.$t('alert.severity'), label: this.$t('alert.severity'),
prop: 'severity', prop: 'severityId',
show: true, show: true,
width: 100 width: 110,
sortable: 'custom'
}, { }, {
label: this.$t('alert.summary'), label: this.$t('alert.summary'),
prop: 'summary', prop: 'summary',
show: true, show: true,
width: 200 minWidth: 200
}, { }, {
label: this.$t('overall.remark'), label: this.$t('overall.remark'),
prop: 'description', prop: 'description',
show: true, show: true,
width: 200 minWidth: 200
}, { }, {
label: this.$t('alert.list.state'), label: this.$t('alert.list.state'),
prop: 'state', prop: 'state',
show: true, show: true,
width: 100 width: 100
}, { },{
label: this.$t('alert.startAt'), label: this.$t('alert.startAt'),
prop: 'startAt', prop: 'startAt',
show: true, show: true,
width: 160 width: 150,
sortable: 'custom'
}, { }, {
label: this.$t('config.terminallog.duration'),
prop: 'duration',
show: true,
width: 150
},{
label: this.$t('alert.endAt'), label: this.$t('alert.endAt'),
prop: 'endAt', prop: 'endAt',
show: true, show: true,
@@ -328,6 +328,14 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {
if (n.id) {
if (!n.param.state && n.param.state != Number) {
n.param.state = "1"
}
if (n.param.severity && n.param.severity != Number) {
n.param.severity = 1
}
}
this.data = Object.assign({}, n) this.data = Object.assign({}, n)
} }
}, },
@@ -700,7 +708,7 @@ export default {
this.getAlerScreetList() this.getAlerScreetList()
}, },
promQueryParamConvert (obj) { promQueryParamConvert (obj) {
let r = '(' + obj.alertRule.expr + ')' let r = '(' + obj.alertRule.expr.replace(/\"/g, '\'') + ')'
let intoLabels = false let intoLabels = false
obj.labels = JSON.parse(obj.labels) obj.labels = JSON.parse(obj.labels)
if (Object.keys(obj.labels).length > 0) { if (Object.keys(obj.labels).length > 0) {

View File

@@ -130,6 +130,12 @@ export default {
justify-content: space-between; justify-content: space-between;
width: calc(100% - 28px); width: calc(100% - 28px);
} }
.tree--node span:nth-of-type(1) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-break: break-word;
}
.tree--operation { .tree--operation {
opacity: 0; opacity: 0;
} }

View File

@@ -64,7 +64,7 @@
</span> </span>
</el-option> </el-option>
</el-select> </el-select>
<i v-if="editAlertRule.severityId" :style="{color:severityData.find(severity => severity.id === editAlertRule.severityId).color,'font-size':'12px'}" class="nz-icon nz-icon-circle severity-circle"></i> <i v-if="editAlertRule.severityId" :style="{color:severityData.length > 0 && severityData.find(severity => severity.id === editAlertRule.severityId).color,'font-size':'12px'}" class="nz-icon nz-icon-circle severity-circle"></i>
</el-form-item> </el-form-item>
<!--receiver--> <!--receiver-->
<el-form-item :label="$t('config.user.receiver')" prop="receiver"> <el-form-item :label="$t('config.user.receiver')" prop="receiver">

View File

@@ -23,7 +23,7 @@
</span> </span>
</el-option> </el-option>
</el-select> </el-select>
<i class="nz-icon nz-icon-circle severity-circle" v-if="parameters.level" :style="{color:alertPriority.find(severity => severity.id === parameters.level).color,'font-size':'12px'}"></i> <i class="nz-icon nz-icon-circle severity-circle" v-if="parameters.level" :style="{color: alertPriority.length > 0 && alertPriority.find(severity => severity.id === parameters.level).color,'font-size':'12px'}"></i>
</el-form-item> </el-form-item>
<el-form-item :label="$t('dashboard.panel.chartForm.alertParam.state')"> <el-form-item :label="$t('dashboard.panel.chartForm.alertParam.state')">
<el-select class="form-item" size="small" popper-class="alert-form-pop no-style-class" v-model="parameters.state" clearable id="alert-param-state"> <el-select class="form-item" size="small" popper-class="alert-form-pop no-style-class" v-model="parameters.state" clearable id="alert-param-state">

View File

@@ -1761,7 +1761,13 @@ export default {
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { if (n.id) {
this.isEdit = true this.isEdit = true;
if (!n.param.state && n.param.state != Number) {
n.param.state = "1"
}
if (n.param.severity && n.param.severity != Number) {
n.param.severity = 1
}
} }
if ((n.param && n.param.valueMapping) && (n.type === 'singleStat' || n.type === 'table')) { if ((n.param && n.param.valueMapping) && (n.type === 'singleStat' || n.type === 'table')) {
n.param.valueMapping.mapping.forEach(item => { n.param.valueMapping.mapping.forEach(item => {