2020-07-27 18:26:44 +08:00
|
|
|
<template>
|
2021-10-26 17:47:49 +08:00
|
|
|
<div :class="calcHeight(that.position,that)" :style="calcPosition(that.position,that)" class="alert-label__border" v-loading="loading">
|
2020-09-29 18:51:03 +08:00
|
|
|
<div class="alert-rule-info" >
|
|
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">ID</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value">{{alertRuleData.id ? alertRuleData.id : '--'}}</div>
|
2020-09-29 18:51:03 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.name')}}</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value">{{alertRuleData.name ? alertRuleData.name : '--'}}</div>
|
2020-09-29 18:51:03 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.type')}}</div>
|
2021-11-02 11:04:06 +08:00
|
|
|
<div class="alert-rule-value">
|
|
|
|
|
<span v-if="alertRuleData.type === 1">
|
|
|
|
|
{{$t('project.metrics.metrics')}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="alertRuleData.type === 2">
|
|
|
|
|
{{$t('overall.logs')}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="alertRuleData.type === 3">SNMP trap</span>
|
|
|
|
|
<span v-else>--</span>
|
|
|
|
|
</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.severity')}}</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value"><i class="nz-icon nz-icon-circle" :style="{color:severityColor,'font-size':'12px','margin-right':'5px'}"></i>{{alertRuleData.severityId ? severityData.find(s => alertRuleData.severityId === s.id).name : '--'}}</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.config.expr')}}</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value">{{alertRuleData.expr ? (alertRuleData.expr + alertRuleData.operator + formatThreshold(alertRuleData.threshold,alertRuleData.unit)) : '--'}}</div>
|
2021-10-26 17:47:49 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.alertNum')}}</div>
|
|
|
|
|
<div class="alert-rule-value">
|
|
|
|
|
<i :class="alertRuleData.alertNum ? 'red' : 'green'" class="nz-icon nz-icon-overview-alert"></i>
|
|
|
|
|
<span>{{alertRuleData.alertNum ? alertRuleData.alertNum : 0}}</span>
|
|
|
|
|
</div>
|
2020-07-27 18:26:44 +08:00
|
|
|
</div>
|
2021-09-14 14:19:38 +08:00
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.config.trbShot')}}</div>
|
2021-11-01 17:23:01 +08:00
|
|
|
<div class="alert-rule-value" @click="trbShotShow"><i class="nz-icon nz-icon-guzhangshuju"></i></div>
|
2021-09-14 14:19:38 +08:00
|
|
|
</div>
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.state')}}</div>
|
|
|
|
|
<div class="alert-rule-value" style="margin-left: 3px">
|
|
|
|
|
<div v-if="alertRuleData.state === 1">
|
|
|
|
|
<i class="active-icon green-bg inline-block"></i>
|
|
|
|
|
{{ $t('overall.enabled') }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="alertRuleData.state === 0">
|
|
|
|
|
<i class="active-icon gray-bg inline-block"></i>
|
|
|
|
|
{{ $t('overall.disabled') }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-07-27 18:26:44 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
import chartDataFormat from '../../charts/chartDataFormat'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'alert-rule-info',
|
|
|
|
|
props: {
|
|
|
|
|
id: {},
|
|
|
|
|
messageLoad: {},
|
2021-05-21 19:28:50 +08:00
|
|
|
that: {},
|
|
|
|
|
severityData: Array
|
2021-03-19 18:52:19 +08:00
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
loading: true,
|
2021-10-26 17:47:49 +08:00
|
|
|
alertRuleData: '',
|
|
|
|
|
severityColor: ''
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components: {
|
2020-07-27 18:26:44 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
calcPosition () {
|
|
|
|
|
return function (position) {
|
2021-09-14 14:19:38 +08:00
|
|
|
if (!position) {
|
|
|
|
|
return {
|
|
|
|
|
left: '0px',
|
|
|
|
|
top: '0px'
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
const clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
|
|
|
|
|
const elHeight = 50
|
|
|
|
|
if (position.top + elHeight > clientHeight) {
|
|
|
|
|
return {
|
2021-10-26 17:47:49 +08:00
|
|
|
left: `${position.left + position.width + 200}px`,
|
2021-05-21 19:28:50 +08:00
|
|
|
top: `${position.top - elHeight - 80}px`
|
2020-09-28 16:27:03 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
|
|
|
|
return {
|
2021-10-26 17:47:49 +08:00
|
|
|
left: `${position.left + position.width + 200}px`,
|
2021-05-21 19:28:50 +08:00
|
|
|
top: `${position.top - 80}px`
|
2020-10-15 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-28 16:27:03 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
calcHeight () {
|
|
|
|
|
return function (position) {
|
|
|
|
|
const clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
|
|
|
|
|
const elHeight = 50
|
2021-09-14 14:19:38 +08:00
|
|
|
if (!position) {
|
|
|
|
|
if (elHeight > clientHeight) {
|
|
|
|
|
return 'alert-rule-abs-Up'
|
|
|
|
|
} else {
|
|
|
|
|
return 'alert-rule-abs'
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
if (position.top + elHeight > clientHeight) {
|
|
|
|
|
return 'alert-rule-tip-Up'
|
2020-07-27 18:26:44 +08:00
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
return 'alert-rule-tip'
|
2020-07-27 18:26:44 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
2020-11-20 11:19:25 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
formatThreshold (value, unit) {
|
|
|
|
|
const unitMethod = chartDataFormat.getUnit(unit)
|
|
|
|
|
if (unitMethod && value) {
|
|
|
|
|
return unitMethod.compute(value, null, 2)
|
|
|
|
|
} else {
|
|
|
|
|
return value
|
|
|
|
|
}
|
2021-09-14 14:19:38 +08:00
|
|
|
},
|
|
|
|
|
trbShotShow () {
|
|
|
|
|
this.$emit('showText')
|
2021-10-26 17:47:49 +08:00
|
|
|
},
|
|
|
|
|
severityDataColor () {
|
|
|
|
|
this.severityData.map(item => {
|
|
|
|
|
this.severityColor = item.color
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted () {
|
2021-05-21 19:28:50 +08:00
|
|
|
this.$get('/alert/rule/' + this.id).then((res) => {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (res.msg === 'success') {
|
|
|
|
|
this.loading = false
|
2021-10-26 17:47:49 +08:00
|
|
|
this.severityDataColor()
|
2021-05-21 19:28:50 +08:00
|
|
|
this.alertRuleData = res.data
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-27 18:26:44 +08:00
|
|
|
|
|
|
|
|
</script>
|