From 02be6b24497db1a7f453a62d5bbadacc00e0f584 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Thu, 3 Oct 2019 02:56:12 -0700 Subject: [PATCH 1/2] Bug fixed --- .../managers/graph-data-manager.ts | 36 +++++++++++-------- .../cartography/widgets/interface-status.ts | 17 ++++----- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/app/cartography/managers/graph-data-manager.ts b/src/app/cartography/managers/graph-data-manager.ts index fdf0a786..0de68ed5 100644 --- a/src/app/cartography/managers/graph-data-manager.ts +++ b/src/app/cartography/managers/graph-data-manager.ts @@ -34,31 +34,39 @@ export class GraphDataManager { ) {} public setNodes(nodes: Node[]) { - const mapNodes = nodes.map(n => this.nodeToMapNode.convert(n)); - this.mapNodesDataSource.set(mapNodes); + if (nodes) { + const mapNodes = nodes.map(n => this.nodeToMapNode.convert(n)); + this.mapNodesDataSource.set(mapNodes); - this.assignDataToLinks(); - this.onDataUpdate(); + this.assignDataToLinks(); + this.onDataUpdate(); + } } public setLinks(links: Link[]) { - const mapLinks = links.map(l => this.linkToMapLink.convert(l)); - this.mapLinksDataSource.set(mapLinks); + if (links) { + const mapLinks = links.map(l => this.linkToMapLink.convert(l)); + this.mapLinksDataSource.set(mapLinks); - this.assignDataToLinks(); - this.onDataUpdate(); + this.assignDataToLinks(); + this.onDataUpdate(); + } } public setDrawings(drawings: Drawing[]) { - const mapDrawings = drawings.map(d => this.drawingToMapDrawing.convert(d)); - this.mapDrawingsDataSource.set(mapDrawings); - - this.onDataUpdate(); + if (drawings) { + const mapDrawings = drawings.map(d => this.drawingToMapDrawing.convert(d)); + this.mapDrawingsDataSource.set(mapDrawings); + + this.onDataUpdate(); + } } public setSymbols(symbols: Symbol[]) { - const mapSymbols = symbols.map(s => this.symbolToMapSymbol.convert(s)); - this.mapSymbolsDataSource.set(mapSymbols); + if (symbols) { + const mapSymbols = symbols.map(s => this.symbolToMapSymbol.convert(s)); + this.mapSymbolsDataSource.set(mapSymbols); + } } public getNodes() { diff --git a/src/app/cartography/widgets/interface-status.ts b/src/app/cartography/widgets/interface-status.ts index 119ec6b7..1fd969cf 100644 --- a/src/app/cartography/widgets/interface-status.ts +++ b/src/app/cartography/widgets/interface-status.ts @@ -16,16 +16,17 @@ export class InterfaceStatusWidget implements Widget { const link_group = select(this); const link_path = link_group.select('path'); - const start_point: SVGPoint = link_path.node().getPointAtLength(45); - const end_point: SVGPoint = link_path.node().getPointAtLength(link_path.node().getTotalLength() - 45); - let statuses = []; + if (link_path.node()) { + const start_point: SVGPoint = link_path.node().getPointAtLength(45); + const end_point: SVGPoint = link_path.node().getPointAtLength(link_path.node().getTotalLength() - 45); - if (link_path.node().getTotalLength() > 2 * 45 + 10) { - statuses = [ - new LinkStatus(start_point.x, start_point.y, l.source.status), - new LinkStatus(end_point.x, end_point.y, l.target.status) - ]; + if (link_path.node().getTotalLength() > 2 * 45 + 10) { + statuses = [ + new LinkStatus(start_point.x, start_point.y, l.source.status), + new LinkStatus(end_point.x, end_point.y, l.target.status) + ]; + } } const status_started = link_group From ce8574d64b0b973c238a4574b6a81ee9d3641474 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Thu, 3 Oct 2019 04:15:30 -0700 Subject: [PATCH 2/2] Update node-to-map-node-converter.ts --- .../cartography/converters/map/node-to-map-node-converter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/cartography/converters/map/node-to-map-node-converter.ts b/src/app/cartography/converters/map/node-to-map-node-converter.ts index 419c938f..b3e64b1d 100644 --- a/src/app/cartography/converters/map/node-to-map-node-converter.ts +++ b/src/app/cartography/converters/map/node-to-map-node-converter.ts @@ -28,14 +28,14 @@ export class NodeToMapNodeConverter implements Converter { mapNode.consoleHost = node.console_host; mapNode.firstPortName = node.first_port_name; mapNode.height = node.height; - mapNode.label = this.labelToMapLabel.convert(node.label, { node_id: node.node_id }); + mapNode.label = this.labelToMapLabel ? this.labelToMapLabel.convert(node.label, { node_id: node.node_id }) : undefined; mapNode.locked = node.locked; mapNode.name = node.name; mapNode.nodeDirectory = node.node_directory; mapNode.nodeType = node.node_type; mapNode.portNameFormat = node.port_name_format; mapNode.portSegmentSize = node.port_segment_size; - mapNode.ports = node.ports.map(port => this.portToMapPort.convert(port)); + mapNode.ports = node.ports ? node.ports.map(port => this.portToMapPort.convert(port)) : []; mapNode.projectId = node.project_id; mapNode.status = node.status; mapNode.symbol = node.symbol;