Skip to content
Snippets Groups Projects
Commit eb074911 authored by Angelo Capossele's avatar Angelo Capossele Committed by Wolfgang Welz
Browse files

:recycle: refactor connectNode (#183)

parent cae647a5
Branches
Tags
No related merge requests found
...@@ -277,16 +277,12 @@ func index(w http.ResponseWriter, r *http.Request) { ...@@ -277,16 +277,12 @@ func index(w http.ResponseWriter, r *http.Request) {
function connectNodes(sourceNodeId, targetNodeId) { function connectNodes(sourceNodeId, targetNodeId) {
if(existingLinks[sourceNodeId + targetNodeId] == undefined) { if(existingLinks[sourceNodeId + targetNodeId] == undefined) {
if (!(sourceNodeId in nodesById)) { if ((sourceNodeId in nodesById) && (targetNodeId in nodesById)) {
addNode(sourceNodeId); //nodesById[sourceNodeId].online = true;
//nodesById[targetNodeId].online = true;
existingLinks[sourceNodeId + targetNodeId] = true
data.links = [...data.links, { source: sourceNodeId, target: targetNodeId }];
} }
if (!(targetNodeId in nodesById)) {
addNode(targetNodeId);
}
nodesById[sourceNodeId].online = true;
nodesById[targetNodeId].online = true;
existingLinks[sourceNodeId + targetNodeId] = true
data.links = [...data.links, { source: sourceNodeId, target: targetNodeId }];
updateGraph(); updateGraph();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment