From f6d177f1dea15586cf5da58e49222b7200ab1c72 Mon Sep 17 00:00:00 2001 From: "massimo.ferraro" Date: Tue, 5 Nov 2024 11:27:01 +0100 Subject: [PATCH 1/2] Disable node interaction when no metadata is available in network area diagram viewer Signed-off-by: massimo.ferraro --- .../network-area-diagram-viewer/network-area-diagram-viewer.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts index 0b721c1e..38431e2e 100644 --- a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts +++ b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts @@ -97,6 +97,8 @@ export class NetworkAreaDiagramViewer { this.originalWidth = 0; this.originalHeight = 0; this.dynamicCssRules = customDynamicCssRules ?? DEFAULT_DYNAMIC_CSS_RULES; + // if no metadata is available disable node interaction + enableNodeInteraction = diagramMetadata == null ? false : enableNodeInteraction; this.init(minWidth, minHeight, maxWidth, maxHeight, enableNodeInteraction, enableLevelOfDetail); this.svgParameters = new SvgParameters(diagramMetadata?.svgParameters); this.layoutParameters = new LayoutParameters(diagramMetadata?.layoutParameters); From eb851f581cfac835ad12ffed6a58741aa7a8f6f2 Mon Sep 17 00:00:00 2001 From: "massimo.ferraro" Date: Tue, 5 Nov 2024 12:47:30 +0100 Subject: [PATCH 2/2] Disable also hover callback when no metadata is available Signed-off-by: massimo.ferraro --- .../network-area-diagram-viewer.ts | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts index 38431e2e..3b53fdce 100644 --- a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts +++ b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts @@ -97,9 +97,15 @@ export class NetworkAreaDiagramViewer { this.originalWidth = 0; this.originalHeight = 0; this.dynamicCssRules = customDynamicCssRules ?? DEFAULT_DYNAMIC_CSS_RULES; - // if no metadata is available disable node interaction - enableNodeInteraction = diagramMetadata == null ? false : enableNodeInteraction; - this.init(minWidth, minHeight, maxWidth, maxHeight, enableNodeInteraction, enableLevelOfDetail); + this.init( + minWidth, + minHeight, + maxWidth, + maxHeight, + enableNodeInteraction, + enableLevelOfDetail, + diagramMetadata !== null + ); this.svgParameters = new SvgParameters(diagramMetadata?.svgParameters); this.layoutParameters = new LayoutParameters(diagramMetadata?.layoutParameters); this.onMoveNodeCallback = onMoveNodeCallback; @@ -193,7 +199,8 @@ export class NetworkAreaDiagramViewer { maxWidth: number, maxHeight: number, enableNodeInteraction: boolean, - enableLevelOfDetail: boolean + enableLevelOfDetail: boolean, + hasMetadata: boolean ): void { if (!this.container || !this.svgContent) { return; @@ -222,7 +229,7 @@ export class NetworkAreaDiagramViewer { drawnSvg.style.overflow = 'visible'; // add events - if (enableNodeInteraction) { + if (enableNodeInteraction && hasMetadata) { this.svgDraw.on('mousedown', (e: Event) => { if ((e as MouseEvent).button == 0) { this.onMouseLeftDown(e as MouseEvent); @@ -237,9 +244,11 @@ export class NetworkAreaDiagramViewer { } }); } - this.svgDraw.on('mouseover', (e: Event) => { - this.onHover(e as MouseEvent); - }); + if (hasMetadata) { + this.svgDraw.on('mouseover', (e: Event) => { + this.onHover(e as MouseEvent); + }); + } this.svgDraw.on('panStart', function () { if (drawnSvg.parentElement != undefined) { drawnSvg.parentElement.style.cursor = 'move'; @@ -284,7 +293,7 @@ export class NetworkAreaDiagramViewer { observer.observe(targetNode, { attributeFilter: ['viewBox'] }); } - if (enableNodeInteraction) { + if (enableNodeInteraction && hasMetadata) { // fill empty elements: unknown buses and three windings transformers const emptyElements: NodeListOf = this.container.querySelectorAll( '.nad-unknown-busnode, .nad-3wt-nodes .nad-winding'