diff --git a/html/admin/js/graphViewer/demo.html b/html/admin/js/graphViewer/demo.html index 456e988bc7..29b143574b 100644 --- a/html/admin/js/graphViewer/demo.html +++ b/html/admin/js/graphViewer/demo.html @@ -156,6 +156,10 @@ viewer.loadGraph($("#startNode").attr("value")); } + function loadGraphFromAttribute() { + viewer.loadGraphWithAttributeValue($("#attribute").attr("value"), $("#value").attr("value")); + } + function createViewer() { var nshape, nlabel, @@ -368,6 +372,32 @@ +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/html/admin/js/graphViewer/graph/arangoAdapter.js b/html/admin/js/graphViewer/graph/arangoAdapter.js index a72cf4a5b9..7faa6bd8fe 100644 --- a/html/admin/js/graphViewer/graph/arangoAdapter.js +++ b/html/admin/js/graphViewer/graph/arangoAdapter.js @@ -165,6 +165,7 @@ function ArangoAdapter(arangodb, nodes, edges, nodeCollection, edgeCollection, w insertEdge(edge); }); }); + console.log(result); if (callback) { callback(result[0].vertex); } @@ -261,20 +262,21 @@ function ArangoAdapter(arangodb, nodes, edges, nodeCollection, edgeCollection, w }; self.loadNodeFromTreeByAttributeValue = function(attribute, value, callback) { - var loadNodeQuery = - "FOR n IN " + nodeCollection - + "FILTER n." + attribute + " == \"" + value + "\"" - + "LET links = (" - + " FOR l IN " + edgeCollection - + " FILTER n._id == l._from" - + " FOR t IN " + nodeCollection - + " FILTER t._id == l._to" - + " RETURN t._id" - + ")" - + "RETURN MERGE(n, {\"children\" : links})"; - - sendQuery(loadNodeQuery, function(res) { - parseResultOfQuery(res, callback); + var traversal = "FOR n in " + + nodeCollection + + " FILTER n." + attribute + + " == " + JSON.stringify(value) + + " RETURN TRAVERSAL(" + + nodeCollection + ", " + + edgeCollection + ", " + + "n._id, " + + "\"outbound\", {" + + "strategy: \"depthfirst\"," + + "maxDepth: 1," + + "paths: true" + + "})"; + sendQuery(traversal, function(res) { + parseResultOfTraversal(res, callback); }); }; diff --git a/html/admin/js/graphViewer/graphViewer.js b/html/admin/js/graphViewer/graphViewer.js index 7fdf53252c..16d6fa72fe 100644 --- a/html/admin/js/graphViewer/graphViewer.js +++ b/html/admin/js/graphViewer/graphViewer.js @@ -258,6 +258,18 @@ function GraphViewer(svg, width, height, }); }; + self.loadGraphWithAttributeValue = function(attribute, value) { + nodes.length = 0; + edges.length = 0; + adapter.loadNodeFromTreeByAttributeValue(attribute, value, function (node) { + node._expanded = true; + node.x = width / 2; + node.y = height / 2; + node.fixed = true; + start(); + }); + }; + self.rebind = function(eventConfig) { bindEventsFromConfig(eventConfig); };