diff --git a/src/store/modules/network-profiling.ts b/src/store/modules/network-profiling.ts index 88cd54d4..0b181111 100644 --- a/src/store/modules/network-profiling.ts +++ b/src/store/modules/network-profiling.ts @@ -92,17 +92,24 @@ export const networkProfilingStore = defineStore({ } return prev; }, []); - calls = calls.map((d: any) => { - d.sourceId = d.source; - d.targetId = d.target; - d.source = d.sourceObj; - d.target = d.targetObj; - delete d.sourceObj; - delete d.targetObj; - return d; - }); + const param = {} as any; + calls = data.calls.reduce((prev: (Call | any)[], next: Call | any) => { + if (param[next.targetId + next.sourceId]) { + next.lowerArc = true; + } + param[next.sourceId + next.targetId] = true; + next.sourceId = next.source; + next.targetId = next.target; + next.source = next.sourceObj; + next.target = next.targetObj; + delete next.sourceObj; + delete next.targetObj; + prev.push(next); + return prev; + }, []); this.calls = calls; this.nodes = data.nodes; + console.log(calls); }, async createNetworkTask(param: { serviceId: string; diff --git a/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts b/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts index 91f4b51e..9e0b7da4 100644 --- a/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts +++ b/src/views/dashboard/related/network-profiling/components/Graph/linkProcess.ts @@ -23,31 +23,7 @@ export const linkElement = (graph: any) => { .attr("class", "topo-call") .attr("marker-end", "url(#arrow)") .attr("stroke", "#97B0F8") - .attr("d", (d: Call) => { - const controlPos = computeControlPoint( - [d.source.x, d.source.y - 5], - [d.target.x, d.target.y - 5], - 0.5 - ); - if (d.lowerArc) { - controlPos[1] = -controlPos[1] - 10; - } - return ( - "M" + - d.source.x + - " " + - (d.source.y - 5) + - " " + - "Q" + - controlPos[0] + - " " + - controlPos[1] + - " " + - d.target.x + - " " + - (d.target.y - 5) - ); - }); + .attr("d", (d: Call) => linkPath(d)); return linkEnter; }; export const anchorElement = (graph: any, funcs: any, tip: any) => { @@ -77,13 +53,7 @@ export const anchorElement = (graph: any, funcs: any, tip: any) => { return p[1] - 13; }) .attr("xlink:href", (d: Call) => { - const types = [...d.sourceComponents, ...d.targetComponents]; - if (types.includes("tcp") || types.includes("http")) { - return icons.HTTPDARK; - } - if (types.includes("https") || types.includes("tls")) { - return icons.HTTPS; - } + return getAnchor(d); }); return linkEnter; }; @@ -135,13 +105,14 @@ function quadraticBezier( const y = (1 - t) * (1 - t) * ps.y + 2 * t * (1 - t) * pc.y + t * t * pe.y; return [x, y]; } -function getMidpoint(d: Call) { +export function getMidpoint(d: Call) { const controlPos = computeControlPoint( [d.source.x, d.source.y], [d.target.x, d.target.y], 0.5 ); if (d.lowerArc) { + console.log(true); controlPos[1] = -controlPos[1]; } const p = quadraticBezier( @@ -152,3 +123,37 @@ function getMidpoint(d: Call) { ); return p; } +export function linkPath(d: Call) { + const controlPos = computeControlPoint( + [d.source.x, d.source.y - 5], + [d.target.x, d.target.y - 5], + 0.5 + ); + if (d.lowerArc) { + controlPos[1] = -controlPos[1] - 10; + } + return ( + "M" + + d.source.x + + " " + + (d.source.y - 5) + + " " + + "Q" + + controlPos[0] + + " " + + controlPos[1] + + " " + + d.target.x + + " " + + (d.target.y - 5) + ); +} +export function getAnchor(d: Call) { + const types = [...d.sourceComponents, ...d.targetComponents]; + if (types.includes("tcp") || types.includes("http")) { + return icons.HTTPDARK; + } + if (types.includes("https") || types.includes("tls")) { + return icons.HTTPS; + } +} diff --git a/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue b/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue index b7907620..71993d6a 100644 --- a/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue +++ b/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue @@ -13,7 +13,89 @@ 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. -->