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

@ -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 ' it('should be able to load a tree node from '
+ 'ArangoDB by internal _id attribute', function() { + 'ArangoDB by internal _id attribute', function() {

View File

@ -1,52 +1,54 @@
<form action="javascript:void(0);" autocomplete="on" class="form-horizontal" id="creationDialog"> <div class="thumbnails" id="background">
<fieldset> <form action="javascript:void(0);" autocomplete="on" class="form-horizontal" id="creationDialog">
<legend>Configuration</legend> <fieldset>
<div class="control-group"> <legend>Configuration</legend>
<label for="nodeCollection" class="control-label">Node Collection</label> <div class="control-group">
<div class="controls"> <label for="nodeCollection" class="control-label">Node Collection</label>
<input id="nodeCollection" type="text" name="nodeCollection" placeholder="Node Collection" maxlength="75" class="input-xlarge" value="Classes"> <div class="controls">
</div> <input id="nodeCollection" type="text" name="nodeCollection" placeholder="Node Collection" maxlength="75" class="input-xlarge" value="Classes">
</div>
<div class="control-group">
<label for="edgeCollection" class="control-label">Edge Collection</label>
<div class="controls">
<input id="edgeCollection" type="text" name="edgeCollection" placeholder="Edge Collection" maxlength="75" class="input-xlarge" value="Connections">
</div>
</div>
<div class="accordion" id="advancedGraphOptions">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#advancedGraphOptions" href="#advancedOptions">
Advanced
</a>
</div> </div>
</div>
<div class="control-group">
<label for="edgeCollection" class="control-label">Edge Collection</label>
<div class="controls">
<input id="edgeCollection" type="text" name="edgeCollection" placeholder="Edge Collection" maxlength="75" class="input-xlarge" value="Connections">
</div>
</div>
<div class="accordion" id="advancedGraphOptions">
<div id="advancedOptions" class="accordion-body collapse out"> <div class="accordion-group">
<div class="accordion-inner"> <div class="accordion-heading">
<div class="control-group"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#advancedGraphOptions" href="#advancedOptions">
<label for="undirected" class="control-label">Undirected Graph</label> Advanced
<div class="controls"> </a>
<input id="undirected" type="checkbox" name="undirected" class="input-xlarge"> </div>
<div id="advancedOptions" class="accordion-body collapse out">
<div class="accordion-inner">
<div class="control-group">
<label for="undirected" class="control-label">Undirected Graph</label>
<div class="controls">
<input id="undirected" type="checkbox" name="undirected" class="input-xlarge">
</div>
</div> </div>
</div> <div class="control-group">
<div class="control-group"> <label for="nodeLabel" class="control-label">Node Label</label>
<label for="nodeLabel" class="control-label">Node Label</label> <div class="controls">
<div class="controls"> <input id="nodeLabel" type="text" name="nodeLabel" placeholder="Node Label" maxlength="75" class="input-xlarge">
<input id="nodeLabel" type="text" name="nodeLabel" placeholder="Node Label" maxlength="75" class="input-xlarge"> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<button type="submit" class="btn btn-primary" id="createViewer" >Start</button> <button type="submit" class="btn btn-primary" id="createViewer" >Start</button>
</div>
</div> </div>
</div> </fieldset>
</fieldset> </form>
</form> </div>