diff --git a/html/admin/js/graphViewer/graph/arangoAdapter.js b/html/admin/js/graphViewer/graph/arangoAdapter.js index 0b251a01a4..db5fbfe169 100644 --- a/html/admin/js/graphViewer/graph/arangoAdapter.js +++ b/html/admin/js/graphViewer/graph/arangoAdapter.js @@ -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; + } + }); + } + }; } \ No newline at end of file diff --git a/html/admin/js/graphViewer/jasmine_test/specAdapter/arangoAdapterSpec.js b/html/admin/js/graphViewer/jasmine_test/specAdapter/arangoAdapterSpec.js index 223a730a1d..d19c7e7331 100644 --- a/html/admin/js/graphViewer/jasmine_test/specAdapter/arangoAdapterSpec.js +++ b/html/admin/js/graphViewer/jasmine_test/specAdapter/arangoAdapterSpec.js @@ -438,7 +438,43 @@ }; }; }); - + + 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() { diff --git a/html/admin/js/templates/graphView.ejs b/html/admin/js/templates/graphView.ejs index 88c5ead42e..117433b683 100644 --- a/html/admin/js/templates/graphView.ejs +++ b/html/admin/js/templates/graphView.ejs @@ -1,52 +1,54 @@ -
-
- Configuration -
- -
- -
-
-
- -
- -
-
- -
- -
-
- - Advanced - +
+ +
+ Configuration +
+ +
+
+
+
+ +
+ +
+
+ +
-
-
-
- -
- +
+ + +
+
+
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
-
- +
+
+ +
-
-
- \ No newline at end of file +
+ + \ No newline at end of file