From 1d19b24feb6855e5dc30303ebde8de941e14138b Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 23 Aug 2022 14:55:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=EF=BC=9A=E8=A1=A5=E5=85=85setUp?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=BC=BA=E5=B0=91=E7=9A=84=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/components/common/language/newcn.js | 3 ++- nezha-fronted/src/components/common/language/newen.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nezha-fronted/src/components/common/language/newcn.js b/nezha-fronted/src/components/common/language/newcn.js index 89e973d93..f958bf620 100644 --- a/nezha-fronted/src/components/common/language/newcn.js +++ b/nezha-fronted/src/components/common/language/newcn.js @@ -87,7 +87,8 @@ const newcn = { system: '系统', back: '返回', enabled: '启用', - disabled: '已禁用' + disabled: '已禁用', + unavailable: '不可用' }, ...zhLocale } diff --git a/nezha-fronted/src/components/common/language/newen.js b/nezha-fronted/src/components/common/language/newen.js index 1c41c844b..cde5ed393 100644 --- a/nezha-fronted/src/components/common/language/newen.js +++ b/nezha-fronted/src/components/common/language/newen.js @@ -95,7 +95,8 @@ const newen = { system: 'System', back: 'Back', enabled: 'Enabled', - disabled: 'Disabled' + disabled: 'Disabled', + unavailable: 'Unavailable' }, ...enLocale } From 0cb0b7131c94544126a399953585ffde00dee064 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Wed, 24 Aug 2022 11:48:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=20alertRule?= =?UTF-8?q?=20=E5=A4=8D=E5=88=B6=E6=97=A0=E6=B3=95=E4=BF=AE=E6=94=B9type?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/chart/chartTimeSeries.vue | 14 ----------- .../src/components/chart/chartDataFormat.js | 6 +++-- .../common/rightBox/alertRuleBox.vue | 25 +++++++++++++------ .../page/dashboard/explore/promqlInput.vue | 3 +++ 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index a9c7fbdfc..2f5e1226e 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -380,20 +380,6 @@ export default { const self = this return function (val, index) { const value = formatScientificNotation(val, 6) - // let chartUnit = self.chartInfo.unit - // chartUnit = chartUnit || 2 - // const unit = chartDataFormat.getUnit(chartUnit) - // // dot是判断最大值是否 小于1 大于1 默认是2 小于1 需要判断最大值是小数点后面几位 - // if (chartDataFormat.Interval(maxValue, copies, unit.type, 'min') < 1 && dot < 2) { // 当其小于1 且 dot < 2 默认給2 如 0.9 dot为1 - // dot = 2 - // } - // if (!dot) { // 默认是2 - // dot = 2 - // } - // dot = bus.countDecimals(value) - // if (dot < self.chartDot) { // 根据具体值计算 - // dot = self.chartDot - // } return unit.compute(value, index, -1, dot) } }, diff --git a/nezha-fronted/src/components/chart/chartDataFormat.js b/nezha-fronted/src/components/chart/chartDataFormat.js index 5ae955974..f0f54108f 100644 --- a/nezha-fronted/src/components/chart/chartDataFormat.js +++ b/nezha-fronted/src/components/chart/chartDataFormat.js @@ -345,6 +345,8 @@ function asciiCompute (num, ascii, units, dot = 2) { return '' } num = Number(num) + const SIGN = num > 0 ? 1 : -1 + num = Math.abs(num) let carry = 0 if (num > 1) { const log = Math.log(num) / Math.log(ascii) @@ -352,9 +354,9 @@ function asciiCompute (num, ascii, units, dot = 2) { num = num / Math.pow(ascii, carry) } if (Number.isInteger(num)) { - return num + ' ' + units[carry] + return num * SIGN + ' ' + units[carry] } else { - return num.toFixed(dot) + ' ' + units[carry] + return num.toFixed(dot) * SIGN + ' ' + units[carry] } } // eslint-disable-next-line no-unused-vars diff --git a/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue b/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue index 881fd55a1..9a46290a8 100644 --- a/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue @@ -50,9 +50,10 @@ - + @@ -612,12 +614,21 @@ export default { this.editAlertRule.operator = '>' } if (val === 1) { - this.showSnmpTrap = true // showSnmpTrap 为 true 时显示 expr,threshold,unit + this.showSnmpTrap = false // showSnmpTrap 为 true 时显示 expr,threshold,unit this.showMetrics = true + this.expressions = [''] this.$refs.alertRuleForm.clearValidate('expr') // 移除from表单的 expr 验证 + this.$nextTick(()=>{ + this.showSnmpTrap = true + }) } else if (val === 2) { - this.showMetrics = false // showMetrics 为 false 时,展示 Logs label - this.showSnmpTrap = true // showSnmpTrap 为 true 时显示 expr,threshold,unit + this.showMetrics = false + this.expressions = [''] + // showMetrics 为 false 时,展示 Logs label + this.showSnmpTrap = false // showSnmpTrap 为 true 时显示 expr,threshold,unit + this.$nextTick(()=>{ + this.showSnmpTrap = true + }) this.$refs.alertRuleForm.clearValidate('expr') // 移除from表单的 expr 验证 } else if (val === 3) { this.showSnmpTrap = false // showSnmpTrap 为 false 时,展示 OID @@ -650,7 +661,7 @@ export default { this.editAlertRule = JSON.parse(JSON.stringify(n)) if (this.editAlertRule.id || this.editAlertRule.name) { this.expressions = [this.editAlertRule.expr] - this.showTypeSelect = true // 当 edit 时禁用 type下拉框 + this.showTypeSelect = !!this.editAlertRule.id // 当 edit 时禁用 type下拉框 if (n.type === 1) { this.editAlertRule.type = 1 } else if (n.type === 2) { diff --git a/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue b/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue index 7493f82b7..6e3bb5485 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue @@ -1183,6 +1183,9 @@ export default { } } } + }, + beforeDestroy () { + this.newView = null } }