diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue new file mode 100644 index 000000000..caac91b46 --- /dev/null +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -0,0 +1,1115 @@ + + + + + diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 7e0efe84c..09cf6a3be 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -135,6 +135,19 @@ :chart-index="index" :editChartId="'editChartId' + item.id" > + + @@ -150,7 +163,7 @@ import chartSingleStat from './chart-single-stat'; import chartAssetInfo from './chart-asset-info' import draggable from 'vuedraggable' import chartDataFormat from "./chartDataFormat"; - +import chartAlertList from './chart-alert-list' export default { name: 'chartList', props: { @@ -158,6 +171,7 @@ export default { additionalInfo:{} }, components: { + chartAlertList, chartAssetInfo, lineChartBlock, chartTable, @@ -832,6 +846,10 @@ export default { this.getAssetInfoChartData(chartItem); return; } + if(chartItem.type === 'alertList'){ + this.getAlertListChartData(chartItem,filterType); + return; + } if (this.isModel) { this.modelStaticData(chartInfo, filterType); } else { @@ -1173,7 +1191,6 @@ export default { host += "}"; } //处理legend别名 - console.log(this.$refs['editChart' + chartInfo.id]) let alias = this.$refs['editChart' + chartInfo.id][0].dealLegendAlias(host, chartInfo.elements[0].legend); if (!alias || alias === '') { alias = host; @@ -1267,31 +1284,6 @@ export default { getAssetInfoChartData(chartInfo){ if(!this.isModel){ this.$refs['editChart'+chartInfo.id][0].showLoad(chartInfo); - // setTimeout(()=>{ - // if(this.additionalInfo){ - // let data={ - // Basic:{ - // sn:'assetInfo Test', - // host:'192.168.40.42', - // 'cpu Num':'8', - // memery:'12GB', - // 'memery free':'3GB' - // }, - // Feature:{ - // CPU:"Intel E500", - // Memory:"256GB", - // NetworkInterface:["eth0","eth1"], - // Disk:[{ - // mount:"/", - // total:"256GB", - // free:"128GB", - // usageRate:"50%" - // }] - // } - // } - // this.$refs['editChart'+chartInfo.id][0].setData(chartInfo, data, this.filter.panelId, this.filter); - // } - // },1000) this.$get('/asset/info?id='+this.additionalInfo.id).then(response=>{ if(response.code == 200){ let data=response.data; @@ -1323,6 +1315,9 @@ export default { this.$refs['editChart'+chartInfo.id][0].setData(chartInfo, data, this.filter.panelId, this.filter); } }, + getAlertListChartData:function(chartInfo,filterType){ + this.$refs['editChart'+chartInfo.id][0].getAlertList(filterType); + }, // 设置图表的宽度 setSize(size, index) { this.$nextTick(() => { diff --git a/nezha-fronted/src/components/common/elementSet.vue b/nezha-fronted/src/components/common/elementSet.vue index 9a4e5271b..c054aa8d1 100644 --- a/nezha-fronted/src/components/common/elementSet.vue +++ b/nezha-fronted/src/components/common/elementSet.vue @@ -187,7 +187,7 @@ export default { color: #606266; background: #fff; border-radius: 4px; - z-index: 999; + z-index: 999999; } .elementset-labels { diff --git a/nezha-fronted/src/components/common/header.vue b/nezha-fronted/src/components/common/header.vue index b0bed8189..a2ced1d86 100644 --- a/nezha-fronted/src/components/common/header.vue +++ b/nezha-fronted/src/components/common/header.vue @@ -240,11 +240,11 @@ url: 'alertConfig', type: 5 }, - { - label: this.$t('config.dc.dc'), - url: 'dc', - type: 6 - } + // { + // label: this.$t('config.dc.dc'), + // url: 'dc', + // type: 6 + // } ], addIdcData: { id: '', diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 235142ed1..5781e7545 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -147,8 +147,8 @@ const en = { singleStat:{ label:"SingleStat" }, - alertInfo:{ - label:"Alert information" + alertList:{ + label:"Alert list" } }, statisticsVal:{ diff --git a/nezha-fronted/src/components/page/alert/config.vue b/nezha-fronted/src/components/page/alert/config.vue index 7467aab10..8961a61a6 100644 --- a/nezha-fronted/src/components/page/alert/config.vue +++ b/nezha-fronted/src/components/page/alert/config.vue @@ -247,6 +247,10 @@ label: this.$t('alert.severity'), prop: 'severity', show: true, + },{ + label: this.$t('alert.summary'), + prop: 'summary', + show: true, }, { label: this.$t('alert.description'), prop: 'description', diff --git a/nezha-fronted/src/components/page/alert/list.vue b/nezha-fronted/src/components/page/alert/list.vue index ed160f8bc..27a0b94f0 100644 --- a/nezha-fronted/src/components/page/alert/list.vue +++ b/nezha-fronted/src/components/page/alert/list.vue @@ -592,6 +592,7 @@ this.$set(item, "current", current); }); }); + this.deleteBox.ids=''; this.pageObj.total = response.data.total; } }); diff --git a/nezha-fronted/src/components/page/dashboard/alertChartParam.vue b/nezha-fronted/src/components/page/dashboard/alertChartParam.vue new file mode 100644 index 000000000..44451f871 --- /dev/null +++ b/nezha-fronted/src/components/page/dashboard/alertChartParam.vue @@ -0,0 +1,263 @@ + + + + + + diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue index 27746a3f3..cd4d306ef 100644 --- a/nezha-fronted/src/components/page/dashboard/chartBox.vue +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -73,7 +73,7 @@ - +
- + {{item.name}} @@ -128,10 +128,10 @@
- +
{{$t('dashboard.panel.chartForm.unit')}}
- +
-
{{$t('dashboard.panel.chartForm.metric')}}
+
{{$t('dashboard.panel.chartForm.metric')}}
+
{{$t('dashboard.panel.chartForm.alertParam.param')}}
- + + + + + --> -
@@ -271,6 +276,7 @@ import ChartMetric from "./chartMetric"; import chartDataFormat from '../../charts/chartDataFormat'; import chartPreview from '../../charts/chartPreview'; + import alertChartParam from "./alertChartParam"; export default { name: "chartBox", props: { @@ -306,6 +312,7 @@ }, isUrl:false, isSingleStat:false, + isAlert:false, rules: { title: [ {required: true, message: this.$t('validate.required'), trigger: 'blur'} @@ -338,10 +345,15 @@ { id:'singleStat', name:this.$t("dashboard.panel.chartForm.typeVal.singleStat.label") + }, + { + id:'alertList', + name:this.$t("dashboard.panel.chartForm.typeVal.alertList.label") } ], elements: [1], // 指标部分 tarNum elementTarget: [], // 本地保存数据 + alertParams:{}, spanList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], // 是否为编辑已有信息 isedit: false, @@ -366,6 +378,7 @@ components:{ 'chart-metric':ChartMetric, 'chart-preview':chartPreview, + 'alert-chart-param':alertChartParam }, mounted() { @@ -718,13 +731,45 @@ }); } }, + getAlertParam:function(param,opType){ + this.$refs.chartForm.validate((valid) => { + const params = { + title: this.chart.title,//this.chart + span: this.chart.span, + height: this.chart.height, + type: this.chart.type, + unit:this.chart.unit, + param:param, + sync: this.chart.sync + }; + if (valid) { + if(opType==='preview') { + if (this.isedit) { + params.id = this.chart.id; + } + this.$refs.chartsPreview.show(params); + }else{ + if (this.isedit) { + params.id = this.chart.id; + this.updateCharts(params); + } else { + this.addCharts(params); + } + } + } + }) + }, confirmAdd() { this.elementTarget = []; // 初始化清空参数 if(this.chart.type!=='url'){ - this.$refs.chartTag.forEach((item, index) => {//循环指标列表 - // 触发每个tag组件内部进行校验 - item.saveTarget(index); - }); + if(this.chart.type == 'alertList'){ + this.$refs.alertParamBox.saveParam(); + }else{ + this.$refs.chartTag.forEach((item, index) => {//循环指标列表 + // 触发每个tag组件内部进行校验 + item.saveTarget(index); + }); + } }else { this.$refs.chartForm.validate((valid) => { const params = { @@ -735,7 +780,8 @@ unit:this.chart.unit, param:{ url:this.chart.param.url, - } + }, + sync: this.chart.sync }; if (valid) { @@ -843,14 +889,22 @@ setIsUrl(){ this.isUrl = true; this.isSingleStat = false; + this.isAlert=false; }, setIsSingleStat(){ this.isUrl = false; this.isSingleStat = true; + this.isAlert=false; + }, + setIsAlertList(){ + this.isAlert=true; + this.isUrl = false; + this.isSingleStat = false; }, setIsOtherChart(){ this.isSingleStat = false; this.isUrl = false; + this.isAlert=false; }, // 编辑chart时使用, set_tdata editData(data, panelId) { @@ -888,6 +942,10 @@ item.setMdata(data.elements[index],data.param.statistics); }); }); + }else if(this.chart.type==='alertLine'){ + this.chart.param=data.param; + this.setIsAlertList(); + this.elements=[1]; }else{ if((this.chart.type==='line'||this.chart.type==='bar'||this.chart.type==='stackArea')&&data.param){ this.chart.param.threshold=data.param.threshold; @@ -901,11 +959,18 @@ this.elements.push(index); }); this.$nextTick(() => { - const cSet = this.$refs.chartTag; - // 派发charttag数据 - cSet.forEach((item, index) => { - item.setMdata(data.elements[index]); - }); + if(this.chart.type==='alertList'){ + this.setIsAlertList(); + this.$nextTick(()=>{ + this.$refs.alertParamBox.setData(data); + }) + }else{ + const cSet = this.$refs.chartTag; + // 派发charttag数据 + cSet.forEach((item, index) => { + item.setMdata(data.elements[index]); + }); + } }); } }, @@ -967,6 +1032,8 @@ item.setSingleStat(); }); }*/ + }else if(chartType === 'alertList'){ + this.setIsAlertList(); }else { this.setIsOtherChart(); if(chartType === 'bar'||chartType === 'line'||chartType === 'stackArea'){ @@ -999,11 +1066,16 @@ preview(){ //验证图表数据是否合法??,合法了再显示预览窗口 this.elementTarget = []; // 初始化清空参数 + this.alertParams={}; if(this.chart.type!=='url'){ - this.$refs.chartTag.forEach((item, index) => {//循环指标列表 - // 触发每个tag组件内部进行校验 - item.saveTarget(index,'preview'); - }); + if(this.chart.type == 'alertList'){ + this.$refs.alertParamBox.saveParam('preview'); + }else{ + this.$refs.chartTag.forEach((item, index) => {//循环指标列表 + // 触发每个tag组件内部进行校验 + item.saveTarget(index,'preview'); + }); + } }else { this.$refs.chartForm.validate((valid) => { const params = { diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 07e1a8aab..8cee0ea28 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -481,7 +481,7 @@ }); }, getTableData: function (clearShowPanel) { - this.$get('panel').then(response => { + this.$get('panel?pageSize=-1').then(response => { if (response.code === 200) { this.panelData = response.data.list; let isInitData = false;