From 37dad22498bc38d0ec98545076160458eb697664 Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Thu, 2 Jul 2020 20:10:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?temp:=20=E6=9A=B4=E9=9B=A8=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=EF=BC=8C=E5=85=88=E6=8F=90=E4=BA=A4=E9=97=AA=E4=BA=BA?= =?UTF-8?q?=E5=9B=9E=E5=AE=B6=E5=81=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/assets/stylus/main.scss | 2 +- .../src/components/charts/chart-detail.vue | 1 + .../components/page/dashboard/chartBox.vue | 152 ++++++++++++++---- .../page/dashboard/explore/editor.vue | 44 ++--- .../page/dashboard/explore/explore.vue | 2 + .../page/dashboard/explore/promqlInput.vue | 46 ++++-- .../src/components/page/dashboard/panel.vue | 18 ++- 7 files changed, 186 insertions(+), 79 deletions(-) diff --git a/nezha-fronted/src/assets/stylus/main.scss b/nezha-fronted/src/assets/stylus/main.scss index d29b543a0..ebfdc4ad6 100644 --- a/nezha-fronted/src/assets/stylus/main.scss +++ b/nezha-fronted/src/assets/stylus/main.scss @@ -1779,7 +1779,7 @@ li{ line-height: 25px !important; } -.el-textarea textarea { +.el-textarea:not(.not-fixed-height) textarea { height: 140px !important; } .nz-message .el-textarea textarea { diff --git a/nezha-fronted/src/components/charts/chart-detail.vue b/nezha-fronted/src/components/charts/chart-detail.vue index 5f6c24922..d2f221a75 100644 --- a/nezha-fronted/src/components/charts/chart-detail.vue +++ b/nezha-fronted/src/components/charts/chart-detail.vue @@ -390,6 +390,7 @@ show:true, } }); + console.info(labels) return labels; }, replaceSplit(key){ diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue index 288cafdec..2f7575e6a 100644 --- a/nezha-fronted/src/components/page/dashboard/chartBox.vue +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -169,7 +169,10 @@ -
{{$t('dashboard.panel.chartForm.metric')}}
+
+ {{$t('alert.config.expr')}} + +
{{$t('dashboard.panel.chartForm.alertParam.param')}}
@@ -177,8 +180,8 @@ - - + + + + + {{$t('dashboard.panel.chartForm.legend')}}  + + + + + + + + @@ -220,9 +245,9 @@ --> - - + @@ -186,8 +186,9 @@ }, /*图表相关操作--start*/ toAddChart: function () { + this.rightBox.show = true; this.$refs.addChartModal.setTitle(this.$t("dashboard.panel.createChartTitle")); - this.$refs.addChartModal.show(true); + //this.$refs.addChartModal.show(true); this.$refs.addChartModal.createData(this.panelId); //初始化创建图表需要的初始数据 }, // 切换tab diff --git a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue index d2ef0dda3..925af9e82 100644 --- a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue @@ -28,10 +28,19 @@
{{alertRule.alertName}}
- + + @@ -122,14 +131,18 @@ - - diff --git a/nezha-fronted/src/components/page/dashboard/explore/explore.vue b/nezha-fronted/src/components/page/dashboard/explore/explore.vue index bc589e4e7..3fa1cbac7 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/explore.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/explore.vue @@ -193,7 +193,7 @@ instance_cpu_time_ns{app="fox", proc="widget", rev="4d3a513", env="prod", job="c - +
+ +
-
+
- +
+
+
+
@@ -163,7 +176,7 @@ } - From 71a3a48c3eee96ca9f33cbd2aa524e175cc4c1fa Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Fri, 3 Jul 2020 11:45:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?NEZ-343=20feat:=20chart=E3=80=81alert-rule?= =?UTF-8?q?=E4=BE=A7=E6=BB=91=E7=9A=84expr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/rightBox/alertConfigBox.vue | 19 +++++++++++++++---- .../components/page/dashboard/chartBox.vue | 2 +- .../page/dashboard/explore/explore.vue | 2 +- .../page/dashboard/explore/promqlInput.vue | 9 +++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue index 925af9e82..cdadfaf83 100644 --- a/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertConfigBox.vue @@ -37,9 +37,7 @@ :expression-list.sync="expressions" :index="0" :styleType="2" - :plugins="['metric']" - @change="expressionChange" - @removeExpression="removeExpression" + :plugins="['metric-input']" > @@ -142,7 +140,11 @@ }, data() { return { - expressions: [], + promqlCount: 1, + promqlKeys: [0], + expressions: [''], + legends: [''], + alertRule: {id: '', receiverShow: [], receiver: ''}, rightBox: {show: false, isEdit: false, title: ''}, rules:{ @@ -248,6 +250,7 @@ this.rightBox.isEdit = isEdit; }, save: function() { + this.alertRule.expr = this.expressions[0]; this.$refs.alertRuleForm.validate((valid) => { if (valid) { this.alertRule.receiver = this.alertRule.receiverShow.join(","); @@ -353,6 +356,14 @@ } else if (this.alertRule.type == 3) { this.getAssetList(); } + this.expressions = [this.alertRule.expr]; + this.$nextTick(() => { + this.expressions.forEach((ex, index) => { + if (ex) { + this.$refs.promql.metricChange(ex); + } + }); + }); } if (this.rightBox.show) { if (this.rightBox.isEdit && this.alertRule.id) { diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue index 66e588993..ef554cec3 100644 --- a/nezha-fronted/src/components/page/dashboard/chartBox.vue +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -199,7 +199,7 @@ :expression-list.sync="expressions" :index="index-1" :styleType="2" - :plugins="['metric', 'remove']" + :plugins="['metric-selector', 'metric-input', 'remove']" @change="expressionChange" @removeExpression="removeExpression" > diff --git a/nezha-fronted/src/components/page/dashboard/explore/explore.vue b/nezha-fronted/src/components/page/dashboard/explore/explore.vue index 3fa1cbac7..67ca20388 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/explore.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/explore.vue @@ -36,7 +36,7 @@ :expression-list="expressions" :index="index-1" :styleType="1" - :plugins="['metric', 'add', 'remove']" + :plugins="['metric-selector', 'metric-input', 'add', 'remove']" @change="expressionChange" @addExpression="addExpression" @removeExpression="removeExpression" diff --git a/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue b/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue index 9b708597f..194dce8f0 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue @@ -20,16 +20,17 @@ From 6ee3e6952972b826ee153cdd2e2f245520bfe2a6 Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Fri, 3 Jul 2020 16:27:04 +0800 Subject: [PATCH 4/4] =?UTF-8?q?NEZ-343=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9chart=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/components/page/dashboard/chartBox.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue index ef554cec3..4fd43e0d6 100644 --- a/nezha-fronted/src/components/page/dashboard/chartBox.vue +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -686,7 +686,7 @@ }, // 更新图表 updateCharts(params) { - this.$put('panel/' + this.panelId + '/charts', params).then(response2 => { + this.$put('panel/' + this.panelId + '/charts', params ? params : this.chart).then(response2 => { if (response2.code === 200) { this.esc(); this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); @@ -812,7 +812,11 @@ this.chart.elements.push({id: this.elementIds[i], expression: expr, type: "expert", legend: this.legends[i]}); }); } - this.addCharts(); + if (this.chart.id) { + this.updateCharts(); + } else { + this.addCharts(); + } }else { this.$refs.chartForm.validate((valid) => { const params = {