mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: Fixed Bug in load Graph by Attribute. Now this works and can be used in demo
This commit is contained in:
parent
e2068ece03
commit
7e8607ffed
|
@ -156,6 +156,10 @@
|
||||||
viewer.loadGraph($("#startNode").attr("value"));
|
viewer.loadGraph($("#startNode").attr("value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadGraphFromAttribute() {
|
||||||
|
viewer.loadGraphWithAttributeValue($("#attribute").attr("value"), $("#value").attr("value"));
|
||||||
|
}
|
||||||
|
|
||||||
function createViewer() {
|
function createViewer() {
|
||||||
var nshape,
|
var nshape,
|
||||||
nlabel,
|
nlabel,
|
||||||
|
@ -368,6 +372,32 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
<br />
|
||||||
|
<form action="javascript:void(0);" autocomplete="on" class="form-vertical" id="creationDialog2">
|
||||||
|
<fieldset>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="attribute" placeholder="Attribute" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="value" placeholder="Value" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<button type="submit" class="btn btn-primary" onclick="loadGraphFromAttribute()">Load</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<button id="createNode" type="submit" class="btn btn-primary">Create Node</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -165,6 +165,7 @@ function ArangoAdapter(arangodb, nodes, edges, nodeCollection, edgeCollection, w
|
||||||
insertEdge(edge);
|
insertEdge(edge);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
console.log(result);
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result[0].vertex);
|
callback(result[0].vertex);
|
||||||
}
|
}
|
||||||
|
@ -261,20 +262,21 @@ function ArangoAdapter(arangodb, nodes, edges, nodeCollection, edgeCollection, w
|
||||||
};
|
};
|
||||||
|
|
||||||
self.loadNodeFromTreeByAttributeValue = function(attribute, value, callback) {
|
self.loadNodeFromTreeByAttributeValue = function(attribute, value, callback) {
|
||||||
var loadNodeQuery =
|
var traversal = "FOR n in "
|
||||||
"FOR n IN " + nodeCollection
|
+ nodeCollection
|
||||||
+ "FILTER n." + attribute + " == \"" + value + "\""
|
+ " FILTER n." + attribute
|
||||||
+ "LET links = ("
|
+ " == " + JSON.stringify(value)
|
||||||
+ " FOR l IN " + edgeCollection
|
+ " RETURN TRAVERSAL("
|
||||||
+ " FILTER n._id == l._from"
|
+ nodeCollection + ", "
|
||||||
+ " FOR t IN " + nodeCollection
|
+ edgeCollection + ", "
|
||||||
+ " FILTER t._id == l._to"
|
+ "n._id, "
|
||||||
+ " RETURN t._id"
|
+ "\"outbound\", {"
|
||||||
+ ")"
|
+ "strategy: \"depthfirst\","
|
||||||
+ "RETURN MERGE(n, {\"children\" : links})";
|
+ "maxDepth: 1,"
|
||||||
|
+ "paths: true"
|
||||||
sendQuery(loadNodeQuery, function(res) {
|
+ "})";
|
||||||
parseResultOfQuery(res, callback);
|
sendQuery(traversal, function(res) {
|
||||||
|
parseResultOfTraversal(res, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
self.rebind = function(eventConfig) {
|
||||||
bindEventsFromConfig(eventConfig);
|
bindEventsFromConfig(eventConfig);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue