feat:NEZ-499 添加告警静默功能
This commit is contained in:
Binary file not shown.
@@ -20,6 +20,9 @@ Created by iconfont
|
|||||||
/>
|
/>
|
||||||
<missing-glyph />
|
<missing-glyph />
|
||||||
|
|
||||||
|
<glyph glyph-name="chaoshi" unicode="" d="M757.82562345 339.48597884000003a201.95579891 201.95579891 0 0 0 201.50486092-202.47115675c0-111.83262109-90.18759766-202.47115673-201.50486092-202.47115673a201.95579891 201.95579891 0 0 0-201.44044109 202.47115673c0 111.76820125 90.18759766 202.47115673 201.44044109 202.47115675zM506.58874414 834.93798828c246.08330193 0 445.59115226-200.47414528 445.59115226-447.8458422a30.92146168 30.92146168 0 0 0-61.58524576-0.70861646v0.70861646c0 213.16482878-171.93621321 385.8740783-383.94148666 385.8740783-212.06969416 0-383.94148753-172.70924951-383.94148754-385.8740783 0-210.97455867 168.45754811-382.39541406 377.56393586-385.8740783h6.37755168a30.92146168 30.92146168 0 0 0 30.79262288-30.92146254 30.92146168 30.92146168 0 0 0-30.79262288-31.05030136C260.56986205-60.75369611999997 61.06201172 139.84928882999998 61.06201172 387.09214608 61.06201172 634.463843 260.56986205 834.93798828 506.65316398 834.93798828z m251.23687931-543.05817756a154.4140515 154.4140515 0 0 1-153.96311351-154.86498863 154.4140515 154.4140515 0 0 1 153.96311351-154.86498948 154.4140515 154.4140515 0 0 1 154.09195232 154.86498948 154.4140515 154.4140515 0 0 1-154.09195232 154.80056879z m80.65348007-138.2447029a26.15440332 26.15440332 0 1 0 0-52.43764631H677.23656322a26.15440332 26.15440332 0 0 0-26.02556452 26.28324299c0 14.43001562 11.65996785 26.15440332 26.02556452 26.15440332h161.2425403z m-326.09258537 488.30142148a32.20985668 32.20985668 0 0 0 32.20985668-32.27427565v-256.26161701c0-10.30715389-4.83147819-19.45475333-12.23974552-25.38136703a31.56565918 31.56565918 0 0 0-22.9978374-9.98505557h-0.12883968l-255.10206169 0.45093798a32.01659717 32.01659717 0 0 0-0.19325951 64.03319434h0.06441983l226.24203045-0.38651815V609.66225365a32.20985668 32.20985668 0 0 0 32.20985668 32.33869549z" horiz-adv-x="1024" />
|
||||||
|
|
||||||
|
|
||||||
<glyph glyph-name="arrow-left1" unicode="" d="M210.88500949 384L841.59694303 759.7816572 672.94613541 448.63444528H2014.63696262v-127.31482565H672.79582245L841.59694303 8.21834279999996z" horiz-adv-x="2218" />
|
<glyph glyph-name="arrow-left1" unicode="" d="M210.88500949 384L841.59694303 759.7816572 672.94613541 448.63444528H2014.63696262v-127.31482565H672.79582245L841.59694303 8.21834279999996z" horiz-adv-x="2218" />
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 145 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
193
nezha-fronted/src/components/common/alert/selectAlertSilence.vue
Normal file
193
nezha-fronted/src/components/common/alert/selectAlertSilence.vue
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
<template>
|
||||||
|
<el-popover :placement="placement" popper-class="nz-pop nz-pop-select-panel nz-pop-select-silence" ref="selectSilencePopBox" transition="slide" v-model="popBox.show" width="400">
|
||||||
|
<div>
|
||||||
|
<div class="pop-item-wider">
|
||||||
|
|
||||||
|
<slot name="header"></slot>
|
||||||
|
|
||||||
|
<div class="select-panel-tree">
|
||||||
|
<el-tree
|
||||||
|
:data="silenceData"
|
||||||
|
:expand-on-click-node="false"
|
||||||
|
:filter-node-method="filterNode"
|
||||||
|
:props="{label: 'name', children: 'children'}"
|
||||||
|
@node-click="selectSilence"
|
||||||
|
@node-drop="nodeDrop"
|
||||||
|
check-on-click-node
|
||||||
|
check-strictly
|
||||||
|
highlight-current
|
||||||
|
node-key="id"
|
||||||
|
v-loading="typeContentLoading"
|
||||||
|
ref="panelTree">
|
||||||
|
<div class="tree--node" slot-scope="{ node, data }">
|
||||||
|
<span>{{ node.label }}</span>
|
||||||
|
</div>
|
||||||
|
</el-tree>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div slot="reference">
|
||||||
|
<slot name="trigger"></slot>
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "selectAlertSilence",
|
||||||
|
props:{
|
||||||
|
placement: {type: String},
|
||||||
|
isEdit: {type: Boolean, default: true},
|
||||||
|
silenceData: {type: Array},
|
||||||
|
filterSilence: {type: String},
|
||||||
|
typeContentLoading:{type: Boolean, default: false}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// this.$refs.panelTree.setCurrentKey();
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
filterSilence: {
|
||||||
|
immediate: true,
|
||||||
|
handler(n) {
|
||||||
|
this.$refs.panelTree && this.$refs.panelTree.filter(n);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/*panel: {
|
||||||
|
immediate: true,
|
||||||
|
handler(n) {
|
||||||
|
if (this.$refs.panelTree) {
|
||||||
|
console.info(n.id, n.name)
|
||||||
|
this.$refs.panelTree.setCurrentKey(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
popBox: {show: false},
|
||||||
|
panel: {id: 0, name: ""},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
/*
|
||||||
|
* node: 被拖的节点
|
||||||
|
* relative: 发生关系的节点
|
||||||
|
* position: ['before', 'after', 'inner'] 与relative节点的关系
|
||||||
|
* */
|
||||||
|
nodeDrop(node, relative, position, event) {
|
||||||
|
if (position === 'inner') {
|
||||||
|
node.data.pid = relative.data.id;
|
||||||
|
} else {
|
||||||
|
node.data.pid = relative.data.pid;
|
||||||
|
}
|
||||||
|
this.updateWeight();
|
||||||
|
},
|
||||||
|
filterNode(value, data) {
|
||||||
|
if (!value) return true;
|
||||||
|
return data.name.indexOf(value) !== -1;
|
||||||
|
},
|
||||||
|
updateWeight() {
|
||||||
|
let toUpdate = [];
|
||||||
|
let count = 0;
|
||||||
|
handler(this.silenceData);
|
||||||
|
|
||||||
|
function handler(silenceData) {
|
||||||
|
silenceData.forEach(panel => {
|
||||||
|
panel.weight = count++;
|
||||||
|
toUpdate.push({id: panel.id, pid: panel.pid, weight: panel.weight});
|
||||||
|
if (panel.children && panel.children.length > 0) {
|
||||||
|
handler(panel.children);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$put("/panel/tree", toUpdate);
|
||||||
|
},
|
||||||
|
deletePanel(data) {
|
||||||
|
this.$emit("deletePanel", data);
|
||||||
|
},
|
||||||
|
editPanel(data) {
|
||||||
|
this.$emit("editPanel", data);
|
||||||
|
},
|
||||||
|
esc(){
|
||||||
|
this.popBox.show = false;
|
||||||
|
},
|
||||||
|
//确认选择某个节点,与父组件交互
|
||||||
|
selectSilence(data, checked, child) {
|
||||||
|
if(data.children) return
|
||||||
|
this.$emit('selectSilence', data);
|
||||||
|
this.$refs.panelTree.setCurrentKey(data);
|
||||||
|
this.esc();
|
||||||
|
},
|
||||||
|
//tree设为单选
|
||||||
|
/*clearOthers(data, checked, child) {
|
||||||
|
if (checked) {
|
||||||
|
this.panel = data;
|
||||||
|
this.$refs.panelTree.setCheckedKeys([data.id]);
|
||||||
|
} else {
|
||||||
|
this.panel = {id: '', name: ''};
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.movable {
|
||||||
|
.el-tree-node__content {
|
||||||
|
cursor: move;
|
||||||
|
.tree--node>span:first-of-type {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.tree--node>span:last-of-type>span {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tree--node>span:last-of-type>span>i {
|
||||||
|
font-weight: normal !important;
|
||||||
|
}
|
||||||
|
.select-panel-tree {
|
||||||
|
height: 350px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
.select-panel-tree .el-tree-node__content {
|
||||||
|
height: 34px;
|
||||||
|
line-height: 34px;
|
||||||
|
}
|
||||||
|
.select-panel-tree .el-tree-node__content:hover {
|
||||||
|
color: $global-text-color-active;
|
||||||
|
}
|
||||||
|
.select-panel-tree .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
|
||||||
|
background-color: #F5F7FA;
|
||||||
|
font-weight: bold;
|
||||||
|
color: $global-text-color-active;
|
||||||
|
}
|
||||||
|
.tree--node {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: calc(100% - 28px);
|
||||||
|
}
|
||||||
|
.tree--operation {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.tree--node:hover .tree--operation {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.panel-dropdown-btn {
|
||||||
|
color: #60BEFF;
|
||||||
|
}
|
||||||
|
.panel-dropdown-btn:hover {
|
||||||
|
color: #409EFF;
|
||||||
|
}
|
||||||
|
.panel-dropdown-btn-delete {
|
||||||
|
color: #F98D9A;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-dropdown-btn-delete:hover {
|
||||||
|
color: #D96D7A;
|
||||||
|
}
|
||||||
|
.nz-pop-select-silence /deep/ .panel-select-header{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -395,6 +395,7 @@ const cn = {
|
|||||||
},
|
},
|
||||||
tip: {
|
tip: {
|
||||||
confirmDelete: "确认删除吗?",
|
confirmDelete: "确认删除吗?",
|
||||||
|
confirmOvertime: "确定要使这个超时?", //Are you sure you want to delete?
|
||||||
killTerm:'确认关闭 terminal 吗?',
|
killTerm:'确认关闭 terminal 吗?',
|
||||||
confirmBatchDelete:'确定删除这{0}条数据吗?',
|
confirmBatchDelete:'确定删除这{0}条数据吗?',
|
||||||
assetConfirmDelete: "关联的Endpoint和告警将会被删除,确认删除吗?",
|
assetConfirmDelete: "关联的Endpoint和告警将会被删除,确认删除吗?",
|
||||||
@@ -914,6 +915,14 @@ const cn = {
|
|||||||
affectEntity: "影响"
|
affectEntity: "影响"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
silence:{
|
||||||
|
silence:"告警静默",
|
||||||
|
create:'创建告警静默',
|
||||||
|
edit:'修改告警静默',
|
||||||
|
time:'时间',
|
||||||
|
matcher:'Matcher',
|
||||||
|
reason:'原因',
|
||||||
|
},
|
||||||
P1Rule:'P1: 万分紧急,可导致业务瘫痪的告警',
|
P1Rule:'P1: 万分紧急,可导致业务瘫痪的告警',
|
||||||
P2Rule:'P2: 急需处理,但不影响业务的告警',
|
P2Rule:'P2: 急需处理,但不影响业务的告警',
|
||||||
P3Rule:'P3: 需要处理,但不紧急的告警',
|
P3Rule:'P3: 需要处理,但不紧急的告警',
|
||||||
|
|||||||
@@ -398,6 +398,7 @@ const en = {
|
|||||||
},
|
},
|
||||||
tip: {
|
tip: {
|
||||||
confirmDelete: "Are you sure you want to delete?", //Are you sure you want to delete?
|
confirmDelete: "Are you sure you want to delete?", //Are you sure you want to delete?
|
||||||
|
confirmOvertime: "Are you sure you want this to time out?",
|
||||||
killTerm:'Are you sure you want to kill terminal?',
|
killTerm:'Are you sure you want to kill terminal?',
|
||||||
confirmBatchDelete:'Are you sure to delete these {0} pieces of data',
|
confirmBatchDelete:'Are you sure to delete these {0} pieces of data',
|
||||||
assetConfirmDelete: 'Related endpoints and alerts will be removed, are you sure you want to delete this asset?',//Related endpoints and alerts will be removed, are you sure you want to delete this asset?
|
assetConfirmDelete: 'Related endpoints and alerts will be removed, are you sure you want to delete this asset?',//Related endpoints and alerts will be removed, are you sure you want to delete this asset?
|
||||||
@@ -919,6 +920,14 @@ const en = {
|
|||||||
affectEntity: "Affect entity"
|
affectEntity: "Affect entity"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
silence:{
|
||||||
|
silence:"Alert silence",
|
||||||
|
create:'New alert silence',
|
||||||
|
edit:'Edit alert silence',
|
||||||
|
time:'Time',
|
||||||
|
matcher:'Matcher',
|
||||||
|
reason:'Reason',
|
||||||
|
},
|
||||||
P1Rule:'P1: Critical, alarm that can cause business paralysis',
|
P1Rule:'P1: Critical, alarm that can cause business paralysis',
|
||||||
P2Rule:'P2: Major, alarm that do not affect the business',
|
P2Rule:'P2: Major, alarm that do not affect the business',
|
||||||
P3Rule:'P3: Minor, alarm that need to deal with, but not urgent',
|
P3Rule:'P3: Minor, alarm that need to deal with, but not urgent',
|
||||||
|
|||||||
506
nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue
Normal file
506
nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue
Normal file
@@ -0,0 +1,506 @@
|
|||||||
|
<template>
|
||||||
|
<div class="right-box right-box-alert-config" v-clickoutside="{obj:editAlertSilence,func:clickOutside}">
|
||||||
|
<!-- begin--顶部按钮-->
|
||||||
|
<div class="right-box-top-btns right-box-form-delete">
|
||||||
|
<button @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien" id="alert-box-del" type="button"
|
||||||
|
v-has="'alert_silence_delete'" v-if="alertSilence.id">
|
||||||
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-delete"></i></span>
|
||||||
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<!-- end--顶部按钮-->
|
||||||
|
|
||||||
|
<!-- begin--标题-->
|
||||||
|
<div class="right-box-title">{{editAlertSilence.id ? $t("alert.silence.edit") + " ID:" + editAlertSilence.id :
|
||||||
|
$t("alert.silence.create")}}
|
||||||
|
</div>
|
||||||
|
<!-- end--标题-->
|
||||||
|
|
||||||
|
<!-- begin--表单-->
|
||||||
|
<div class="right-box-form-box">
|
||||||
|
<el-form class="right-box-form right-box-form-left" :model="editAlertSilence" label-position="top"
|
||||||
|
label-width="120px" :rules="rules" ref="alertSilenceForm">
|
||||||
|
<el-form-item :label='$t("alert.silence.time")' prop="time" class="range-time">
|
||||||
|
<div>
|
||||||
|
<el-radio-group v-model="rangeTime" size="small" @change="rangeTimeChange">
|
||||||
|
<el-radio-button label="1">1 hour</el-radio-button>
|
||||||
|
<el-radio-button label="2">2 hour</el-radio-button>
|
||||||
|
<el-radio-button label="6">6hour</el-radio-button>
|
||||||
|
<el-radio-button label="12">12 hour</el-radio-button>
|
||||||
|
<el-radio-button label="24">1 day</el-radio-button>
|
||||||
|
<el-radio-button label="48">2 day</el-radio-button>
|
||||||
|
<el-radio-button label="168">1 week</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</div>
|
||||||
|
<div class="datepicker">
|
||||||
|
<el-date-picker prefix-icon=" " class="panel-time-picker-hidden " size="mini" ref="calendar"
|
||||||
|
format="yyyy/MM/dd HH:mm:ss" @change="dateChange" v-model="editAlertSilence.time"
|
||||||
|
type="datetimerange"
|
||||||
|
popper-class="panel-time-picker-popper"
|
||||||
|
:range-separator="$t('dashboard.panel.to')"
|
||||||
|
:start-placeholder="$t('dashboard.panel.startTime')"
|
||||||
|
:end-placeholder="$t('dashboard.panel.endTime')" align="right"
|
||||||
|
>
|
||||||
|
</el-date-picker>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item :label='$t("alert.silence.matcher")' prop="matcher" class="matcher">
|
||||||
|
<div class="matcher-type">
|
||||||
|
<div class="matcher-type-title">Alert rule</div>
|
||||||
|
<el-select v-model="editAlertSilence.ruleId" filterable @change="matcherChange" :popper-append-to-body="false" size="small" class="matcher-type-content">
|
||||||
|
<el-option
|
||||||
|
v-for="item in ruleList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.alertName"
|
||||||
|
:value="item.id">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="matcher-type">
|
||||||
|
<el-select class="matcher-type-title" v-model="editAlertSilence.type" :popper-append-to-body="false" size="small" @change="typeChange">
|
||||||
|
<el-option
|
||||||
|
v-for="item in typeList"
|
||||||
|
:key="item.type"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.type">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
<div class="matcher-type-content">
|
||||||
|
<select-alert-silence :filter-silence="filterSilence" :silence-data="silenceData" :panel-lock="false" :placement="'bottom-start'" :typeContentLoading="typeContentLoading"
|
||||||
|
@selectSilence="silenceChange" ref="selectPanel" style="width: 300px;">
|
||||||
|
<template v-slot:header>
|
||||||
|
<div class="panel-select-header">
|
||||||
|
<el-input :placeholder="$t('overall.search')" clearable size="mini" style="width: 340px; margin-right: 5px;" v-model="filterSilence" id="panel-list-search"></el-input>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:trigger>
|
||||||
|
<el-input class="panel-name" placeholder="" readonly="readonly" v-model="editAlertSilence.name" size="small">
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</select-alert-silence>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item :label='$t("alert.silence.reason")' prop="reason" class="range-time">
|
||||||
|
<el-input
|
||||||
|
type="textarea"
|
||||||
|
:placeholder="$t('alert.description')"
|
||||||
|
v-model="editAlertSilence.reason"
|
||||||
|
maxlength="512"
|
||||||
|
show-word-limit>
|
||||||
|
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- end--表单-->
|
||||||
|
|
||||||
|
<!--底部按钮-->
|
||||||
|
<div class="right-box-bottom-btns">
|
||||||
|
<button v-cancel="{obj:editAlertSilence,func:esc}" id="alert-box-esc"
|
||||||
|
class="nz-btn nz-btn-size-normal-new nz-btn-style-light-new">
|
||||||
|
<span>{{$t('overall.cancel')}}</span>
|
||||||
|
</button>
|
||||||
|
<button :class="{'nz-btn-disabled':prevent_opt.save}" :disabled="prevent_opt.save" @click="save"
|
||||||
|
class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new" id="alert-box-save">
|
||||||
|
<span>{{$t('overall.save')}}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import bus from '../../../libs/bus';
|
||||||
|
import selectAlertSilence from '../alert/selectAlertSilence'
|
||||||
|
export default {
|
||||||
|
name:"alertSilenceBox",
|
||||||
|
components:{
|
||||||
|
selectAlertSilence,
|
||||||
|
},
|
||||||
|
|
||||||
|
props:{
|
||||||
|
alertSilence:Object
|
||||||
|
},
|
||||||
|
watch:{
|
||||||
|
alertSilence:{
|
||||||
|
deep:true,
|
||||||
|
immediate:true,
|
||||||
|
handler(n,o){
|
||||||
|
let obj=JSON.parse(JSON.stringify(n))
|
||||||
|
if(obj.ruleId==-1){
|
||||||
|
obj.ruleId=null;
|
||||||
|
}
|
||||||
|
if(obj.linkId==-1){
|
||||||
|
obj.linkId=null;
|
||||||
|
}
|
||||||
|
this.editAlertSilence=Object.assign(this.editAlertSilence,obj);
|
||||||
|
console.log(this.editAlertSilence);
|
||||||
|
this.editAlertSilence.time=[];
|
||||||
|
this.editAlertSilence.time.push(this.editAlertSilence.startAt);
|
||||||
|
this.editAlertSilence.time.push(this.editAlertSilence.endAt);
|
||||||
|
this.rangeTimeCallback();
|
||||||
|
this.typeChange(this.editAlertSilence.type,obj.linkId);
|
||||||
|
if(obj.linkId || obj.ruleId){
|
||||||
|
this.matcherChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
editAlertSilence:{
|
||||||
|
id:'',
|
||||||
|
startAt:'',
|
||||||
|
endAt:'',
|
||||||
|
ruleId:'',
|
||||||
|
type:'',
|
||||||
|
linkId:'',
|
||||||
|
reason:'',
|
||||||
|
time:[],
|
||||||
|
matcher:'',
|
||||||
|
name:''
|
||||||
|
},
|
||||||
|
rules:{
|
||||||
|
time: [
|
||||||
|
{ required: true, message: '请选择时间', trigger: 'change' },
|
||||||
|
],
|
||||||
|
matcher:[
|
||||||
|
{ required: true, message: '请选择Mather', trigger: 'change' },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
rangeTime:'',
|
||||||
|
ruleList:[],
|
||||||
|
filterSilence:'',
|
||||||
|
silenceData:[],
|
||||||
|
typeContentLoading:false,
|
||||||
|
typeList:[
|
||||||
|
{type:'datacenter',name:'Datacenter'},
|
||||||
|
{type:'project',name:'Project'},
|
||||||
|
{type:'module',name:'Module'},
|
||||||
|
{type:'endpoint',name:'Endpoint'},
|
||||||
|
{type:'asset',name:'Asset'},
|
||||||
|
],
|
||||||
|
datacenterData:null,
|
||||||
|
assetData:null,
|
||||||
|
projectData:null,
|
||||||
|
moduleData:null,
|
||||||
|
endpointData:null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted(){
|
||||||
|
this.getRuleList()
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
clickOutside(){
|
||||||
|
this.esc(false);
|
||||||
|
},
|
||||||
|
esc(refresh){
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
this.$emit("close",refresh);
|
||||||
|
},
|
||||||
|
save(){
|
||||||
|
if(this.prevent_opt.save){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
;
|
||||||
|
this.prevent_opt.save=true;
|
||||||
|
this.editAlertSilence.matcher=this.editAlertSilence.ruleId || this.editAlertSilence.linkId ;
|
||||||
|
console.log(this.editAlertSilence);
|
||||||
|
this.$refs.alertSilenceForm.validate((valid)=>{
|
||||||
|
this.editAlertSilence.startAt=this.editAlertSilence.time[0];
|
||||||
|
this.editAlertSilence.state=1;
|
||||||
|
this.editAlertSilence.endAt=this.editAlertSilence.time[1];
|
||||||
|
let params={...this.editAlertSilence};
|
||||||
|
delete params.time;
|
||||||
|
delete params.matcher;
|
||||||
|
if(valid){
|
||||||
|
if(this.editAlertSilence.id){
|
||||||
|
this.$put('/alert/silence',params).then(response=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
if(response.code===200){
|
||||||
|
this.$message({duration:1000,type:'success',message:this.$t("tip.saveSuccess")});
|
||||||
|
this.esc(true);
|
||||||
|
}else{
|
||||||
|
this.$message.error(response.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
this.$post('/alert/silence',params).then(response=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
if(response.code===200){
|
||||||
|
this.$message({duration:1000,type:'success',message:this.$t("tip.saveSuccess")});
|
||||||
|
this.esc(true);
|
||||||
|
}else{
|
||||||
|
this.$message.error(response.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
del(){
|
||||||
|
if(this.prevent_opt.save){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
;
|
||||||
|
this.prevent_opt.save=true;
|
||||||
|
this.$confirm(this.$t("tip.confirmDelete"),{
|
||||||
|
confirmButtonText:this.$t("tip.yes"),
|
||||||
|
cancelButtonText:this.$t("tip.no"),
|
||||||
|
type:'warning'
|
||||||
|
}).then(()=>{
|
||||||
|
this.$delete("/alert/silence?ids="+this.editAlertSilence.id).then(response=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
if(response.code===200){
|
||||||
|
this.$message({type:'success',message:this.$t("tip.deleteSuccess")});
|
||||||
|
this.esc(true);
|
||||||
|
}else{
|
||||||
|
this.$message.error(response.msg);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch(()=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getRuleList(){
|
||||||
|
this.$get('/alert/rule',{pageNo:1,pageSize:-1}).then(response=>{
|
||||||
|
if(response.code==200){
|
||||||
|
this.ruleList=response.data.list;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
dateChange(val){
|
||||||
|
if(val){
|
||||||
|
this.editAlertSilence.time[0]=bus.timeFormate(val[0],'yyyy-MM-dd hh:mm:ss');
|
||||||
|
this.editAlertSilence.time[1]=bus.timeFormate(val[1],'yyyy-MM-dd hh:mm:ss');
|
||||||
|
}
|
||||||
|
this.rangeTimeCallback()
|
||||||
|
},
|
||||||
|
rangeTimeCallback(){
|
||||||
|
if(this.editAlertSilence.time){
|
||||||
|
let num=new Date(this.editAlertSilence.time[1]).getTime() - new Date(this.editAlertSilence.time[0]).getTime();
|
||||||
|
this.rangeTime=num/(60*60*1000);//以小时为单位
|
||||||
|
}else{
|
||||||
|
this.rangeTime=null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rangeTimeChange(val){
|
||||||
|
let arr=[bus.timeFormate(bus.getOffsetTimezoneData(),'yyyy-MM-dd hh:mm:ss'),bus.timeFormate(bus.getOffsetTimezoneData(val*1),'yyyy-MM-dd hh:mm:ss')]
|
||||||
|
this.$set(this.editAlertSilence,'time',arr)
|
||||||
|
},
|
||||||
|
matcherChange(val){
|
||||||
|
this.editAlertSilence.matcher=this.editAlertSilence.ruleId || this.editAlertSilence.linkId;
|
||||||
|
console.log(this.editAlertSilence,"this.editAlertSilence")
|
||||||
|
},
|
||||||
|
silenceChange(val){
|
||||||
|
this.editAlertSilence.linkId=val.id;
|
||||||
|
this.editAlertSilence.matcher=this.editAlertSilence.ruleId || this.editAlertSilence.linkId;
|
||||||
|
console.log(val);
|
||||||
|
if(this.editAlertSilence.type==='datacenter'){
|
||||||
|
this.editAlertSilence.name=val.name;
|
||||||
|
}
|
||||||
|
if(this.editAlertSilence.type==='asset'){
|
||||||
|
this.editAlertSilence.name=val.idc.name+'/'+val.sn
|
||||||
|
}
|
||||||
|
if(this.editAlertSilence.type==='project'){
|
||||||
|
this.editAlertSilence.name=val.name;
|
||||||
|
}
|
||||||
|
if(this.editAlertSilence.type==='module'){
|
||||||
|
this.editAlertSilence.name=val.project.name +'/'+val.name;
|
||||||
|
}
|
||||||
|
if(this.editAlertSilence.type==='endpoint'){
|
||||||
|
this.editAlertSilence.name=val.project.name +'/'+val.module.name+'/'+val.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
typeChange(val,linkId){
|
||||||
|
let firstArr=[]
|
||||||
|
let secondArr=[];
|
||||||
|
let thirddiArr=[];
|
||||||
|
this.typeContentLoading=true;
|
||||||
|
this.editAlertSilence.linkId=linkId?linkId:'';
|
||||||
|
this.editAlertSilence.name='';
|
||||||
|
if(val==='datacenter'){
|
||||||
|
this.$get('/idc',{pageNo:1,pageSize:-1}).then(response=>{
|
||||||
|
if(response.code==200){
|
||||||
|
firstArr=response.data.list;
|
||||||
|
if(linkId){
|
||||||
|
this.editAlertSilence.name=firstArr.find(item=>item.id===linkId).name;
|
||||||
|
}
|
||||||
|
this.silenceData=firstArr;
|
||||||
|
this.datacenterData=firstArr;
|
||||||
|
this.typeContentLoading=false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if(val==='asset'){
|
||||||
|
this.$get('/asset?pageNo=1&pageSize=-1').then(res=>{
|
||||||
|
if(res.code==200){
|
||||||
|
let arr=[];
|
||||||
|
res.data.list.forEach(asset=>{
|
||||||
|
asset.name=asset.sn;
|
||||||
|
if(linkId===asset.id){
|
||||||
|
this.editAlertSilence.name=asset.idc.name +'/'+asset.name;
|
||||||
|
}
|
||||||
|
let idcF=arr.find(idc=>idc.id===asset.idc.id);
|
||||||
|
if(idcF){
|
||||||
|
idcF.children.push(asset);
|
||||||
|
} else{
|
||||||
|
let idc={...asset.idc};
|
||||||
|
idc.children=[asset];
|
||||||
|
arr.push(idc);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.silenceData=arr;
|
||||||
|
this.assetData=arr;
|
||||||
|
this.typeContentLoading=false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if(val==='project'){
|
||||||
|
this.$get('/project',{pageNo:1,pageSize:-1}).then(response=>{
|
||||||
|
if(response.code==200){
|
||||||
|
firstArr=response.data.list;
|
||||||
|
if(linkId){
|
||||||
|
this.editAlertSilence.name=firstArr.find(item=>item.id===linkId).name;
|
||||||
|
}
|
||||||
|
this.silenceData=firstArr;
|
||||||
|
this.projectData=firstArr;
|
||||||
|
this.typeContentLoading=false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(val==='module'){
|
||||||
|
this.$get('/module?pageNo=1&pageSize=-1').then(res=>{
|
||||||
|
if(res.code==200){
|
||||||
|
let arr=[];
|
||||||
|
res.data.list.forEach(module=>{
|
||||||
|
if(linkId===module.id){
|
||||||
|
this.editAlertSilence.name=module.project.name +'/'+module.name;
|
||||||
|
}
|
||||||
|
let projectF=arr.find(project=>project.id===module.project.id)
|
||||||
|
if(projectF){
|
||||||
|
projectF.children.push(module);
|
||||||
|
} else{
|
||||||
|
let project={...module.project};
|
||||||
|
project.children=[module];
|
||||||
|
arr.push(project);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.silenceData=arr;
|
||||||
|
this.moduleData=arr;
|
||||||
|
this.typeContentLoading=false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if(val==='endpoint'){
|
||||||
|
this.$get('/endpoint?pageNo=1&pageSize=-1').then(res=>{
|
||||||
|
if(res.code=200){
|
||||||
|
let arr=[];
|
||||||
|
res.data.list.forEach(item=>{
|
||||||
|
item.name=item.host;
|
||||||
|
if(linkId===item.id){
|
||||||
|
this.editAlertSilence.name=item.project.name +'/'+item.module.name+'/'+item.name;
|
||||||
|
}
|
||||||
|
let projectF = arr.find(project=>item.project.id===project.id);
|
||||||
|
if(projectF){
|
||||||
|
let moduleF = projectF.children.find(module=>module.id===item.module.id);
|
||||||
|
if(moduleF){
|
||||||
|
moduleF.children.push(item)
|
||||||
|
} else{
|
||||||
|
projectF.children.push({...item.module,children:[item]});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let project={...item.project};
|
||||||
|
project.children=[{...item.module,children:[item]}]
|
||||||
|
arr.push(project);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.silenceData=arr;
|
||||||
|
this.endpointData=arr;
|
||||||
|
this.typeContentLoading=false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
returnOnj(obj){
|
||||||
|
console.log(obj);
|
||||||
|
return {...obj,name:''}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.range-time {
|
||||||
|
/deep/ .el-radio-button--small .el-radio-button__inner, /deep/ .el-radio-group {
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .el-radio-button {
|
||||||
|
width: 14.2%
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .el-date-editor.el-range-editor.el-input__inner.panel-time-picker-hidden.el-date-editor--datetimerange.el-range-editor--mini {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.datepicker {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.matcher{
|
||||||
|
/deep/ .el-input--prefix .el-input__inner{
|
||||||
|
}
|
||||||
|
/deep/ .el-input__prefix{
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
.matcher-type{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 20px;
|
||||||
|
.matcher-type-title{
|
||||||
|
width: 125px;
|
||||||
|
background:#E7EAED;
|
||||||
|
font-family: ArialMT;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333333;
|
||||||
|
letter-spacing: 0;
|
||||||
|
font-weight: 400;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
/deep/ .matcher-type-title.el-select--small .el-input__inner{
|
||||||
|
background:#E7EAED;
|
||||||
|
font-family: ArialMT;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333333;
|
||||||
|
letter-spacing: 0;
|
||||||
|
font-weight: 400;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.matcher-type-content{
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
569
nezha-fronted/src/components/page/alert/silence.vue
Normal file
569
nezha-fronted/src/components/page/alert/silence.vue
Normal file
@@ -0,0 +1,569 @@
|
|||||||
|
<template>
|
||||||
|
<div class="main-list main-and-sub-transition" :class="{'main-list-with-sub': bottomBox.showSubList}">
|
||||||
|
<!--工具组-->
|
||||||
|
<div class="top-tools" v-show="bottomBox.mainResizeShow">
|
||||||
|
<div class="top-tool-main-right" :class="{'top-tool-main-right-to-left': bottomBox.showSubList}">
|
||||||
|
<div class="top-tool-search margin-r-20">
|
||||||
|
<search-input :searchMsg="searchMsg" @search="search"
|
||||||
|
:bottomBox.inTransform="bottomBox.inTransform"></search-input>
|
||||||
|
</div>
|
||||||
|
<button :title="$t('overall.exportExcelLower')" @click="addSilence" type="button" v-has="'alertsilence_save'"
|
||||||
|
class="nz-btn nz-btn-size-normal nz-btn-style-light" id="alert-list-export">
|
||||||
|
<i class="nz-icon nz-icon-create-square"></i>
|
||||||
|
</button>
|
||||||
|
<delete-button :delete-objs="batchDeleteObjs" @after="getAlertSilence"
|
||||||
|
:api="'alert/silence'" v-has="'alert_silence_delete'" id="alert-msg-batch-delete"></delete-button>
|
||||||
|
</div>
|
||||||
|
<div class="pagination-top pagination-top-hide display-none"></div>
|
||||||
|
</div>
|
||||||
|
<!--表格开始-->
|
||||||
|
<transition name="el-zoom-in-top">
|
||||||
|
<element-set
|
||||||
|
id="alert-rule-element-set"
|
||||||
|
v-if="tools.showCustomTableTitle"
|
||||||
|
@close="tools.showCustomTableTitle = false"
|
||||||
|
:custom-table-title.sync="tools.customTableTitle"
|
||||||
|
:original-table-title="tableTitle"
|
||||||
|
ref="customTableTitle"
|
||||||
|
></element-set>
|
||||||
|
</transition>
|
||||||
|
<el-table
|
||||||
|
id="alert-rule-table"
|
||||||
|
class="nz-table"
|
||||||
|
:data="tableData"
|
||||||
|
border
|
||||||
|
v-show="bottomBox.mainResizeShow"
|
||||||
|
ref="alertSilenceTable"
|
||||||
|
tooltip-effect="light"
|
||||||
|
:height="mainTableHeight"
|
||||||
|
v-loading="tools.loading"
|
||||||
|
style="width: 100%;"
|
||||||
|
@sort-change="tableDataSort"
|
||||||
|
@selection-change="(selection)=>{this.batchDeleteObjs=selection}"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
:resizable="false"
|
||||||
|
type="selection"
|
||||||
|
width="40"
|
||||||
|
align="center">
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
:resizable="true"
|
||||||
|
v-for="(item, index) in tools.customTableTitle"
|
||||||
|
v-if="item.show"
|
||||||
|
:key="`col-${index}`"
|
||||||
|
:label="item.label"
|
||||||
|
:show-overflow-tooltip="item.prop!=='matchers'"
|
||||||
|
:sort-orders="['ascending', 'descending']"
|
||||||
|
:sortable="$tableSet.sortableShow(item.prop,'alertRules')"
|
||||||
|
:prop="$tableSet.propTitle(item.prop,'alertRules')"
|
||||||
|
:width="item.width"
|
||||||
|
>
|
||||||
|
<template slot-scope="scope" :column="item">
|
||||||
|
<div v-if="item.prop == 'option'" class="content-right-options">
|
||||||
|
<span :id="'alert-edit-'+scope.row.id" :title="$t('overall.edit')" @click.stop="edit(scope.row)"
|
||||||
|
class="content-right-option" v-has="'alert_silence_modify'" v-if="scope.row.buildIn != 1"><i
|
||||||
|
class="nz-icon nz-icon-edit"></i>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
:id="'alert-del-'+scope.row.id"
|
||||||
|
:title="$t('overall.delete')"
|
||||||
|
@click="overtime(scope.row)"
|
||||||
|
class="content-right-option"
|
||||||
|
v-if="scope.row.state===1"
|
||||||
|
v-has="'alert_silence_delete'">
|
||||||
|
<i class="nz-icon nz-icon-chaoshi"></i>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
:id="'alert-del-'+scope.row.id"
|
||||||
|
:title="$t('overall.delete')"
|
||||||
|
@click="del(scope.row)"
|
||||||
|
class="content-right-option"
|
||||||
|
v-if="scope.row.state===2"
|
||||||
|
v-has="'alert_silence_delete'">
|
||||||
|
<i class="nz-icon nz-icon-delete"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<template v-else-if="item.prop == 'duration'">
|
||||||
|
<el-tooltip placement="right" effect="light" :disabled="!scope.row.endAt">
|
||||||
|
<div slot="content">
|
||||||
|
{{$t('config.terminallog.endTime')}}<br/>
|
||||||
|
{{scope.row.endAt}}
|
||||||
|
</div>
|
||||||
|
<span>{{getDuration(scope.row)}}</span>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="item.prop == 'matchers'">
|
||||||
|
<div class="nz-silence-tag-box">
|
||||||
|
<span class="nz-silence-tag blue" v-if="scope.row.linkId!==-1">
|
||||||
|
<span class="nz-silence-tag-title">{{scope.row.type}}</span>
|
||||||
|
<span class="nz-silence-tag-content" :title="scope.row.linkName">{{scope.row.linkName}}</span>
|
||||||
|
</span>
|
||||||
|
<span class="nz-silence-tag rule-gray" v-if="scope.row.ruleId!==-1">
|
||||||
|
<span class="nz-silence-tag-title">Alert rule</span>
|
||||||
|
<span class="nz-silence-tag-content" :title="scope.row.ruleName">{{scope.row.ruleName}}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="item.prop == 'state'">
|
||||||
|
<span v-if="scope.row.state===1" class="silence-active">active</span>
|
||||||
|
<span v-if="scope.row.state===2" class="silence-pending">pending</span>
|
||||||
|
<span v-if="scope.row.state===3" class="silence-expired">expired</span>
|
||||||
|
</template>
|
||||||
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop] || '-'}}</span>
|
||||||
|
<template v-else>-</template>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
|
||||||
|
<el-table-column width="28" :resizable="false">
|
||||||
|
<template slot="header" slot-scope="scope">
|
||||||
|
<span @mousedown.stop="!tools.showCustomTableTitle && (tools.showCustomTableTitle = true)"
|
||||||
|
class="nz-table-gear">
|
||||||
|
<i class="nz-icon nz-icon-gear"></i>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<button :class="{'to-top-is-hover': tools.tableHover}" :style="{top: tools.toTopBtnTop}"
|
||||||
|
@click="toTop(scrollbarWrap)" class="to-top" v-show="tools.showTopBtn && bottomBox.mainResizeShow"
|
||||||
|
id="alert-rule-toTop"><i class="nz-icon nz-icon-top"></i></button>
|
||||||
|
<!--表格结束-->
|
||||||
|
<!--分页部分-->
|
||||||
|
<div class="pagination-bottom" v-show="!bottomBox.showSubList">
|
||||||
|
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize'
|
||||||
|
ref="Pagination"></Pagination>
|
||||||
|
</div>
|
||||||
|
<!--导出-->
|
||||||
|
<div class="export-xlsx">
|
||||||
|
<el-dialog :visible.sync="importBox.show" :title="importBox.title" :modal-append-to-body='false'
|
||||||
|
:show-close="true" width="300px" @close="closeDialog" class="nz-dialog">
|
||||||
|
<div class="upload-body">
|
||||||
|
<button @click="exportCur" class="el-button el-button--default el-button--small" id="alert-msg-exportcur">
|
||||||
|
<span>{{$t('overall.exportCur')}}</span>
|
||||||
|
</button>
|
||||||
|
<button @click="exportAll" class="el-button el-button--default el-button--small" id="alert-msg-exportall">
|
||||||
|
<span>{{$t('overall.exportAll')}}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
<!--侧滑-->
|
||||||
|
<transition name="right-box">
|
||||||
|
<alert-silence-box v-if="rightBox.show" :alert-silence="alertSilence" @close="closeRightBox"
|
||||||
|
ref="alertSilenceBox"></alert-silence-box>
|
||||||
|
</transition>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import bus from '../../../libs/bus';
|
||||||
|
import axios from 'axios';
|
||||||
|
import deleteButton from "../../common/deleteButton";
|
||||||
|
import alertSilenceBox from'../../common/rightBox/alertSilenceBox';
|
||||||
|
import {calcDurationByStringTimeB} from "../../common/js/tools";
|
||||||
|
export default {
|
||||||
|
name:"silence",
|
||||||
|
components:{
|
||||||
|
deleteButton,
|
||||||
|
alertSilenceBox
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
tableId:'silence',
|
||||||
|
//侧滑
|
||||||
|
rightBox:{
|
||||||
|
show:false,
|
||||||
|
},
|
||||||
|
/*二级列表相关*/
|
||||||
|
mainTableHeight:this.$tableHeight.normal, //主列表table高度
|
||||||
|
/*二级页面相关*/
|
||||||
|
bottomBox:{
|
||||||
|
tabList:[], //二级列表的标签
|
||||||
|
tabDetailList:[], //多个详情
|
||||||
|
mainResizeShow:true, //dom高度改变时是否展示|隐藏
|
||||||
|
subResizeShow:true,
|
||||||
|
isFullScreen:false, //全屏状态
|
||||||
|
showSubList:false, //是否显示二级列表
|
||||||
|
targetTab:'', //显示二级列表中的哪个页签
|
||||||
|
inTransform:false, //搜索框相关,搜索条件下拉框是否在transform里
|
||||||
|
},
|
||||||
|
/*工具参数*/
|
||||||
|
tools:{
|
||||||
|
loading:false, //是否显示table加载动画
|
||||||
|
toTopBtnTop:this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
||||||
|
tableHover:false, //控制滚动条和top按钮同时出现
|
||||||
|
showTopBtn:false, //显示To top按钮
|
||||||
|
showCustomTableTitle:false, //自定义列弹框是否显示
|
||||||
|
customTableTitle:[], //自定义列工具的数据
|
||||||
|
},
|
||||||
|
/*批量删除相关*/
|
||||||
|
batchDeleteObjs:[],
|
||||||
|
/*搜素相关*/
|
||||||
|
searchMsg:{ //给搜索框子组件传递的信息
|
||||||
|
zheze_none:true,
|
||||||
|
searchLabelList:[
|
||||||
|
{
|
||||||
|
id:11,
|
||||||
|
name:this.$t('config.terminallog.host'),
|
||||||
|
type:'input',
|
||||||
|
label:'host',
|
||||||
|
disabled:false
|
||||||
|
},{
|
||||||
|
id:12,
|
||||||
|
name:this.$t('config.terminallog.user'),
|
||||||
|
type:'input',
|
||||||
|
label:'username',
|
||||||
|
disabled:false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
searchLabel:{}, //搜索参数
|
||||||
|
pageObj:{
|
||||||
|
pageNo:1,
|
||||||
|
pageSize:this.$CONSTANTS.defaultPageSize,
|
||||||
|
total:0
|
||||||
|
},
|
||||||
|
/*表格相关*/
|
||||||
|
tableTitle:[
|
||||||
|
{
|
||||||
|
label:'ID',
|
||||||
|
prop:'id',
|
||||||
|
show:true,
|
||||||
|
width:80
|
||||||
|
},{
|
||||||
|
label:'matchers',
|
||||||
|
prop:'matchers',
|
||||||
|
show:true,
|
||||||
|
width:600,
|
||||||
|
},{
|
||||||
|
label:'Start time',
|
||||||
|
prop:'startAt',
|
||||||
|
show:true,
|
||||||
|
width:300,
|
||||||
|
},{
|
||||||
|
label: this.$t('config.terminallog.duration'),
|
||||||
|
prop: 'duration',
|
||||||
|
show: true,
|
||||||
|
},{
|
||||||
|
label: 'Reason',
|
||||||
|
prop: 'reason',
|
||||||
|
show: true,
|
||||||
|
},{
|
||||||
|
label: 'Update time',
|
||||||
|
prop: 'utime',
|
||||||
|
show: true,
|
||||||
|
},{
|
||||||
|
label:'State',
|
||||||
|
prop:'state',
|
||||||
|
show:true,
|
||||||
|
width:120,
|
||||||
|
},{
|
||||||
|
label:this.$t('alert.config.option'),
|
||||||
|
prop:'option',
|
||||||
|
show:true,
|
||||||
|
width:120
|
||||||
|
}
|
||||||
|
],
|
||||||
|
tableData:[],
|
||||||
|
//导出相关
|
||||||
|
importBox:{show:false,title:this.$t('overall.exportExcel')},
|
||||||
|
deleteBox:{show:false,ids:"",remark:'',state:2},
|
||||||
|
//创建修改相关
|
||||||
|
blackSilence:{
|
||||||
|
id:'',
|
||||||
|
startAt:'',
|
||||||
|
endAt:'',
|
||||||
|
ruleId:'',
|
||||||
|
matcher:'',
|
||||||
|
type:'asset',
|
||||||
|
linkId:'',
|
||||||
|
reason:'',
|
||||||
|
},
|
||||||
|
alertSilence:{
|
||||||
|
|
||||||
|
},
|
||||||
|
nowTime:''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
getDuration(){
|
||||||
|
return function(record) {
|
||||||
|
if (record.endAt) {
|
||||||
|
return calcDurationByStringTimeB(record.startAt, record.endAt);
|
||||||
|
}
|
||||||
|
return calcDurationByStringTimeB(record.startAt, this.nowTime);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created(){
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted(){
|
||||||
|
//初始化表头
|
||||||
|
this.tools.customTableTitle=localStorage.getItem("nz-tableTitle-"+localStorage.getItem("nz-username")+"-"+this.$route.path)
|
||||||
|
?JSON.parse(localStorage.getItem("nz-tableTitle-"+localStorage.getItem("nz-username")+"-"+this.$route.path))
|
||||||
|
:this.tableTitle;
|
||||||
|
console.log(this.tools.customTableTitle,this.tableTitle);
|
||||||
|
this.tableTitleReset(this.tableTitle,this.tools.customTableTitle);
|
||||||
|
this.initEvent();
|
||||||
|
this.getAlertSilence();
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
initEvent(){
|
||||||
|
bus.$on("alert-rule-list-change",()=>{
|
||||||
|
this.getAlertSilence();
|
||||||
|
});
|
||||||
|
bus.$on("dc-list-change",()=>{
|
||||||
|
this.getAlertSilence();
|
||||||
|
});
|
||||||
|
bus.$on('alert-message-change',()=>{
|
||||||
|
this.getAlertSilence();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getAlertSilence(){
|
||||||
|
if(!this.hasButton('rule_view')){
|
||||||
|
this.$message.error(this.$t("tip.noAccess"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$set(this.searchLabel,"pageNo",this.pageObj.pageNo);
|
||||||
|
this.$set(this.searchLabel,"pageSize",this.pageObj.pageSize);
|
||||||
|
this.tools.loading=true;
|
||||||
|
this.$get('/alert/silence',this.searchLabel).then(response=>{
|
||||||
|
this.tools.loading=false;
|
||||||
|
if(response.code==200){
|
||||||
|
this.tableData=response.data.list;
|
||||||
|
this.pageObj.total=response.data.total;
|
||||||
|
this.nowTime=response.time;
|
||||||
|
console.info(this.$refs.alertSilenceTable)
|
||||||
|
if(!this.scrollbarWrap){
|
||||||
|
this.$nextTick(()=>{
|
||||||
|
this.scrollbarWrap=this.$refs.alertSilenceTable.bodyWrapper;
|
||||||
|
this.toTopBtnHandler(this.scrollbarWrap);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
pageNo(val){
|
||||||
|
this.pageObj.pageNo=val;
|
||||||
|
this.getAlertSilence();
|
||||||
|
},
|
||||||
|
pageSize(val){
|
||||||
|
this.pageObj.pageSize=val;
|
||||||
|
localStorage.setItem('nz-pageSize-'+localStorage.getItem('nz-username')+'-'+this.tableId,val);
|
||||||
|
this.getAlertSilence();
|
||||||
|
},
|
||||||
|
search(searchObj){
|
||||||
|
let orderBy='';
|
||||||
|
if(this.searchLabel.orderBy){
|
||||||
|
orderBy=this.searchLabel.orderBy
|
||||||
|
}
|
||||||
|
this.searchLabel={};
|
||||||
|
this.pageObj.pageNo=1;
|
||||||
|
for(let item in searchObj){
|
||||||
|
if(searchObj[item]){
|
||||||
|
if(item=="alertMessageState"){
|
||||||
|
this.$set(this.searchLabel,"state",searchObj[item]);
|
||||||
|
}else{
|
||||||
|
this.$set(this.searchLabel,item,searchObj[item]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(orderBy){
|
||||||
|
this.$set(this.searchLabel,'orderBy',orderBy);
|
||||||
|
}
|
||||||
|
this.$refs.alertMessageTable.$refs.alertListTable.bodyWrapper.scrollTop=0;
|
||||||
|
this.getAlertSilence();
|
||||||
|
},
|
||||||
|
// 数据排序
|
||||||
|
tableDataSort(item){
|
||||||
|
let orderBy='';
|
||||||
|
if(item.order==='ascending'){
|
||||||
|
orderBy=item.prop;
|
||||||
|
}
|
||||||
|
if(item.order==='descending'){
|
||||||
|
orderBy='-'+item.prop;
|
||||||
|
}
|
||||||
|
this.$set(this.searchLabel,"orderBy",orderBy);
|
||||||
|
this.getAlertSilence();
|
||||||
|
},
|
||||||
|
openDelMessageBox:function(){
|
||||||
|
if(this.batchDeleteObjs.length<1) return;
|
||||||
|
console.log(this.batchDeleteObjs);
|
||||||
|
},
|
||||||
|
showExportDialog(){
|
||||||
|
this.importBox.show=true;
|
||||||
|
},
|
||||||
|
closeDialog(){
|
||||||
|
this.importBox.show=false;
|
||||||
|
this.deleteBox.show=false;
|
||||||
|
},
|
||||||
|
exportCur:function(){
|
||||||
|
let searchLabel=Object.assign({},this.searchLabel)
|
||||||
|
this.$set(searchLabel,'language',localStorage.getItem("nz-language")?localStorage.getItem("nz-language"):'en')
|
||||||
|
this.exportExcel(searchLabel);
|
||||||
|
this.closeDialog();
|
||||||
|
},
|
||||||
|
exportAll:function(){
|
||||||
|
let temp=JSON.parse(JSON.stringify(this.searchLabel));
|
||||||
|
temp.pageSize= -1;
|
||||||
|
this.$set(temp,'language',localStorage.getItem("nz-language")?localStorage.getItem("nz-language"):'en')
|
||||||
|
this.exportExcel(temp);
|
||||||
|
this.closeDialog();
|
||||||
|
},
|
||||||
|
addSilence(){
|
||||||
|
this.blackSilence.startAt=bus.timeFormate(bus.getOffsetTimezoneData(),'yyyy-MM-dd hh:mm:ss');
|
||||||
|
this.blackSilence.endAt=bus.timeFormate(bus.getOffsetTimezoneData(1),'yyyy-MM-dd hh:mm:ss');
|
||||||
|
this.alertSilence=JSON.parse(JSON.stringify(this.blackSilence));
|
||||||
|
this.rightBox.show=true;
|
||||||
|
},
|
||||||
|
edit(row){
|
||||||
|
console.log(123123123123);
|
||||||
|
this.$get('/alert/silence/'+row.id).then(res=>{
|
||||||
|
this.alertSilence={...res.data};
|
||||||
|
this.rightBox.show=true;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
del(row){
|
||||||
|
if(this.prevent_opt.save){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
;
|
||||||
|
this.prevent_opt.save=true;
|
||||||
|
this.$confirm(this.$t("tip.confirmDelete"),{
|
||||||
|
confirmButtonText:this.$t("tip.yes"),
|
||||||
|
cancelButtonText:this.$t("tip.no"),
|
||||||
|
type:'warning'
|
||||||
|
}).then(()=>{
|
||||||
|
this.$delete("/alert/silence?ids="+row.id).then(response=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
if(response.code===200){
|
||||||
|
this.$message({type:'success',message:this.$t("tip.deleteSuccess")});
|
||||||
|
this.getAlertSilence();
|
||||||
|
}else{
|
||||||
|
this.$message.error(response.msg);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch(()=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
overtime(row){
|
||||||
|
if(this.prevent_opt.save){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
;
|
||||||
|
this.prevent_opt.save=true;
|
||||||
|
this.$confirm(this.$t("tip.confirmOvertime"),{
|
||||||
|
confirmButtonText:this.$t("tip.yes"),
|
||||||
|
cancelButtonText:this.$t("tip.no"),
|
||||||
|
type:'warning'
|
||||||
|
}).then(()=>{
|
||||||
|
this.$delete("/alert/silence?ids="+row.id).then(response=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
if(response.code===200){
|
||||||
|
this.$message({type:'success',message:this.$t("tip.deleteSuccess")});
|
||||||
|
this.getAlertSilence();
|
||||||
|
}else{
|
||||||
|
this.$message.error(response.msg);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch(()=>{
|
||||||
|
this.prevent_opt.save=false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
closeRightBox(refresh) {
|
||||||
|
this.rightBox.show = false;
|
||||||
|
if (refresh) {
|
||||||
|
this.delFlag=true;
|
||||||
|
this.getAlertSilence();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.content-right-options{
|
||||||
|
display: flex;
|
||||||
|
justify-content: start;
|
||||||
|
sapn:not(:first-child){
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.nz-silence-tag-box{
|
||||||
|
width: 100%;
|
||||||
|
.nz-silence-tag{
|
||||||
|
float: left;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.nz-silence-tag{
|
||||||
|
min-width: 120px;
|
||||||
|
margin-right: 5px;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: inline-flex;
|
||||||
|
width: auto;
|
||||||
|
height: 20px;
|
||||||
|
line-height: 20px;
|
||||||
|
.nz-silence-tag-title{
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
.nz-silence-tag-content{
|
||||||
|
padding: 0 10px;
|
||||||
|
max-width: 200px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.nz-silence-tag.blue{
|
||||||
|
border: 1px solid #3C92F1;
|
||||||
|
.nz-silence-tag-title{
|
||||||
|
background: #3C92F1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.nz-silence-tag.rule-gray{
|
||||||
|
border: 1px solid #7F8696;
|
||||||
|
.nz-silence-tag-title{
|
||||||
|
background: #7F8696;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.silence-active{
|
||||||
|
background: #E3F2D9;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: PingFangSC-Regular;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #0AB000;
|
||||||
|
line-height: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
.silence-pending{
|
||||||
|
background: #FFECD9;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: PingFangSC-Regular;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #FA901C;
|
||||||
|
line-height: 20px;
|
||||||
|
font-weight: 400;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
.silence-expired{
|
||||||
|
background: #FFE3DC;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: PingFangSC-Regular;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #EC7F66;
|
||||||
|
line-height: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -88,6 +88,10 @@ export default new Router({
|
|||||||
{
|
{
|
||||||
path: '/alertConfig',
|
path: '/alertConfig',
|
||||||
component: resolve => require(['../components/page/alert/config.vue'], resolve),
|
component: resolve => require(['../components/page/alert/config.vue'], resolve),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/alertSilence',
|
||||||
|
component: resolve => require(['../components/page/alert/silence.vue'], resolve),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user