diff --git a/src/views/dashboard/related/topology/components/Chart.vue b/src/views/dashboard/related/topology/components/Chart.vue deleted file mode 100644 index a601e651..00000000 --- a/src/views/dashboard/related/topology/components/Chart.vue +++ /dev/null @@ -1,654 +0,0 @@ - - - - diff --git a/src/views/dashboard/related/topology/components/Graph.vue b/src/views/dashboard/related/topology/components/Graph.vue index 7ccfb9b1..c95ae466 100644 --- a/src/views/dashboard/related/topology/components/Graph.vue +++ b/src/views/dashboard/related/topology/components/Graph.vue @@ -21,7 +21,7 @@ limitations under the License. --> :style="`height: ${height}px`" > - + height.value = dom.height - 40; width.value = dom.width; svg.value = d3.select(".svg-topology"); - graph.value = d3.select(".svg-graph"); + graph.value = d3.select(".graph"); loading.value = true; const json = await selectorStore.fetchServices(dashboardStore.layerId); if (json.errors) { @@ -612,9 +612,7 @@ limitations under the License. --> fill: none; } - .topo-svg { - width: 100%; - height: calc(100% - 5px); + .svg-topology { cursor: move; } diff --git a/src/views/dashboard/related/topology/components/utils/linkElement.ts b/src/views/dashboard/related/topology/components/utils/linkElement.ts deleted file mode 100644 index efc3c388..00000000 --- a/src/views/dashboard/related/topology/components/utils/linkElement.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const linkElement = (graph: any) => { - const linkEnter = graph - .append("path") - .attr("class", "topo-line") - .attr("marker-end", "url(#arrow)") - .attr("stroke", "#217EF25f"); - return linkEnter; -}; -export const anchorElement = (graph: any, funcs: any, tip: any) => { - const linkEnter = graph - .append("circle") - .attr("class", "topo-line-anchor") - .attr("r", 5) - .attr("fill", "#217EF25f") - .on("mouseover", function (event: unknown, d: unknown) { - tip.html(funcs.tipHtml).show(d, this); - }) - .on("mouseout", function () { - tip.hide(this); - }) - .on("click", (event: unknown, d: unknown) => { - funcs.handleLinkClick(event, d); - }); - return linkEnter; -}; -export const arrowMarker = (graph: any) => { - const defs = graph.append("defs"); - const arrow = defs - .append("marker") - .attr("id", "arrow") - .attr("class", "topo-line-arrow") - .attr("markerUnits", "strokeWidth") - .attr("markerWidth", "6") - .attr("markerHeight", "6") - .attr("viewBox", "0 0 12 12") - .attr("refX", "5") - .attr("refY", "6") - .attr("orient", "auto"); - const arrowPath = "M2,2 L10,6 L2,10 L6,6 L2,2"; - - arrow.append("path").attr("d", arrowPath).attr("fill", "#217EF25f"); - return arrow; -}; diff --git a/src/views/dashboard/related/topology/components/utils/nodeElement.ts b/src/views/dashboard/related/topology/components/utils/nodeElement.ts deleted file mode 100644 index 6aefc1e9..00000000 --- a/src/views/dashboard/related/topology/components/utils/nodeElement.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import icons from "@/assets/img/icons"; -import type { Node } from "@/types/topology"; - -icons["KAFKA-CONSUMER"] = icons.KAFKA; -export default (d3: any, graph: any, funcs: any, tip: any, legend?: any) => { - const nodeEnter = graph - .append("g") - .call(d3.drag().on("start", funcs.dragstart).on("drag", funcs.dragged).on("end", funcs.dragended)) - .on("mouseover", function (event: PointerEvent, d: Node) { - tip.html(funcs.tipHtml).show(d, this); - }) - .on("mouseout", function () { - tip.hide(this); - }) - .on("click", (event: PointerEvent, d: Node | any) => { - event.stopPropagation(); - event.preventDefault(); - funcs.handleNodeClick(event, d); - }); - nodeEnter - .append("image") - .attr("width", 49) - .attr("height", 49) - .attr("x", 2) - .attr("y", 10) - .attr("style", "cursor: move;") - .attr("xlink:href", (d: { [key: string]: number }) => { - if (!legend) { - return icons.CUBE; - } - if (!legend.length) { - return icons.CUBE; - } - let c = true; - for (const l of legend) { - if (l.condition === "<") { - c = c && d[l.name] < Number(l.value); - } else { - c = c && d[l.name] > Number(l.value); - } - } - return c && d.isReal ? icons.CUBEERROR : icons.CUBE; - }); - nodeEnter - .append("image") - .attr("width", 32) - .attr("height", 32) - .attr("x", 6) - .attr("y", -10) - .attr("style", "opacity: 0.5;") - .attr("xlink:href", icons.LOCAL); - nodeEnter - .append("image") - .attr("width", 18) - .attr("height", 18) - .attr("x", 13) - .attr("y", -7) - .attr("xlink:href", (d: { type: string }) => - !d.type || d.type === "N/A" ? icons.UNDEFINED : icons[d.type.toUpperCase().replace("-", "")], - ); - nodeEnter - .append("text") - .attr("class", "topo-text") - .attr("text-anchor", "middle") - .attr("x", 22) - .attr("y", 70) - .text((d: { name: string }) => (d.name.length > 20 ? `${d.name.substring(0, 20)}...` : d.name)); - return nodeEnter; -}; diff --git a/src/views/dashboard/related/topology/components/utils/simulation.ts b/src/views/dashboard/related/topology/components/utils/simulation.ts deleted file mode 100644 index 7642aa1c..00000000 --- a/src/views/dashboard/related/topology/components/utils/simulation.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export const simulationInit = (d3: any, nodes: any, links: any, ticked: any) => { - const simulation = d3 - .forceSimulation(nodes) - .force( - "collide", - d3.forceCollide().radius(() => 110), - ) - .force("yPos", d3.forceY().strength(1)) - .force("xPos", d3.forceX().strength(1)) - .force("charge", d3.forceManyBody().strength(-520)) - .force( - "link", - d3.forceLink(links).id((d: { id: string }) => d.id), - ) - .force("center", d3.forceCenter(window.innerWidth / 2, window.innerHeight / 2 - 20)) - .on("tick", ticked) - .stop(); - simulationSkip(d3, simulation, ticked); - return simulation; -}; - -export const simulationSkip = (d3: any, simulation: any, ticked: any) => { - d3.timeout(() => { - const n = Math.ceil(Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())); - for (let i = 0; i < n; i += 1) { - simulation.tick(); - ticked(); - } - }); -};