diff --git a/nezha-fronted/src/assets/css/common.scss b/nezha-fronted/src/assets/css/common.scss index eefa8cd62..0d44c5092 100644 --- a/nezha-fronted/src/assets/css/common.scss +++ b/nezha-fronted/src/assets/css/common.scss @@ -186,14 +186,14 @@ td .nz-icon-gear:before{ box-shadow: -1px 1px 10px -1px $--dropdown-menu-box-shadow-color !important; } .el-input__count-inner { - background-color: $--input-background-color !important; + background-color: $--background-color-empty !important; } .el-textarea { .el-textarea__inner { background-color: $--background-color-empty !important; } .el-input__count { - background-color: $--input-background-color !important; + background-color: $--background-color-empty !important; } } @@ -219,6 +219,7 @@ td .nz-icon-gear:before{ } .el-message-box { background-color: $--background-color-empty !important; + border: 1px solid $--border-color-light; .el-button:nth-of-type(1) { background-color: $--button-light-hover-background-color; border: 1px solid $--button-light-border-color; @@ -327,3 +328,17 @@ td .nz-icon-gear:before{ background-color: $--background-color-empty; border-color: $--border-color-light; } +/* 颜色选择器 */ +.vc-sketch { + background-color: $--background-color-empty; + border: 1px solid $--border-color-light; + margin-top: 6px; + .vc-input__input { + background-color: $--project-input-background-color; + color: $--color-text-regular; + box-shadow: inset 0 0 0 1px $--border-color-light; + } + .vc-sketch-presets { + border-top: none; + } +} diff --git a/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss b/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss index 7f2318218..015663356 100644 --- a/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss +++ b/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss @@ -7,6 +7,16 @@ font-size: 14px; .el-form { padding-top: 0px; + .thresholds-from-item{ + margin-bottom: 0; + flex: 1; + } + .el-form-item__error { + padding-top: 0; + } + .el-input-number--small { + width: 100%; + } } .chart-title-config { border: 1px solid $--border-color-light; @@ -46,6 +56,12 @@ margin-bottom: 10px; align-items: center; justify-items: center; + .el-form-item__content{ + display: flex; + align-items: center; + justify-items: center; + width: 100%; + } .el-input-number--small{ display: inline-block; flex: 1; @@ -90,5 +106,39 @@ border-bottom: none; margin-bottom: 10px; } + .vue-tags-input{ + display: inline-block; + width: 100%; + .ti-input{ + padding: 1px 3px; + } + } + .system-chart-config { + display: flex; + height: 150px; + align-items: center; + margin-bottom: 10px; + } + .system-chart-config-left{ + width: 40%; + height: 100%; + overflow-y: auto; + .system-chart-item { + font-size: 14px; + padding: 3px 5px; + } + .system-chart-item:hover{ + color: $--color-primary; + background: $--background-color-base !important; + } + .system-chart-item.is-select{ + color: $--color-text-secondary; + } + } + .system-chart-config-right{ + flex: 1; + margin-left: 10px; + height: 100%; + } } } diff --git a/nezha-fronted/src/assets/css/components/page/monitor/project/project.scss b/nezha-fronted/src/assets/css/components/page/monitor/project/project.scss index 7270705eb..44e5b9fa2 100644 --- a/nezha-fronted/src/assets/css/components/page/monitor/project/project.scss +++ b/nezha-fronted/src/assets/css/components/page/monitor/project/project.scss @@ -77,19 +77,6 @@ height: 36px; color: $--color-text-primary; } - .vc-sketch { - background-color: $--background-color-empty; - border: 1px solid $--border-color-light; - margin-top: 6px; - .vc-input__input { - background-color: $--project-input-background-color; - color: $--color-text-regular; - box-shadow: inset 0 0 0 1px $--border-color-light; - } - .vc-sketch-presets { - border-top: none; - } - } } .project-calendar .el-input__inner { height: 24px; @@ -131,3 +118,13 @@ background-color: $--background-color-empty; border: 1px solid $--border-color-light; } +.el-collapse { + border-bottom: 1px solid $--border-color-light; + border-top: 1px solid $--border-color-light; +} +.el-collapse-item__header:nth-of-type(1) { + border-bottom: none; +} +.el-collapse-item__header { + border-bottom: 1px solid $--border-color-light; +} diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue new file mode 100644 index 000000000..9d120da90 --- /dev/null +++ b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue @@ -0,0 +1,780 @@ + + + + + diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue index 50ae6d165..1d206fa5c 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue @@ -15,7 +15,7 @@
- + @@ -59,16 +59,16 @@
- + - + - + - - + + @@ -84,7 +84,7 @@ - @@ -102,8 +102,7 @@ import richTextEditor from '@/components/charts/richTextEditor' import selectPanel from '@/components/common/popBox/selectPanel' import nezhaColor from '@/components/common/nezhaColor' import diagram from '@/components/common/ChartDiagram/diagram' -import metricsChartConfig from '@/components/common/rightBox/chart/metricsChartConfig' -import logsChartConfig from '@/components/common/rightBox/chart/logsChartConfig' +import chartConfig from '@/components/common/rightBox/chart/chartConfig' import otherChartConfig from '@/components/common/rightBox/chart/otherChartConfig' import systemChartConfig from '@/components/common/rightBox/chart/systemChartConfig' const rz = { @@ -136,8 +135,7 @@ export default { selectPanel, nezhaColor, diagram, - metricsChartConfig, - logsChartConfig, + chartConfig, systemChartConfig, otherChartConfig }, @@ -156,6 +154,8 @@ export default { groupArr: [], panelName: '', rules: { + name: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }], + panelName: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }] } } }, @@ -171,24 +171,20 @@ export default { }, // 保存endpoint save () { - if (this.prevent_opt.save) { return } ; - this.prevent_opt.save = true - // 对endpointList进行处理,避免携带过多无用数据 - const endpointList = [] - this.endpointTableData.forEach((item, index) => { - const endpoint = { - moduleId: item.moduleId, - assetId: item.assetId, - name: item.name, - configs: JSON.stringify(item.configs), - id: item.id - } - endpointList.push(endpoint) - }) - this.$refs.addEndpoint.validate((valid) => { - if (valid) { - this.$put('monitor/endpoint', endpointList).then(response => { - this.prevent_opt.save = false + const arr = [this.$refs.chartForm.validate()] + arr.push(this.$refs['childrenFrom' + this.editChart.datasource].$refs.chartForm.validate()) + Promise.all(arr).then(res => { + if (this.editChart.id) { // 修改 + this.$put('visual/panel/chart', this.editChart).then(response => { + if (response.code === 200) { + this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') }) + this.esc(true) + } else { + this.$message.error(response.msg) + } + }) + } else { // 新增 + this.$post('visual/panel/chart', this.editChart).then(response => { if (response.code === 200) { this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') }) this.esc(true) @@ -196,10 +192,9 @@ export default { this.$message.error(response.msg) } }) - } else { - this.prevent_opt.save = false - return false } + }).catch(res => { + console.log(res) }) }, selectPanel (panel) { @@ -235,8 +230,7 @@ export default { } }) }, - datasourceChange (val, e) { - console.log(val, e, this.editChart.datasource) + datasourceChange () { if (this.editChart.datasource == 1) { this.editChart = { ...this.editChart, @@ -250,10 +244,53 @@ export default { nullType: 'null', legend: { placement: 'bottom', values: [], show: true }, thresholdShow: true, - thresholds: [{ value: '', color: '#eeeeeeff' }] + thresholds: [{ value: undefined, color: '#eeeeeeff' }] } } } + if (this.editChart.datasource == 2) { + this.editChart = { + ...this.editChart, + span: 4, + height: 4, + unit: 2, + type: 'log', + elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A' }], + param: { + limit: 100 + } + } + } + if (this.editChart.datasource == 3) { + this.editChart = { + ...this.editChart, + span: 4, + height: 4, + unit: 2, + type: 'stat', + param: { + refer: 1, + system: '', + systemGroup: '', + systemSelect: '', + sort: 'desc', + limit: 100 + } + } + delete this.editChart.elements + } + if (this.editChart.datasource == 4) { + this.editChart = { + ...this.editChart, + span: 4, + height: 4, + type: 'url', + param: { + url: '' + } + } + delete this.editChart.elements + } }, editChartChange (newEditChart) { this.editChart = JSON.parse(JSON.stringify(newEditChart)) diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js new file mode 100644 index 000000000..138c18788 --- /dev/null +++ b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js @@ -0,0 +1,123 @@ +export default { + methods: { + isStackShow (type) { + switch (type) { + case 'line': + case 'stackArea': + case 'point': + return true + case 'table': + case 'singleStat': + case 'bar': + case 'treemap': + case 'pie': + return false + default: return false + } + }, + isStatisticsShow (type) { + switch (type) { + case 'line': + case 'stackArea': + case 'point': + return false + case 'table': + case 'singleStat': + case 'bar': + case 'treemap': + case 'pie': + return true + default: return false + } + }, + isShowLegend (type) { + switch (type) { + case 'line': + case 'stackArea': + case 'point': + return true + case 'table': + case 'singleStat': + case 'bar': + case 'treemap': + case 'pie': + return false + default: return false + } + }, + isShowValueMapping (type) { + switch (type) { + case 'line': + case 'stackArea': + case 'point': + case 'table': + return false + case 'singleStat': + case 'bar': + case 'treemap': + case 'pie': + return true + default: return false + } + }, + isTable (type) { + switch (type) { + case 'table': + return true + case 'line': + case 'stackArea': + case 'point': + case 'singleStat': + case 'bar': + case 'treemap': + case 'pie': + return false + default: return false + } + }, + isLog (type) { + switch (type) { + case 'log': + return true + case 'table': + case 'line': + case 'stackArea': + case 'point': + case 'singleStat': + case 'bar': + case 'treemap': + case 'pie': + return false + default: return false + } + }, + isUrl (type) { + switch (type) { + case 'url': + return true + default: return false + } + }, + isDiagram (type) { + switch (type) { + case 'diagram': + return true + default: return false + } + }, + isText (type) { + switch (type) { + case 'text': + return true + default: return false + } + }, + isGroup (type) { + switch (type) { + case 'group': + return true + default: return false + } + } + } +} diff --git a/nezha-fronted/src/components/common/rightBox/chart/logsChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/logsChartConfig.vue deleted file mode 100644 index b53662a50..000000000 --- a/nezha-fronted/src/components/common/rightBox/chart/logsChartConfig.vue +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/nezha-fronted/src/components/common/rightBox/chart/metricsChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/metricsChartConfig.vue index 561454c67..4e01efdee 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/metricsChartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/metricsChartConfig.vue @@ -1,9 +1,11 @@