Merge pull request #519 from GNS3/WebUI-Cannot-read-property-'forEach'-of-undefined

Web ui cannot read property 'for each' of undefined
This commit is contained in:
piotrpekala7 2019-10-03 13:48:35 +02:00 committed by GitHub
commit 0ab0e7712e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 24 deletions

View File

@ -28,14 +28,14 @@ export class NodeToMapNodeConverter implements Converter<Node, MapNode> {
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;

View File

@ -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() {

View File

@ -16,16 +16,17 @@ export class InterfaceStatusWidget implements Widget {
const link_group = select<SVGGElement, MapLink>(this);
const link_path = link_group.select<SVGPathElement>('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