Skip to content

Commit

Permalink
Bit of work towards #831, add a currently empty handler for connectio…
Browse files Browse the repository at this point in the history
…nDetached and add a handler for new connections
  • Loading branch information
gashcrumb committed Dec 11, 2013
1 parent 4988dc2 commit fe20737
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions hawtio-web/src/main/webapp/app/wiki/js/camelCanvas.ts
Expand Up @@ -297,10 +297,7 @@ module Wiki {
}

function showGraph(nodes, links) {
var width = getWidth();
var height = Camel.getCanvasHeight($($element));
layoutGraph(nodes, links, width, height);
return width;
layoutGraph(nodes, links);
}

function getNodeId(node) {
Expand Down Expand Up @@ -336,7 +333,7 @@ module Wiki {
return jsPlumb;
}

function layoutGraph(nodes, links, width, height) {
function layoutGraph(nodes, links) {
var transitions = [];
var states = Core.createGraphStates(nodes, links, transitions);

Expand Down Expand Up @@ -500,6 +497,27 @@ module Wiki {
alert("double click on connection from " + connection.sourceId + " to " + connection.targetId);
});

// TODO implement these
jsPlumb.bind('connection', function(info, evt) {
//log.debug("Connection event: ", info);
log.debug("Creating connection from ", info.source.get(0).id, " to ", info.target.get(0).id);
log.debug("Nodes:" , nodes);
var link = getLink(info);
var source:Folder = $scope.folders[link.source];
var target:Folder = $scope.folders[link.target];
source.moveChild(target);
treeModified();
});

jsPlumb.bind('connectionDetached', function(info, evt) {
//log.debug("Connection detach event: ", info);
log.debug("Detaching connection from ", info.source.get(0).id, " to ", info.target.get(0).id);
var link = getLink(info);
var source:Folder = $scope.folders[link.source];
var target:Folder = $scope.folders[link.target];
// TODO orphan target folder without actually deleting it
});

// lets delete connections on click
jsPlumb.bind("click", function (c) {
jsPlumb.detach(c);
Expand All @@ -515,6 +533,25 @@ module Wiki {
return states;
}

function removeEdge(source, target) {

}

function getLink(info) {
var sourceId = info.source.get(0).id;
var targetId = info.target.get(0).id;
return {
source: sourceId,
target: targetId
}
}

function getNodeByCID(nodes, cid) {
return nodes.find((node) => {
return node.cid === cid;
});
}

/*
* Updates the selection with the given folder or ID
*/
Expand Down

0 comments on commit fe20737

Please sign in to comment.