diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 354fa5e64..982d94a02 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -105,6 +105,16 @@ :panel-id="filter.panelId" :chart-index="index" :editChartId="'editChartId' + item.id"> + + @@ -115,6 +125,7 @@ import axios from 'axios'; import bus from '../../libs/bus'; import lineChartBlock from './line-chart-block'; import chartTable from './chart-table'; +import chartUrl from './chart-url'; import draggable from 'vuedraggable' export default { @@ -124,6 +135,7 @@ export default { components: { lineChartBlock, chartTable, + chartUrl, draggable, }, data() { @@ -489,6 +501,7 @@ export default { }else { this.dataList = this.dataTotalList; } + console.log('0000==========',this.dataList); this.$nextTick(() => { if (this.dataList.length > 0 && this.$refs.editChart) { this.$refs.editChart.forEach((item, i) => { @@ -508,7 +521,12 @@ export default { if(oldDataListLen){ realIndex += oldDataListLen; } - this.getChartData(item, realIndex); + let chartType = item.type; + if(chartType!=='url'){ + this.getChartData(item, realIndex); + }else { + this.setSize(item.span, realIndex); // 设置该图表宽度 + } }); } }, diff --git a/nezha-fronted/src/components/charts/chart-url.scss b/nezha-fronted/src/components/charts/chart-url.scss new file mode 100644 index 000000000..4b3ea93ba --- /dev/null +++ b/nezha-fronted/src/components/charts/chart-url.scss @@ -0,0 +1,196 @@ +/* ---------edit-chart-move--------- */ +.clearfix:after{ + display: block; + content: ""; + clear: both; +} +.clearfix{ + margin-bottom: 10px; +} +.loading-font{ + color:#232f3e !important; +} +.dialog-tool { + margin-right: 40px; +} +.hidden{ + visibility: hidden; +} +.visible{ + visibility: visible; +} +.nz-chart-dropdown { + height: 147px; + li { + /*padding: 0 20px !important;*/ + padding-left:15px !important; + padding-right:0px !important; + width:140px; + text-align: left; + i { + margin-right: 10px; + } + } +} +.chart-url { + width: 100%; + height: 100%;//calc(100% - 40px); + // min-height: 500px; + position: relative; + background: #FFF; + border: 1px solid #d8dce1; + padding: 0px 0px; + margin-bottom: 10px; + padding-bottom: 3px; + .url-container{ + padding-left: 8px; + padding-right: 8px; + } + .vue-resizable-handle { + position: absolute; + width: 20px; + height: 20px; + bottom: 0; + right: 0; + cursor: se-resize; + box-sizing: border-box; + } + .vue-resizable-handle:after { + border-right: 2px solid #555; + border-bottom: 2px solid #555; + content: ""; + position: absolute; + right: 3px; + bottom: 3px; + width: 5px; + height: 5px; + /*border-right: 2px solid rgba(0,0,0,.4); + border-bottom: 2px solid rgba(0,0,0,.4);*/ + box-sizing: inherit; + } + .chartTitle:hover { + background-color:#d8dce1; + } + .dragTitle{ + background-color:#d8dce1; + } + .chartTitle { + text-align: center; + width: 100%; + line-height: 28px; + .nz-chart-top{ + width:100%; + } + .el-dropdown-link { + cursor: move; + } + .el-icon-arrow-down { + font-size: 12px; + } + .chart-title { + font-weight: bold; + font-size: 18px; + line-height: 26px; + color: #333; + margin: -3px 0 3px 3px; + display:flex; + justify-content:center; + align-items:center; + .chart-title-text{ + max-width:calc(100% - 20px); + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + cursor: pointer; + } + .chart-title-icon{ + display: inline-block; + cursor: pointer; + } + } + } + .edit:after{ + display: block; + content: ""; + clear: both; + } + + .button-panel-height{ + height:26px; + } + .button-panel-height button{ + height:26px; + } + .edit { + position: absolute; + right: 20px; + top: 17px; + z-index: 10; + /*background: $btn-light-background-color; + border-radius: 6px;; + border: 1px solid #ccc; + .set-icon { + display: inline-block; + cursor: pointer; + padding: 5px 15px; + border-right: 1px solid #ccc; + + } + .set-icon:hover{ + background: $btn-light-background-color-hover; + } + .set-icon:last-child{ + border-right: none !important; + } + .el-icon-refresh-right{ + color: #F0BF84; + } + i{ + font-size: 16px; + color: #000; + } + .list-icon { + float: left; + } + .show-icon { + cursor: pointer; + float: right; + font-size: 14px; + }*/ + } + .chart-select { + position: absolute; + left: 40px; + top: 25px; + z-index: 10; + font-size: 14px; + .chart-select-btn { + margin-right: 10px; + cursor: pointer; + &.active { + color: #5aacff; + } + } + } + /*没有数据显示*/ + .null { + position: absolute; + top: 50%; + width: 100%; + text-align: center; + font-size: 24px; + font-weight: 600; + } + .chart-table-col{ + width: 100%; + } + .element-bottom-border { + border-bottom: 1px solid #dfe7f2; + margin-bottom:-20px; + } + .element-top-border { + padding-top: 10px; + border-top: 1px solid #dfe7f2; + margin-top:-25px; + } +} diff --git a/nezha-fronted/src/components/charts/chart-url.vue b/nezha-fronted/src/components/charts/chart-url.vue new file mode 100644 index 000000000..924a5e982 --- /dev/null +++ b/nezha-fronted/src/components/charts/chart-url.vue @@ -0,0 +1,374 @@ + + + + + diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index 96045e117..fb73e155d 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -12,6 +12,11 @@ visibility: visible; } + + + @@ -108,12 +121,6 @@ xAxis: [], theData: [], // series数据组 }, - //panelIdInner: '', // 看板id=panelId,原写作chart,由set_data获取 - //chartName: '', - //firstLoad: false, // 是否第一次加载 - //divFirstShow:false, - //highchartStore: null, // 保存图表数据 - //echartStore:null,// 保存图表数据 echartModalStore: null, // 全屏查看时数据 chartType: 'line', // 图表类型 screenModal: false, @@ -136,6 +143,7 @@ //dropdownMenuShow:false, showLegend:true, tableShow:true, + urlShow:true, searchTime:[new Date().setHours(new Date().getHours()-1),new Date()], //oldSearchTime:[], minHeight:200, @@ -234,25 +242,19 @@ show(chartInfo) { this.searchTime = [new Date().setHours(new Date().getHours()-1),new Date()]; this.chart=chartInfo; + let chartType= chartInfo.type; let chartContainerId = 'chartEchartPreview' if(chartType==='table'){ - /* - for(let i=0;i<8;i++){ - this.seriesItemScreen.push({//表格数据 - // label: '',//label - // metric: '',//metric列 - element:'', - time: '',//采集时间 - value: '',//数值 - }); - }*/ this.tableShow = false; chartContainerId = 'chartTablePreview'; }else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4) { this.isGreyScreen=[]; this.showLegend = false; chartContainerId = 'chartEchartPreview'; + }else if(chartType==='url'){ + this.urlShow = false; + chartContainerId = 'chartUrlPreview'; } //设置高度 chart-table @@ -275,6 +277,33 @@ this.setSize(chartInfo.span); // 设置该图表宽度 this.screenModal = true; + + }, + setLoadFrame(){ + if(this.chart.type==='url'){ + let that = this; + this.$nextTick(() => { + let iframeBox = document.querySelector('#chartUrlPreview'); + let iframe = document.querySelector('#chartUrlFrame'); + + // 处理兼容行问题 + if (iframe.attachEvent) { + iframe.attachEvent('onload', function () { + // iframe加载完毕以后执行操作 + console.log('iframe已加载完毕'); + that.$refs.loadingPreview.endLoading(); + }) + } else { + iframe.onload = function () { + // iframe加载完毕以后执行操作 + console.log('iframe已加载完毕'); + that.$refs.loadingPreview.endLoading(); + } + } +console.log('=======',this.chart) + iframe.src = this.chart.param.url; + }); + } }, filterShowData(source,pageObj){ return source.slice((pageObj.pageNo-1)*pageObj.pageSize,pageObj.pageNo*pageObj.pageSize) @@ -288,10 +317,18 @@ if(this.echartModalStore){ this.echartModalStore.clear(); } + }else if(chartType==='url'){ + } //后台获得数据 - this.$refs.loadingPreview.startLoading(); - this.getChartData(); + if(this.chart.type!=='url'){ + this.$refs.loadingPreview.startLoading(); + this.getChartData(); + }else { + this.$refs.loadingPreview.startLoading(); + this.urlShow = true; + this.setLoadFrame(); + } }, // 设置图表的宽度 setSize(size) { @@ -789,6 +826,12 @@ this.seriesItemScreen = []; this.searchTime[0] = new Date().setHours(new Date().getHours()-1); this.searchTime[1] =new Date(); + + let iframe = document.querySelector('#chartUrlFrame'); + if(iframe){ + iframe.src=""; + } + }, // 重新请求数据 刷新操作 /* @@ -955,6 +998,7 @@ }, }, mounted() { + }, beforeDestroy() { this.clearChart(); diff --git a/nezha-fronted/src/components/charts/line-chart-block.scss b/nezha-fronted/src/components/charts/line-chart-block.scss index 6f318713f..6abee510f 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.scss +++ b/nezha-fronted/src/components/charts/line-chart-block.scss @@ -61,6 +61,19 @@ } } } +.nz-chart-dropdown-one { + height: 36px; + li { + /*padding: 0 20px !important;*/ + padding-left:15px !important; + padding-right:0px !important; + width:140px; + text-align: left; + i { + margin-right: 10px; + } + } +} .line-chart-block { height: 100%; //min-height: 0px; diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 39ada87e5..52c7fd436 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -38,12 +38,12 @@ {{$t('dashboard.screen')}} --> -