feat:endpoint增加Alerts列

This commit is contained in:
wangwenrui
2020-09-25 15:33:02 +08:00
parent 52100510a6
commit 49d9782e15
7 changed files with 64 additions and 14 deletions

View File

@@ -20,7 +20,7 @@
<!--机柜--> <!--机柜-->
<cabinet-tab v-show="subResizeShow" v-if="from == 'dc' && targetTab == 'cabinet'" :obj="obj" @changeTab="changeTab"></cabinet-tab> <cabinet-tab v-show="subResizeShow" v-if="from == 'dc' && targetTab == 'cabinet'" :obj="obj" @changeTab="changeTab"></cabinet-tab>
<!--告警信息--> <!--告警信息-->
<alert-message-tab v-show="subResizeShow" v-if="((from == 'alertRule' || from == 'asset') && targetTab == 'alertMessage')" :from="from" :obj="obj" @changeTab="changeTab"></alert-message-tab> <alert-message-tab v-show="subResizeShow" v-if="((from == 'alertRule' || from == 'asset' || from == 'endpoint') && targetTab == 'alertMessage')" :from="from" :obj="obj" @changeTab="changeTab"></alert-message-tab>
<!--asset页的endpoint列表--> <!--asset页的endpoint列表-->
<endpoint-tab v-show="subResizeShow" v-if="from == 'asset' && targetTab == 'endpoint'" :from="from" :obj="obj" @changeTab="changeTab"></endpoint-tab> <endpoint-tab v-show="subResizeShow" v-if="from == 'asset' && targetTab == 'endpoint'" :from="from" :obj="obj" @changeTab="changeTab"></endpoint-tab>
<!--endpoint-query--> <!--endpoint-query-->

View File

@@ -5,10 +5,12 @@
<div class="sub-list-tab-title"> <div class="sub-list-tab-title">
<template v-if="from == 'asset'">{{obj.host}}</template> <template v-if="from == 'asset'">{{obj.host}}</template>
<template v-if="from == 'alertRule'">{{obj.alertName}}</template> <template v-if="from == 'alertRule'">{{obj.alertName}}</template>
<template v-if="from == 'endpoint'"><div class="sub-list-tab-title">{{$t("project.endpoint.endpointId")}}: {{obj ? obj.id : ''}}</div></template>
</div><div </div><div
class="sub-list-tab" @click="changeTab(from == 'asset' || from == 'alertRule' ? 'panel' : 'detail')">{{$t("overall.detail")}}</div><div class="sub-list-tab" @click="changeTab(from == 'asset' || from == 'alertRule' || from == 'endpoint'? 'panel' : 'detail')">{{$t("overall.detail")}}</div><div
class="sub-list-tab sub-list-tab-active">{{$t("asset.tableTitle.alerts")}}</div><div v-if="from == 'asset'" class="sub-list-tab sub-list-tab-active">{{$t("asset.tableTitle.alerts")}}</div><div v-if="from == 'asset'"
class="sub-list-tab" @click="changeTab('endpoint')">{{$t("asset.tableTitle.modules")}}</div> class="sub-list-tab" @click="changeTab('endpoint')">{{$t("asset.tableTitle.modules")}}</div>
<div v-if="from == 'endpoint'" class="sub-list-tab" @click="changeTab('endpointQuery')">{{$t("overall.query")}}</div>
</div> </div>
<div class="top-tool-right"> <div class="top-tool-right">
<div class="top-tool-search"> <div class="top-tool-search">
@@ -550,6 +552,8 @@
this.searchLabel.ruleId = this.obj.id; this.searchLabel.ruleId = this.obj.id;
} else if (this.from == "asset") { } else if (this.from == "asset") {
this.searchLabel.assetId = this.obj.id; this.searchLabel.assetId = this.obj.id;
}else if(this.from == 'endpoint'){
this.searchLabel.endpointId=this.obj.id;
} }
this.pageObj.pageNo = 1; this.pageObj.pageNo = 1;
for (let item in searchObj) { for (let item in searchObj) {
@@ -590,6 +594,11 @@
return item.label != "alertType" && item.label != "asset" return item.label != "alertType" && item.label != "asset"
}); });
this.searchLabel.assetId = n.id; this.searchLabel.assetId = n.id;
} else if(this.from == 'endpoint'){
this.searchMsg.searchLabelList = this.searchMsg.searchLabelList.filter((item, index) => {
return item.label != "alertType" && item.label != "endpoint"
});
this.searchLabel.endpointId = n.id;
} }
if (n.alertNum) { if (n.alertNum) {
this.defaultSearchValue = 1; this.defaultSearchValue = 1;

View File

@@ -15,8 +15,9 @@
<div class="sub-top-tools"> <div class="sub-top-tools">
<div class="sub-list-tabs"> <div class="sub-list-tabs">
<div class="sub-list-tab-title">{{$t("project.endpoint.endpointId")}}: {{currentEndpoint ? currentEndpoint.id : ''}}</div><div <div class="sub-list-tab-title">{{$t("project.endpoint.endpointId")}}: {{currentEndpoint ? currentEndpoint.id : ''}}</div><div
class="sub-list-tab" @click="changeTab('panel')">{{$t("overall.detail")}}</div><div class="sub-list-tab" @click="changeTab('panel')">{{$t("overall.detail")}}</div>
class="sub-list-tab sub-list-tab-active">{{$t("overall.query")}}</div> <div class="sub-list-tab" @click="changeTab('alertMessage')">{{$t("asset.tableTitle.alerts")}}</div>
<div class="sub-list-tab sub-list-tab-active">{{$t("overall.query")}}</div>
</div> </div>
<div class="top-tool-right"> <div class="top-tool-right">
<div class="top-tool-search margin-r-20"> <div class="top-tool-search margin-r-20">

View File

@@ -17,6 +17,7 @@
class="sub-list-tab" @click="changeTab('alertMessage')">{{$t("asset.tableTitle.alerts")}}</div> class="sub-list-tab" @click="changeTab('alertMessage')">{{$t("asset.tableTitle.alerts")}}</div>
</template><template v-if="from == 'endpoint'"><div </template><template v-if="from == 'endpoint'"><div
class="sub-list-tab sub-list-tab-active">{{$t("overall.detail")}}</div><div class="sub-list-tab sub-list-tab-active">{{$t("overall.detail")}}</div><div
class="sub-list-tab " @click="changeTab('alertMessage')">{{$t("asset.tableTitle.alerts")}}</div><div
class="sub-list-tab" @click="changeTab('endpointQuery')">{{$t("overall.query")}}</div> class="sub-list-tab" @click="changeTab('endpointQuery')">{{$t("overall.query")}}</div>
</template> </template>
</div> </div>

View File

@@ -841,8 +841,9 @@ const cn = {
dialogTitle: "历史值", dialogTitle: "历史值",
hideSameLabels: "隐藏重复标签", hideSameLabels: "隐藏重复标签",
stateInfo_230009: "无法获取prometheus服务", stateInfo_230009: "无法获取prometheus服务",
stateInfo_230010: "prometheus服务可用", stateInfo_230010: "Prometheus服务可用",
stateInfo_230011: "prometheus服务不可用 " stateInfo_230011: "Endpoint 连接错误",
alerts:"告警",
}, },
metrics: { metrics: {
metrics: "指标", metrics: "指标",

View File

@@ -849,8 +849,8 @@ const en = {
hideSameLabels:'Hide same labels', hideSameLabels:'Hide same labels',
stateInfo_230009:'Promserver unavailable', stateInfo_230009:'Promserver unavailable',
stateInfo_230010:'Promserver can be used', stateInfo_230010:'Promserver can be used',
stateInfo_230011:'Promserver can not be used', stateInfo_230011:'Endpoint connection refused',
alerts:'Alerts'
}, },
metrics: { metrics: {
metrics: 'Metrics',//"指标" metrics: 'Metrics',//"指标"

View File

@@ -61,6 +61,7 @@
v-scrollBar:el-table="'large'" v-scrollBar:el-table="'large'"
v-show="bottomBox.mainResizeShow" v-show="bottomBox.mainResizeShow"
ref="endpointTable" ref="endpointTable"
:cell-class-name="messageStyle"
v-loading="tools.loading" v-loading="tools.loading"
style="width: 100%;" style="width: 100%;"
@sort-change="tableDataSort" @sort-change="tableDataSort"
@@ -86,6 +87,15 @@
</template> </template>
<template v-else>-</template> <template v-else>-</template>
</span> </span>
<template v-else-if="item.prop=='alerts'">
<el-tooltip :content="scope.row.alertNum+' '+$t('overall.active')" placement="top" effect="light" :disabled=" scope.row.alertNum < 99">
<span :id="'endpoint-alerts-'+scope.row.id" @click="jumpToAlertMsg(scope.row)" class="link">
{{(scope.row.alertNum < 99 ? scope.row.alertNum : 99)}}
<sup class="linkSup" v-if="scope.row.alertNum > 99">+</sup>
{{' ' + $t('overall.active')}}
</span>
</el-tooltip>
</template>
<template v-else-if="item.prop == 'type'">{{currentModule.type}}</template> <template v-else-if="item.prop == 'type'">{{currentModule.type}}</template>
<div v-else-if="item.prop == 'option'" class="content-right-options"> <div v-else-if="item.prop == 'option'" class="content-right-options">
<span :title="$t('overall.view')" @click="detailEndpoint(scope.row)" class="content-right-option" :id="'edp-detail-'+scope.row.id"><i class="nz-icon nz-icon-view"></i></span> <span :title="$t('overall.view')" @click="detailEndpoint(scope.row)" class="content-right-option" :id="'edp-detail-'+scope.row.id"><i class="nz-icon nz-icon-view"></i></span>
@@ -131,9 +141,19 @@
</template> </template>
<transition name="el-zoom-in-bottom"> <transition name="el-zoom-in-bottom">
<bottom-box v-if="bottomBox.showSubList" :sub-resize-show="bottomBox.subResizeShow" :is-full-screen="bottomBox.isFullScreen" <bottom-box v-if="bottomBox.showSubList"
:from="'endpoint'" :target-tab.sync="bottomBox.targetTab" :detail="bottomBox.endpointDetail" :obj="endpoint" :asset-detail="bottomBox.assetDetail" :sub-resize-show="bottomBox.subResizeShow"
@closeSubList="bottomBox.showSubList = false" @fullScreen="fullScreen" @exitFullScreen="exitFullScreen" @listResize="listResize" ></bottom-box> :is-full-screen="bottomBox.isFullScreen"
:from="'endpoint'"
:target-tab.sync="bottomBox.targetTab"
:detail="bottomBox.endpointDetail"
:obj="endpoint"
:detail-list="bottomBox.alertList"
:asset-detail="bottomBox.assetDetail"
@closeSubList="bottomBox.showSubList = false"
@fullScreen="fullScreen"
@exitFullScreen="exitFullScreen"
@listResize="listResize" ></bottom-box>
</transition> </transition>
<transition name="right-box"> <transition name="right-box">
<add-endpoint-box v-if="rightBox.addEndpoint.show" :current-project="currentProject" :current-module="currentModule" @close="closeAddEndpointRightBox" ref="addEndpointBox"></add-endpoint-box> <add-endpoint-box v-if="rightBox.addEndpoint.show" :current-project="currentProject" :current-module="currentModule" @close="closeAddEndpointRightBox" ref="addEndpointBox"></add-endpoint-box>
@@ -168,7 +188,7 @@
/*二级页面相关*/ /*二级页面相关*/
bottomBox: { bottomBox: {
endpoint: {}, //asset详情 endpoint: {}, //asset详情
endpointDetail: [], endpointDetail: null,
mainResizeShow: true, //dom高度改变时部分内容是否展示 mainResizeShow: true, //dom高度改变时部分内容是否展示
subResizeShow: true, subResizeShow: true,
isFullScreen: false, //是否是全屏,用来控制拖动条是否展示, isFullScreen: false, //是否是全屏,用来控制拖动条是否展示,
@@ -212,6 +232,10 @@
label: this.$t("project.endpoint.port"), label: this.$t("project.endpoint.port"),
prop: 'port', prop: 'port',
show: true, show: true,
},{
label: this.$t("project.endpoint.alerts"),
prop: 'alerts',
show: true,
},{ },{
label: this.$t("overall.type"), label: this.$t("overall.type"),
prop: 'type', prop: 'type',
@@ -387,7 +411,6 @@
this.bottomBox.showSubList = false; this.bottomBox.showSubList = false;
this.currentProject = project; this.currentProject = project;
}, },
//弹出endpoint编辑页 //弹出endpoint编辑页
editEndpoint(endpoint) { editEndpoint(endpoint) {
this.endpoint = JSON.parse(JSON.stringify(endpoint)); this.endpoint = JSON.parse(JSON.stringify(endpoint));
@@ -412,6 +435,11 @@
this.bottomBox.targetTab = "panel"; this.bottomBox.targetTab = "panel";
this.bottomBox.showSubList = true; this.bottomBox.showSubList = true;
}, },
jumpToAlertMsg(endpoint) {
this.endpoint = Object.assign({}, endpoint);
this.bottomBox.targetTab = 'alertMessage';
this.bottomBox.showSubList = true;
},
addModule() { addModule() {
this.module = this.newModule(); this.module = this.newModule();
this.rightBox.module.show = true; this.rightBox.module.show = true;
@@ -585,7 +613,17 @@
bus.$on("endpoint-list-change", menu => { bus.$on("endpoint-list-change", menu => {
this.getEndpointTableData(); this.getEndpointTableData();
}); });
},
messageStyle(e) {
if (e.column.label == 'Alerts' || e.column.label == this.$t("asset.tableTitle.alerts")) {
if (e.row.alertNum > 0) {
return 'danger';
} else {
return 'success';
} }
}
return '';
},
}, },
created() { created() {
this.currentProject = this.$store.state.currentProject; this.currentProject = this.$store.state.currentProject;