From bee63f211f8e09be8a59348dea84c3561af509d5 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 14 Jun 2022 11:13:39 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-1925=20fix=EF=BC=9AProjects=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=8B=93=E6=89=91=E5=9B=BE=E6=97=B6=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=B8=8D=E5=90=8CMetric=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8D=A1=E6=AD=BB=E7=8E=B0=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/chart/chart/chartTopology.vue | 7 --- .../page/dashboard/explore/promqlInput.vue | 49 +++++++++++++------ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartTopology.vue b/nezha-fronted/src/components/chart/chart/chartTopology.vue index 10a6f5cef..59e5d483b 100644 --- a/nezha-fronted/src/components/chart/chart/chartTopology.vue +++ b/nezha-fronted/src/components/chart/chart/chartTopology.vue @@ -226,7 +226,6 @@ export default { .enter().append('g') .attr('class', 'node animation') .attr('id', function (d) { - console.log(d) return 'node' + d.id }) .attr('style', function (d) { @@ -477,7 +476,6 @@ export default { .join( enter => enter.append('g').attr('class', 'node') .attr('id', function (child) { - console.log(child) return 'node' + child.id } ) @@ -516,13 +514,11 @@ export default { const prevParentId = d.parentId ? d.parentId[d.parentId.length - 1] : '' simulation.stop() nodes = nodes.filter(child => child.parentId.indexOf(d.id) === -1) - console.log(nodes, 'hide') node = node .data(nodes) .join( enter => enter.append('g').attr('class', 'node') .attr('id', function (child) { - console.log(child) return 'node' + child.id }) .call(drag(simulation)) @@ -558,7 +554,6 @@ export default { } function render () { - console.log(node.nodes()) node.nodes().forEach(item => { const box = d3.select(item) const d = box.data()[0] @@ -722,7 +717,6 @@ export default { str += 0.05 return str + ';cursor:pointer' }).duration(300) - console.log(svg, item, node, linkCopy) }, graphIconLeave (item) { const svg = d3.select('#svgHex' + this.chartId) @@ -743,7 +737,6 @@ export default { watch: { 'data.nodes': { handler (n) { - console.log(n, 'data.nodes') this.graphIconArr = [] this.data.nodes.forEach(item => { if (this.graphIconArr.indexOf(item.type) === -1) { diff --git a/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue b/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue index fbf10116f..d15615862 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/promqlInput.vue @@ -898,20 +898,21 @@ export default { const children = this.$store.state.metricsList.find(item => item.value === data.value).children resolve(children) }).then((children) => { - const childrenCopy = JSON.parse(JSON.stringify(children)) - this.metricOptions.find(item => item.label === data.label).children = childrenCopy - // if (childrenCopy.length > 100) { - // childrenCopy.splice(100, children.length) - // childrenCopy.push({ - // label: 'More', - // value: false, - // parent: data.label, - // more: true - // }) - // this.metricOptions.find(item => item.label === data.label).children = childrenCopy - // } else { - // this.metricOptions.find(item => item.label === data.label).children = childrenCopy - // } + let childrenCopy = JSON.parse(JSON.stringify(children)) + const findChild = this.metricOptions.find(item => item.label === data.label) + + if (childrenCopy.length > 100) { + childrenCopy.splice(100, childrenCopy.length) + childrenCopy.push({ + label: 'More', + value: false, + parent: data.label, + more: true + }) + findChild.children = childrenCopy + } else { + findChild.children = childrenCopy + } }) }) } else if (data.more) { @@ -920,7 +921,25 @@ export default { const children = this.$store.state.metricsList.find(item => item.label === data.parent).children resolve(children) }).then((children) => { - this.metricOptions.find(item => item.label === data.parent).children = children + let childrenCopy = JSON.parse(JSON.stringify(children)) + const findChild = this.metricOptions.find(item => item.label === data.parent) + if (childrenCopy.length > 100) { + childrenCopy = childrenCopy.splice(findChild.children.length, findChild.children.length + 101) + findChild.children.splice(findChild.children.length - 1, 1) + findChild.children.push(...childrenCopy) + if (findChild.children.length < children.length) { + findChild.children.push({ + label: 'More', + value: false, + parent: data.parent, + more: true + }) + } else { + findChild.children.splice(findChild.children.length - 1, 1) + } + } else { + findChild.children = childrenCopy + } }) }) }