Skip to content

Commit a902057

Browse files
committed
fixed issue which caused graph view to crash after deleting an element
1 parent a54c480 commit a902057

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

client/src/app/dashboard/graph-view/graph-view.service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,22 @@ export class GraphViewService {
118118
}
119119

120120
private mapLinksToEdges(links: Array<InstanceLink>): Array<cytoscape.ElementDefinition> {
121-
const edges: Array<cytoscape.ElementDefinition> = links.map((edgeVal) => {
122-
return {data: {id: edgeVal.idFrom + '_' + edgeVal.idTo, source: edgeVal.idFrom, target: edgeVal.idTo, status: edgeVal.linkState}};
121+
const edges: Array<cytoscape.ElementDefinition> = links.filter(edgeVal => this.targetsExists(edgeVal)).map((edgeVal) => {
122+
return {data: {id: edgeVal.idFrom + '_' + edgeVal.idTo, source: edgeVal.idFrom, target: edgeVal.idTo, status: edgeVal.linkState}};
123123
});
124124
return edges;
125125
}
126126

127+
private targetsExists(instanceLink: InstanceLink) {
128+
129+
const instances = this.storeService.getState().instances;
130+
if (instances[instanceLink.idFrom] && instances[instanceLink.idTo]) {
131+
return true;
132+
} else {
133+
return false;
134+
}
135+
}
136+
127137
public getGraphConfig() {
128138
return new GraphConfig();
129139
}

0 commit comments

Comments
 (0)