mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel
This commit is contained in:
commit
13f91392bb
|
@ -664,9 +664,9 @@ TRI_associative_pointer_t* TRI_CreateFunctionsAql (void) {
|
|||
REGISTER_FUNCTION("GRAPH_SHORTEST_PATH", "GENERAL_GRAPH_SHORTEST_PATH", false, false, "s,als,als|a", NULL);
|
||||
REGISTER_FUNCTION("GRAPH_DISTANCE_TO", "GENERAL_GRAPH_DISTANCE_TO", false, false, "s,als,als|a", NULL);
|
||||
REGISTER_FUNCTION("TRAVERSAL", "GRAPH_TRAVERSAL", false, false, "h,h,s,s|a", NULL);
|
||||
REGISTER_FUNCTION("GRAPH_TRAVERSAL", "GENERAL_GRAPH_TRAVERSAL", false, false, "s,s,s|a", NULL);
|
||||
REGISTER_FUNCTION("GRAPH_TRAVERSAL", "GENERAL_GRAPH_TRAVERSAL", false, false, "s,als,s|a", NULL);
|
||||
REGISTER_FUNCTION("TRAVERSAL_TREE", "GRAPH_TRAVERSAL_TREE", false, false, "h,h,s,s,s|a", NULL);
|
||||
REGISTER_FUNCTION("GRAPH_TRAVERSAL_TREE", "GENERAL_GRAPH_TRAVERSAL_TREE", false, false, "s,s,s,s|a", NULL);
|
||||
REGISTER_FUNCTION("GRAPH_TRAVERSAL_TREE", "GENERAL_GRAPH_TRAVERSAL_TREE", false, false, "s,als,s,s|a", NULL);
|
||||
REGISTER_FUNCTION("EDGES", "GRAPH_EDGES", false, false, "h,s,s|l", NULL);
|
||||
REGISTER_FUNCTION("GRAPH_EDGES", "GENERAL_GRAPH_EDGES", false, false, "s,als|a", NULL);
|
||||
REGISTER_FUNCTION("GRAPH_VERTICES", "GENERAL_GRAPH_VERTICES", false, false, "s,als|a", NULL);
|
||||
|
|
|
@ -161,6 +161,18 @@ function EventLibrary() {
|
|||
});
|
||||
};
|
||||
};
|
||||
|
||||
this.SelectNodeCollection = function(config) {
|
||||
self.checkNodeEditorConfig(config);
|
||||
var adapter = config.adapter;
|
||||
if (!_.isFunction(adapter.useNodeCollection)) {
|
||||
throw "The adapter has to support collection changes";
|
||||
}
|
||||
return function(name, callback) {
|
||||
adapter.useNodeCollection(name);
|
||||
callback();
|
||||
};
|
||||
};
|
||||
|
||||
this.InsertEdge = function (config) {
|
||||
self.checkEdgeEditorConfig(config);
|
||||
|
|
|
@ -0,0 +1,532 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global $, d3, _, console, document*/
|
||||
/*global AbstractAdapter*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @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 GharialAdapter(nodes, edges, viewer, config) {
|
||||
"use strict";
|
||||
|
||||
if (nodes === undefined) {
|
||||
throw "The nodes have to be given.";
|
||||
}
|
||||
if (edges === undefined) {
|
||||
throw "The edges have to be given.";
|
||||
}
|
||||
if (viewer === undefined) {
|
||||
throw "A reference to the graph viewer has to be given.";
|
||||
}
|
||||
if (config === undefined) {
|
||||
throw "A configuration with graphName has to be given.";
|
||||
}
|
||||
if (config.graphName === undefined) {
|
||||
throw "The graphname has to be given.";
|
||||
}
|
||||
|
||||
var self = this,
|
||||
absAdapter,
|
||||
absConfig = {},
|
||||
api = {},
|
||||
queries = {},
|
||||
nodeCollections,
|
||||
selectedNodeCol,
|
||||
edgeCollections,
|
||||
selectedEdgeCol,
|
||||
graphName,
|
||||
direction,
|
||||
|
||||
getCollectionsFromGraph = function(name) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: 'GET',
|
||||
async: false,
|
||||
url: api.graph + "/" + name + "/edge",
|
||||
contentType: "application/json",
|
||||
success: function(data) {
|
||||
edgeCollections = data.collections;
|
||||
selectedEdgeCol = edgeCollections[0];
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: 'GET',
|
||||
async: false,
|
||||
url: api.graph + "/" + name + "/vertex",
|
||||
contentType: "application/json",
|
||||
success: function(data) {
|
||||
nodeCollections = data.collections;
|
||||
selectedNodeCol = nodeCollections[0];
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setGraphName = function(name) {
|
||||
graphName = name;
|
||||
getCollectionsFromGraph(name);
|
||||
api.edges = api.graph + "/" + graphName + "/edge/";
|
||||
api.vertices = api.graph + "/" + graphName + "/vertex/";
|
||||
api.any = api.base + "simple/any";
|
||||
},
|
||||
|
||||
parseConfig = function(config) {
|
||||
var arangodb = config.baseUrl || "";
|
||||
if (config.width !== undefined) {
|
||||
absAdapter.setWidth(config.width);
|
||||
}
|
||||
if (config.height !== undefined) {
|
||||
absAdapter.setHeight(config.height);
|
||||
}
|
||||
if (config.undirected !== undefined) {
|
||||
if (config.undirected === true) {
|
||||
direction = "any";
|
||||
} else {
|
||||
direction = "outbound";
|
||||
}
|
||||
} else {
|
||||
direction = "outbound";
|
||||
}
|
||||
|
||||
api.base = arangodb + "_api/";
|
||||
api.cursor = api.base + "cursor";
|
||||
api.graph = api.base + "gharial";
|
||||
|
||||
if (config.graphName) {
|
||||
setGraphName(config.graphName);
|
||||
}
|
||||
},
|
||||
|
||||
sendQuery = function(query, bindVars, onSuccess) {
|
||||
if (query !== queries.getAllGraphs) {
|
||||
bindVars.graph = graphName;
|
||||
if (query !== queries.connectedEdges
|
||||
&& query !== queries.childrenCentrality) {
|
||||
bindVars.dir = direction;
|
||||
}
|
||||
}
|
||||
var data = {
|
||||
query: query,
|
||||
bindVars: bindVars
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: api.cursor,
|
||||
data: JSON.stringify(data),
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
onSuccess(data.result);
|
||||
},
|
||||
error: function(data) {
|
||||
try {
|
||||
console.log(data.statusText);
|
||||
throw "[" + data.errorNum + "] " + data.errorMessage;
|
||||
}
|
||||
catch (e) {
|
||||
throw "Undefined ERROR";
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getNRandom = function(n, callback) {
|
||||
var list = [],
|
||||
i = 0,
|
||||
rand,
|
||||
onSuccess = function(data) {
|
||||
list.push(data.document || {});
|
||||
if (list.length === n) {
|
||||
callback(list);
|
||||
}
|
||||
};
|
||||
for (i = 0; i < n; i++) {
|
||||
rand = Math.floor(Math.random() * nodeCollections.length);
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: 'PUT',
|
||||
url: api.any,
|
||||
data: JSON.stringify({
|
||||
collection: nodeCollections[rand]
|
||||
}),
|
||||
contentType: "application/json",
|
||||
success: onSuccess
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
parseResultOfTraversal = function (result, callback) {
|
||||
if (result.length === 0) {
|
||||
if (callback) {
|
||||
callback({
|
||||
errorCode: 404
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
result = result[0];
|
||||
if (result.length === 0) {
|
||||
if (callback) {
|
||||
callback({
|
||||
errorCode: 404
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
var inserted = {},
|
||||
n = absAdapter.insertNode(result[0].vertex),
|
||||
oldLength = nodes.length;
|
||||
|
||||
_.each(result, function(visited) {
|
||||
var node = absAdapter.insertNode(visited.vertex),
|
||||
path = visited.path;
|
||||
if (oldLength < nodes.length) {
|
||||
inserted[node._id] = node;
|
||||
oldLength = nodes.length;
|
||||
}
|
||||
_.each(path.vertices, function(connectedNode) {
|
||||
var ins = absAdapter.insertNode(connectedNode);
|
||||
if (oldLength < nodes.length) {
|
||||
inserted[ins._id] = ins;
|
||||
oldLength = nodes.length;
|
||||
}
|
||||
});
|
||||
_.each(path.edges, function(edge) {
|
||||
absAdapter.insertEdge(edge);
|
||||
});
|
||||
});
|
||||
delete inserted[n._id];
|
||||
absAdapter.checkSizeOfInserted(inserted);
|
||||
absAdapter.checkNodeLimit(n);
|
||||
if (callback) {
|
||||
callback(n);
|
||||
}
|
||||
},
|
||||
|
||||
insertInitialCallback = function(callback) {
|
||||
return function (n) {
|
||||
if (n && n.errorCode) {
|
||||
callback(n);
|
||||
return;
|
||||
}
|
||||
callback(absAdapter.insertInitialNode(n));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
if (config.prioList) {
|
||||
absConfig.prioList = config.prioList;
|
||||
}
|
||||
absAdapter = new AbstractAdapter(nodes, edges, this, viewer, absConfig);
|
||||
|
||||
parseConfig(config);
|
||||
|
||||
queries.getAllGraphs = "FOR g IN _graphs"
|
||||
+ " return g._key";
|
||||
queries.traversal = "RETURN GRAPH_TRAVERSAL("
|
||||
+ "@graph, "
|
||||
+ "@example, "
|
||||
+ "@dir, {"
|
||||
+ "strategy: \"depthfirst\","
|
||||
+ "maxDepth: 1,"
|
||||
+ "paths: true"
|
||||
+ "})";
|
||||
queries.childrenCentrality = "RETURN LENGTH(GRAPH_EDGES(@graph, @id, {direction: any}))";
|
||||
queries.connectedEdges = "RETURN GRAPH_EDGES(@graph, @id)";
|
||||
|
||||
self.explore = absAdapter.explore;
|
||||
|
||||
self.loadNode = function(nodeId, callback) {
|
||||
self.loadNodeFromTreeById(nodeId, callback);
|
||||
};
|
||||
|
||||
self.loadRandomNode = function(callback) {
|
||||
getNRandom(1, function(list) {
|
||||
var r = list[0];
|
||||
if (r._id) {
|
||||
self.loadInitialNode(r._id, callback);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
});
|
||||
};
|
||||
|
||||
self.loadInitialNode = function(nodeId, callback) {
|
||||
absAdapter.cleanUp();
|
||||
self.loadNode(nodeId, insertInitialCallback(callback));
|
||||
};
|
||||
|
||||
self.loadNodeFromTreeById = function(nodeId, callback) {
|
||||
sendQuery(queries.traversal, {
|
||||
example: nodeId
|
||||
}, function(res) {
|
||||
parseResultOfTraversal(res, callback);
|
||||
});
|
||||
};
|
||||
|
||||
self.loadNodeFromTreeByAttributeValue = function(attribute, value, callback) {
|
||||
var example = {};
|
||||
example[attribute] = value;
|
||||
sendQuery(queries.traversal, {
|
||||
example: example
|
||||
}, function(res) {
|
||||
parseResultOfTraversal(res, callback);
|
||||
});
|
||||
};
|
||||
|
||||
self.loadInitialNodeByAttributeValue = function(attribute, value, callback) {
|
||||
absAdapter.cleanUp();
|
||||
self.loadNodeFromTreeByAttributeValue(attribute, value, insertInitialCallback(callback));
|
||||
};
|
||||
|
||||
self.requestCentralityChildren = function(nodeId, callback) {
|
||||
sendQuery(queries.childrenCentrality,{
|
||||
id: nodeId
|
||||
}, function(res) {
|
||||
callback(res[0]);
|
||||
});
|
||||
};
|
||||
|
||||
self.createEdge = function (info, callback) {
|
||||
var edgeToAdd = {};
|
||||
edgeToAdd._from = info.source._id;
|
||||
edgeToAdd._to = info.target._id;
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
url: api.edges + selectedEdgeCol,
|
||||
data: JSON.stringify(edgeToAdd),
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
data._from = edgeToAdd._from;
|
||||
data._to = edgeToAdd._to;
|
||||
delete data.error;
|
||||
var edge = absAdapter.insertEdge(data);
|
||||
callback(edge);
|
||||
},
|
||||
error: function(data) {
|
||||
throw data.statusText;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.deleteEdge = function (edgeToRemove, callback) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "DELETE",
|
||||
url: api.edges + edgeToRemove._id,
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
processData: false,
|
||||
success: function() {
|
||||
absAdapter.removeEdge(edgeToRemove);
|
||||
if (callback !== undefined && _.isFunction(callback)) {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
throw data.statusText;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.patchEdge = function (edgeToPatch, patchData, callback) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "PUT",
|
||||
url: api.edges + edgeToPatch._id,
|
||||
data: JSON.stringify(patchData),
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function() {
|
||||
edgeToPatch._data = $.extend(edgeToPatch._data, patchData);
|
||||
callback();
|
||||
},
|
||||
error: function(data) {
|
||||
throw data.statusText;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.createNode = function (nodeToAdd, callback) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
url: api.vertices + selectedNodeCol,
|
||||
data: JSON.stringify(nodeToAdd),
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
if (data.error === false) {
|
||||
nodeToAdd._key = data._key;
|
||||
nodeToAdd._id = data._id;
|
||||
nodeToAdd._rev = data._rev;
|
||||
absAdapter.insertNode(nodeToAdd);
|
||||
callback(nodeToAdd);
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
throw data.statusText;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.deleteNode = function (nodeToRemove, callback) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "DELETE",
|
||||
url: api.vertices + nodeToRemove._id,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function() {
|
||||
absAdapter.removeEdgesForNode(nodeToRemove);
|
||||
absAdapter.removeNode(nodeToRemove);
|
||||
if (callback !== undefined && _.isFunction(callback)) {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
throw data.statusText;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.patchNode = function (nodeToPatch, patchData, callback) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "PUT",
|
||||
url: api.vertices + nodeToPatch._id,
|
||||
data: JSON.stringify(patchData),
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function() {
|
||||
nodeToPatch._data = $.extend(nodeToPatch._data, patchData);
|
||||
callback(nodeToPatch);
|
||||
},
|
||||
error: function(data) {
|
||||
throw data.statusText;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.changeToGraph = function (name, dir) {
|
||||
absAdapter.cleanUp();
|
||||
setGraphName(name);
|
||||
if (dir !== undefined) {
|
||||
if (dir === true) {
|
||||
direction = "any";
|
||||
} else {
|
||||
direction = "outbound";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.setNodeLimit = function (pLimit, callback) {
|
||||
absAdapter.setNodeLimit(pLimit, callback);
|
||||
};
|
||||
|
||||
self.setChildLimit = function (pLimit) {
|
||||
absAdapter.setChildLimit(pLimit);
|
||||
};
|
||||
|
||||
self.expandCommunity = function (commNode, callback) {
|
||||
absAdapter.expandCommunity(commNode);
|
||||
if (callback !== undefined) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
self.getGraphs = function(callback) {
|
||||
if (callback && callback.length >= 1) {
|
||||
sendQuery(
|
||||
queries.getAllGraphs,
|
||||
{},
|
||||
callback
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
self.getAttributeExamples = function(callback) {
|
||||
if (callback && callback.length >= 1) {
|
||||
getNRandom(10, function(l) {
|
||||
var ret = _.sortBy(
|
||||
_.uniq(
|
||||
_.flatten(
|
||||
_.map(l, function(o) {
|
||||
return _.keys(o);
|
||||
})
|
||||
)
|
||||
), function(e) {
|
||||
return e.toLowerCase();
|
||||
}
|
||||
);
|
||||
callback(ret);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
self.getEdgeCollections = function() {
|
||||
return edgeCollections;
|
||||
};
|
||||
|
||||
self.useEdgeCollection = function(name) {
|
||||
if (!_.contains(edgeCollections, name)) {
|
||||
throw "Collection " + name + " is not available in the graph.";
|
||||
}
|
||||
selectedEdgeCol = name;
|
||||
};
|
||||
|
||||
self.getNodeCollections = function() {
|
||||
return nodeCollections;
|
||||
};
|
||||
|
||||
self.useNodeCollection = function(name) {
|
||||
if (!_.contains(nodeCollections, name)) {
|
||||
throw "Collection " + name + " is not available in the graph.";
|
||||
}
|
||||
selectedNodeCol = name;
|
||||
};
|
||||
|
||||
self.getDirection = function () {
|
||||
return direction;
|
||||
};
|
||||
|
||||
self.getGraphName = function () {
|
||||
return graphName;
|
||||
};
|
||||
|
||||
self.setWidth = absAdapter.setWidth;
|
||||
self.changeTo = absAdapter.changeTo;
|
||||
self.getPrioList = absAdapter.getPrioList;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global _, $*/
|
||||
/*global ArangoAdapter, JSONAdapter, FoxxAdapter, PreviewAdapter */
|
||||
/*global ArangoAdapter, JSONAdapter, FoxxAdapter, PreviewAdapter, GharialAdapter*/
|
||||
/*global ForceLayouter, EdgeShaper, NodeShaper, ZoomManager */
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
|
@ -136,6 +136,17 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
|
|||
);
|
||||
adapter.setChildLimit(10);
|
||||
break;
|
||||
case "gharial":
|
||||
adapterConfig.width = width;
|
||||
adapterConfig.height = height;
|
||||
adapter = new GharialAdapter(
|
||||
nodes,
|
||||
edges,
|
||||
this,
|
||||
adapterConfig
|
||||
);
|
||||
adapter.setChildLimit(10);
|
||||
break;
|
||||
case "foxx":
|
||||
adapterConfig.width = width;
|
||||
adapterConfig.height = height;
|
||||
|
@ -197,6 +208,20 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.loadGraphWithRandomStart = function(callback) {
|
||||
adapter.loadRandomNode(function (node) {
|
||||
if (node.errorCode) {
|
||||
callback(node);
|
||||
return;
|
||||
}
|
||||
node._expanded = true;
|
||||
self.start();
|
||||
if (_.isFunction(callback)) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.loadGraphWithAttributeValue = function(attribute, value, callback) {
|
||||
adapter.loadInitialNodeByAttributeValue(attribute, value, function (node) {
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/*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 GharialAdapterControls(list, adapter) {
|
||||
"use strict";
|
||||
|
||||
if (list === undefined) {
|
||||
throw "A list element has to be given.";
|
||||
}
|
||||
if (adapter === undefined) {
|
||||
throw "The GharialAdapter has to be given.";
|
||||
}
|
||||
this.addControlChangeGraph = function(callback) {
|
||||
var prefix = "control_adapter_graph",
|
||||
idprefix = prefix + "_";
|
||||
|
||||
adapter.getGraphs(function(graphs) {
|
||||
uiComponentsHelper.createButton(list, "Graph", prefix, function() {
|
||||
modalDialogHelper.createModalDialog("Switch Graph",
|
||||
idprefix, [{
|
||||
type: "list",
|
||||
id: "graph",
|
||||
objects: graphs,
|
||||
text: "Select graph",
|
||||
selected: adapter.getGraphName()
|
||||
},{
|
||||
type: "checkbox",
|
||||
text: "Start with random vertex",
|
||||
id: "random",
|
||||
selected: true
|
||||
},{
|
||||
type: "checkbox",
|
||||
id: "undirected",
|
||||
selected: (adapter.getDirection() === "any")
|
||||
}], function () {
|
||||
var graph = $("#" + idprefix + "graph")
|
||||
.children("option")
|
||||
.filter(":selected")
|
||||
.text(),
|
||||
undirected = !!$("#" + idprefix + "undirected").prop("checked"),
|
||||
random = !!$("#" + idprefix + "random").prop("checked");
|
||||
adapter.changeToGraph(graph, undirected);
|
||||
if (random) {
|
||||
adapter.loadRandomNode(callback);
|
||||
return;
|
||||
}
|
||||
if (_.isFunction(callback)) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.addControlChangePriority = function() {
|
||||
var prefix = "control_adapter_priority",
|
||||
idprefix = prefix + "_",
|
||||
label = "Group vertices";
|
||||
|
||||
uiComponentsHelper.createButton(list, label, prefix, function() {
|
||||
modalDialogHelper.createModalChangeDialog(label,
|
||||
idprefix, [{
|
||||
type: "extendable",
|
||||
id: "attribute",
|
||||
objects: adapter.getPrioList()
|
||||
}], function () {
|
||||
var attrList = $("input[id^=" + idprefix + "attribute_]"),
|
||||
prios = [];
|
||||
_.each(attrList, function(t) {
|
||||
var val = $(t).val();
|
||||
if (val !== "") {
|
||||
prios.push(val);
|
||||
}
|
||||
});
|
||||
adapter.changeTo({
|
||||
prioList: prios
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
this.addAll = function() {
|
||||
this.addControlChangeGraph();
|
||||
this.addControlChangePriority();
|
||||
};
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global document, $, _ */
|
||||
/*global EventDispatcherControls, NodeShaperControls, EdgeShaperControls */
|
||||
/*global LayouterControls, ArangoAdapterControls*/
|
||||
/*global GraphViewer, d3, window*/
|
||||
/*global LayouterControls, GharialAdapterControls*/
|
||||
/*global GraphViewer, d3, window, alert*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
|
@ -375,7 +375,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
|
|||
configureLists.edges,
|
||||
graphViewer.edgeShaper
|
||||
);
|
||||
adapterUI = new ArangoAdapterControls(
|
||||
adapterUI = new GharialAdapterControls(
|
||||
configureLists.col,
|
||||
graphViewer.adapter
|
||||
);
|
||||
|
@ -402,7 +402,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
|
|||
transparentHeader.appendChild(buttons);
|
||||
transparentHeader.appendChild(title);
|
||||
|
||||
adapterUI.addControlChangeCollections(function() {
|
||||
adapterUI.addControlChangeGraph(function() {
|
||||
updateAttributeExamples();
|
||||
graphViewer.start();
|
||||
});
|
||||
|
@ -448,7 +448,15 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
|
|||
createColourList();
|
||||
|
||||
if (startNode) {
|
||||
graphViewer.loadGraph(startNode);
|
||||
if (typeof startNode === "string") {
|
||||
graphViewer.loadGraph(startNode);
|
||||
} else {
|
||||
graphViewer.loadGraphWithRandomStart(function(node) {
|
||||
if (node && node.errorCode) {
|
||||
alert("Sorry your graph seems to be empty");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.changeWidth = function(w) {
|
||||
|
|
|
@ -233,7 +233,7 @@
|
|||
new window.GraphManagementView(
|
||||
{
|
||||
collection: new window.GraphCollection(),
|
||||
collectionCollection: new window.arangoCollections()
|
||||
collectionCollection: this.arangoCollectionsStore
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<tr class="tableRow" id="row_newEdgeDefinitions<%= number%>">
|
||||
<th class="collectionTh">Edge definitions*:</th>
|
||||
<th class="collectionTh">
|
||||
<input onkeypress="return event.keyCode!=13" type="hidden" id="newEdgeDefinitions<%= number%>" value="" placeholder="Edge definitions" tabindex="-1" class="select2-offscreen">
|
||||
<input onkeypress="event.stopPropagation()" type="hidden" id="newEdgeDefinitions<%= number%>" value="" placeholder="Edge definitions" tabindex="-1" class="select2-offscreen">
|
||||
<button id="remove_newEdgeDefinitions<%= number%>" class="graphViewer-icon-button gv_internal_remove_line gv-icon-small delete"></button>
|
||||
</th><th>
|
||||
<a class="modalTooltips" title="Some info for edge definitions">
|
||||
|
@ -13,7 +13,7 @@
|
|||
<tr class="tableRow" id="row_fromCollections<%= number%>">
|
||||
<th class="collectionTh">fromCollections*:</th>
|
||||
<th class="collectionTh">
|
||||
<input onkeypress="return event.keyCode!=13" type="hidden" id="newfromCollections<%= number%>" value="" placeholder="fromCollections" tabindex="-1" class="select2-offscreen">
|
||||
<input onkeypress="event.stopPropagation()" type="hidden" id="newfromCollections<%= number%>" value="" placeholder="fromCollections" tabindex="-1" class="select2-offscreen">
|
||||
</th><th>
|
||||
<a class="modalTooltips" title="The collection that contain the start vertices of the relation.">
|
||||
<span class="arangoicon icon_arangodb_info"></span>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<tr class="tableRow" id="row_toCollections<%= number%>">
|
||||
<th class="collectionTh">toCollections*:</th>
|
||||
<th class="collectionTh">
|
||||
<input onkeypress="return event.keyCode!=13" type="hidden" id="newtoCollections<%= number%>" value="" placeholder="toCollections" tabindex="-1" class="select2-offscreen">
|
||||
<input onkeypress="event.stopPropagation()" type="hidden" id="newtoCollections<%= number%>" value="" placeholder="toCollections" tabindex="-1" class="select2-offscreen">
|
||||
</th><th>
|
||||
<a class="modalTooltips" title="The collection that contain the end vertices of the relation.">
|
||||
<span class="arangoicon icon_arangodb_info"></span>
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
var graphName = graph.get("_key");
|
||||
%>
|
||||
|
||||
<div class="tile">
|
||||
<div class="tile tile-graph" id="<%=graphName %>_tile">
|
||||
<div class="iconSet">
|
||||
<span class="icon_arangodb_settings2 editGraph" id="<%=graphName %>_settings" alt="Edit graph" title="Edit graph"></span>
|
||||
<span class="icon_arangodb_info" id="<%=graphName %>_info" alt="Show graph properties" title="Show graph properties"></span>
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<script id="modalGraphTable.ejs" type="text/template">
|
||||
<%
|
||||
var createTR = function(row) {
|
||||
var createTR = function(row, disableSubmitOnEnter) {
|
||||
var mandatory = '';
|
||||
if (row.mandatory) {
|
||||
mandatory = '*';
|
||||
}
|
||||
|
||||
var disableSubmitOnEnterString = '';
|
||||
if (disableSubmitOnEnter) {
|
||||
disableSubmitOnEnterString = 'onkeypress="event.stopPropagation()"';
|
||||
}
|
||||
%>
|
||||
<tr class="tableRow" id="<%='row_' + row.id%>">
|
||||
<th class="collectionTh"><%=row.label%><%=mandatory%>:</th>
|
||||
|
@ -13,12 +18,12 @@
|
|||
switch(row.type) {
|
||||
case "text":
|
||||
%>
|
||||
<input type="text" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
|
||||
<input <%=disableSubmitOnEnterString%> type="text" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
|
||||
<%
|
||||
break;
|
||||
case "password":
|
||||
%>
|
||||
<input type="password" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
|
||||
<input <%=disableSubmitOnEnterString%> type="password" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
|
||||
<%
|
||||
break;
|
||||
case "readonly":
|
||||
|
@ -36,7 +41,7 @@
|
|||
disabled = 'disabled';
|
||||
}
|
||||
%>
|
||||
<input type="checkbox" id="<%=row.id%>" value="<%=row.value%>" <%=checked%> <%=disabled%>></input>
|
||||
<input <%=disableSubmitOnEnterString%> type="checkbox" id="<%=row.id%>" value="<%=row.value%>" <%=checked%> <%=disabled%>></input>
|
||||
<%
|
||||
break;
|
||||
case "select":
|
||||
|
@ -54,7 +59,7 @@
|
|||
break;
|
||||
case "select2":
|
||||
%>
|
||||
<input type="hidden" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
|
||||
<input <%=disableSubmitOnEnterString%> type="hidden" id="<%=row.id%>" value="<%=row.value||''%>" placeholder="<%=row.placeholder||''%>"></input>
|
||||
<% if (row.addAdd) {%>
|
||||
<button id="<%='addAfter_' + row.id%>" class="graphViewer-icon-button gv-icon-small add"></button>
|
||||
<% } %>
|
||||
|
@ -84,7 +89,7 @@
|
|||
<tbody>
|
||||
<%
|
||||
_.each(content, function(row) {
|
||||
createTR(row);
|
||||
createTR(row, disableSubmitOnEnter);
|
||||
});
|
||||
%>
|
||||
|
||||
|
@ -106,7 +111,7 @@
|
|||
<tbody>
|
||||
<%
|
||||
_.each(advancedContent.content, function(row) {
|
||||
createTR(row);
|
||||
createTR(row, disableSubmitOnEnter);
|
||||
});
|
||||
%>
|
||||
</tbody>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true*/
|
||||
/*global Backbone, $, _, window, templateEngine, arangoHelper*/
|
||||
/*global Backbone, $, _, window, templateEngine, arangoHelper, GraphViewerUI, require */
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
@ -15,12 +15,35 @@
|
|||
"click .icon_arangodb_info" : "info",
|
||||
"click #createGraph" : "addNewGraph",
|
||||
"keyup #graphManagementSearchInput" : "search",
|
||||
"click #graphManagementSearchSubmit" : "search"
|
||||
"click #graphManagementSearchSubmit" : "search",
|
||||
"click .tile-graph" : "loadGraphViewer"
|
||||
},
|
||||
|
||||
loadGraphViewer: function(e) {
|
||||
var name = $(e.currentTarget).attr("id");
|
||||
name = name.substr(0, name.length - 5);
|
||||
var adapterConfig = {
|
||||
type: "gharial",
|
||||
graphName: name,
|
||||
baseUrl: require("internal").arango.databasePrefix("/")
|
||||
};
|
||||
var width = $("#content").width() - 75;
|
||||
$("#content").html("");
|
||||
this.ui = new GraphViewerUI($("#content")[0], adapterConfig, width, 680, {
|
||||
nodeShaper: {
|
||||
label: "_key",
|
||||
color: {
|
||||
type: "attribute",
|
||||
key: "_key"
|
||||
}
|
||||
}
|
||||
|
||||
}, true);
|
||||
},
|
||||
|
||||
addNewGraph: function(e) {
|
||||
e.preventDefault();
|
||||
this.createNewGraphModal2();
|
||||
this.createNewGraphModal();
|
||||
},
|
||||
|
||||
deleteGraph: function(e) {
|
||||
|
@ -55,13 +78,17 @@
|
|||
},
|
||||
|
||||
editGraph : function(e) {
|
||||
e.stopPropagation();
|
||||
this.collection.fetch();
|
||||
this.graphToEdit = this.evaluateGraphName($(e.currentTarget).attr("id"), '_settings');
|
||||
var graph = this.collection.findWhere({_key: this.graphToEdit});
|
||||
this.createEditGraphModal(this.graphToEdit, graph.get("vertices"), graph.get("edges"));
|
||||
this.createEditGraphModal(
|
||||
this.graphToEdit, graph.get("edgeDefinitions"), graph.get("orphanCollections")
|
||||
);
|
||||
},
|
||||
|
||||
info : function(e) {
|
||||
e.stopPropagation();
|
||||
this.collection.fetch();
|
||||
var graph = this.collection.findWhere(
|
||||
{_key: this.evaluateGraphName($(e.currentTarget).attr("id"), '_info')}
|
||||
|
@ -73,6 +100,10 @@
|
|||
);
|
||||
},
|
||||
|
||||
saveEditedGraph: function() {
|
||||
|
||||
},
|
||||
|
||||
evaluateGraphName : function(str, substr) {
|
||||
var index = str.lastIndexOf(substr);
|
||||
return str.substring(0, index);
|
||||
|
@ -114,75 +145,38 @@
|
|||
},
|
||||
|
||||
createNewGraph: function() {
|
||||
var _key = $("#createNewGraphName").val(),
|
||||
vertices = $("#newGraphVertices").val(),
|
||||
edges = $("#newGraphEdges").val(),
|
||||
self = this;
|
||||
if (!_key) {
|
||||
arangoHelper.arangoNotification(
|
||||
"A name for the graph has to be provided."
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!vertices) {
|
||||
arangoHelper.arangoNotification(
|
||||
"A vertex collection has to be provided."
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!edges) {
|
||||
arangoHelper.arangoNotification(
|
||||
"An edge collection has to be provided."
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.collection.create({
|
||||
_key: _key,
|
||||
vertices: vertices,
|
||||
edges: edges
|
||||
}, {
|
||||
success: function() {
|
||||
self.updateGraphManagementView();
|
||||
window.modalView.hide();
|
||||
},
|
||||
error: function(obj, err) {
|
||||
var response = JSON.parse(err.responseText),
|
||||
msg = response.errorMessage;
|
||||
// Gritter does not display <>
|
||||
msg = msg.replace("<", "");
|
||||
msg = msg.replace(">", "");
|
||||
arangoHelper.arangoError(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
createNewGraph2: function() {
|
||||
var name = $("#createNewGraphName").val(),
|
||||
vertexCollections = _.pluck($('#newVertexCollections').select2("data"), "text"),
|
||||
edgeDefinitions = [],
|
||||
self = this,
|
||||
collection,
|
||||
from,
|
||||
to, i;
|
||||
for (i = 0 ; i < $("tr[id*='newEdgeDefinitions']").length ; i++) {
|
||||
if ($('#s2id_fromCollections' + i) &&
|
||||
_.pluck($('#s2id_fromCollections' + i).select2("data"), "text") &&
|
||||
$('#newEdgeDefinitions' + i) &&
|
||||
$('#newEdgeDefinitions' + i).val() &&
|
||||
$('#s2id_toCollections' + i) &&
|
||||
_.pluck($('#s2id_toCollections' + i).select2("data"), "text") ) {
|
||||
from = _.pluck($('#s2id_fromCollections' + i).select2("data"), "text");
|
||||
to = _.pluck($('#s2id_toCollections' + i).select2("data"), "text");
|
||||
collection = $('#newEdgeDefinitions' + i).val();
|
||||
edgeDefinitions.push(
|
||||
{
|
||||
collection: collection,
|
||||
from: from,
|
||||
to: to
|
||||
to,
|
||||
index,
|
||||
edgeDefinitionElements;
|
||||
|
||||
|
||||
edgeDefinitionElements = $('[id^=s2id_newEdgeDefinitions]').toArray();
|
||||
edgeDefinitionElements.forEach(
|
||||
function(eDElement) {
|
||||
index = $(eDElement).attr("id");
|
||||
index = index.replace("s2id_newEdgeDefinitions", "");
|
||||
collection = _.pluck($('#s2id_newEdgeDefinitions' + index).select2("data"), "text")[0];
|
||||
if (collection && collection !== "") {
|
||||
from = _.pluck($('#s2id_newFromCollections' + index).select2("data"), "text");
|
||||
to = _.pluck($('#s2id_newToCollections' + index).select2("data"), "text");
|
||||
if (from !== 1 && to !== 1) {
|
||||
edgeDefinitions.push(
|
||||
{
|
||||
collection: collection,
|
||||
from: from,
|
||||
to: to
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!name) {
|
||||
arangoHelper.arangoNotification(
|
||||
|
@ -210,51 +204,13 @@
|
|||
});
|
||||
},
|
||||
|
||||
createNewGraphModal: function() {
|
||||
createEditGraphModal: function(name, edgeDefinitions, orphanCollections) {
|
||||
var buttons = [],
|
||||
tableContent = [];
|
||||
tableContent = [],
|
||||
maxIndex;
|
||||
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"createNewGraphName",
|
||||
"Name",
|
||||
"",
|
||||
"The name to identify the graph. Has to be unique.",
|
||||
"graphName",
|
||||
true
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"newGraphVertices",
|
||||
"Vertices",
|
||||
"",
|
||||
"The path name of the document collection that should be used as vertices. "
|
||||
+ "If this does not exist it will be created.",
|
||||
"Vertex Collection",
|
||||
true
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"newGraphEdges",
|
||||
"Edges",
|
||||
"",
|
||||
"The path name of the edge collection that should be used as edges. "
|
||||
+ "If this does not exist it will be created.",
|
||||
"Edge Collection",
|
||||
true
|
||||
)
|
||||
);
|
||||
buttons.push(
|
||||
window.modalView.createSuccessButton("Create", this.createNewGraph2.bind(this))
|
||||
);
|
||||
window.modalView.show("modalTable.ejs", "Add new Graph", buttons, tableContent);
|
||||
},
|
||||
|
||||
createEditGraphModal: function(name, vertices, edges) {
|
||||
var buttons = [],
|
||||
tableContent = [];
|
||||
this.counter = 0;
|
||||
window.modalView.disableSubmitOnEnter = true;
|
||||
|
||||
tableContent.push(
|
||||
window.modalView.createReadOnlyEntry(
|
||||
|
@ -264,28 +220,95 @@
|
|||
false
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createReadOnlyEntry(
|
||||
"editVertices",
|
||||
"Vertices",
|
||||
vertices,
|
||||
false
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createReadOnlyEntry(
|
||||
"editEdges",
|
||||
"Edges",
|
||||
edges,
|
||||
false
|
||||
)
|
||||
|
||||
edgeDefinitions.forEach(
|
||||
function(edgeDefinition, index) {
|
||||
maxIndex = index;
|
||||
if (index === 0) {
|
||||
tableContent.push(
|
||||
window.modalView.createSelect2Entry(
|
||||
"newEdgeDefinitions" + index,
|
||||
"Edge definitions",
|
||||
edgeDefinition.collection,
|
||||
"Some info for edge definitions",
|
||||
"Edge definitions",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1
|
||||
)
|
||||
);
|
||||
} else {
|
||||
tableContent.push(
|
||||
window.modalView.createSelect2Entry(
|
||||
"newEdgeDefinitions" + index,
|
||||
"Edge definitions",
|
||||
edgeDefinition.collection,
|
||||
"Some info for edge definitions",
|
||||
"Edge definitions",
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
1
|
||||
)
|
||||
);
|
||||
}
|
||||
tableContent.push(
|
||||
window.modalView.createSelect2Entry(
|
||||
"newFromCollections" + index,
|
||||
"fromCollections",
|
||||
edgeDefinition.from,
|
||||
"The collection that contain the start vertices of the relation.",
|
||||
"fromCollections",
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
10
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createSelect2Entry(
|
||||
"newToCollections" + index,
|
||||
"toCollections",
|
||||
edgeDefinition.to,
|
||||
"The collection that contain the end vertices of the relation.",
|
||||
"toCollections",
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
10
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
tableContent.push(
|
||||
window.modalView.createSelect2Entry(
|
||||
"newVertexCollections",
|
||||
"Vertex collections",
|
||||
orphanCollections,
|
||||
"Some info for vertex collections",
|
||||
"Vertex Collections",
|
||||
false
|
||||
)
|
||||
);
|
||||
buttons.push(
|
||||
window.modalView.createDeleteButton("Delete", this.deleteGraph.bind(this))
|
||||
);
|
||||
buttons.push(
|
||||
window.modalView.createSuccessButton("Save", this.saveEditedGraph.bind(this))
|
||||
);
|
||||
|
||||
window.modalView.show("modalTable.ejs", "Edit Graph", buttons, tableContent);
|
||||
|
||||
window.modalView.show(
|
||||
"modalGraphTable.ejs", "Add new Graph", buttons, tableContent, null, this.events
|
||||
);
|
||||
|
||||
var i;
|
||||
for (i = 0; i <= maxIndex; i++) {
|
||||
$('#row_newFromCollections' + i).hide();
|
||||
$('#row_newToCollections' + i).hide();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
@ -333,6 +356,12 @@
|
|||
},
|
||||
|
||||
addRemoveDefinition : function(e) {
|
||||
var collList = [],
|
||||
collections = this.options.collectionCollection.models;
|
||||
|
||||
collections.forEach(function (c) {
|
||||
collList.push(c.id);
|
||||
});
|
||||
e.stopPropagation();
|
||||
var id = $(e.currentTarget).attr("id"), number;
|
||||
if (id.indexOf("addAfter_newEdgeDefinitions") !== -1 ) {
|
||||
|
@ -343,21 +372,21 @@
|
|||
})
|
||||
);
|
||||
$('#newEdgeDefinitions'+this.counter).select2({
|
||||
tags: [],
|
||||
tags: collList,
|
||||
showSearchBox: false,
|
||||
minimumResultsForSearch: -1,
|
||||
width: "336px",
|
||||
maximumSelectionSize: 1
|
||||
});
|
||||
$('#newfromCollections'+this.counter).select2({
|
||||
tags: [],
|
||||
tags: collList,
|
||||
showSearchBox: false,
|
||||
minimumResultsForSearch: -1,
|
||||
width: "336px",
|
||||
maximumSelectionSize: 10
|
||||
});
|
||||
$('#newtoCollections'+this.counter).select2({
|
||||
tags: [],
|
||||
tags: collList,
|
||||
showSearchBox: false,
|
||||
minimumResultsForSearch: -1,
|
||||
width: "336px",
|
||||
|
@ -376,9 +405,12 @@
|
|||
},
|
||||
|
||||
createNewGraphModal2: function() {
|
||||
var buttons = [],
|
||||
tableContent = [];
|
||||
var buttons = [], collList = [],
|
||||
tableContent = [], collections = this.options.collectionCollection.models;
|
||||
|
||||
collections.forEach(function (c) {
|
||||
collList.push(c.id);
|
||||
});
|
||||
this.counter = 0;
|
||||
window.modalView.disableSubmitOnEnter = true;
|
||||
|
||||
|
@ -403,7 +435,8 @@
|
|||
true,
|
||||
false,
|
||||
true,
|
||||
1
|
||||
1,
|
||||
collList
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
|
@ -416,7 +449,8 @@
|
|||
true,
|
||||
false,
|
||||
false,
|
||||
10
|
||||
10,
|
||||
collList
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
|
@ -429,7 +463,8 @@
|
|||
true,
|
||||
false,
|
||||
false,
|
||||
10
|
||||
10,
|
||||
collList
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -441,7 +476,11 @@
|
|||
"",
|
||||
"Some info for vertex collections",
|
||||
"Vertex Collections",
|
||||
false
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
10,
|
||||
collList
|
||||
)
|
||||
);
|
||||
buttons.push(
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
};
|
||||
|
||||
var createTextStub = function(type, label, value, info, placeholder, mandatory, regexp,
|
||||
addDelete, addAdd, maxEntrySize) {
|
||||
addDelete, addAdd, maxEntrySize, tags) {
|
||||
var obj = {
|
||||
type: type,
|
||||
label: label
|
||||
|
@ -40,6 +40,9 @@
|
|||
if (maxEntrySize !== undefined) {
|
||||
obj.maxEntrySize = maxEntrySize;
|
||||
}
|
||||
if (tags !== undefined) {
|
||||
obj.tags = tags;
|
||||
}
|
||||
if (regexp){
|
||||
// returns true if the string contains the match
|
||||
obj.validateInput = function(el){
|
||||
|
@ -186,9 +189,9 @@
|
|||
},
|
||||
|
||||
createSelect2Entry: function(
|
||||
id, label, value, info, placeholder, mandatory, addDelete, addAdd, maxEntrySize) {
|
||||
id, label, value, info, placeholder, mandatory, addDelete, addAdd, maxEntrySize, tags) {
|
||||
var obj = createTextStub(this.tables.SELECT2, label, value, info, placeholder,
|
||||
mandatory, undefined, addDelete, addAdd, maxEntrySize);
|
||||
mandatory, undefined, addDelete, addAdd, maxEntrySize, tags);
|
||||
obj.id = id;
|
||||
return obj;
|
||||
},
|
||||
|
@ -283,7 +286,7 @@
|
|||
_.each(tableContent, function(r) {
|
||||
if (r.type === self.tables.SELECT2) {
|
||||
$('#'+r.id).select2({
|
||||
tags: [],
|
||||
tags: r.tags || [],
|
||||
showSearchBox: false,
|
||||
minimumResultsForSearch: -1,
|
||||
width: "336px",
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
"frontend/js/graphViewer/graph/communityNode.js",
|
||||
"frontend/js/graphViewer/graph/abstractAdapter.js",
|
||||
"frontend/js/graphViewer/graph/arangoAdapter.js",
|
||||
"frontend/js/graphViewer/graph/gharialAdapter.js",
|
||||
"frontend/js/graphViewer/graph/zoomManager.js",
|
||||
"frontend/js/graphViewer/graph/modularityJoiner.js",
|
||||
"frontend/js/graphViewer/graph/nodeReducer.js",
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
"frontend/js/graphViewer/graph/abstractAdapter.js",
|
||||
"frontend/js/graphViewer/graph/JSONAdapter.js",
|
||||
"frontend/js/graphViewer/graph/arangoAdapter.js",
|
||||
"frontend/js/graphViewer/graph/gharialAdapter.js",
|
||||
"frontend/js/graphViewer/graph/foxxAdapter.js",
|
||||
"frontend/js/graphViewer/graph/previewAdapter.js",
|
||||
"frontend/js/graphViewer/graph/edgeShaper.js",
|
||||
|
@ -85,6 +86,7 @@
|
|||
"frontend/js/graphViewer/ui/nodeShaperControls.js",
|
||||
"frontend/js/graphViewer/ui/edgeShaperControls.js",
|
||||
"frontend/js/graphViewer/ui/arangoAdapterControls.js",
|
||||
"frontend/js/graphViewer/ui/gharialAdapterControls.js",
|
||||
"frontend/js/graphViewer/ui/layouterControls.js",
|
||||
"frontend/js/graphViewer/ui/uiComponentsHelper.js",
|
||||
"frontend/js/graphViewer/ui/eventDispatcherControls.js",
|
||||
|
@ -187,9 +189,11 @@
|
|||
"test/specs/graphViewer/specAdapter/abstractAdapterSpec.js",
|
||||
"test/specs/graphViewer/specAdapter/jsonAdapterSpec.js",
|
||||
"test/specs/graphViewer/specAdapter/arangoAdapterSpec.js",
|
||||
"test/specs/graphViewer/specAdapter/gharialAdapterSpec.js",
|
||||
"test/specs/graphViewer/specAdapter/foxxAdapterSpec.js",
|
||||
"test/specs/graphViewer/specAdapter/previewAdapterSpec.js",
|
||||
"test/specs/graphViewer/specAdapter/arangoAdapterUISpec.js",
|
||||
"test/specs/graphViewer/specAdapter/gharialAdapterUISpec.js",
|
||||
"test/specs/graphViewer/specNodeShaper/nodeShaperSpec.js",
|
||||
"test/specs/graphViewer/specNodeShaper/nodeShaperUISpec.js",
|
||||
"test/specs/graphViewer/specEdgeShaper/edgeShaperSpec.js",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,392 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect*/
|
||||
/*global runs, waitsFor, spyOn */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper, uiMatchers*/
|
||||
/*global GharialAdapterControls, GharialAdapter*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @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 () {
|
||||
"use strict";
|
||||
|
||||
describe('Gharial Adapter UI', function () {
|
||||
var adapter, adapterUI, list, prioList;
|
||||
|
||||
beforeEach(function () {
|
||||
prioList = [];
|
||||
adapter = {
|
||||
getPrioList: function(){
|
||||
return undefined;
|
||||
},
|
||||
changeToGraph: function(){
|
||||
return undefined;
|
||||
},
|
||||
changeTo: function(){
|
||||
return undefined;
|
||||
},
|
||||
getGraphs: function(cb) {
|
||||
cb(["oldGraph", "newGraph"]);
|
||||
},
|
||||
getGraphName: function() {
|
||||
return undefined;
|
||||
},
|
||||
getDirection: function() {
|
||||
return undefined;
|
||||
},
|
||||
loadRandomNode: function() {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
list = document.createElement("ul");
|
||||
document.body.appendChild(list);
|
||||
list.id = "control_adapter_list";
|
||||
adapterUI = new GharialAdapterControls(list, adapter);
|
||||
spyOn(adapter, 'changeTo');
|
||||
spyOn(adapter, 'changeToGraph');
|
||||
spyOn(adapter, "getGraphs").andCallThrough();
|
||||
spyOn(adapter, "getPrioList").andCallFake(function() {
|
||||
return prioList;
|
||||
});
|
||||
uiMatchers.define(this);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(list);
|
||||
});
|
||||
|
||||
it('should throw errors if not setup correctly', function() {
|
||||
expect(function() {
|
||||
var e = new GharialAdapterControls();
|
||||
return e;
|
||||
}).toThrow("A list element has to be given.");
|
||||
expect(function() {
|
||||
var e = new GharialAdapterControls(list);
|
||||
return e;
|
||||
}).toThrow("The GharialAdapter has to be given.");
|
||||
});
|
||||
|
||||
it('should check adapter interface consistency', function() {
|
||||
var realAdapter = new GharialAdapter([], [], {}, {graphName: "oldGraph"});
|
||||
this.addMatchers({
|
||||
toOfferFunction: function(name) {
|
||||
this.message = function() {
|
||||
return "Function \"" + name + "\" is not available on adapter.";
|
||||
};
|
||||
return _.isFunction(this.actual[name]);
|
||||
}
|
||||
});
|
||||
_.each(
|
||||
_.keys(adapter), function(name) {
|
||||
expect(realAdapter).toOfferFunction(name);
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
describe('change graph control', function() {
|
||||
|
||||
var idPrefix = "#control_adapter_graph",
|
||||
callbacks;
|
||||
|
||||
beforeEach(function() {
|
||||
runs(function() {
|
||||
callbacks = {
|
||||
cb: function() {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
spyOn(callbacks, "cb");
|
||||
adapterUI.addControlChangeGraph(callbacks.cb);
|
||||
expect($("#control_adapter_list " + idPrefix).length).toEqual(1);
|
||||
expect($("#control_adapter_list " + idPrefix)[0]).toConformToListCSS();
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_button");
|
||||
expect($(idPrefix + "_modal").length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
waitsFor(function() {
|
||||
return $(idPrefix + "_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
});
|
||||
|
||||
it('should be added to the list', function() {
|
||||
runs(function() {
|
||||
$(idPrefix + "_graph").prop("selectedIndex", 1);
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
expect(adapter.changeToGraph).toHaveBeenCalledWith(
|
||||
"oldGraph",
|
||||
false
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should change graph and traversal direction to directed', function() {
|
||||
runs(function() {
|
||||
$(idPrefix + "_graph").prop("selectedIndex", 1);
|
||||
$(idPrefix + "_undirected").attr("checked", false);
|
||||
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
|
||||
expect(adapter.changeToGraph).toHaveBeenCalledWith(
|
||||
"oldGraph",
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should change graph and traversal direction to undirected', function() {
|
||||
runs(function() {
|
||||
$(idPrefix + "_graph").prop("selectedIndex", 1);
|
||||
$(idPrefix + "_undirected").attr("checked", true);
|
||||
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
|
||||
expect(adapter.changeToGraph).toHaveBeenCalledWith(
|
||||
"oldGraph",
|
||||
true
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be possible to start with a random vertex', function() {
|
||||
runs(function() {
|
||||
spyOn(adapter, "loadRandomNode");
|
||||
$(idPrefix + "_graph").prop("selectedIndex", 1);
|
||||
$(idPrefix + "_undirected").attr("checked", true);
|
||||
$(idPrefix + "_random").attr("checked", true);
|
||||
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
|
||||
expect(adapter.loadRandomNode).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be possible to not start with a random vertex', function() {
|
||||
runs(function() {
|
||||
spyOn(adapter, "loadRandomNode");
|
||||
$(idPrefix + "_graph").prop("selectedIndex", 1);
|
||||
$(idPrefix + "_undirected").attr("checked", true);
|
||||
$(idPrefix + "_random").attr("checked", false);
|
||||
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
|
||||
expect(adapter.loadRandomNode).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should trigger the callback', function() {
|
||||
runs(function() {
|
||||
$(idPrefix + "_graph").prop("selectedIndex", 1);
|
||||
$(idPrefix + "_undirected").attr("checked", true);
|
||||
$(idPrefix + "_random").attr("checked", false);
|
||||
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
|
||||
expect(callbacks.cb).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should offer the available graphs as sorted lists', function() {
|
||||
runs(function() {
|
||||
var graphList = document.getElementById(idPrefix.substr(1) + "_graph"),
|
||||
graphCollectionOptions = graphList.children;
|
||||
|
||||
expect(adapter.getGraphs).toHaveBeenCalled();
|
||||
|
||||
expect(graphList).toBeTag("select");
|
||||
expect(graphCollectionOptions.length).toEqual(2);
|
||||
expect(graphCollectionOptions[0]).toBeTag("option");
|
||||
expect(graphCollectionOptions[1]).toBeTag("option");
|
||||
|
||||
expect(graphCollectionOptions[0].value).toEqual("newGraph");
|
||||
expect(graphCollectionOptions[1].value).toEqual("oldGraph");
|
||||
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('change priority list control', function() {
|
||||
|
||||
var idPrefix;
|
||||
|
||||
beforeEach(function() {
|
||||
idPrefix = "#control_adapter_priority";
|
||||
adapterUI.addControlChangePriority();
|
||||
|
||||
expect($("#control_adapter_list " + idPrefix).length).toEqual(1);
|
||||
expect($("#control_adapter_list " + idPrefix)[0]).toConformToListCSS();
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_button");
|
||||
expect($(idPrefix + "_modal").length).toEqual(1);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
waitsFor(function() {
|
||||
return $(idPrefix + "_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
});
|
||||
|
||||
it('should be added to the list', function() {
|
||||
runs(function() {
|
||||
$(idPrefix + "_attribute_1").attr("value", "foo");
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
expect(adapter.changeTo).toHaveBeenCalledWith({
|
||||
prioList: ["foo"]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not add empty attributes to priority', function() {
|
||||
runs(function() {
|
||||
$(idPrefix + "_attribute_1").attr("value", "");
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
expect(adapter.changeTo).toHaveBeenCalledWith({
|
||||
prioList: []
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a new line to priority on demand', function() {
|
||||
runs(function() {
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_attribute_addLine");
|
||||
expect($(idPrefix + "_attribute_1").length).toEqual(1);
|
||||
expect($(idPrefix + "_attribute_2").length).toEqual(1);
|
||||
expect($(idPrefix + "_attribute_addLine").length).toEqual(1);
|
||||
$(idPrefix + "_attribute_1").val("foo");
|
||||
$(idPrefix + "_attribute_2").val("bar");
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
expect(adapter.changeTo).toHaveBeenCalledWith({
|
||||
prioList: ["foo", "bar"]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should add many new lines to priority on demand', function() {
|
||||
|
||||
runs(function() {
|
||||
var idPrefixAttr = idPrefix.substr(1) + "_attribute_";
|
||||
helper.simulateMouseEvent("click", idPrefixAttr + "addLine");
|
||||
helper.simulateMouseEvent("click", idPrefixAttr + "addLine");
|
||||
helper.simulateMouseEvent("click", idPrefixAttr + "addLine");
|
||||
helper.simulateMouseEvent("click", idPrefixAttr + "addLine");
|
||||
expect($("#" + idPrefixAttr + "1").length).toEqual(1);
|
||||
expect($("#" + idPrefixAttr + "2").length).toEqual(1);
|
||||
expect($("#" + idPrefixAttr + "3").length).toEqual(1);
|
||||
expect($("#" + idPrefixAttr + "4").length).toEqual(1);
|
||||
expect($("#" + idPrefixAttr + "5").length).toEqual(1);
|
||||
|
||||
expect($("#" + idPrefixAttr + "1").val()).toEqual("");
|
||||
expect($("#" + idPrefixAttr + "2").val()).toEqual("");
|
||||
expect($("#" + idPrefixAttr + "3").val()).toEqual("");
|
||||
expect($("#" + idPrefixAttr + "4").val()).toEqual("");
|
||||
expect($("#" + idPrefixAttr + "5").val()).toEqual("");
|
||||
|
||||
expect($("#" + idPrefixAttr + "addLine").length).toEqual(1);
|
||||
$("#" + idPrefixAttr + "1").val("foo");
|
||||
$("#" + idPrefixAttr + "2").val("bar");
|
||||
$("#" + idPrefixAttr + "3").val("");
|
||||
$("#" + idPrefixAttr + "4").val("baz");
|
||||
$("#" + idPrefixAttr + "5").val("foxx");
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
expect(adapter.changeTo).toHaveBeenCalledWith({
|
||||
prioList: ["foo", "bar", "baz", "foxx"]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should remove all but the first line', function() {
|
||||
runs(function() {
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_attribute_addLine");
|
||||
expect($(idPrefix + "_attribute_1_remove").length).toEqual(0);
|
||||
expect($(idPrefix + "_attribute_2_remove").length).toEqual(1);
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_attribute_2_remove");
|
||||
|
||||
expect($(idPrefix + "_attribute_addLine").length).toEqual(1);
|
||||
expect($(idPrefix + "_attribute_2_remove").length).toEqual(0);
|
||||
expect($(idPrefix + "_attribute_2").length).toEqual(0);
|
||||
|
||||
$(idPrefix + "_attribute_1").attr("value", "foo");
|
||||
helper.simulateMouseEvent("click", idPrefix.substr(1) + "_submit");
|
||||
expect(adapter.changeTo).toHaveBeenCalledWith({
|
||||
prioList: ["foo"]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* TO_DO
|
||||
|
||||
it('should load the current prioList from the adapter', function() {
|
||||
|
||||
runs(function() {
|
||||
helper.simulateMouseEvent("click", "control_adapter_priority_cancel");
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_adapter_priority_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
runs(function() {
|
||||
expect($("#control_adapter_priority_cancel").length).toEqual(0);
|
||||
prioList.push("foo");
|
||||
prioList.push("bar");
|
||||
prioList.push("baz");
|
||||
helper.simulateMouseEvent("click", "control_adapter_priority");
|
||||
expect(adapter.getPrioList).wasCalled();
|
||||
var idPrefix = "#control_adapter_priority_attribute_";
|
||||
expect($(idPrefix + "1").length).toEqual(1);
|
||||
expect($(idPrefix + "2").length).toEqual(1);
|
||||
expect($(idPrefix + "3").length).toEqual(1);
|
||||
expect($(idPrefix + "4").length).toEqual(0);
|
||||
expect($(idPrefix + "addLine").length).toEqual(1);
|
||||
expect($(idPrefix + "1_remove").length).toEqual(0);
|
||||
expect($(idPrefix + "2_remove").length).toEqual(1);
|
||||
expect($(idPrefix + "3_remove").length).toEqual(1);
|
||||
expect($(idPrefix + "1").attr("value")).toEqual("foo");
|
||||
expect($(idPrefix + "2").attr("value")).toEqual("bar");
|
||||
expect($(idPrefix + "3").attr("value")).toEqual("baz");
|
||||
expect($("#control_adapter_priority_modal").length).toEqual(1);
|
||||
expect($("#control_adapter_priority_cancel").length).toEqual(1);
|
||||
helper.simulateMouseEvent("click", "control_adapter_priority_cancel");
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
it('should be able to add all controls to the list', function() {
|
||||
adapterUI.addAll();
|
||||
expect($("#control_adapter_list #control_adapter_graph").length).toEqual(1);
|
||||
expect($("#control_adapter_list #control_adapter_priority").length).toEqual(1);
|
||||
});
|
||||
});
|
||||
}());
|
|
@ -48,7 +48,7 @@
|
|||
+ argCounter
|
||||
+ " arguments.";
|
||||
};
|
||||
if (typeof(obj[func]) !== "function") {
|
||||
if (typeof obj[func] !== "function") {
|
||||
return false;
|
||||
}
|
||||
if (obj[func].length < argCounter) {
|
||||
|
|
|
@ -151,7 +151,9 @@ describe("Graph Viewer", function() {
|
|||
width = 20,
|
||||
height = 10;
|
||||
spyOn(window, "ArangoAdapter").andReturn({
|
||||
setChildLimit: function(){}
|
||||
setChildLimit: function(){
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
gv = new GraphViewer(svg, width, height, adapterConfig);
|
||||
expect(window.ArangoAdapter).wasCalledWith(
|
||||
|
@ -162,6 +164,25 @@ describe("Graph Viewer", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it('should be able to be setup with a gharial adapter', function() {
|
||||
var adapterConfig = {type: "gharial"},
|
||||
gv,
|
||||
width = 20,
|
||||
height = 10;
|
||||
spyOn(window, "GharialAdapter").andReturn({
|
||||
setChildLimit: function(){
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
gv = new GraphViewer(svg, width, height, adapterConfig);
|
||||
expect(window.GharialAdapter).wasCalledWith(
|
||||
jasmine.any(Array),
|
||||
jasmine.any(Array),
|
||||
gv,
|
||||
jasmine.any(Object)
|
||||
);
|
||||
});
|
||||
|
||||
it('should be able to be setup with a preview adapter', function() {
|
||||
var adapterConfig = {type: "preview"},
|
||||
gv;
|
||||
|
|
|
@ -193,7 +193,7 @@
|
|||
expect($(menuSelector).length).toEqual(1);
|
||||
expect($("span", menuSelector).attr("title")).toEqual("Configure");
|
||||
expect($("span", menuSelector)).toBeOfClass("icon_arangodb_settings2");
|
||||
expect($(dropDownSelector + " #control_adapter_collections").length).toEqual(1);
|
||||
expect($(dropDownSelector + " #control_adapter_graph").length).toEqual(1);
|
||||
expect($(dropDownSelector + " #control_node_labelandcolourlist").length).toEqual(1);
|
||||
expect($(dropDownSelector + " #control_adapter_priority").length).toEqual(1);
|
||||
});
|
||||
|
|
|
@ -5390,7 +5390,8 @@ function GRAPH_TRAVERSAL (vertexCollection,
|
|||
///
|
||||
/// *Parameters*
|
||||
/// * *graphName* : The name of the graph as a string.
|
||||
/// * *startVertex* : The ID of the start vertex of the traversal as a string.
|
||||
/// * *startVertexExample* : An example for the desired
|
||||
/// vertices (see [example](#short_explaination_of_the_vertex_example_parameter)).
|
||||
/// * *direction* : The direction of the edges as a string. Possible values
|
||||
/// are *outbound*, *inbound* and *any* (default).
|
||||
/// * *options* (optional) : Object containing optional options, see
|
||||
|
@ -5425,19 +5426,28 @@ function GRAPH_TRAVERSAL (vertexCollection,
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function GENERAL_GRAPH_TRAVERSAL (graphName,
|
||||
startVertex,
|
||||
startVertexExample,
|
||||
direction,
|
||||
options) {
|
||||
"use strict";
|
||||
|
||||
var result = [];
|
||||
options = TRAVERSAL_PARAMS(options);
|
||||
options.fromVertexExample = startVertexExample;
|
||||
options.direction = direction;
|
||||
|
||||
return TRAVERSAL_FUNC("GRAPH_TRAVERSAL",
|
||||
TRAVERSAL.generalGraphDatasourceFactory(graphName),
|
||||
TO_ID(startVertex),
|
||||
undefined,
|
||||
direction,
|
||||
options);
|
||||
var graph = RESOLVE_GRAPH_TO_DOCUMENTS(graphName, options);
|
||||
var factory = TRAVERSAL.generalGraphDatasourceFactory(graphName);
|
||||
|
||||
graph.fromVertices.forEach(function (f) {
|
||||
result.push(TRAVERSAL_FUNC("GRAPH_TRAVERSAL",
|
||||
factory,
|
||||
TO_ID(f),
|
||||
undefined,
|
||||
direction,
|
||||
options));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -5572,8 +5582,8 @@ function GENERAL_GRAPH_DISTANCE_TO (graphName,
|
|||
/// *Parameters*
|
||||
///
|
||||
/// * *graphName* : The name of the graph as a string.
|
||||
/// * *startVertex* : The ID of the start vertex
|
||||
/// of the traversal as a string.
|
||||
/// * *startVertexExample* : An example for the desired
|
||||
/// vertices (see [example](#short_explaination_of_the_vertex_example_parameter)).
|
||||
/// * *direction* : The direction of the edges as a string.
|
||||
/// Possible values are *outbound*, *inbound* and *any* (default).
|
||||
/// * *connectName* : The result attribute which
|
||||
|
@ -5611,25 +5621,32 @@ function GENERAL_GRAPH_DISTANCE_TO (graphName,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function GENERAL_GRAPH_TRAVERSAL_TREE (graphName,
|
||||
startVertex,
|
||||
startVertexExample,
|
||||
direction,
|
||||
connectName,
|
||||
options) {
|
||||
"use strict";
|
||||
|
||||
var result = [];
|
||||
options = TRAVERSAL_TREE_PARAMS(options, connectName, "GRAPH_TRAVERSAL_TREE");
|
||||
options.fromVertexExample = startVertexExample;
|
||||
options.direction = direction;
|
||||
|
||||
var result = TRAVERSAL_FUNC("GRAPH_TRAVERSAL_TREE",
|
||||
TRAVERSAL.generalGraphDatasourceFactory(graphName),
|
||||
TO_ID(startVertex),
|
||||
undefined,
|
||||
direction,
|
||||
options);
|
||||
var graph = RESOLVE_GRAPH_TO_DOCUMENTS(graphName, options);
|
||||
var factory = TRAVERSAL.generalGraphDatasourceFactory(graphName), r;
|
||||
|
||||
if (result.length === 0) {
|
||||
return [ ];
|
||||
}
|
||||
return [ result[0][options.connect] ];
|
||||
graph.fromVertices.forEach(function (f) {
|
||||
r = TRAVERSAL_FUNC("GRAPH_TRAVERSAL_TREE",
|
||||
factory,
|
||||
TO_ID(f),
|
||||
undefined,
|
||||
direction,
|
||||
options);
|
||||
if (r.length > 0) {
|
||||
result.push([ r[0][options.connect] ]);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -701,6 +701,7 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
|
|||
var actual, result = [];
|
||||
|
||||
actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL('werKenntWen', 'UnitTests_Hamburger/Caesar', 'outbound') RETURN e");
|
||||
actual = actual[0];
|
||||
actual.forEach(function (s) {
|
||||
result.push(s.vertex._key);
|
||||
});
|
||||
|
@ -716,11 +717,18 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
|
|||
]);
|
||||
},
|
||||
|
||||
testGRAPH_TRAVERSALWithExamples: function () {
|
||||
var actual, result = [];
|
||||
|
||||
actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL('werKenntWen', {}, 'outbound') RETURN e");
|
||||
assertEqual(actual.length , 7);
|
||||
},
|
||||
|
||||
testGENERAL_GRAPH_TRAVERSAL_TREE: function () {
|
||||
var actual, start, middle;
|
||||
|
||||
actual = getQueryResults("FOR e IN GRAPH_TRAVERSAL_TREE('werKenntWen', 'UnitTests_Hamburger/Caesar', 'outbound', 'connected') RETURN e");
|
||||
start = actual[0][0];
|
||||
start = actual[0][0][0];
|
||||
|
||||
assertEqual(start._key, "Caesar");
|
||||
assertTrue(start.hasOwnProperty("connected"));
|
||||
|
|
Loading…
Reference in New Issue