diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index de06c99d9..07470eebe 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -705,7 +705,6 @@ export default { }else{ chart=Object.assign({},this.chartInfo) } - console.info(chart) if(chart && chart.param){ //按照粒度,project>module>endpoint 查询只传最细粒度 let param=chart.param; if(param.endpointId&¶m.endpointId != ''){ @@ -730,7 +729,6 @@ export default { queryParam.state=param.state; } } - console.info(queryParam) this.startLoading(filterType); this.$get('/alert/message', queryParam).then(response => { if (response.code == 200) { diff --git a/nezha-fronted/src/components/charts/chart-detail.vue b/nezha-fronted/src/components/charts/chart-detail.vue index 672de18d3..fc41cac58 100644 --- a/nezha-fronted/src/components/charts/chart-detail.vue +++ b/nezha-fronted/src/components/charts/chart-detail.vue @@ -35,7 +35,7 @@
- {{assetKey[key]}} + {{assetKey[key]}}
{{assetKey[key]}}
@@ -46,13 +46,16 @@
{{value ? value + 'ms' : ''}} - {{value ? value : " "}} +
- {{key}} + {{key}}
{{key}}
@@ -83,14 +86,17 @@ - {{value ? value : " "}} +
- {{projectKey[key]}} + {{projectKey[key]}}
{{projectKey[key]}}
@@ -102,13 +108,16 @@
{{value[2]}} - {{value ? value : " "}} +
- {{moduleKey[key]}} + {{moduleKey[key]}}
{{moduleKey[key]}}
@@ -126,40 +135,48 @@ {{value[1]}}   - {{value ? value : " "}} +
- {{endpointKey[key]}} + {{endpointKey[key]}}
{{endpointKey[key]}}
- {{value ? value : " "}} +
- {{key}} + {{key}}
{{key}}
- {{value ? value : " "}} + {{value ? value : " "}} +
{{value}}
- {{key}} + {{key}}
{{key}}
- {{value ? value : " "}} + {{value ? value : " "}} +
{{value}}
@@ -202,6 +219,15 @@ default: 0, } }, + watch: { + data: { + deep: true, + immediate: true, + handler(n) { + console.info(n) + } + } + }, data() { return { ready: false, @@ -273,25 +299,26 @@ }, }; }, - methods: { - itemTip(type, content, index, ready) { - let className = ""; - this.$nextTick(() => { - if (ready) { - let cellDom = document.querySelector(`#${type}-${index}`); - let spanDom = document.createElement("span"); - spanDom.style.display = "inline-block"; - spanDom.innerText = content; - cellDom.appendChild(spanDom); - if (cellDom.offsetWidth-16 < spanDom.offsetWidth) { - className = "item-tip-show"; + computed: { + itemTip() { + return function(type, content, index, ready) { + let className = "item-tip-show"; + this.$nextTick(() => { + if (ready) { + let cellDom = document.querySelector(`#${type}-${index}`); + let spanDom = document.querySelector(`#${type}-${index} .content-text`); + if (cellDom.offsetWidth - 16 <= spanDom.offsetWidth) { + document.querySelector(`#${type}-${index}>.el-popover`).classList.add(className); + } else { + document.querySelector(`#${type}-${index}>.el-popover`).classList.remove(className); + } } - cellDom.removeChild(spanDom); - return className; - } - }); - return className; + }); + return ""; + } }, + }, + methods: { startResize(e) { let vm = this; this.$chartResizeTool.start(vm, this.data, e); @@ -368,7 +395,6 @@ // 设置数据, filter区分 setData(chartItem, detail, panelId, filter, area, errorMsg) { //this.resize(chartItem); - console.info(chartItem, detail) if(errorMsg && errorMsg !== ''){ this.isError = true; this.errorContent = errorMsg; diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 0359e0b46..419b60f24 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -494,6 +494,7 @@ } }, // 获取panel详情数据,获取panel下所有chart列表 + getData(params) { const param = { panelId: params.panelId, @@ -526,6 +527,7 @@ type: "line", prev: -10, next: -1, + unit: 1, buildIn: 1, elements: [{ id: '', @@ -533,6 +535,8 @@ type: '' }] }); + this.$set(this.filter, "start_time", bus.timeFormate(new Date().getTime()-24*60*60*1000, "yyyy-MM-dd hh:mm:ss")); + this.$set(this.filter, "end_time", bus.timeFormate(new Date().getTime(), "yyyy-MM-dd hh:mm:ss")); this.$nextTick(() => { this.dataList.forEach((item,index) => { this.$set(item, "from", params.from); @@ -741,6 +745,10 @@ const chartItem = chartInfo; const index = pos; // 指标 if(chartItem.type === 'assetInfo'){ + if (chartItem.from != 'endpoint') { + this.$set(chartItem, "draggable", true); + this.$set(chartItem, "resizable", true); + } this.getAssetInfoChartData(chartItem); return; } @@ -1225,7 +1233,6 @@ }); }); alertMsg.then(result => { - console.info(detail); this.$refs['editChart'+chartInfo.id][0].setData(chartInfo, detail); }, err => { diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index 98edf0c35..5c490d6af 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -229,7 +229,7 @@ if(chartType==='table'){ this.tableShow = false; chartContainerId = 'chartTablePreview'; - }else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4 || chartType == "endpointInfo") { + }else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4) { this.isGreyScreen=[]; this.showLegend = false; chartContainerId = 'chartEchartPreview'; @@ -422,11 +422,14 @@ }, metric_name: '', }; - if (chartItem.type === 'stackArea' || chartItem.type === "endpointInfo") { + if (chartItem.type === 'stackArea') { seriesItem.theData.type = 'line'; seriesItem.theData.stack = chartItem.title; seriesItem.theData.areaStyle = {"opacity": 0.3}; } + if (chartItem.type === "endpointInfo") { + seriesItem.theData.type = 'line'; + } // 图表中每条线的名字,后半部分 let host = '';//up, if (queryItem.metric.__name__) { @@ -475,7 +478,6 @@ return [dpsItem[0] * 1000, dpsItem[1]]; }); series.push(seriesItem.theData); - console.info(seriesItem.theData) } else if (chartItem.elements && chartItem.elements[innerPos]) { // 无数据提示 @@ -506,7 +508,7 @@ //if(this.$refs.editChart&&this.$refs.editChart[index]) { if (chartItem.type === 'table') {//表格 this.setTableData(tableData); - } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4 || chartItem.type == "endpointInfo") { + } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4 || chartItem.from == "endpoint") { if (series.length && chartItem.type === 4) {//曲线汇总 } if(series.length<1){ @@ -515,7 +517,7 @@ this.noData=false; } let _chartItem = JSON.parse(JSON.stringify(chartItem)); - if (chartItem.type == "endpointInfo") { + if (chartItem.from == "endpoint") { _chartItem.type = "line"; } this.setData(_chartItem, series, legend); @@ -745,7 +747,12 @@ str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; - str += chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(val,null,2); + str += function(){ + if (chartInfo.from == 'endpoint') { + return val == 1 ? "up" : "down"; + } + return chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(val,null,2); + }(); str += `
`; str += `
`; @@ -878,6 +885,7 @@ }, yAxis: { type: 'value', + minInterval: 1, splitLine:{ show:true }, @@ -891,6 +899,13 @@ //去掉y轴--end axisLabel: { formatter: function(value,index){ + if (self.chart.from == 'endpoint') { + if (value == 1) { + return "up"; + } else { + return "down"; + } + } let chartUnit=chartInfo.unit; chartUnit=chartUnit?chartUnit:2; let unit=chartDataFormat.getUnit(chartUnit); @@ -902,7 +917,6 @@ useUTC: false,//使用本地时间 series: dataArg }; - if(this.echartModalStore){ this.echartModalStore.clear(); } @@ -912,12 +926,12 @@ if(legend){ this.screenLegendList = []; legend.forEach((item, i) => { - const legend = { + let _legend = { name:item.name, alias:item.alias, showText:this.formatLegend(chartWidth,item.alias?item.alias:item.name) }; - this.screenLegendList.push(legend); + this.screenLegendList.push(_legend); this.isGreyScreen.push(false); }); } @@ -1080,9 +1094,11 @@ this.tableShow = false; this.$refs.loadingPreview.startLoading(); this.getChartData(); - } else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4) { + } else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4 || this.chart.from == 'endpoint') { this.echartModalStore.clear(); - this.showLegend = false; + if (this.chart.from != 'endpoint') { + this.showLegend = false; + } this.$refs.loadingPreview.startLoading(); this.getQueryChart(); }else if (chartType === 'singleStat') { @@ -1111,7 +1127,7 @@ return this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step); }); // 一个图表 - axios.all(axiosArr).then((res) => { + axios.all(axiosArr).then(res => { if (res.length > 0) { const series = []; const legend = []; @@ -1121,7 +1137,7 @@ visible: true, threshold: null, }; - if(!this.chart.type){ + if(!this.chart.type || this.chart.from == 'endpoint'){ this.chart.type='line'; } res.forEach((response,pos) => { @@ -1211,7 +1227,7 @@ this.setColor(legend.length); this.initChart(this.chart,series, this.$refs.screenShowArea,legend); } - }).catch((error) => { + }).catch(error => { if (error) { this.$message.error(error.toString()); } diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 28c4c0134..dc49e23d2 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -655,6 +655,7 @@ axisLine:{ show:false }, + minInterval: 1, axisTick: { show: false, }, @@ -1082,6 +1083,7 @@ } let step = bus.getStep(startTime,endTime); if (type === 'list') { // 普通模式,主控台使用 + console.info(this.data); axiosArr = this.data.elements.map((ele) => { const filterItem = ele; let query = encodeURIComponent(filterItem.expression); diff --git a/nezha-fronted/src/components/common/bottomBox/bottomBox.vue b/nezha-fronted/src/components/common/bottomBox/bottomBox.vue index 8a36db3d3..c1031bf5b 100644 --- a/nezha-fronted/src/components/common/bottomBox/bottomBox.vue +++ b/nezha-fronted/src/components/common/bottomBox/bottomBox.vue @@ -15,10 +15,10 @@ - + >--> @@ -26,17 +26,17 @@ - + @changeTab="changeTab">--> -