From 4d799ed86a2c0d558ab5c9c5cc911f3ebba5df9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E9=A1=BA=E5=81=A5?= Date: Fri, 15 Apr 2022 10:10:28 +0000 Subject: [PATCH 01/19] =?UTF-8?q?build:=20=E7=BC=96=E8=AF=91=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=20config.json=20=E4=B8=ADv?= =?UTF-8?q?ersion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2c1a0236..71695fd75 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,6 +47,7 @@ dev_build: - echo "
" > ./static/git-log.html
     - "git log -100 --pretty=format:'%ad : %s' >> ./static/git-log.html"
     - echo "
" >> ./static/git-log.html + - echo "{'baseUrl':'/','version':'$CI_COMMIT_SHORT_SHA'}" > ./static/config.json - zip -q -r $FILE_NAME ./* # 将 dist zip 上传到 minio From a64a0aea648098e03d0f0d04fcc1f824dba5dda9 Mon Sep 17 00:00:00 2001 From: zyh Date: Tue, 19 Apr 2022 15:30:49 +0800 Subject: [PATCH 02/19] =?UTF-8?q?NEZ-1820=20fix=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?dashboard=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/chart/chartAutotopology.vue | 5 +-- .../src/components/chart/chart/chartMap.vue | 20 ++++------- .../src/components/chart/chartMixin.js | 8 ++--- .../src/components/common/js/constants.js | 1 + .../src/components/common/pickTime.vue | 8 ++++- .../components/common/project/topologyL5.vue | 36 ++++++++++--------- 6 files changed, 42 insertions(+), 36 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue index a65e93c8d..f6e2bdd53 100644 --- a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue +++ b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue @@ -46,7 +46,7 @@ export default { this.$get('monitor/project', { pageSize: -1 }).then(res => { this.topologyLoading = true const axiosAll = [] - const temp = [] + let temp = [] if (res.data.list.length === 0) { this.topologyLoading = false } @@ -64,7 +64,8 @@ export default { res2.forEach(item => { temp.push(item) }) - this.allProject = temp + this.allProject = JSON.parse(JSON.stringify(temp)) + temp = [] this.topologyLoading = false }) }) diff --git a/nezha-fronted/src/components/chart/chart/chartMap.vue b/nezha-fronted/src/components/chart/chart/chartMap.vue index fd2223aec..fa20e8d9a 100644 --- a/nezha-fronted/src/components/chart/chart/chartMap.vue +++ b/nezha-fronted/src/components/chart/chart/chartMap.vue @@ -16,12 +16,7 @@ import axios from 'axios' import icon from 'leaflet/dist/images/marker-icon.png' import iconShadow from 'leaflet/dist/images/marker-shadow.png' import 'leaflet/dist/leaflet.css' -import * as echarts from 'echarts' -import chartConfig from '@/components/page/dashboard/overview/chartConfig' -// 引入Leaflet对象 挂载到Vue上,便于全局使用,也可以单独页面中单独引用 -let tooltipEndpointChart -let tooltipPrometheusChart const regNum = /^[0-9]+.?[0-9]*/ export default { name: 'chartMap', @@ -61,7 +56,6 @@ export default { }, 500) }, loadMapConfig () { - const vm = this return new Promise(resolve => { const DefaultIcon = L.icon({ iconUrl: icon, @@ -85,13 +79,13 @@ export default { maxBounds: L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180)) }).setView([mapConfig.latitude, mapConfig.longitude], mapConfig.zoom) map.createPane('myPane', document.querySelector('.my-pane-' + this.chartId)) - map.on('tooltipopen', function (param) { - // setTimeout(() => { - // vm.initTooltipChart(param) - // }, 100) - }) - map.on('tooltipclose', function (param) { - }) + // map.on('tooltipopen', function (param) { + // // setTimeout(() => { + // // vm.initTooltipChart(param) + // // }, 100) + // }) + // map.on('tooltipclose', function (param) { + // }) this.map = map L.tileLayer( diff --git a/nezha-fronted/src/components/chart/chartMixin.js b/nezha-fronted/src/components/chart/chartMixin.js index 6031edef2..a4dd5757a 100644 --- a/nezha-fronted/src/components/chart/chartMixin.js +++ b/nezha-fronted/src/components/chart/chartMixin.js @@ -144,7 +144,7 @@ export default { } }, handleLegendAlias (legend, aliasExpression) { - console.log(legend, aliasExpression) + // console.log(legend, aliasExpression) if (/\{\{.+\}\}/.test(aliasExpression)) { const labelValue = aliasExpression.replace(/(\{\{.+?\}\})/g, function (i) { const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2) @@ -293,11 +293,11 @@ export default { } }, mounted () { - this.chartId = `${this.chartInfo.id}${this.isFullscreen ? '-fullscreen' : ''}` }, beforeDestroy () { - getChart(this.chartId) && getChart(this.chartId).dispose() - setChart(this.chartId, null) + // getChart(this.chartId) && getChart(this.chartId).dispose() + // setChart(this.chartId, null) + getChart(this.chartId) && setChart(this.chartId, null) } } diff --git a/nezha-fronted/src/components/common/js/constants.js b/nezha-fronted/src/components/common/js/constants.js index 972d5e6b0..cc1e14370 100644 --- a/nezha-fronted/src/components/common/js/constants.js +++ b/nezha-fronted/src/components/common/js/constants.js @@ -290,6 +290,7 @@ export const chart = { export const intervalList = [ { value: -1, label: i18n.t('dashboard.panel.refreshInterval.never') }, + { value: 3, label: '3s' }, { value: 30, label: '30s' }, { value: 60, label: '1m' }, { value: 300, label: '5m' }, diff --git a/nezha-fronted/src/components/common/pickTime.vue b/nezha-fronted/src/components/common/pickTime.vue index a6df94c41..10648cb2c 100644 --- a/nezha-fronted/src/components/common/pickTime.vue +++ b/nezha-fronted/src/components/common/pickTime.vue @@ -67,7 +67,7 @@ export default { defaultPick: Number, showEmpty: { type: Boolean, default: false }, id: String, - sign:[Number,String] + sign: [Number, String] }, data () { return { @@ -168,6 +168,12 @@ export default { this.$emit('unitChange', n) } } + }, + beforeDestroy () { + if (this.intervalTimer) { + clearInterval(this.intervalTimer) + this.intervalTimer = null + } } } diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 93fb92957..9d97a3143 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -660,12 +660,11 @@ export default { this.chartGetData = [] const axiosArr = [] const promiseArr = [] - const self = this const pensPromise = (pen, arr, index) => { - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { Promise.all(arr).then((res) => { - self.chartGetData[index].res = self.computeData(res, pen.data.aggregation, pen) - self.setAnimation(pen, self.chartGetData[index].res) + this.chartGetData[index].res = this.computeData(res, pen.data.aggregation, pen) + this.setAnimation(pen, this.chartGetData[index].res) resolve() }) }) @@ -774,9 +773,10 @@ export default { return } if (!getTopology(this.topologyIndex)) { - const canvas = new Topology('topology-canvas' + this.topologyIndexF, canvasOptions) + let canvas = new Topology('topology-canvas' + this.topologyIndexF, canvasOptions) canvas.open(data) setTopology(this.topologyIndex, canvas) + canvas = null } else { getTopology(this.topologyIndex).open(data) } @@ -801,7 +801,7 @@ export default { if (!res.data) { return } - let data = res.data.topo + let data = JSON.parse(JSON.stringify(res.data.topo)) if (!res.data.topo || !res.data.topo.pens.length) { this.showNoData = true } else { @@ -846,12 +846,11 @@ export default { const arr = data.pens.filter(item => !item.type) this.addNodeInit(arr) } - const timer = setInterval(() => { + let timer = setInterval(() => { if (!this.imgInit) { return } const promiseArr = [] - const self = this for (let i = 0; i < data.pens.length; i++) { const line = data.pens[i] if (line.type === 1) { @@ -914,13 +913,15 @@ export default { } } }) - self.saveData = { ...data } + this.saveData = { ...data } resolve(data) clearInterval(timer) + timer = null }).catch(res => { - self.saveData = { ...data } + this.saveData = { ...data } resolve(data) clearInterval(timer) + timer = null }) }, 100) } @@ -1062,7 +1063,6 @@ export default { }, getNodesArr () { - const arr = [] if (!getTopology(this.topologyIndex)) return this.offsetX = getTopology(this.topologyIndex).data.x this.offsetY = getTopology(this.topologyIndex).data.y @@ -1556,7 +1556,7 @@ export default { fileList = fileList.splice(fileList.length - 1, 1) return false } - const isSize = new Promise(function (resolve, reject) { + new Promise(function (resolve, reject) { const width = 0 const height = 0 const _URL = window.URL || window.webkitURL @@ -1839,8 +1839,7 @@ export default { // resolve(img) // }) }) - .catch(err => { - }) + .catch() }) } }, @@ -2250,8 +2249,13 @@ export default { } } }, - destroyed () { + beforeDestroy () { + if (this.timer) { + clearInterval(this.timer) + this.timer = null + } if (getTopology(this.topologyIndex)) { + getTopology(this.topologyIndex).off('contextmenu', this.onContextMenu) getTopology(this.topologyIndex).destroy() setTopology(this.topologyIndex, null) } @@ -2259,7 +2263,7 @@ export default { document.getElementById('topology-canvas' + this.topologyIndexF).removeEventListener('mousemove', this.canvasMove) } window.removeEventListener('resize', this.winResize) - window.removeEventListener('resize', this.contextmenuNone) + window.removeEventListener('click', this.contextmenuNone) } } From 0ec76cd5c51c2321142b06d5a6704f1447ed37cd Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 19 Apr 2022 15:33:19 +0800 Subject: [PATCH 03/19] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=20topology?= =?UTF-8?q?=20=E5=9B=BE=E7=89=87=20=E4=BB=A5=E5=8F=8A=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=95=B0=E9=87=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/js/common.js | 13 ++++ .../components/common/project/topologyL5.vue | 65 +++++++++++++------ 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/nezha-fronted/src/components/common/js/common.js b/nezha-fronted/src/components/common/js/common.js index c254fabe2..a7654d8b9 100644 --- a/nezha-fronted/src/components/common/js/common.js +++ b/nezha-fronted/src/components/common/js/common.js @@ -34,6 +34,7 @@ export function getHexagon (key) { const topologyCache = {} export function getTopology (key) { + // console.log(topologyCache, 'topologyCache') return topologyCache[`topology${key}`] } @@ -41,6 +42,18 @@ export function setTopology (key, value) { topologyCache[`topology${key}`] = value } +// const topologyImgList = localStorage.getItem('nz-imgList') ? JSON.parse(localStorage.getItem('nz-imgList')) : {} + +export function getTopologyImg (key) { + // console.log(topologyCache, 'topologyCache') + // console.log(localStorage.getItem('nz-img-' + key), !localStorage.getItem('nz-img-' + key)) + return localStorage.getItem('nz-img-' + key) +} + +export function setTopologyImg (key, img) { + localStorage.setItem('nz-img-' + key, img) +} + export function setHexagon (key, value) { hexagonCache[`hexagon${key}`] = value } diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index da74ed855..8c4498f21 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -1,9 +1,9 @@ - + + + + @@ -198,7 +207,8 @@ import chartUrl from './chart/chartUrl' import chartValue from './chart/chartValue' import chartHexagonD3 from './chart/chartHexagonD3' import chartMap from './chart/chartMap' -import { getOption, isTimeSeries, isHexagon, isUrl, isText, isChartPie, isChartBar, isTreemap, isLog, isStat, isDiagram, isGroup, isAutotopology, isMap, isAssetInfo, isEndpointInfo, isTable, isGauge, isClock } from './chart/tools' +import chartTopology from './chart/chartTopology' +import { getOption, isTimeSeries, isHexagon, isUrl, isText, isChartPie, isChartBar, isTreemap, isLog, isStat, isDiagram, isGroup, isAutotopology, isMap, isAssetInfo, isEndpointInfo, isTable, isGauge, isClock, isTopology } from './chart/tools' import lodash from 'lodash' export default { @@ -224,7 +234,8 @@ export default { chartUrl, chartValue, chartHexagonD3, - chartMap + chartMap, + chartTopology }, props: { chartInfo: Object, @@ -293,6 +304,7 @@ export default { isTable, isGauge, isClock, + isTopology, chartIsNoData (flag) { this.chartChildrenData = flag }, diff --git a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue index fb47b5912..f6e2bdd53 100644 --- a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue +++ b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue @@ -1,5 +1,5 @@ @@ -233,8 +224,7 @@ export default { chartUrl, chartValue, chartHexagonD3, - chartMap, - chartTopology + chartMap }, props: { chartInfo: Object, @@ -303,7 +293,6 @@ export default { isTable, isGauge, isClock, - isTopology, chartIsNoData (flag) { this.chartChildrenData = flag }, From 49f0a616f5c9ced0dad6482d8cec5394367e50c7 Mon Sep 17 00:00:00 2001 From: zyh Date: Tue, 19 Apr 2022 16:17:14 +0800 Subject: [PATCH 06/19] =?UTF-8?q?NEZ-1820=20fix=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?dashboard=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/components/chart/chart.vue | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart.vue b/nezha-fronted/src/components/chart/chart.vue index c9148793d..862f804e4 100644 --- a/nezha-fronted/src/components/chart/chart.vue +++ b/nezha-fronted/src/components/chart/chart.vue @@ -172,15 +172,6 @@ :is-fullscreen="isFullscreen" @chartIsNoData="chartIsNoData" > - @@ -207,8 +198,7 @@ import chartUrl from './chart/chartUrl' import chartValue from './chart/chartValue' import chartHexagonD3 from './chart/chartHexagonD3' import chartMap from './chart/chartMap' -import chartTopology from './chart/chartTopology' -import { getOption, isTimeSeries, isHexagon, isUrl, isText, isChartPie, isChartBar, isTreemap, isLog, isStat, isDiagram, isGroup, isAutotopology, isMap, isAssetInfo, isEndpointInfo, isTable, isGauge, isClock, isTopology } from './chart/tools' +import { getOption, isTimeSeries, isHexagon, isUrl, isText, isChartPie, isChartBar, isTreemap, isLog, isStat, isDiagram, isGroup, isAutotopology, isMap, isAssetInfo, isEndpointInfo, isTable, isGauge, isClock } from './chart/tools' import lodash from 'lodash' export default { @@ -234,8 +224,7 @@ export default { chartUrl, chartValue, chartHexagonD3, - chartMap, - chartTopology + chartMap }, props: { chartInfo: Object, @@ -304,7 +293,6 @@ export default { isTable, isGauge, isClock, - isTopology, chartIsNoData (flag) { this.chartChildrenData = flag }, From f444f8e9219408829d9a05f59732f9ddf1c90dc2 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 19 Apr 2022 16:18:43 +0800 Subject: [PATCH 07/19] =?UTF-8?q?fix=EF=BC=9A=E4=BC=98=E5=8C=96=20topology?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/chart/chartAutotopology.vue | 2 +- .../components/common/project/topologyL5.vue | 65 +++++++++++-------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue index f6e2bdd53..04f09289f 100644 --- a/nezha-fronted/src/components/chart/chart/chartAutotopology.vue +++ b/nezha-fronted/src/components/chart/chart/chartAutotopology.vue @@ -1,5 +1,5 @@