diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 739de0b37..a8df07f62 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -119,6 +119,17 @@ :editChartId="'editChartId' + item.id" > + + 0) { + if (filterType === 'showFullScreen') {//全屏查询 + this.$refs['editChart' + chartItem.id][0].setData(chartItem, null, + this.filter.panelId, null, filterType); + } else { + this.$refs['editChart' + chartItem.id][0].setData(chartItem, null, + this.filter.panelId, null, ''); + } + } + return; + } + if (this.isModel) { this.modelStaticData(chartInfo, filterType); } else { @@ -1098,9 +1126,11 @@ }, computeDistance:function(str){ let span = document.querySelector(".temp-dom"); - span.textContent = str; - let txtWidth = parseFloat(window.getComputedStyle(span).width); - return Number('-'+(txtWidth+5)); + if(span){ + span.textContent = str; + let txtWidth = parseFloat(window.getComputedStyle(span).width); + return Number('-'+(txtWidth+5)); + } }, modelStaticData(chartInfo, filterType) { let series = []; @@ -1467,7 +1497,6 @@ }); }); req.then(result => { - console.info(detail); this.$refs['editChart'+chartInfo.id][0].setData(chartInfo, detail); }, err => {}); diff --git a/nezha-fronted/src/components/charts/chart.scss b/nezha-fronted/src/components/charts/chart.scss index 531de283e..a37e03222 100644 --- a/nezha-fronted/src/components/charts/chart.scss +++ b/nezha-fronted/src/components/charts/chart.scss @@ -474,7 +474,7 @@ box-sizing: border-box; } } - .line-chart-block, .chart-table, .chart-single-stat, .chart-url, .chart-asset-info, .chart-alert-info, .chart-project-info, .chart-alert-rule-info ,.vis-network{ + .line-chart-block, .chart-table, .chart-single-stat, .chart-url,.chart-text, .chart-asset-info, .chart-alert-info, .chart-project-info, .chart-alert-rule-info ,.vis-network{ height: 100%; position: relative; background-color: white; @@ -605,3 +605,24 @@ } } +.chart-text{ + width: 100%; +} +.rich-text-container .text-content{ + padding: 10px; + width: calc(100% - 20px); + flex-grow: 1; + height: calc(100% - 28px); + white-space: pre-wrap; +} +.rich-text-screen-container{ + height: 100%; + +} + +.rich-text-screen-container .text-content{ + padding: 15px; + //border: 1px rgba(205,205,205,0.77); + //box-shadow:-1px 1px 9px -1px rgba(205,205,205,0.77); + height: calc(100% - 10px); +} diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index b602af9f7..8303a69b4 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -59,7 +59,7 @@ {{chart.title}} - + + + + {{data.title}} + + + + + + + + + + + + + diff --git a/nezha-fronted/src/components/common/language/cn.js b/nezha-fronted/src/components/common/language/cn.js index 6b1939234..e3bbd8036 100644 --- a/nezha-fronted/src/components/common/language/cn.js +++ b/nezha-fronted/src/components/common/language/cn.js @@ -153,6 +153,9 @@ const cn = { }, alertList:{ label:"告警列表" + }, + text:{ + label:"文本" } }, statisticsVal:{ @@ -188,7 +191,8 @@ const cn = { value:'Value', range:'Range', }, - legendValue:'Legend option' + legendValue:'Legend option', + content:'内容' }, chartTableColumn: { metric: "指标", diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 486a8f005..1bdac509a 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -162,6 +162,9 @@ const en = { }, alertList:{ label:"Alert list" + }, + text:{ + label:'Text' } }, statisticsVal:{ @@ -194,7 +197,8 @@ const en = { value:'Value', range:'Range', }, - legendValue:'Legend option' + legendValue:'Legend option', + content:'Content' }, chartTableColumn:{ metric:'Metric', //'指标' @@ -513,7 +517,7 @@ const en = { lastReply:'Ping last reply', modules: 'Endpoint',//'组件' alerts: 'Alerts',//'告警信息' - dataCenter: 'DC',//DC + dataCenter: 'Data Center',//DC cabinet: 'Cabinet',//'机柜' model: 'Model',//'型号' vendor: 'Vendor',//'厂商' diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue index 476a923be..97149f645 100644 --- a/nezha-fronted/src/components/page/dashboard/chartBox.vue +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -112,7 +112,7 @@ - + - + {{$t('alert.config.expr')}} @@ -177,6 +177,9 @@ + + {{$t('dashboard.panel.chartForm.content')}} + {{$t('dashboard.panel.chartForm.alertParam.param')}} @@ -184,7 +187,7 @@ - + + + + @@ -318,6 +324,7 @@ import alertChartParam from "./alertChartParam"; import promqlInput from "./explore/promqlInput"; import {nzNumber} from "../../common/js/validate"; + import richTextEditor from "../../charts/richTextEditor"; var rz = { methods: { rz(e) { @@ -390,10 +397,15 @@ id:'alertList', name:this.$t("dashboard.panel.chartForm.typeVal.alertList.label") }, + { + id:'text', + name:this.$t("dashboard.panel.chartForm.typeVal.text.label") + }, { id:'url', name:this.$t("dashboard.panel.chartForm.typeVal.url.label") }, + ], elements: [1], // 指标部分 tarNum elementTarget: [], // 本地保存数据 @@ -427,7 +439,8 @@ }, heightSuggestions:['300','400','500','600'], unitOptions:chartDataFormat.unitOptions(), - sortedOptionKeys:[{key:'min',label:'Min'},{key:'max',label:'Max'},{key:'avg',label:'Avg'},{key:'last',label:'Last'},{key:'total',label:'Total'}] + sortedOptionKeys:[{key:'min',label:'Min'},{key:'max',label:'Max'},{key:'avg',label:'Avg'},{key:'last',label:'Last'},{key:'total',label:'Total'}], + textShow:false } }, components:{ @@ -435,11 +448,17 @@ 'chart-preview':chartPreview, 'alert-chart-param':alertChartParam, 'promql-input': promqlInput, + 'rich-text-editor':richTextEditor }, mounted() { this.$nextTick(() => { this.initElements(); + }); + + setTimeout(()=>{ + this.textShow=true; + },300) }, methods: { clickOutside() { @@ -817,7 +836,7 @@ }, confirmAdd() { this.elementTarget = []; // 初始化清空参数 - if(this.editChart.type!=='url'){ + if(this.editChart.type!=='url'&&this.editChart.type != 'text'){ /*if(this.editChart.type == 'alertList'){ this.$refs.alertParamBox.saveParam(); }else{ @@ -847,29 +866,54 @@ this.addCharts(); } }else { - this.$refs.chartForm.validate((valid) => { - const params = { - title: this.editChart.title,//this.editChart - span: this.editChart.span, - height: this.editChart.height, - type: this.editChart.type, - unit:this.editChart.unit, - param:{ - url:this.editChart.param.url, - }, - sync: this.editChart.sync - }; + if(this.editChart.type == 'url'){ + this.$refs.chartForm.validate((valid) => { + const params = { + title: this.editChart.title,//this.editChart + span: this.editChart.span, + height: this.editChart.height, + type: this.editChart.type, + unit:this.editChart.unit, + param:{ + url:this.editChart.param.url, + }, + sync: this.editChart.sync + }; - if (valid) { - params.elements = []; - if (this.isedit) { - params.id = this.editChart.id; - this.updateCharts(params); - } else { - this.addCharts(params); + if (valid) { + params.elements = []; + if (this.isedit) { + params.id = this.editChart.id; + this.updateCharts(params); + } else { + this.addCharts(params); + } } - } - }); + }); + }else{ + this.$refs.chartForm.validate((valid) => { + const params = { + title: this.editChart.title,//this.editChart + span: this.editChart.span, + height: this.editChart.height, + type: this.editChart.type, + param:{ + text:this.$refs.richTextEditor.getHtml() + }, + sync: this.editChart.sync + }; + + if (valid) { + params.elements = []; + if (this.isedit) { + params.id = this.editChart.id; + this.updateCharts(params); + } else { + this.addCharts(params); + } + } + }); + } } }, // 获取metric列表 @@ -1166,7 +1210,7 @@ //验证图表数据是否合法??,合法了再显示预览窗口 this.elementTarget = []; // 初始化清空参数 this.alertParams={}; - if(this.editChart.type!=='url'){ + if(this.editChart.type!=='url'&&this.editChart.type!=='text'){ if(this.editChart.type == 'alertList'){ this.$refs.alertParamBox.saveParam('preview'); }else{ @@ -1217,7 +1261,7 @@ } }); } - }else { + }else if(this.editChart.type=='url'){ this.$refs.chartForm.validate((valid) => { const params = { title: this.editChart.title,//this.editChart @@ -1230,6 +1274,26 @@ } }; + if (valid) { + if (this.isedit) { + params.id = this.editChart.id; + } + this.$refs.chartsPreview.show(params); + } + }); + }else{ + this.$refs.chartForm.validate((valid) => { + const params = { + title: this.editChart.title,//this.editChart + span: this.editChart.span, + height: this.editChart.height, + type: this.editChart.type, + unit:this.editChart.unit, + param:{ + text:this.$refs.richTextEditor.getHtml() + } + }; + if (valid) { if (this.isedit) { params.id = this.editChart.id; @@ -1277,7 +1341,7 @@ }, delMapping:function(index){ this.editChart.param.valueMapping.mapping.splice(index,1) - } + }, }, created() { this.getSuggestMetric(); diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue index 15b58093d..c831b4f69 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue @@ -335,7 +335,11 @@ return new Promise(resolve => { this.$get('/healthy').then(response=>{ if(response.code==200){ - this.system_server_time=this.utcTimeToTimezone(response.time) + if(response.time){ + this.system_server_time=this.utcTimeToTimezone(response.time) + }else{ + this.system_server_time=bus.computeTimezone(new Date().getTime()) + } }else{ this.system_server_time=bus.computeTimezone(new Date().getTime()) }