1
0
Fork 0

GraphViewer: It is now possible to switch collections on the fly

This commit is contained in:
Michael Hackstein 2013-04-15 12:00:15 +02:00
parent 2238f0db0f
commit 810d2ad83f
4 changed files with 100 additions and 6 deletions

View File

@ -469,8 +469,7 @@ function ArangoAdapter(arangodb, nodes, edges, nodeCollection, edgeCollection, w
nodeCollection = nodesCol;
edgeCollection = edgesCol;
api.node = api.base + "document?collection=" + nodeCollection;
api.edge = api.base + "edge?collection=" + edgeCollection;
console.log(api.node);
api.edge = api.base + "edge?collection=" + edgeCollection;
};
}

View File

@ -6,6 +6,7 @@
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
<link rel="stylesheet" type="text/css" href="../style/bootstrap.min.css">
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jslint.js"></script>
@ -14,16 +15,21 @@
<script type="text/javascript" src="../../lib/d3.v3.min.js"></script>
<script type="text/javascript" src="../../lib/underscore.js"></script>
<script type="text/javascript" src="../../lib/jquery-1.8.3.js"></script>
<script type="text/javascript" src="../../lib/bootstrap.js"></script>
<script type="text/javascript" src="../../lib/jquery.livequery.js"></script>
<script type="text/javascript" src="helper/eventHelper.js"></script>
<script type="text/javascript" src="../graph/arangoAdapter.js"></script>
<script type="text/javascript" src="../ui/uiComponentsHelper.js"></script>
<script type="text/javascript" src="../ui/modalDialogHelper.js"></script>
<script type="text/javascript" src="../ui/arangoAdapterControls.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="specAdapter/interfaceSpec.js"></script>
<script type="text/javascript" src="specAdapter/arangoAdapterSpec.js"></script>
<script type="text/javascript" src="specAdapter/arangoAdapterUISpec.js"></script>
<!-- run JSLINT -->
<script type="text/javascript" src="specJSLint/jsLintSpec.js"></script>

View File

@ -43,14 +43,32 @@
beforeEach(function () {
adapter = {
changeTo: function(){}
};
list = document.createElement("ul");
document.body.appendChild(list);
list.id = "control_list";
adapterUI = new ArangoAdapterControls(list, adapter);
spyOn(adapter, 'changeTo');
this.addMatchers({
toBeTag: function(name) {
var el = this.actual;
this.message = function() {
return "Expected " + el.tagName.toLowerCase() + " to be a " + name;
};
return el.tagName.toLowerCase() === name;
},
toConformToListCSS: function() {
var li = this.actual,
a = li.firstChild,
lbl = a.firstChild;
expect(li).toBeTag("li");
expect(a).toBeTag("a");
expect(lbl).toBeTag("label");
return true;
}
});
});
afterEach(function () {
@ -77,8 +95,8 @@
expect($("#control_collections_modal").length).toEqual(1);
$("#control_collections_nodes").attr("value", "newNodes");
$("#control_collections_edges").attr("value", "newEdges");
$("#control_collections_nodecollection").attr("value", "newNodes");
$("#control_collections_edgecollection").attr("value", "newEdges");
helper.simulateMouseEvent("click", "control_collections_submit");
@ -88,5 +106,10 @@
);
});
});
it('should be able to add all controls to the list', function() {
adapterUI.addAll();
expect($("#control_list #control_collections").length).toEqual(1);
});
});
}());

View File

@ -0,0 +1,66 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global $, _, d3*/
/*global document*/
/*global modalDialogHelper, uiComponentsHelper*/
////////////////////////////////////////////////////////////////////////////////
/// @brief Graph functionality
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Michael Hackstein
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
function ArangoAdapterControls(list, adapter) {
"use strict";
if (list === undefined) {
throw "A list element has to be given.";
}
if (adapter === undefined) {
throw "The ArangoAdapter has to be given.";
}
var self = this,
baseClass = "adapter";
this.addControlChangeCollections = function() {
var prefix = "control_collections",
idprefix = prefix + "_";
uiComponentsHelper.createButton(baseClass, list, "Collections", prefix, function() {
modalDialogHelper.createModalDialog("Switch Collections",
idprefix, [{
type: "text",
id: "nodecollection"
},{
type: "text",
id: "edgecollection"
}], function () {
var nodes = $("#" + idprefix + "nodecollection").attr("value"),
edges = $("#" + idprefix + "edgecollection").attr("value");
adapter.changeTo(nodes, edges);
}
);
});
};
this.addAll = function() {
this.addControlChangeCollections();
};
}