feat : 添加alertMessageinfo detail

This commit is contained in:
zhangyu
2022-03-31 10:45:20 +08:00
parent 0e6c1ab974
commit 0c662135b4
5 changed files with 118 additions and 64 deletions

View File

@@ -139,19 +139,16 @@
import bus from '../../../../libs/bus'
import axios from 'axios'
import table from '@/components/common/mixin/table'
import nzAlertTag from '../../../page/alert/nzAlertTag'
import chartDataFormat from '../../../charts/chartDataFormat'
import alertRuleInfo from '../../alert/alertRuleInfo'
import alertLabel from '../../alert/alertLabel'
import { calcDurationByStringTimeB } from '../../js/tools'
import { alertMessage as alertMessageConstant } from '@/components/common/js/constants'
import alertLabelMixin from '@/components/common/mixin/alertLabelMixin'
import alertMessageLabelMixin from '@/components/common/alert/alertMessageLabelMixin'
export default {
name: 'alertMessageTable',
components: {
nzAlertTag,
alertRuleInfo: alertRuleInfo,
alertLabel: alertLabel
},
props: {
nowTime: {
@@ -165,7 +162,7 @@ export default {
loading: Boolean,
chartAlertList: Boolean
},
mixins: [table, bus, alertLabelMixin],
mixins: [table, bus, alertLabelMixin, alertMessageLabelMixin],
data () {
return {
/* 二级列表相关 */
@@ -176,7 +173,6 @@ export default {
graphShow: false,
chartDatas: [],
sameLabels: ['instance', 'module', 'project', 'asset', 'endpoint', 'dc'],
exclusiveLabels: ['_id', 'severity', '__name__'],
legend: [],
searchTime: [new Date().setHours(new Date().getHours() - 1), new Date()],
currentMsg: {},
@@ -254,29 +250,6 @@ export default {
}
},
computed: {
tagType () {
return (key) => {
if (key == 'asset' || key == 'module' || key == 'project' || key == 'dc' || key == 'endpoint') {
return 'normal'
} else {
return 'info'
}
}
},
tagValue () {
return (key, value) => {
if (key == 'type') {
if (value == 1) {
value = this.$t('project.project.projectName')
} else if (value == 2) {
value = this.$t('module.module.module')
} else if (value == 3) {
value = this.$t('asset.asset')
}
}
return key + '' + value
}
},
getDuration () {
return function (record) {
if (record.endAt) {
@@ -297,35 +270,6 @@ export default {
}
})
},
labelsSort (obj) {
const buildIn = ['asset', 'endpoint', 'module', 'cpu', 'datacenter', 'project', 'parent_asset', 'user']
if (typeof obj === 'string') obj = JSON.parse(obj)
const labels = JSON.parse(JSON.stringify(obj))
const result = []
for (const key of this.exclusiveLabels) {
Object.keys(labels).forEach(labelsKey => {
if (labelsKey.indexOf(key) !== -1) {
delete labels[labelsKey]
}
})
}
for (const key of buildIn) {
if (key in labels) {
if (key === 'datacenter') {
result.push({ label: 'dc', value: labels.datacenter })
delete labels.datacenter
} else {
result.push({ label: key, value: labels[key] })
}
delete labels[key]
}
}
Object.keys(labels).sort().forEach(key => {
result.push({ label: key, value: labels[key] })
delete labels[key]
})
return result
},
chartUnitChange: function (unit) {
this.chartUnit = unit
this.$nextTick(() => {