diff --git a/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.css b/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.css index 7b6a23e1c..abd57e32f 100644 --- a/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.css +++ b/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.css @@ -1 +1 @@ -.right-box-record-rule .metric-selector-input-box .input-box{width:100%;height:100%}.right-box-record-rule .metric-selector-input-box .input-box .not-fixed-height.no-resize.no-close{width:100%;height:100%}.right-box-record-rule .promqlInput .metric-selector-title{width:80px}.right-box-record-rule .promqlInput .metric-selector-input-box{width:calc(100% - 92px) !important}.right-box-record-rule .promqlInput .cm-editor.ͼ1.ͼ2.ͼo.cm-focused{height:100%}.right-box-record-rule .promqlInput .cm-editor.ͼ1.ͼ2.ͼo{height:100%}.right-box-record-rule .promqlInput .cm-content.cm-lineWrapping{display:flex;align-items:center}.right-box-record-rule .silence-matchers-value{width:100%}.right-box-record-rule .param-box-row-symbol{padding-left:20px} +.right-box-record-rule .metric-selector-input-box .input-box{width:100%;height:100%}.right-box-record-rule .metric-selector-input-box .input-box .not-fixed-height.no-resize.no-close{width:100%;height:100%}.right-box-record-rule .metric-selector-input-box .input-box .el-textarea .el-input__count{right:5px !important}.right-box-record-rule .promqlInput .cm-editor.ͼ1.ͼ2.ͼo.cm-focused{height:100%}.right-box-record-rule .promqlInput .cm-editor.ͼ1.ͼ2.ͼo{height:100%}.right-box-record-rule .promqlInput .cm-content.cm-lineWrapping{display:flex;align-items:center}.right-box-record-rule .silence-matchers-value{width:100%}.right-box-record-rule .param-box-row-symbol{padding-left:20px} diff --git a/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.scss b/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.scss index d7e4ecb45..afa59159c 100644 --- a/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.scss +++ b/nezha-fronted/src/assets/css/components/common/rightBox/recordRuleBox.scss @@ -7,15 +7,18 @@ width: 100%; height: 100%; } + .el-textarea .el-input__count{ + right: 5px !important; + } } } .promqlInput{ - .metric-selector-title{ - width: 80px; - } - .metric-selector-input-box{ - width: calc(100% - 92px) !important; - } + // .metric-selector-title{ + // width: 80px; + // } + // .metric-selector-input-box{ + // width: calc(100% - 92px) !important; + // } .cm-editor.ͼ1.ͼ2.ͼo.cm-focused{ height: 100%; } diff --git a/nezha-fronted/src/components/common/alert/alertLabel.vue b/nezha-fronted/src/components/common/alert/alertLabel.vue index 3a09a45ff..be446cc9b 100644 --- a/nezha-fronted/src/components/common/alert/alertLabel.vue +++ b/nezha-fronted/src/components/common/alert/alertLabel.vue @@ -36,7 +36,7 @@ {{ alertLabelData && alertLabelData.name ? alertLabelData.name : "--" }} - +
+ + +
+
+
ID
+
+ {{ alertLabelData && alertLabelData.id ? alertLabelData.id : "--" }} +
+
+
+
{{$t('overall.name')}}
+
{{alertLabelData && alertLabelData.name ? alertLabelData.name : '--'}}
+ +
+
+
{{ $t("overall.type") }}
+
+ {{ alertLabelData && alertLabelData.type == "1" ? $t('overall.metric') : $t("overall.logs")}} +
+
+
+
{{ $t("config.exprTemp.expression") }}
+
+ {{ alertLabelData && alertLabelData.expr ? alertLabelData.expr : "--" }} +
+
+
+
{{ $t("config.assetLabel.interval") }}
+
+ {{ alertLabelData && alertLabelData.inr ? alertLabelData.inr : "--" }} +
+
+
+
{{ $t("overall.remark") }}
+
+ {{ alertLabelData && alertLabelData.remark ? alertLabelData.remark : "--" }} +
+
+
+
{{ $t("overall.state") }}
+
+
+ {{ alertLabelData && alertLabelData.state == "1" ? $t("overall.enabled") : $t("overall.disabled")}} +
+
+
@@ -892,6 +942,10 @@ export default { this.loading = false this.alertLabelData = this.that } + if (this.type === 'recordRule') { + this.loading = false + this.alertLabelData = this.that + } const weekDays = this.getWeeksTime() if (this.trendTimer) { clearTimeout(this.trendTimer) @@ -954,6 +1008,8 @@ export default { return 'nz-icon-Alertrule' case 'user': return 'nz-icon-user1' + case 'recordRule': + return 'nz-icon-Alertrule' } return 'nz-icon-module5' }, diff --git a/nezha-fronted/src/components/common/mixin/alertLabelMixin.js b/nezha-fronted/src/components/common/mixin/alertLabelMixin.js index c9cae186c..ea03f866f 100644 --- a/nezha-fronted/src/components/common/mixin/alertLabelMixin.js +++ b/nezha-fronted/src/components/common/mixin/alertLabelMixin.js @@ -39,7 +39,7 @@ export default { this.alertLabelObj = item this.alertLabelType = type } - this.$set(item[type], 'loading', loading) + this.$set(item, 'loading', loading) } this.timer = setTimeout(() => { this.alertLabelShow = loading @@ -61,6 +61,7 @@ export default { case 'project': case 'dc': case 'user': + case 'recordRule': return false default: return true } diff --git a/nezha-fronted/src/components/common/mixin/dataList.js b/nezha-fronted/src/components/common/mixin/dataList.js index e13550b2d..d84e73ec7 100644 --- a/nezha-fronted/src/components/common/mixin/dataList.js +++ b/nezha-fronted/src/components/common/mixin/dataList.js @@ -1002,6 +1002,115 @@ export default { jsonKey: 'valnum' } } + } else if (path === 'recordRule') { + searchKeys = { + // key: path 键 + // value: vue set 参数 + pageNo: { target: this.pageObj, propertyName: 'pageNo', type: 'number' }, + pageSize: { target: this.pageObj, propertyName: 'pageSize', type: 'number' }, + orderBy: { target: this.$data, propertyName: 'orderBy', type: 'string' }, + ids: { + target: this.searchLabel, + isSearchInput: true, + propertyName: 'ids', + type: 'string', + defaultJson: { + disabled: false, + label: 'ids', + name: 'ID', + type: 'input', + val: '' + }, + jsonKey: 'val' + }, + state: { + target: this.searchLabel, + isSearchInput: true, + propertyName: 'state', + type: 'Number', + defaultJson: { + disabled: false, + label: 'recordState', + name: 'State', + readonly: true, + type: 'select', + val: '' + }, + jsonKey: 'val' + }, + name: { + target: this.searchLabel, + isSearchInput: true, + propertyName: 'name', + type: 'string', + defaultJson: { + disabled: false, + id: 'name', + label: 'name', + name: 'Name', + type: 'input', + val: '' + }, + jsonKey: 'val' + }, + type: { + target: this.searchLabel, + isSearchInput: true, + propertyName: 'type', + type: 'Number', + defaultJson: { + disabled: false, + label: 'recordType', + name: 'Type', + readonly: true, + type: 'select', + val: '' + }, + jsonKey: 'val' + }, + expr: { + target: this.searchLabel, + isSearchInput: true, + propertyName: 'expr', + type: 'string', + defaultJson: { + disabled: false, + label: 'expr', + name: 'Expression', + type: 'input', + val: '' + }, + jsonKey: 'val' + }, + starrd: { + target: this.searchLabel, + isSearchInput: true, + propertyName: 'starrd', + type: 'Number', + defaultJson: { + disabled: false, + label: 'starrd', + name: 'Starrd', + type: 'select', + val: '' + }, + jsonKey: 'val' + }, + buildIn: { + target: this.searchLabel, + isSearchInput: true, + propertyName: 'buildIn', + type: 'Number', + defaultJson: { + disabled: false, + label: 'buildIn', + name: 'buildIn', + type: 'select', + val: '' + }, + jsonKey: 'val' + } + } } this.initQueryFromPath(searchKeys) }, diff --git a/nezha-fronted/src/components/common/rightBox/recordRuleBox.vue b/nezha-fronted/src/components/common/rightBox/recordRuleBox.vue index f9bbeb10c..0cd2544f0 100644 --- a/nezha-fronted/src/components/common/rightBox/recordRuleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/recordRuleBox.vue @@ -69,7 +69,7 @@ - + @@ -195,8 +195,15 @@ export default { this.editRecordRule.labels.forEach(item => { obj[item.label] = item.value }) - this.editRecordRule.labels = JSON.stringify(obj) - const params = { ...this.editRecordRule } + + const params = { + ...this.editRecordRule, + state: Number(this.editRecordRule.state), + type: Number(this.editRecordRule.type), + inr: Number(this.editRecordRule.inr), + labels: this.editRecordRule.labels[0].label != '' ? JSON.stringify(obj) : {} + } + // 处理exp if (!this.expressions[0]) { this.prevent_opt.save = false @@ -205,7 +212,6 @@ export default { } if (valid) { this.prevent_opt.save = true - console.log(params) if (this.editRecordRule.id) { this.$put('/record/rule', params).then(response => { this.prevent_opt.save = false @@ -246,15 +252,15 @@ export default { }, metricChange (val) { this.editRecordRule.expr = val + }, + labelsSort (obj) { + const labels = JSON.parse(JSON.parse(JSON.stringify(obj))) + const result = [] + for (const key in labels) { + result.push({ label: key, value: labels[key] }) + } + return result } - // labelsSort (obj) { - // const labels = this.$lodash.cloneDeep(obj) - // const result = [] - // for (const key in labels) { - // result.push({ label: key, value: labels[key] }) - // } - // return result - // } }, watch: { recordRule: { @@ -262,7 +268,13 @@ export default { immediate: true, handler (n, o) { this.isEdit = true - const obj = this.$lodash.cloneDeep(n) + this.editRecordRule = { + ...n, + type: n.type + '', + inr: n.inr + '', + labels: this.labelsSort(n.labels), + state: n.state + '' + } // expression if (this.editRecordRule.id || this.editRecordRule.name) { this.expressions = [this.editRecordRule.expr] @@ -274,7 +286,13 @@ export default { }) }) } - this.editRecordRule = Object.assign(this.editRecordRule, obj) + } + }, + 'editRecordRule.type': { + deep: true, + immediate: true, + handler (n, o) { + if (n == 2) { this.showMetrics = false } else { this.showMetrics = true } } } } diff --git a/nezha-fronted/src/components/common/searchInput.vue b/nezha-fronted/src/components/common/searchInput.vue index f315b868c..b5eb933eb 100644 --- a/nezha-fronted/src/components/common/searchInput.vue +++ b/nezha-fronted/src/components/common/searchInput.vue @@ -902,6 +902,14 @@ export default { objectInfo.statuses = val.valnum } else if (val.label === 'ipamState') { objectInfo.state = val.valnum + } else if (val.label === 'recordState') { + objectInfo.state = val.valnum + } else if (val.label === 'starrd') { + objectInfo.starrd = val.valnum + } else if (val.label === 'recordType') { + objectInfo.type = val.valnum + } else if (val.label === 'buildIn') { + objectInfo.buildIn = val.valnum } else if (typeof (val.valnum) === 'undefined' || val.valnum == '') { this.selectInfoList[val.label].forEach(item => { if (item.label === val.val) { diff --git a/nezha-fronted/src/components/common/searchSelectInfo.vue b/nezha-fronted/src/components/common/searchSelectInfo.vue index 5c58a5fae..20beb9867 100644 --- a/nezha-fronted/src/components/common/searchSelectInfo.vue +++ b/nezha-fronted/src/components/common/searchSelectInfo.vue @@ -186,6 +186,46 @@ const searchSelectInfo = { // value: 传给后台的值;label:显示给用 label: i18n.t('overall.disabled') } ], + recordState: [ + { + value: 1, + label: i18n.t('overall.enabled') + }, + { + value: 0, + label: i18n.t('overall.disabled') + } + ], + starrd: [ + { + value: 1, + label: i18n.t('overall.starred') + }, + { + value: 0, + label: i18n.t('overall.unstarred') + } + ], + recordType: [ + { + value: 1, + label: i18n.t('overall.metric') + }, + { + value: 2, + label: i18n.t('overall.logs') + } + ], + buildIn: [ + { + value: 1, + label: i18n.t('overall.buildIn') + }, + { + value: 0, + label: i18n.t('overall.unbuildIn') + } + ], ack: [ { value: '1', diff --git a/nezha-fronted/src/components/common/table/settings/recordRuleTable.vue b/nezha-fronted/src/components/common/table/settings/recordRuleTable.vue index 370b43f59..d6b5acad7 100644 --- a/nezha-fronted/src/components/common/table/settings/recordRuleTable.vue +++ b/nezha-fronted/src/components/common/table/settings/recordRuleTable.vue @@ -43,12 +43,12 @@ - - {{ - scope.row[item.prop] || "-" - }} +
+
+ {{ $t('overall.enabled') }} +
+
+
+ {{ $t('overall.disabled') }} +
+ + @@ -122,9 +126,9 @@ :id="alertLabelId" :that="alertLabelObj" :type="alertLabelType" - :alert-table-dialog="chartAlertList" @tipHover='tipHover' > + @@ -132,8 +136,6 @@ import table from '@/components/common/mixin/table' import nzAlertTag from '../../../page/alert/nzAlertTag' import alertLabelMixin from '@/components/common/mixin/alertLabelMixin' -// import { calcDurationByStringTimeB } from '@/components/common/js/tools' -// import { sameLabels } from '@/components/common/js/constants' export default { name: 'recordRuleTable', components: { @@ -158,23 +160,25 @@ export default { label: this.$t('overall.name'), prop: 'name', show: true, - minWidth: 150 + minWidth: 150, + sortable: 'custom' }, { label: this.$t('overall.type'), prop: 'type', show: true, - minWidth: 150 + minWidth: 150, + sortable: 'custom' }, { label: this.$t('config.exprTemp.expression'), - prop: 'expression', + prop: 'expr', show: true, width: 300 }, { label: this.$t('config.assetLabel.interval'), - prop: 'interval', + prop: 'inr', show: true, width: 300 }, @@ -195,14 +199,32 @@ export default { label: this.$t('overall.state'), prop: 'state', show: true, - width: 150 + width: 150, + sortable: 'custom' } ] } }, computed: { + tagType () { + return (key) => { + if (key == 'asset' || key == 'module' || key == 'project' || key == 'dc' || key == 'endpoint') { + return 'normal' + } else { + return 'info' + } + } + } }, methods: { + labelsSort (obj) { + const labels = JSON.parse(JSON.parse(JSON.stringify(obj))) + const result = [] + for (const key in labels) { + result.push({ label: key, value: labels[key] }) + } + return result + } } } diff --git a/nezha-fronted/src/components/page/config/recordRule.vue b/nezha-fronted/src/components/page/config/recordRule.vue index ad4073a6c..e85834931 100644 --- a/nezha-fronted/src/components/page/config/recordRule.vue +++ b/nezha-fronted/src/components/page/config/recordRule.vue @@ -106,6 +106,42 @@ export default { type: 'input', label: 'ids', disabled: false + }, + { + name: 'Name', + type: 'input', + label: 'name', + disabled: false + }, + { + name: 'Type', + type: 'select', + label: 'recordType', + disabled: false + }, + { + name: 'Expression', + type: 'input', + label: 'expr', + disabled: false + }, + { + name: 'State', + type: 'select', + label: 'recordState', + disabled: false + }, + { + name: 'Starrd', + type: 'select', + label: 'starrd', + disabled: false + }, + { + name: 'Build_in', + type: 'select', + label: 'buildIn', + disabled: false } ] }, @@ -125,23 +161,6 @@ export default { mounted () { }, methods: { - edit (u) { - this.$get(`${this.url}/${u.id}`).then(response => { - if (response.code === 200) { - this.object = response.data - this.object.labels = this.labelsSort(response.data.labels) - this.rightBox.show = true - } - }) - }, - labelsSort (obj) { - const labels = this.$lodash.cloneDeep(obj) - const result = [] - for (const key in labels) { - result.push({ label: key, value: labels[key] }) - } - return result - } }, created () { }