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-05-21 19:28:50 +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-05-21 19:28:50 +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>
|
|
|
|
|
<div class="alert-rule-value">{{alertRuleData.type ? alertRuleData.type : ''}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.severity')}}</div>
|
|
|
|
|
<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>
|
|
|
|
|
<!-- <div class="alert-rule-value severity">
|
|
|
|
|
<span v-if="alertRuleData && alertRuleData.severity === 'P1'" class="P1">
|
|
|
|
|
{{$CONSTANTS.alertMessage.severityData.find(s => {return s.value === 'P1'}).label}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="alertRuleData && alertRuleData.severity === 'P2'" class="P2">
|
|
|
|
|
{{$CONSTANTS.alertMessage.severityData.find(s => {return s.value === 'P2'}).label}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="alertRuleData && alertRuleData.severity === 'P3'" class="P3">
|
|
|
|
|
{{$CONSTANTS.alertMessage.severityData.find(s => {return s.value === 'P3'}).label}}
|
|
|
|
|
</span>
|
|
|
|
|
</div>-->
|
2021-05-21 19:28:50 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.config.threshold')}}</div>
|
|
|
|
|
<div class="alert-rule-value">{{alertRuleData.threshold ? alertRuleData.threshold : ''}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.config.expr')}}</div>
|
|
|
|
|
<div class="alert-rule-value">{{alertRuleData.expr ? (alertRuleData.expr + alertRuleData.operator + formatThreshold(alertRuleData.threshold,alertRuleData.unit)) : ''}}</div>
|
|
|
|
|
</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>
|
|
|
|
|
<div class="alert-rule-value" @click="trbShotShow"><i class="nz-icon nz-icon-guzhangshuju" style="color: #fa901c"></i></div>
|
|
|
|
|
</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 => {
|
|
|
|
|
console.log(item.color)
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2020-09-29 18:51:03 +08:00
|
|
|
.alert-rule-tip {
|
|
|
|
|
position: fixed;
|
|
|
|
|
background-color: white;
|
|
|
|
|
z-index: 3000;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: -1px 1px 9px -1px rgba(205,205,205,0.77);
|
|
|
|
|
}
|
|
|
|
|
.alert-rule-tip::after {
|
|
|
|
|
content: '';
|
|
|
|
|
display: block;
|
|
|
|
|
width:0;
|
|
|
|
|
height:0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
font-size: 0;
|
|
|
|
|
line-height: 0;
|
|
|
|
|
border: 5px;
|
|
|
|
|
border-style: dashed solid dashed dashed;
|
|
|
|
|
border-color: transparent #fff transparent transparent;
|
|
|
|
|
position: absolute;
|
2021-05-21 19:28:50 +08:00
|
|
|
top: 100px;
|
2020-09-29 18:51:03 +08:00
|
|
|
left: 0;
|
|
|
|
|
transform: translate(-100%, -50%);
|
|
|
|
|
}
|
2021-09-14 14:19:38 +08:00
|
|
|
.alert-rule-abs {
|
|
|
|
|
background-color: white;
|
|
|
|
|
z-index: 3000;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: -1px 1px 9px -1px rgba(205,205,205,0.77);
|
|
|
|
|
}
|
2020-10-15 18:20:32 +08:00
|
|
|
.alert-rule-tip-Up {
|
|
|
|
|
position: fixed;
|
|
|
|
|
background-color: white;
|
|
|
|
|
z-index: 3000;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: -1px 1px 9px -1px rgba(205,205,205,0.77);
|
|
|
|
|
}
|
|
|
|
|
.alert-rule-tip-Up::after {
|
|
|
|
|
content: '';
|
|
|
|
|
display: block;
|
|
|
|
|
width:0;
|
|
|
|
|
height:0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
font-size: 0;
|
|
|
|
|
line-height: 0;
|
|
|
|
|
border: 5px;
|
|
|
|
|
border-style: dashed solid dashed dashed;
|
|
|
|
|
border-color: transparent #fff transparent transparent;
|
|
|
|
|
position: absolute;
|
2021-05-21 19:28:50 +08:00
|
|
|
bottom: 95px;
|
2020-10-15 18:20:32 +08:00
|
|
|
left: 0;
|
|
|
|
|
transform: translate(-100%, -50%);
|
|
|
|
|
}
|
2021-09-14 14:19:38 +08:00
|
|
|
.alert-rule-abs-Up {
|
|
|
|
|
background-color: white;
|
|
|
|
|
z-index: 3000;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: -1px 1px 9px -1px rgba(205,205,205,0.77);
|
|
|
|
|
}
|
2020-09-29 18:51:03 +08:00
|
|
|
.alert-rule-info{
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 26px;
|
|
|
|
|
}
|
|
|
|
|
.alert-rule-box{
|
|
|
|
|
display: flex;
|
2021-10-26 17:47:49 +08:00
|
|
|
flex-direction: row;
|
2020-09-29 18:51:03 +08:00
|
|
|
}
|
|
|
|
|
.alert-rule-title{
|
|
|
|
|
text-align: left;
|
2020-10-20 14:01:47 +08:00
|
|
|
width: 110px;
|
2020-09-29 18:51:03 +08:00
|
|
|
color: #666;
|
|
|
|
|
padding: 0 3px 0 13px;
|
|
|
|
|
}
|
|
|
|
|
.alert-rule-value{
|
|
|
|
|
text-align: left;
|
|
|
|
|
color: #1a1a1a;
|
|
|
|
|
padding: 0 3px 0 13px;
|
2020-10-09 11:26:16 +08:00
|
|
|
word-wrap: break-word;
|
|
|
|
|
white-space: normal;
|
|
|
|
|
overflow: hidden;
|
2020-09-29 18:51:03 +08:00
|
|
|
}
|
2020-10-16 16:11:23 +08:00
|
|
|
.severity .P1{
|
|
|
|
|
background: #F5846A;
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
}
|
|
|
|
|
.severity .P2{
|
|
|
|
|
background: #F7A54A;
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
}
|
|
|
|
|
.severity .P3{
|
|
|
|
|
background: #F1C13D;
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
}
|
2021-10-26 17:47:49 +08:00
|
|
|
.alert-label__border {
|
|
|
|
|
background: #FFFFFF;
|
|
|
|
|
border: 1px solid #E7EAED;
|
|
|
|
|
box-shadow: 0 6px 16px 0 rgba(0,0,0,0.08);
|
|
|
|
|
border-radius: 3px 3px 3px 3px 0 0;
|
|
|
|
|
}
|
2020-09-29 18:51:03 +08:00
|
|
|
/* .alert-rule-info::after {
|
2020-09-28 16:27:03 +08:00
|
|
|
content: '';
|
|
|
|
|
display: block;
|
|
|
|
|
width:0;
|
|
|
|
|
height:0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
font-size: 0;
|
|
|
|
|
line-height: 0;
|
|
|
|
|
border: 5px;
|
|
|
|
|
border-style: dashed solid dashed dashed;
|
|
|
|
|
border-color: transparent #fff transparent transparent;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: calc(50% - 6px);
|
|
|
|
|
left: 0;
|
|
|
|
|
transform: translate(-100%, -100%);
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-rule-info{
|
2020-07-27 18:26:44 +08:00
|
|
|
border: 1px solid #ebeef5;
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 26px;
|
2020-09-29 18:51:03 +08:00
|
|
|
}*/
|
|
|
|
|
/* .alert-rule-info{
|
|
|
|
|
border: 1px solid #ebeef5;
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 26px;
|
|
|
|
|
display: flex;
|
2020-09-28 16:27:03 +08:00
|
|
|
background-color: white;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: -1px 1px 9px -1px rgba(205,205,205,0.77);
|
2020-07-27 18:26:44 +08:00
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-rule-box{
|
2020-07-27 18:26:44 +08:00
|
|
|
display: flex;
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-rule-title{
|
2020-07-27 18:26:44 +08:00
|
|
|
text-align: left;
|
|
|
|
|
width: 80px;
|
|
|
|
|
border-right: 1px solid #ebeef5;
|
|
|
|
|
color: #666;
|
|
|
|
|
padding: 0 3px 0 13px;
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-rule-value{
|
2020-07-27 18:26:44 +08:00
|
|
|
text-align: left;
|
|
|
|
|
color: #1a1a1a;
|
|
|
|
|
padding: 0 3px 0 13px;
|
2020-09-29 18:51:03 +08:00
|
|
|
}*/
|
2020-07-27 18:26:44 +08:00
|
|
|
</style>
|