1
0
Fork 0

GraphViewer: The ArangoAdapter can now deliver the available collections

This commit is contained in:
Michael Hackstein 2013-05-24 16:51:58 +02:00
parent fe2825df88
commit 6592881302
3 changed files with 110 additions and 42 deletions

View File

@ -717,4 +717,34 @@ function ArangoAdapter(nodes, edges, config) {
}
};
self.getCollections = function(callback) {
if (callback && callback.length >= 2) {
$.ajax({
cache: false,
type: "GET",
url: api.collection,
contentType: "application/json",
dataType: "json",
processData: false,
success: function(data) {
var cols = data.collections,
docs = [],
edgeCols = [];
_.each(cols, function(c) {
if (!c.name.match(/^_/)) {
if (c.type === 3) {
edgeCols.push(c.name);
} else if (c.type === 2){
docs.push(c.name);
}
}
});
callback(docs, edgeCols);
},
error: function(data) {
throw data.statusText;
}
});
}
};
}

View File

@ -439,6 +439,42 @@
};
});
it('should offer lists of available collections', function() {
var collections = [],
sys1 = {id: "1", name: "_sys1", status: 3, type: 2},
sys2 = {id: "2", name: "_sys2", status: 2, type: 2},
doc1 = {id: "3", name: "doc1", status: 3, type: 2},
doc2 = {id: "4", name: "doc2", status: 2, type: 2},
doc3 = {id: "5", name: "doc3", status: 3, type: 2},
edge1 = {id: "6", name: "edge1", status: 3, type: 3},
edge2 = {id: "7", name: "edge2", status: 2, type: 3};
collections.push(sys1);
collections.push(sys2);
collections.push(doc1);
collections.push(doc2);
collections.push(doc3);
collections.push(edge1);
collections.push(edge2);
spyOn($, "ajax").andCallFake(function(request) {
request.success({collections: collections});
});
adapter.getCollections(function(docs, edge) {
expect(docs).toContain("doc1");
expect(docs).toContain("doc2");
expect(docs).toContain("doc3");
expect(docs.length).toEqual(3);
expect(edge).toContain("edge1");
expect(edge).toContain("edge2");
expect(edge.length).toEqual(2);
});
});
it('should be able to load a tree node from '
+ 'ArangoDB by internal _id attribute', function() {

View File

@ -1,4 +1,5 @@
<form action="javascript:void(0);" autocomplete="on" class="form-horizontal" id="creationDialog">
<div class="thumbnails" id="background">
<form action="javascript:void(0);" autocomplete="on" class="form-horizontal" id="creationDialog">
<fieldset>
<legend>Configuration</legend>
<div class="control-group">
@ -49,4 +50,5 @@
</div>
</div>
</fieldset>
</form>
</form>
</div>