From 48cc2ae1fe3cb7411f9bf717ee4ab0e0da95f735 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Fri, 23 Jul 2021 15:49:18 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-863=20fix=EF=BC=9A=E4=BF=AE=E6=94=B9panel?= =?UTF-8?q?=20=E9=A1=B5=E9=9D=A2=20=E6=90=9C=E7=B4=A0=E5=90=8E=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/charts/chart-alert-list.vue | 2 +- .../charts/chart-bar-statistics.vue | 4 +- .../src/components/charts/chart-group.vue | 10 +- .../components/charts/chart-list-group.vue | 36 +++-- .../src/components/charts/chart-list.vue | 15 ++- .../src/components/charts/chart-pie.vue | 4 +- .../components/charts/line-chart-block.vue | 4 +- .../common/bottomBox/tabs/assetTab.vue | 2 +- .../common/bottomBox/tabs/cabinetTab.vue | 2 +- .../common/bottomBox/tabs/endpointTabNew.vue | 2 +- .../bottomBox/tabs/terminalLogMonitorTab.vue | 10 +- .../common/js/radomcolor/randomcolor.js | 9 +- nezha-fronted/src/components/common/login.vue | 4 +- .../src/components/common/mixin/dataList.js | 4 +- .../common/project/L5/CanvasContextMenu.vue | 2 +- .../common/project/L5/CanvasProps.vue | 126 +++++++++--------- .../common/project/L5/services/img.js | 2 +- .../common/project/popData/alertTable.vue | 2 +- .../common/project/popData/assetTable.vue | 14 +- .../common/project/popData/endpointTable.vue | 4 +- .../rightBox/administration/assetTypeBox.vue | 14 +- .../common/rightBox/alertSilenceBox.vue | 5 +- .../src/components/common/searchInput.vue | 4 +- .../common/table/settings/assetTypeTable.vue | 23 ++-- .../common/table/settings/cabinetTable.vue | 4 +- .../common/table/settings/chartTmplTable.vue | 2 +- .../common/table/settings/exprTmplTable.vue | 6 +- .../common/table/settings/roleTable.vue | 4 +- .../src/components/layout/header.vue | 2 +- .../components/page/alert/alertSilence.vue | 2 +- .../src/components/page/config/agent.vue | 2 +- .../src/components/page/config/assetType.vue | 10 +- .../src/components/page/config/menus.vue | 4 +- .../src/components/page/config/model.vue | 8 +- .../src/components/page/config/system.vue | 2 +- .../page/config/system/apiKeyTable.vue | 2 +- .../page/config/system/linkTable.vue | 4 +- .../page/config/template/chartTemp.vue | 2 +- .../components/page/config/template/index.vue | 2 +- .../components/page/dashboard/chartBox.vue | 2 +- 40 files changed, 196 insertions(+), 166 deletions(-) diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index 5c7607274..9f6311762 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -326,7 +326,7 @@ export default { handler (n, o) { if (n.id) { if (!n.param.state && n.param.state != Number) { - n.param.state = "1" + n.param.state = '1' } if (n.param.severity && n.param.severity != Number) { n.param.severity = 1 diff --git a/nezha-fronted/src/components/charts/chart-bar-statistics.vue b/nezha-fronted/src/components/charts/chart-bar-statistics.vue index ce84ed9cc..6d8ef102a 100644 --- a/nezha-fronted/src/components/charts/chart-bar-statistics.vue +++ b/nezha-fronted/src/components/charts/chart-bar-statistics.vue @@ -293,7 +293,9 @@ export default { this.screenModal = true }, resize (chartItem) { - getChart(this.chartIndex).resize() + if (getChart(this.chartIndex)) { + getChart(this.chartIndex).resize() + } }, // 设置数据, filter区分 setData (chartItem, seriesItem, panelId, filter, legend, area, errorMsg) { diff --git a/nezha-fronted/src/components/charts/chart-group.vue b/nezha-fronted/src/components/charts/chart-group.vue index 0ac85fee1..35c28a568 100644 --- a/nezha-fronted/src/components/charts/chart-group.vue +++ b/nezha-fronted/src/components/charts/chart-group.vue @@ -12,7 +12,7 @@ - + {{chartData.name}} @@ -286,6 +286,14 @@ export default { that.firstShow = true that.endLoading('screen') }) + }, + showListChange () { + this.showList = !this.showList + if (this.showList) { + this.$nextTick(() => { + this.$refs.listGroup.resize() + }) + } } }, watch: { diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue index 984cfd3d3..07206155d 100644 --- a/nezha-fronted/src/components/charts/chart-list-group.vue +++ b/nezha-fronted/src/components/charts/chart-list-group.vue @@ -75,7 +75,7 @@ @sync="()=>{chartBySync(item)}" :panel-id="filter.panelId" :is-lock="panelLock" - :chart-index="item.chartIndex" + :chart-index="item.id" @dropmenu-change="(show) => {dropmenuChange(item.id, show)}" :chart-data="item" > @@ -92,7 +92,7 @@ :is-lock="panelLock" :panel-id="filter.panelId" @dropmenu-change="(show) => {dropmenuChange(item.id, show)}" - :chart-index="item.chartIndex"> + :chart-index="item.id"> + :chart-index="item.id"> + :chart-index="item.id"> + :chart-index="item.id"> + :chart-index="item.id"> @@ -424,13 +424,13 @@ export default { this.pagePanelId = this.filter.panelId this.getData(this.filter) }, - searchCharts (searchName) { + searchCharts (searchName, group) { // this.dataList = []; // this.dataTotalList = []; const chartListTmp = [] if (searchName && searchName.trim() !== '') { this.dataTotalListBak.forEach((item) => { - if (item.name.indexOf(searchName) > -1) { + if (item.name.indexOf(searchName) > -1 || group.name.indexOf(searchName) > -1) { item.isLoaded = false item.isHide = false chartListTmp.push(item) @@ -455,7 +455,7 @@ export default { if (this.dataList.length > 0) { this.dataList.forEach((item, index) => { this.$refs['editChart' + item.id][0].showLoad(item)// 之后要实现 - this.setChartSize(item.span, index)// 设置该图表宽度 + this.setChartSize(item, index)// 设置该图表宽度 if (!item.isLoaded) { // 获得当前显示在浏览器的图表,从后台获取数据 const chartBox = document.getElementById('chart-' + item.id)// this.$refs['editChart'+item.id][0]; @@ -1468,6 +1468,18 @@ export default { this.getChartData(item, index, this.filter) }) }, + resize () { + this.dataList.forEach((item, index) => { + if (item.isHide) { + return + } + if (this.$refs['editChart' + item.id][0].chartResize) { + this.$refs['editChart' + item.id][0].chartResize() + } else if (this.$refs['editChart' + item.id][0].resize) { + this.$refs['editChart' + item.id][0].resize() + } + }) + }, searchData (chartId, searchTime) { if (searchTime) { // 全屏时间查询 this.filter.start_time = bus.timeFormate(searchTime[0], 'yyyy-MM-dd hh:mm:ss') diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 6f9cf7d9c..440eb8108 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -476,14 +476,22 @@ export default { } else { item.isLoaded = true item.isHide = true + let groupShowFlag = false // 判断group内的chart是否被匹配 if (item.type === 'group' && item.children) { item.children.forEach(groupItem => { if (groupItem.name.indexOf(searchName) > -1) { item.isLoaded = false item.isHide = false - chartListTmp.push(item) + groupShowFlag = true } }) + if (groupShowFlag) { + item.isLoaded = false + item.isHide = false + chartListTmp.push(item) + } else { + chartListTmp.push(item) + } } else { chartListTmp.push(item) } @@ -504,14 +512,14 @@ export default { if (this.dataList.length > 0) { this.dataList.forEach((item, index) => { this.$refs['editChart' + item.id][0].showLoad(item)// 之后要实现 - this.setChartSize(item.span, index)// 设置该图表宽度 + this.setChartSize(item, index)// 设置该图表宽度 if (!item.isLoaded) { // 获得当前显示在浏览器的图表,从后台获取数据 const chartBox = document.getElementById('chart-' + item.id)// this.$refs['editChart'+item.id][0]; this.handleElementInViewport(chartBox, 0, item, index, true) } if (item.type === 'group') { - this.$refs['editChart' + item.id][0].$refs.listGroup.searchCharts(searchName) + this.$refs['editChart' + item.id][0].$refs.listGroup.searchCharts(searchName, item) } }) } @@ -833,7 +841,6 @@ export default { if (chartItem.type == 'diagram') { if (this.$refs['editChart' + chartItem.id] && this.$refs['editChart' + chartItem.id].length > 0) { - if (filterType === 'refresh') { this.$get('visual/panel/chart/' + chartItem.id).then(res => { const data = res.data.data diff --git a/nezha-fronted/src/components/charts/chart-pie.vue b/nezha-fronted/src/components/charts/chart-pie.vue index 4b4ca4308..e508da630 100644 --- a/nezha-fronted/src/components/charts/chart-pie.vue +++ b/nezha-fronted/src/components/charts/chart-pie.vue @@ -289,7 +289,9 @@ export default { this.screenModal = true }, resize (chartItem) { - getChart(this.chartIndex).resize() + if (getChart(this.chartIndex)) { + getChart(this.chartIndex).resize() + } }, // 设置数据, filter区分 setData (chartItem, seriesItem, panelId, filter, legend, area, errorMsg) { diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index d275adef6..8683e5727 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -1982,7 +1982,9 @@ export default { } }, chartResize () { - getChart(this.chartIndex).resize() + if (getChart(this.chartIndex)) { + getChart(this.chartIndex).resize() + } } }, created () { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/assetTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/assetTab.vue index ad30687f6..15f6ad6d0 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/assetTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/assetTab.vue @@ -58,7 +58,7 @@ import subDataListMixin from '@/components/common/mixin/subDataList' import nzBottomDataList from '@/components/common/bottomBox/nzBottomDataList' import assetTable from '@/components/common/table/asset/assetTable' import assetBox from '@/components/common/rightBox/asset/assetBox' -import { fromRoute } from "@/components/common/js/constants"; +import { fromRoute } from '@/components/common/js/constants' import alertSilenceBox from '@/components/common/rightBox/alertSilenceBox' export default { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue index 578832f6f..fe2bbdbd6 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue @@ -70,7 +70,7 @@ import dataListMixin from '@/components/common/mixin/dataList' import subDataListMixin from '@/components/common/mixin/subDataList' import nzBottomDataList from '@/components/common/bottomBox/nzBottomDataList' import cabinetTable from '@/components/common/table/settings/cabinetTable' -import topToolMoreOptions from "@/components/common/popBox/topToolMoreOptions"; +import topToolMoreOptions from '@/components/common/popBox/topToolMoreOptions' export default { name: 'cabinetTab', mixins: [dataListMixin, subDataListMixin], diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue index 0c5a768f2..a6da51d09 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue @@ -47,7 +47,7 @@ import subDataListMixin from '@/components/common/mixin/subDataList' import nzBottomDataList from '@/components/common/bottomBox/nzBottomDataList' import endpointTable from '@/components/common/table/settings/endpointTable' import EditEndpointBoxNew from '@/components/common/rightBox/editEndpointBoxNew' -import { fromRoute } from "@/components/common/js/constants"; +import { fromRoute } from '@/components/common/js/constants' import alertSilenceBox from '@/components/common/rightBox/alertSilenceBox' export default { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogMonitorTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogMonitorTab.vue index 6419197e5..fb1fb0893 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogMonitorTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogMonitorTab.vue @@ -113,11 +113,11 @@ export default { } // 登录后,你输入的内容从后台服务返回 this.terminal.on('data', function (data) { - // let code = data.charCodeAt(0); - // if(code==13){ - // }else { - // that.term.write(data); - // } + // let code = data.charCodeAt(0); + // if(code==13){ + // }else { + // that.term.write(data); + // } }) // 返回 this.terminalSocket.onmessage = function (evt) { diff --git a/nezha-fronted/src/components/common/js/radomcolor/randomcolor.js b/nezha-fronted/src/components/common/js/radomcolor/randomcolor.js index 3b40b3b3e..aab7262b4 100644 --- a/nezha-fronted/src/components/common/js/radomcolor/randomcolor.js +++ b/nezha-fronted/src/components/common/js/radomcolor/randomcolor.js @@ -1,11 +1,10 @@ -function randomNum(){ - let array = window.crypto.getRandomValues(new Uint32Array(3)) +function randomNum () { + const array = window.crypto.getRandomValues(new Uint32Array(3)) - let avg = eval(array.join('+'))/3 - - return array[0]>avg?avg/array[0]:array[0]/avg; + const avg = eval(array.join('+')) / 3 + return array[0] > avg ? avg / array[0] : array[0] / avg } function randomcolor () { diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index c88987ffc..3439f5a68 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -112,9 +112,9 @@ export default { } }, licenseStat () { - /*this.license.valid = false + /* this.license.valid = false this.license.warnInfo = 'hehehe' - this.license.token = 'dRqrWja/PzI8FrWVJeGqLw=='*/ + this.license.token = 'dRqrWja/PzI8FrWVJeGqLw==' */ this.$get('/sys/license/state').then(response => { if (response.code && response.code === 200) { this.license.warnInfo = '' diff --git a/nezha-fronted/src/components/common/mixin/dataList.js b/nezha-fronted/src/components/common/mixin/dataList.js index 87c45a367..cd84c8181 100644 --- a/nezha-fronted/src/components/common/mixin/dataList.js +++ b/nezha-fronted/src/components/common/mixin/dataList.js @@ -1,7 +1,7 @@ import bus from '@/libs/bus' import { tableSet } from '@/components/common/js/tools' import { fromRoute } from '@/components/common/js/constants' -import {object} from "cytoscape/src/is"; +import { object } from 'cytoscape/src/is' export default { data () { return { @@ -234,7 +234,7 @@ export default { }) } else if (type === 'alertRule') { this.objectSilence.matchers = [ - { name: 'alertName', value: row.name, regex: 0 }, + { name: 'alertName', value: row.name, regex: 0 } ] } this.silenceBoxShow = true diff --git a/nezha-fronted/src/components/common/project/L5/CanvasContextMenu.vue b/nezha-fronted/src/components/common/project/L5/CanvasContextMenu.vue index 92d5dbdec..ed389178b 100644 --- a/nezha-fronted/src/components/common/project/L5/CanvasContextMenu.vue +++ b/nezha-fronted/src/components/common/project/L5/CanvasContextMenu.vue @@ -132,7 +132,7 @@ export default { }, canvaspaste () { getTopology(this.index).paste() - }, + } } } diff --git a/nezha-fronted/src/components/common/project/L5/CanvasProps.vue b/nezha-fronted/src/components/common/project/L5/CanvasProps.vue index 6b8a950ae..c90498d5e 100644 --- a/nezha-fronted/src/components/common/project/L5/CanvasProps.vue +++ b/nezha-fronted/src/components/common/project/L5/CanvasProps.vue @@ -1109,22 +1109,22 @@ diff --git a/nezha-fronted/src/components/page/config/agent.vue b/nezha-fronted/src/components/page/config/agent.vue index 923a26038..776484b34 100644 --- a/nezha-fronted/src/components/page/config/agent.vue +++ b/nezha-fronted/src/components/page/config/agent.vue @@ -269,7 +269,7 @@ export default { link.click() window.URL.revokeObjectURL(link.href) } - }).catch(()=>{ + }).catch(() => { this.downloadAgentFlag = false }) } diff --git a/nezha-fronted/src/components/page/config/assetType.vue b/nezha-fronted/src/components/page/config/assetType.vue index 1592dbcf0..eacdb3ae8 100644 --- a/nezha-fronted/src/components/page/config/assetType.vue +++ b/nezha-fronted/src/components/page/config/assetType.vue @@ -63,11 +63,11 @@ export default { id: '', name: '', vm: '', - vmh:'', - authProtocol:'', - snmpEnable:'', - snmpCollect:'', - sshCollect:'' + vmh: '', + authProtocol: '', + snmpEnable: '', + snmpCollect: '', + sshCollect: '' }, tableId: 'typeConfTable', searchMsg: { // 给搜索框子组件传递的信息 diff --git a/nezha-fronted/src/components/page/config/menus.vue b/nezha-fronted/src/components/page/config/menus.vue index 093f6eac7..fe9032dec 100644 --- a/nezha-fronted/src/components/page/config/menus.vue +++ b/nezha-fronted/src/components/page/config/menus.vue @@ -128,9 +128,9 @@ export default { }, methods: { edit (u) { - this.object ={...u} + this.object = { ...u } this.rightBox.show = true - }, + } } } diff --git a/nezha-fronted/src/components/page/config/model.vue b/nezha-fronted/src/components/page/config/model.vue index 2008ed48f..23064045e 100644 --- a/nezha-fronted/src/components/page/config/model.vue +++ b/nezha-fronted/src/components/page/config/model.vue @@ -68,7 +68,7 @@ import modelBox from '@/components/common/rightBox/administration/modelBox' import nzDataList from '@/components/common/table/nzDataList' import dataListMixin from '@/components/common/mixin/dataList' import modelTable from '@/components/common/table/settings/modelTable' -import topToolMoreOptions from "@/components/common/popBox/topToolMoreOptions"; +import topToolMoreOptions from '@/components/common/popBox/topToolMoreOptions' export default { name: 'model', @@ -77,7 +77,7 @@ export default { modelBox, deleteButton, modelTable, - topToolMoreOptions, + topToolMoreOptions }, mixins: [dataListMixin], data () { @@ -120,9 +120,9 @@ export default { this.$message.error(res.msg) } }) - }, + } }, - created() { + created () { }, computed: { diff --git a/nezha-fronted/src/components/page/config/system.vue b/nezha-fronted/src/components/page/config/system.vue index 500f5005a..b01a1ef24 100644 --- a/nezha-fronted/src/components/page/config/system.vue +++ b/nezha-fronted/src/components/page/config/system.vue @@ -785,7 +785,7 @@ export default { const reader = new FileReader() reader.readAsDataURL(file)// 转化二进制流,异步方法 let base64Str = '' - reader.onload = function () { // 完成后this.result为二进制流console.log(this.result); + reader.onload = function () { // 完成后this.result为二进制流; base64Str = this.result resolve(base64Str) } diff --git a/nezha-fronted/src/components/page/config/system/apiKeyTable.vue b/nezha-fronted/src/components/page/config/system/apiKeyTable.vue index 645c3b219..9c1a83a49 100644 --- a/nezha-fronted/src/components/page/config/system/apiKeyTable.vue +++ b/nezha-fronted/src/components/page/config/system/apiKeyTable.vue @@ -181,7 +181,7 @@ export default { }, save: function (obj) { const copy = JSON.parse(JSON.stringify(obj)) - copy.expireAt = this.timezoneToUtcTimeStr(copy.expireAt); + copy.expireAt = this.timezoneToUtcTimeStr(copy.expireAt) if (copy.role) { copy.roleId = copy.role.id } diff --git a/nezha-fronted/src/components/page/config/system/linkTable.vue b/nezha-fronted/src/components/page/config/system/linkTable.vue index e8041d80a..12ab715a7 100644 --- a/nezha-fronted/src/components/page/config/system/linkTable.vue +++ b/nezha-fronted/src/components/page/config/system/linkTable.vue @@ -82,7 +82,7 @@