1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Frank Celler 2013-04-09 16:26:12 +02:00
commit 1d98c4b0f0
37 changed files with 1869 additions and 693 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,8 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 2.4.1. */
/* Bison interface for Yacc-like parsers in C
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -98,7 +96,7 @@
typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
/* Line 2132 of yacc.c */
#line 26 "arangod/Ahuacatl/ahuacatl-grammar.y"
TRI_aql_node_t* node;
@ -108,8 +106,8 @@ typedef union YYSTYPE
/* Line 1676 of yacc.c */
#line 113 "arangod/Ahuacatl/ahuacatl-grammar.h"
/* Line 2132 of yacc.c */
#line 111 "arangod/Ahuacatl/ahuacatl-grammar.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

@ -1099,10 +1099,10 @@ static v8::Handle<v8::Value> SaveEdgeCol (
if (argv.Length() < 3 || argv.Length() > 4) {
if (replace) {
TRI_V8_EXCEPTION_USAGE(scope, "save(<from>, <to>, <data>, <waitForSync>)");
TRI_V8_EXCEPTION_USAGE(scope, "saveOrReplace(<from>, <to>, <data>, [<waitForSync>])");
}
else {
TRI_V8_EXCEPTION_USAGE(scope, "saveOrReplace(<from>, <to>, <data>, <waitForSync>)");
TRI_V8_EXCEPTION_USAGE(scope, "save(<from>, <to>, <data>, [<waitForSync>])");
}
}

View File

@ -1,7 +1,7 @@
{
"apiVersion":"1.2beta",
"swaggerVersion":"1.1",
"basePath":"http://127.0.0.1:8529/_admin/html/api-docs",
"basexPath":"http://192.168.173.10:8529/_admin/html/api-docs",
"apis":[ {
"path": "/document",
"description": "Interface for Documents"

View File

@ -0,0 +1,52 @@
{
"apiVersion":"1.2beta",
"swaggerVersion":"1.1",
"apis":[ {
"path": "/document",
"description": "Interface for Documents"
},
{
"path": "/edges",
"description": "Interface for Edges"
},
{
"path": "/collection",
"description": "Interface for Collections"
},
{
"path": "/graph",
"description": "Interface for Graphs"
},
{
"path": "/user",
"description": "Interface for Users"
},
{
"path": "/system",
"description": "Interface for System"
},
{
"path": "/cursor",
"description": "Interface for Cursors"
},
{
"path": "/explain",
"description": "Interface for Explain"
},
{
"path": "/index",
"description": "Interface for Indexes"
},
{
"path": "/simple",
"description": "Interface for SimpleQueries"
},
{
"path": "/query",
"description": "Interface for Queries"
},
{
"path": "/structure",
"description": "Interface for Structures"
}]
}

View File

@ -67,22 +67,6 @@
"operations": [
{
"errorResponses": [
{
"reason": "If the document exists, this is returned and the JSON representation of the document is the body of the response. ",
"code": "200"
},
{
"reason": "If the <b>document-handle</b> points to a non-existing document, then a <b>HTTP 404</b> is returned and the body contains an error document. ",
"code": "404"
},
{
"reason": "If the \"If-None-Match\" header is given, then it must contain exactly one etag. The document is returned, if it has a different revision than the given etag. Otherwise a <b>HTTP 304</b> is returned. ",
"code": "304"
},
{
"reason": "If the \"If-Match\" header is given, then it must contain exactly one etag. The document is returned, if it has the same revision ad the given etag. Otherwise a <b>HTTP 412</b> is returned. As an alternative you can supply the etag in an attribute <b>rev</b> in the URL. ",
"code": "412"
},
{
"reason": "is returned if the document was found ",
"code": "200"
@ -156,7 +140,7 @@
"notes": "Like <b>GET</b>, but only returns the header fields and not the body. You can use this call to get the current revision of a document or check if the document was deleted. <br><br>",
"summary": "reads a document header",
"httpMethod": "HEAD",
"examples": "<br><br><pre><code class=\"json\" >> curl -X HEAD --dump - http://localhost:8529/_api/document/73482/29591342\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"29591342\"\n</code></pre><br> var cn = \"productshead\"; db._drop(cn); db._create(cn); var collection = db._collection(cn); var document = db.productshead.save({\"hallo\":\"world\"}); var url = \"/_api/document/\" + document._id; var response = logCurlRequest('HEAD', url, \"{}\"); assert(response.code === 200); logJsonResponse(response); db._drop(cn); @END_EXAMPLE_ARANGOSH_RUN ",
"examples": "<br><br><pre><code class=\"json\" >unix> curl --data @- --dump - http://localhost:8529/_api/document/productshead/32256602\n{}\n\n</code></pre><br>",
"nickname": "readsADocumentHeader"
}
],

View File

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ArangoDB web interface -->

View File

@ -809,6 +809,7 @@
var useColor = context.useColor;
var customInspect = context.customInspect;
var useToString = context.useToString;
if (typeof context.seen === "undefined") {
context.seen = [];
@ -836,7 +837,7 @@
else if (value.__proto__ === Object.prototype) {
printObject(value, context);
}
else if (typeof value.toString === "function") {
else if (typeof value === "function") {
// it's possible that toString() throws, and this looks quite ugly
try {
@ -863,8 +864,20 @@
context.output += "[Function]";
}
}
else {
else if (useToString && typeof value.toString === "function") {
try {
context.output += value.toString();
}
catch (e) {
context.output += "[Object ";
printObject(value, context);
context.output += "]";
}
}
else {
context.output += "[Object ";
printObject(value, context);
context.output += "]";
}
}
else if (value === undefined) {
@ -879,8 +892,7 @@
context.output += colors.COLOR_RESET;
}
}
else {
if (typeof(value) === "string") {
else if (typeof(value) === "string") {
if (useColor) {
context.output += colors.COLOR_STRING;
}
@ -928,7 +940,6 @@
context.output += String(value);
}
}
}
};
////////////////////////////////////////////////////////////////////////////////
@ -1000,7 +1011,8 @@
output: "",
prettyPrint: usePrettyPrint,
useColor: useColor,
customInspect: true
customInspect: true,
useToString: true
};
printRecursive(arguments[i], context);
@ -1040,7 +1052,8 @@
output: "",
prettyPrint: true,
useColor: false,
customInspect: options && options.customInspect
customInspect: options && options.customInspect,
useToString: false
};
printRecursive(object, context);

View File

@ -45,13 +45,20 @@ function JSONAdapter(jsonPath, nodes, edges, width, height) {
}
throw "Too many nodes with the same ID, should never happen";
},
insertNode = function(node) {
insertNode = function(data) {
var node = {
_data: data,
_id: data._id,
children: data.children
};
delete data.children;
initialY.getStart();
node.x = initialX.getStart();
node.y = initialY.getStart();
nodes.push(node);
node._outboundCounter = 0;
node._inboundCounter = 0;
return node;
},
insertEdge = function(source, target) {
@ -81,8 +88,7 @@ function JSONAdapter(jsonPath, nodes, edges, width, height) {
}
var n = findNode(node);
if (!n) {
insertNode(node);
n = node;
n = insertNode(node);
} else {
n.children = node.children;
}

View File

@ -61,28 +61,38 @@ function ArangoAdapter(arangodb, nodes, edges, nodeCollection, edgeCollection, w
throw "Too many nodes with the same ID, should never happen";
},
insertNode = function(node) {
var n = findNode(node._id);
insertNode = function(data) {
var node = {
_data: data,
_id: data._id
},
n = findNode(node._id);
if (n) {
return n;
}
initialY.getStart();
node.x = initialX.getStart();
node.y = initialY.getStart();
nodes.push(node);
node._outboundCounter = 0;
node._inboundCounter = 0;
return node;
},
insertEdge = function(edge) {
insertEdge = function(data) {
var source,
target,
edge = {
_data: data,
_id: data._id
},
e = findEdge(edge._id);
if (e) {
return e;
}
source = findNode(edge._from);
target = findNode(edge._to);
source = findNode(data._from);
target = findNode(data._to);
if (!source) {
throw "Unable to insert Edge, source node not existing " + edge._from;
}
@ -94,6 +104,7 @@ function ArangoAdapter(arangodb, nodes, edges, nodeCollection, edgeCollection, w
edges.push(edge);
source._outboundCounter++;
target._inboundCounter++;
return edge;
},
removeNode = function (node) {

View File

@ -32,7 +32,93 @@ function EventDispatcher(nodeShaper, edgeShaper, config) {
var eventlib,
expandConfig,
self = this;
self = this,
parseNodeEditorConfig = function(config) {
if (config.shaper === undefined) {
config.shaper = nodeShaper;
}
if (eventlib.checkNodeEditorConfig(config)) {
var insert = new eventlib.InsertNode(config),
patch = new eventlib.PatchNode(config),
del = new eventlib.DeleteNode(config);
self.events.CREATENODE = function(callback) {
return function() {
insert(callback);
};
};
self.events.PATCHNODE = function(node, getNewData, callback) {
if (!_.isFunction(getNewData)) {
throw "Please give a function to extract the new node data";
}
return function() {
patch(node, getNewData(), callback);
};
};
self.events.DELETENODE = function(callback) {
return function(node) {
del(node, callback);
};
};
}
},
parseEdgeEditorConfig = function(config) {
if (config.shaper === undefined) {
config.shaper = edgeShaper;
}
if (eventlib.checkEdgeEditorConfig(config)) {
var insert = new eventlib.InsertEdge(config),
patch = new eventlib.PatchEdge(config),
del = new eventlib.DeleteEdge(config),
edgeStart = null,
didInsert = false;
self.events.STARTCREATEEDGE = function(callback) {
return function(node) {
edgeStart = node;
didInsert = false;
if (callback !== undefined) {
callback();
}
};
};
self.events.CANCELCREATEEDGE = function(callback) {
return function() {
edgeStart = null;
if (callback !== undefined && !didInsert) {
callback();
}
};
};
self.events.FINISHCREATEEDGE = function(callback) {
return function(node) {
if (edgeStart !== null && node !== edgeStart) {
insert(edgeStart, node, callback);
didInsert = true;
}
};
};
self.events.PATCHEDGE = function(edge, getNewData, callback) {
if (!_.isFunction(getNewData)) {
throw "Please give a function to extract the new node data";
}
return function() {
patch(edge, getNewData(), callback);
};
};
self.events.DELETEEDGE = function(callback) {
return function(edge) {
del(edge, callback);
};
};
}
};
if (nodeShaper === undefined) {
throw "NodeShaper has to be given.";
@ -52,25 +138,16 @@ function EventDispatcher(nodeShaper, edgeShaper, config) {
self.events.EXPAND = new eventlib.Expand(config.expand);
}
}
if (config.drag !== undefined) {
if (eventlib.checkDragConfig(config.drag)) {
self.events.DRAG = new eventlib.Drag(config.drag);
}
}
if (config.nodeEditor !== undefined) {
if (config.nodeEditor.shaper === undefined) {
config.nodeEditor.shaper = nodeShaper;
}
if (eventlib.checkNodeEditorConfig(config.nodeEditor)) {
self.events.CREATENODE = new eventlib.InsertNode(config.nodeEditor);
self.events.PATCHNODE = new eventlib.PatchNode(config.nodeEditor);
self.events.DELETENODE = new eventlib.DeleteNode(config.nodeEditor);
}
parseNodeEditorConfig(config.nodeEditor);
}
if (config.edgeEditor !== undefined) {
if (config.edgeEditor.shaper === undefined) {
config.edgeEditor.shaper = edgeShaper;
}
if (eventlib.checkEdgeEditorConfig(config.edgeEditor)) {
self.events.CREATEEDGE = new eventlib.InsertEdge(config.edgeEditor);
self.events.PATCHEDGE = new eventlib.PatchEdge(config.edgeEditor);
self.events.DELETEEDGE = new eventlib.DeleteEdge(config.edgeEditor);
}
parseEdgeEditorConfig(config.edgeEditor);
}
}
Object.freeze(self.events);
@ -105,7 +182,28 @@ function EventDispatcher(nodeShaper, edgeShaper, config) {
}
};
self.rebind = function (object, actions) {
actions = actions || {};
actions.reset = true;
switch (object) {
case "nodes":
nodeShaper.changeTo({
actions: actions
});
break;
case "edges":
edgeShaper.changeTo({
actions: actions
});
break;
default:
throw "Sorry cannot rebind to object. Please give either "
+ "\"nodes\" or \"edges\"";
}
};
/*
self.unbind = function () {
throw "Not implemented";
};
*/
}

View File

@ -142,6 +142,22 @@ function EventLibrary() {
};
};
this.checkDragConfig = function (config) {
if (config.layouter === undefined) {
throw "A layouter has to be defined";
}
if (config.layouter.drag === undefined || !_.isFunction(config.layouter.drag)) {
throw "The layouter has to offer a drag function";
}
return true;
};
this.Drag = function (config) {
self.checkDragConfig(config);
return config.layouter.drag;
};
this.checkNodeEditorConfig = function (config) {
if (config.nodes === undefined) {
throw "Nodes have to be defined";

View File

@ -276,11 +276,11 @@ function GraphViewer(svg, width, height,
//TODO REMOVE
//HACK to view the Controls in the Demo
/*
var edgeShaperControls = new EdgeShaperControls($("#controls")[0], edgeShaper);
edgeShaperControls.addAll();
var nodeShaperControls = new NodeShaperControls($("#controls")[0], nodeShaper);
nodeShaperControls.addAll();
*/
}

View File

@ -1,5 +1,33 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global document, window*/
////////////////////////////////////////////////////////////////////////////////
/// @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
////////////////////////////////////////////////////////////////////////////////
var helper = helper || {};
(function eventHelper() {

View File

@ -0,0 +1,49 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global document, window*/
////////////////////////////////////////////////////////////////////////////////
/// @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
////////////////////////////////////////////////////////////////////////////////
var mocks = mocks || {};
(function mocksCreator() {
"use strict";
mocks.layouter = {
drag: function(){}
};
mocks.adapter = {
createNode: function(){},
deleteNode: function(){},
patchNode: function(){},
createEdge: function(){},
deleteEdge: function(){},
patchEdge: function(){}
};
}());

View File

@ -19,6 +19,7 @@
<script type="text/javascript" src="../../lib/jquery.livequery.js"></script>
<script type="text/javascript" src="helper/eventHelper.js"></script>
<script type="text/javascript" src="helper/mocks.js"></script>
<script type="text/javascript" src="../graphViewer.js"></script>
<script type="text/javascript" src="../graph/colourMapper.js"></script>
@ -48,6 +49,8 @@
<script type="text/javascript" src="specEdgeShaper/edgeShaperUISpec.js"></script>
<script type="text/javascript" src="specForceLayouter/forceLayouterSpec.js"></script>
<script type="text/javascript" src="specEvents/eventLibrarySpec.js"></script>
<script type="text/javascript" src="specEvents/eventDispatcherSpec.js"></script>
<script type="text/javascript" src="specEvents/eventDispatcherUISpec.js"></script>
<!-- run JSLINT -->
<script type="text/javascript" src="specJSLint/jsLintSpec.js"></script>

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>
@ -15,15 +16,19 @@
<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="helper/mocks.js"></script>
<script type="text/javascript" src="../graph/eventLibrary.js"></script>
<script type="text/javascript" src="../graph/colourMapper.js"></script>
<script type="text/javascript" src="../graph/nodeShaper.js"></script>
<script type="text/javascript" src="../graph/edgeShaper.js"></script>
<script type="text/javascript" src="../graph/eventDispatcher.js"></script>
<script type="text/javascript" src="../ui/modalDialogHelper.js"></script>
<script type="text/javascript" src="../ui/uiComponentsHelper.js"></script>
<script type="text/javascript" src="../ui/eventDispatcherControls.js"></script>
<!-- include spec files here... -->

View File

@ -18,12 +18,20 @@
<script type="text/javascript" src="helper/eventHelper.js"></script>
<script type="text/javascript" src="../graph/colourMapper.js"></script>
<script type="text/javascript" src="../graph/nodeShaper.js"></script>
<script type="text/javascript" src="../graph/edgeShaper.js"></script>
<script type="text/javascript" src="../graph/forceLayouter.js"></script>
<script type="text/javascript" src="../graph/JSONAdapter.js"></script>
<script type="text/javascript" src="../graph/eventLibrary.js"></script>
<script type="text/javascript" src="../graph/eventDispatcher.js"></script>
<!-- UI Modules> -->
<script type="text/javascript" src="../ui/modalDialogHelper.js"></script>
<script type="text/javascript" src="../ui/nodeShaperControls.js"></script>
<script type="text/javascript" src="../ui/edgeShaperControls.js"></script>
<script type="text/javascript" src="../graphViewer.js"></script>
<!-- include spec files here... -->

View File

@ -1,6 +1,6 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global beforeEach, afterEach */
/*global describe, it, expect */
/*global describe, it, expect, jasmine */
/*global runs, spyOn, waitsFor, waits */
/*global window, eb, loadFixtures, document */
/*global $, _, d3*/
@ -50,28 +50,6 @@
nodesCollId,
edgesCollection,
edgesCollId,
c0,
c1,
c2,
c3,
c4,
c5,
c6,
c7,
c8,
c9,
c10,
c11,
c12,
c42,
c43,
c44,
c45,
delTriple1,
delTriple2,
delTriple3,
e1_5,
e2_8,
callbackCheck,
checkCallbackFunction = function() {
callbackCheck = true;
@ -158,14 +136,15 @@
}
});
},
insertEdge = function (collectionID, from, to) {
insertEdge = function (collectionID, from, to, cont) {
var id;
cont = cont || {};
$.ajax({
cache: false,
type: "POST",
async: false,
url: arangodb + "/_api/edge?collection=" + collectionID + "&from=" + from + "&to=" + to,
data: JSON.stringify({}),
data: JSON.stringify(cont),
contentType: "application/json",
processData: false,
success: function(data) {
@ -177,14 +156,16 @@
});
return id;
},
insertNode = function (collectionID, nodeId) {
insertNode = function (collectionID, nodeId, cont) {
var id;
cont = cont || {};
cont.id = nodeId;
$.ajax({
cache: false,
type: "POST",
async: false,
url: arangodb + "/_api/document?collection=" + collectionID,
data: JSON.stringify({id: nodeId}),
data: JSON.stringify(cont),
contentType: "application/json",
processData: false,
success: function(data) {
@ -238,11 +219,7 @@
it('should be able to load a tree node from ArangoDB by internal _id attribute', function() {
var c0,
c1,
c2,
c3,
c4;
var c0, c1, c2, c3, c4;
runs(function() {
c0 = insertNode(nodesCollection, 0);
@ -301,6 +278,52 @@
});
});
it('should encapsulate all attributes of nodes and edges in _data', function() {
var c0, c1, e1_2;
runs(function() {
c0 = insertNode(nodesCollection, 0, {name: "Alice", age: 42});
c1 = insertNode(nodesCollection, 1, {name: "Bob", age: 1337});
e1_2 = insertEdge(edgesCollection, c0, c1, {label: "knows"});
callbackCheck = false;
adapter.loadNodeFromTreeById(c0, checkCallbackFunction);
});
waitsFor(function() {
return callbackCheck;
});
runs(function() {
expect(nodes[0]._data).toEqual({
_id: c0,
_key: jasmine.any(String),
_rev: jasmine.any(String),
id: 0,
name: "Alice",
age: 42
});
expect(nodes[1]._data).toEqual({
_id: c1,
_key: jasmine.any(String),
_rev: jasmine.any(String),
id: 1,
name: "Bob",
age: 1337
});
expect(edges[0]._data).toEqual({
_id: e1_2,
_from: c0,
_to: c1,
_key: jasmine.any(String),
_rev: jasmine.any(String),
label: "knows"
});
});
});
describe('that has already loaded one graph', function() {
var c0, c1, c2, c3, c4, c5, c6, c7;
@ -503,7 +526,7 @@
});
describe('that has loaded several queries', function() {
var c8, c9;
var c8, c9, e2_8;
beforeEach(function() {

View File

@ -125,6 +125,29 @@
});
});
it('should encapsulate all attributes of nodes in _data', function() {
var callbackCheck;
runs(function() {
adapter.loadNodeFromTreeById(1337, function() {
callbackCheck = true;
});
});
waitsFor(function() {
return callbackCheck;
});
runs(function() {
expect(nodes[0]._data).toEqual({
_id: 1337,
name: "Alice",
age: 42
});
});
});
describe('that has already loaded one file', function() {
beforeEach(function() {

View File

@ -1,9 +1,9 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global beforeEach, afterEach */
/*global describe, it, expect */
/*global describe, it, expect, jasmine */
/*global runs, spyOn, waitsFor */
/*global window, document, $, d3, _*/
/*global helper*/
/*global helper, mocks*/
/*global EventDispatcher, NodeShaper, EdgeShaper*/
////////////////////////////////////////////////////////////////////////////////
@ -42,20 +42,34 @@
var dispatcher,
nodes,
edges,
adapter,
adapter = mocks.adapter,
layouter = mocks.layouter,
nodeShaper,
edgeShaper,
completeConfig,
expandConfig,
dragConfig,
nodeEditorConfig,
edgeEditorConfig,
svg;
svg,
bindSpies = function() {
spyOn(layouter, "drag");
spyOn(adapter, "createNode");
spyOn(adapter, "patchNode");
spyOn(adapter, "deleteNode");
spyOn(adapter, "createEdge");
spyOn(adapter, "patchEdge");
spyOn(adapter, "deleteEdge");
};
beforeEach(function() {
svg = document.createElement("svg");
svg.id = "svg";
document.body.appendChild(svg);
adapter = null;
bindSpies();
nodes = [];
edges = [];
@ -68,6 +82,10 @@
reshapeNode: function() {}
};
dragConfig = {
layouter: layouter
};
nodeEditorConfig = {
nodes: nodes,
adapter: adapter
@ -80,15 +98,12 @@
completeConfig = {
expand: expandConfig,
drag: dragConfig,
nodeEditor: nodeEditorConfig,
edgeEditor: edgeEditorConfig
};
nodeShaper = new NodeShaper(d3.select("svg"),
{
"shape": NodeShaper.shapes.CIRCLE
}
);
nodeShaper = new NodeShaper(d3.select("svg"));
edgeShaper = new EdgeShaper(d3.select("svg"));
dispatcher = new EventDispatcher(nodeShaper, edgeShaper, completeConfig);
});
@ -148,16 +163,26 @@
t = new EventDispatcher(nodeShaper, edgeShaper, config);
expect(t.events).toBeDefined();
expect(_.keys(t.events).length).toEqual(3);
expect(t.events.CREATEEDGE).toBeDefined();
expect(_.keys(t.events).length).toEqual(5);
expect(t.events.STARTCREATEEDGE).toBeDefined();
expect(t.events.FINISHCREATEEDGE).toBeDefined();
expect(t.events.CANCELCREATEEDGE).toBeDefined();
expect(t.events.PATCHEDGE).toBeDefined();
expect(t.events.DELETEEDGE).toBeDefined();
});
it('should offer the drag event if config is correct', function() {
var config = {drag: dragConfig},
t = new EventDispatcher(nodeShaper, edgeShaper, config);
expect(t.events).toBeDefined();
expect(_.keys(t.events).length).toEqual(1);
expect(t.events.DRAG).toBeDefined();
});
});
describe('checking objects to bind events to', function() {
it('should be able to bind to any DOM-element', function() {
var called = false,
callback = function() {
@ -365,17 +390,259 @@
});
});
it('should be able to bind to drag', function() {
var called;
runs(function() {
var nodes = [{_id: 1}],
callback = function() {
called = true;
};
called = false;
nodeShaper.drawNodes(nodes);
dispatcher.bind("nodes", "drag", callback);
helper.simulateMouseEvent("drag", "1");
});
waitsFor(function() {
return called;
}, 1000, "The drag event should have been triggered.");
runs(function() {
// Just display that everything had worked
expect(true).toBeTruthy();
});
});
});
/*
describe('checking different events', function() {
it('should be able to bind the expand event', function() {
});
it('should be able to bind the drag event', function() {
runs(function() {
nodes = [{_id: 1}];
nodeShaper.drawNodes(nodes);
dispatcher.bind("nodes", "drag", dispatcher.events.DRAG);
helper.simulateMouseEvent("drag", "1");
window.meierei = layouter.drag;
});
waitsFor(function() {
return layouter.drag.wasCalled;
}, 1000, "The drag event should have been triggered.");
runs(function() {
expect(true).toBeTruthy();
});
});
it('should be able to bind the create node event', function() {
runs(function() {
dispatcher.bind($("svg"), "click", dispatcher.events.CREATENODE(
function() {
// Never reached as the spy stops propagation
return 0;
}
));
helper.simulateMouseEvent("click", "svg");
});
waitsFor(function() {
return adapter.createNode.wasCalled;
}, 1000, "The event should have been triggered.");
runs(function() {
expect(true).toBeTruthy();
});
});
it('should be able to bind the patch node event', function() {
runs(function() {
nodes = [{_id: 1}];
dispatcher.bind($("svg"), "click", dispatcher.events.PATCHNODE(
nodes[0],
function() {
return {
name: "Alice"
};
},
function() {
// Never reached as the spy stops propagation
return 0;
}
));
helper.simulateMouseEvent("click", "svg");
});
waitsFor(function() {
return adapter.patchNode.wasCalled;
}, 1000, "The event should have been triggered.");
runs(function() {
expect(adapter.patchNode).toHaveBeenCalledWith(
nodes[0],
{ name: "Alice" },
jasmine.any(Function));
});
});
it('should be able to bind the delete node event', function() {
runs(function() {
nodes = [{_id: 1}];
nodeShaper.drawNodes(nodes);
dispatcher.bind("nodes", "click", dispatcher.events.DELETENODE(
function(node) {
// Never reached as the spy stops propagation
return 0;
}
));
helper.simulateMouseEvent("click", "1");
});
waitsFor(function() {
return adapter.deleteNode.wasCalled;
}, 1000, "The event should have been triggered.");
runs(function() {
expect(adapter.deleteNode).toHaveBeenCalledWith(
nodes[0],
jasmine.any(Function));
});
});
it('should be able to bind the events to create an edge', function() {
nodes = [{_id: 1}, {_id: 2}, {_id: 3}];
edges = [{source: nodes[0], target: nodes[2]}];
nodeShaper.drawNodes(nodes);
edgeShaper.drawEdges(edges);
var started = 0,
canceled = 0;
runs(function() {
dispatcher.bind("nodes", "mousedown", dispatcher.events.STARTCREATEEDGE(
function() {
started++;
}
));
dispatcher.bind("nodes", "mouseup", dispatcher.events.FINISHCREATEEDGE(
function() {
// Never reached as the spy stops propagation
return 0;
}
));
dispatcher.bind($("svg"), "mouseup", dispatcher.events.CANCELCREATEEDGE(
function() {
return canceled++;
}
));
helper.simulateMouseEvent("mousedown", "1");
helper.simulateMouseEvent("mouseup", "svg");
helper.simulateMouseEvent("mousedown", "1");
helper.simulateMouseEvent("mouseup", "1-3");
helper.simulateMouseEvent("mousedown", "1");
helper.simulateMouseEvent("mouseup", "1");
helper.simulateMouseEvent("mousedown", "1");
helper.simulateMouseEvent("mouseup", "2");
});
waitsFor(function() {
return adapter.createEdge.wasCalled;
}, 1000, "The event should have been triggered.");
runs(function() {
expect(started).toEqual(4);
expect(canceled).toEqual(3);
expect(adapter.createEdge.calls.length).toEqual(1);
expect(adapter.createEdge).toHaveBeenCalledWith({
source: nodes[0],
target: nodes[1]
}, jasmine.any(Function));
});
});
it('should be able to bind the patch edge event', function() {
runs(function() {
nodes = [{
_id: 1
},{
_id: 2
}];
edges = [{source: nodes[0], target: nodes[1]}];
dispatcher.bind($("svg"), "click", dispatcher.events.PATCHEDGE(
edges[0],
function() {
return {
name: "Alice"
};
},
function() {
// Never reached as the spy stops propagation
return 0;
}
));
helper.simulateMouseEvent("click", "svg");
});
waitsFor(function() {
return adapter.patchEdge.wasCalled;
}, 1000, "The event should have been triggered.");
runs(function() {
expect(adapter.patchEdge).toHaveBeenCalledWith(
edges[0],
{ name: "Alice" },
jasmine.any(Function));
});
});
it('should be able to bind the delete edge event', function() {
runs(function() {
nodes = [{
_id: 1
},{
_id: 2
}];
edges = [{source: nodes[0], target: nodes[1]}];
edgeShaper.drawEdges(edges);
dispatcher.bind("edges", "click", dispatcher.events.DELETEEDGE(
function(edge) {
// Never reached as the spy stops propagation
return 0;
}
));
helper.simulateMouseEvent("click", "1-2");
});
waitsFor(function() {
return adapter.deleteEdge.wasCalled;
}, 1000, "The event should have been triggered.");
runs(function() {
expect(adapter.deleteEdge).toHaveBeenCalledWith(
edges[0],
jasmine.any(Function));
});
});
});
*/
describe('checking overwriting of events', function() {
@ -471,6 +738,89 @@
});
});
describe('checking rebinding of events', function() {
it('should be able to bind only the given events and unbind all other for nodes', function() {
var falseCalls, called;
runs(function() {
var nodes = [{_id: 1}, {_id:2}],
callback = function() {
called++;
},
falseCallback = function() {
falseCalls++;
};
falseCalls = 0;
called = 0;
nodeShaper.drawNodes(nodes);
dispatcher.bind("nodes", "click", falseCallback);
dispatcher.bind("nodes", "mousedown", falseCallback);
dispatcher.bind("nodes", "mouseup", falseCallback);
dispatcher.rebind("nodes", {
click: callback
});
helper.simulateMouseEvent("mousedown", "2");
helper.simulateMouseEvent("mouseup", "2");
helper.simulateMouseEvent("click", "1");
helper.simulateMouseEvent("click", "2");
});
waitsFor(function() {
return called === 2;
}, 1000, "The two click events should have been triggered.");
runs(function() {
// Just display that everything had worked
expect(falseCalls).toEqual(0);
});
});
it('should be able to bind only the given events and unbind all other for edges', function() {
var falseCalls, called;
runs(function() {
var n1 = {_id: 1},
n2 = {_id: 2},
n3 = {_id: 3},
edges = [
{source: n1, target: n2},
{source: n2, target: n3}
],
callback = function() {
called++;
},
falseCallback = function() {
falseCalls++;
};
falseCalls = 0;
called = 0;
edgeShaper.drawEdges(edges);
dispatcher.bind("edges", "click", falseCallback);
dispatcher.bind("edges", "mousedown", falseCallback);
dispatcher.bind("edges", "mouseup", falseCallback);
dispatcher.rebind("edges", {
click: callback
});
helper.simulateMouseEvent("mousedown", "1-2");
helper.simulateMouseEvent("mouseup", "1-2");
helper.simulateMouseEvent("click", "1-2");
helper.simulateMouseEvent("click", "2-3");
});
waitsFor(function() {
return called === 2;
}, 1000, "The two click events should have been triggered.");
runs(function() {
// Just display that everything had worked
expect(falseCalls).toEqual(0);
});
});
});
});
}());

View File

@ -1,10 +1,10 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global beforeEach, afterEach */
/*global describe, it, expect*/
/*global describe, it, expect, jasmine*/
/*global runs, waitsFor, spyOn */
/*global window, eb, loadFixtures, document */
/*global $, _, d3*/
/*global helper*/
/*global helper, mocks*/
/*global EventDispatcher, EventDispatcherControls, NodeShaper, EdgeShaper*/
////////////////////////////////////////////////////////////////////////////////
@ -41,30 +41,78 @@
describe('Event Dispatcher UI', function () {
var svg, dispatcher, dispatcherUI, list,
nodeShaper, edgeShaper, layouter,
nodes, edges;
nodes, edges, adapter,
addSpies = function() {
spyOn(layouter, "drag");
spyOn(adapter, "createNode");
spyOn(adapter, "patchNode");
spyOn(adapter, "deleteNode");
spyOn(adapter, "createEdge");
spyOn(adapter, "patchEdge");
spyOn(adapter, "deleteEdge");
};
beforeEach(function () {
nodes = [{
_id: 1
_id: 1,
name: "Alice"
},{
_id: 2
}];
edges = [{
source: nodes[0],
target: nodes[1]
target: nodes[1],
label: "oldLabel"
}];
adapter = mocks.adapter;
layouter = mocks.layouter;
this.loadNode = function() {};
spyOn(this, "loadNode");
addSpies();
var expandConfig = {
edges: edges,
nodes: nodes,
startCallback: function() {},
loadNode: this.loadNode,
reshapeNode: function() {}
},
dragConfig = {
layouter: layouter
},
nodeEditorConfig = {
nodes: nodes,
adapter: adapter
},
edgeEditorConfig = {
edges: edges,
adapter: adapter
},
completeConfig = {
expand: expandConfig,
drag: dragConfig,
nodeEditor: nodeEditorConfig,
edgeEditor: edgeEditorConfig
};
svg = document.createElement("svg");
document.body.appendChild(svg);
nodeShaper = new NodeShaper(d3.select("svg"));
edgeShaper = new EdgeShaper(d3.select("svg"));
dispatcher = new EventDispatcher(nodeShaper, edgeShaper);
list = document.createElement("ul");
document.body.appendChild(list);
list.id = "control_list";
nodeShaper.drawNodes(nodes);
edgeShaper.drawEdges(edges);
dispatcherUI = new EventDispatcherControls(list, dispatcher);
dispatcherUI = new EventDispatcherControls(list, nodeShaper, edgeShaper, completeConfig);
spyOn(nodeShaper, "changeTo").andCallThrough();
spyOn(edgeShaper, "changeTo").andCallThrough();
@ -80,7 +128,10 @@
}).toThrow("A list element has to be given.");
expect(function() {
var e = new EventDispatcherControls(list);
}).toThrow("The Dispatcher has to be given.");
}).toThrow("The NodeShaper has to be given.");
expect(function() {
var e = new EventDispatcherControls(list, nodeShaper);
}).toThrow("The EdgeShaper has to be given.");
});
it('should be able to add a drag control to the list', function() {
@ -94,7 +145,7 @@
expect(nodeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true,
drag: layouter.drag
drag: jasmine.any(Function)
}
});
@ -103,10 +154,15 @@
reset: true
}
});
});
helper.simulateMouseEvent("drag", "1");
expect(layouter.drag).toHaveBeenCalled();
});
it('should be able to add a edit control to the list', function() {
});
it('should be able to add an edit control to the list', function() {
runs(function() {
dispatcherUI.addControlEdit();
@ -114,14 +170,35 @@
helper.simulateMouseEvent("click", "control_edit");
expect(nodeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true,
click: jasmine.any(Function)
}
});
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true,
click: jasmine.any(Function)
}
});
helper.simulateMouseEvent("click", "1");
expect($("#control_node_edit_modal").length).toEqual(1);
// Todo check node edit dialog
helper.simulateMouseEvent("click", "control_node_edit_submit");
// Todo check adapter call
$("#control_node_edit_name_value").val("Bob");
helper.simulateMouseEvent("click", "control_node_edit_submit");
expect(adapter.patchNode).toHaveBeenCalledWith(
{ _id: 1,
name: "Alice"
},
{ _id: "1",
name: "Bob"
},
jasmine.any(Function));
});
waitsFor(function() {
@ -133,9 +210,17 @@
expect($("#control_edge_edit_modal").length).toEqual(1);
// Todo check node edit dialog
$("#control_edge_edit_label_value").val("newLabel");
helper.simulateMouseEvent("click", "control_edge_edit_submit");
// Todo check adapter call
expect(adapter.patchEdge).toHaveBeenCalledWith(
edges[0],
{
source: nodes[0],
target: nodes[1],
label: "newLabel"
},
jasmine.any(Function));
});
waitsFor(function() {
@ -152,6 +237,13 @@
helper.simulateMouseEvent("click", "control_expand");
expect(nodeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true,
click: jasmine.any(Function)
}
});
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true
@ -160,7 +252,7 @@
helper.simulateMouseEvent("click", "1");
//Todo Check for expand event
expect(this.loadNode).toHaveBeenCalledWith(nodes[0]._id, jasmine.any(Function));
});
});
@ -173,13 +265,34 @@
helper.simulateMouseEvent("click", "control_delete");
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true,
click: jasmine.any(Function)
}
});
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true,
click: jasmine.any(Function)
}
});
helper.simulateMouseEvent("click", "1");
// Todo check for del event
expect(adapter.deleteNode).toHaveBeenCalledWith(
nodes[0],
jasmine.any(Function)
);
helper.simulateMouseEvent("click", "1-2");
// Todo check for del event
expect(adapter.deleteEdge).toHaveBeenCalledWith(
edges[0],
jasmine.any(Function)
);
});
});
@ -192,6 +305,14 @@
helper.simulateMouseEvent("click", "control_connect");
expect(nodeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true,
mousedown: jasmine.any(Function),
mouseup: jasmine.any(Function)
}
});
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
actions: {
reset: true
}
@ -201,7 +322,10 @@
helper.simulateMouseEvent("mouseup", "1");
// Todo Adapter Check
expect(adapter.createEdge).toHaveBeenCalledWith(
{source: nodes[1], target: nodes[0]},
jasmine.any(Function)
);
});
});

View File

@ -220,6 +220,62 @@
});
describe('Drag', function() {
describe('setup process', function() {
it('should throw an error if layouter is not given', function() {
var testConfig = {};
expect(
function() {
eventLib.checkDragConfig(testConfig);
}
).toThrow("A layouter has to be defined");
expect(
function() {
eventLib.Drag(testConfig);
}
).toThrow("A layouter has to be defined");
});
it('should throw an error if the layouter does not offer a drag function', function() {
var testConfig = {
layouter: {}
};
expect(
function() {
eventLib.checkDragConfig(testConfig);
}
).toThrow("The layouter has to offer a drag function");
expect(
function() {
eventLib.Drag(testConfig);
}
).toThrow("The layouter has to offer a drag function");
testConfig.layouter.drag = 42;
expect(
function() {
eventLib.checkDragConfig(testConfig);
}
).toThrow("The layouter has to offer a drag function");
expect(
function() {
eventLib.Drag(testConfig);
}
).toThrow("The layouter has to offer a drag function");
});
});
});
describe('Insert Node', function() {
it('should create an event to add a node', function() {

View File

@ -0,0 +1,6 @@
{
"_id": 1337,
"children": [],
"name": "Alice",
"age": 42
}

View File

@ -7,3 +7,8 @@ Node: Children
4: 5 12
42: 43 44 45
1337: {
name: "Alice",
age: 42
}

View File

@ -0,0 +1,165 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global $, _, d3*/
/*global document*/
/*global modalDialogHelper, uiComponentsHelper */
/*global EventDispatcher, EventLibrary*/
////////////////////////////////////////////////////////////////////////////////
/// @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 EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig) {
"use strict";
if (list === undefined) {
throw "A list element has to be given.";
}
if (nodeShaper === undefined) {
throw "The NodeShaper has to be given.";
}
if (edgeShaper === undefined) {
throw "The EdgeShaper has to be given.";
}
var self = this,
baseClass = "event",
eventlib = new EventLibrary(),
dispatcher = new EventDispatcher(nodeShaper, edgeShaper, dispatcherConfig),
createButton = function(title, callback) {
uiComponentsHelper.createButton(
baseClass,
list,
title,
"control_" + title,
callback
);
},
rebindNodes = function(actions) {
dispatcher.rebind("nodes", actions);
},
rebindEdges = function(actions) {
dispatcher.rebind("edges", actions);
};
this.addControlDrag = function() {
var prefix = "control_drag",
idprefix = prefix + "_",
callback = function() {
rebindNodes( {
drag: dispatcher.events.DRAG
});
rebindEdges();
};
createButton("drag", callback);
};
this.addControlEdit = function() {
var prefix = "control_edit",
idprefix = prefix + "_",
nodeCallback = function(n) {
modalDialogHelper.createModalEditDialog(
"Edit Node " + n._id,
"control_node_edit_",
n,
function(newData) {
dispatcher.events.PATCHNODE(n, newData, function() {
$("#control_node_edit_modal").modal('hide');
})();
}
);
},
edgeCallback = function(e) {
modalDialogHelper.createModalEditDialog(
"Edit Edge " + e.source._id + "->" + e.target._id,
"control_edge_edit_",
e,
function(newData) {
dispatcher.events.PATCHEDGE(e, newData, function() {
$("#control_edge_edit_modal").modal('hide');
})();
}
);
},
callback = function() {
rebindNodes({click: nodeCallback});
rebindEdges({click: edgeCallback});
};
createButton("edit", callback);
};
this.addControlExpand = function() {
var prefix = "control_expand",
idprefix = prefix + "_",
callback = function() {
rebindNodes({click: dispatcher.events.EXPAND});
rebindEdges();
};
createButton("expand", callback);
};
this.addControlDelete = function() {
var prefix = "control_delete",
idprefix = prefix + "_",
callback = function() {
rebindNodes({click: dispatcher.events.DELETENODE(function() {
nodeShaper.reshapeNodes();
})});
rebindEdges({click: dispatcher.events.DELETEEDGE(function() {
edgeShaper.reshapeEdges();
})});
};
createButton("delete", callback);
};
this.addControlConnect = function() {
var prefix = "control_connect",
idprefix = prefix + "_",
callback = function() {
rebindNodes({
mousedown: dispatcher.events.STARTCREATEEDGE(),
mouseup: dispatcher.events.FINISHCREATEEDGE(function(){
edgeShaper.reshapeEdges();
})
});
rebindEdges();
};
createButton("connect", callback);
};
this.addAll = function () {
self.addControlDrag();
self.addControlEdit();
self.addControlExpand();
self.addControlDelete();
self.addControlConnect();
};
}

View File

@ -40,6 +40,8 @@ var modalDialogHelper = modalDialogHelper || {};
bodyDiv.className = "modal_body";
bodyTable.id = idprefix + "table";
footerDiv.className = "modal_footer";
buttonCancel.id = idprefix + "cancel";
@ -111,4 +113,48 @@ var modalDialogHelper = modalDialogHelper || {};
$("#" + idprefix + "modal").modal('show');
};
modalDialogHelper.createModalEditDialog = function(title, idprefix, object, callback) {
var tableToJSON,
callbackCapsule = function() {
callback(tableToJSON);
},
table = modalDialogHelper.modalDivTemplate(title, idprefix, callbackCapsule);
tableToJSON = function() {
var result = {};
_.each($("#" + idprefix + "table tr"), function(tr) {
var key = tr.children[0].children[0].value,
value = tr.children[1].children[0].value;
result[key] = value;
});
return result;
};
_.each(object, function(value, key) {
var tr = document.createElement("tr"),
keyTh = document.createElement("th"),
valueTh = document.createElement("th"),
keyInput,
valueInput;
table.appendChild(tr);
tr.appendChild(keyTh);
keyTh.className = "collectionTh";
keyInput = document.createElement("input");
keyInput.type = "text";
keyInput.id = idprefix + key + "_key";
keyInput.value = key;
keyTh.appendChild(keyInput);
tr.appendChild(valueTh);
valueTh.className = "collectionTh";
valueInput = document.createElement("input");
valueInput.type = "text";
valueInput.id = idprefix + key + "_value";
valueInput.value = value;
valueTh.appendChild(valueInput);
}
);
$("#" + idprefix + "modal").modal('show');
};
}());

View File

@ -0,0 +1,17 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
/*global document, $, _ */
var uiComponentsHelper = uiComponentsHelper || {};
(function componentsHelper() {
"use strict";
uiComponentsHelper.createButton = function(baseclass, list, title, prefix, callback) {
var button = document.createElement("li");
button.className = baseclass + "_control " + prefix;
button.id = prefix;
button.appendChild(document.createTextNode(title));
list.appendChild(button);
button.onclick = callback;
};
}());

View File

@ -332,7 +332,7 @@ Edge.prototype.properties = function () {
////////////////////////////////////////////////////////////////////////////////
Edge.prototype._PRINT = function (context) {
if (!this._id) {
if (!this._properties._id) {
context.output += "[deleted Edge]";
}
else if (this._properties._key !== undefined) {
@ -508,7 +508,7 @@ Vertex.prototype.properties = function () {
////////////////////////////////////////////////////////////////////////////////
Vertex.prototype._PRINT = function (context) {
if (! this._id) {
if (! this._properties._id) {
context.output += "[deleted Vertex]";
}
else if (this._properties._key !== undefined) {

View File

@ -58,7 +58,7 @@
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
discoveryUrl:"api-docs.json",
discoveryUrl:"http://192.168.173.10:8529/_admin/html/api-docs/api-docs.json",
apiKey: false,
dom_id:"swagger-ui-container",
supportHeaderParams: true,

View File

@ -809,6 +809,7 @@
var useColor = context.useColor;
var customInspect = context.customInspect;
var useToString = context.useToString;
if (typeof context.seen === "undefined") {
context.seen = [];
@ -836,7 +837,7 @@
else if (value.__proto__ === Object.prototype) {
printObject(value, context);
}
else if (typeof value.toString === "function") {
else if (typeof value === "function") {
// it's possible that toString() throws, and this looks quite ugly
try {
@ -863,8 +864,20 @@
context.output += "[Function]";
}
}
else {
else if (useToString && typeof value.toString === "function") {
try {
context.output += value.toString();
}
catch (e) {
context.output += "[Object ";
printObject(value, context);
context.output += "]";
}
}
else {
context.output += "[Object ";
printObject(value, context);
context.output += "]";
}
}
else if (value === undefined) {
@ -879,8 +892,7 @@
context.output += colors.COLOR_RESET;
}
}
else {
if (typeof(value) === "string") {
else if (typeof(value) === "string") {
if (useColor) {
context.output += colors.COLOR_STRING;
}
@ -928,7 +940,6 @@
context.output += String(value);
}
}
}
};
////////////////////////////////////////////////////////////////////////////////
@ -1000,7 +1011,8 @@
output: "",
prettyPrint: usePrettyPrint,
useColor: useColor,
customInspect: true
customInspect: true,
useToString: true
};
printRecursive(arguments[i], context);
@ -1040,7 +1052,8 @@
output: "",
prettyPrint: true,
useColor: false,
customInspect: options && options.customInspect
customInspect: options && options.customInspect,
useToString: false
};
printRecursive(object, context);

View File

@ -1212,7 +1212,7 @@ function require (path) {
libpath = fs.join(this._root, this._path, this._manifest[type]);
}
else {
libpath = fs.join(this._root, this._path);
libpath = fs.join(this._root, this._path, type);
}
var pkg = new Package("application",

View File

@ -331,7 +331,7 @@ Edge.prototype.properties = function () {
////////////////////////////////////////////////////////////////////////////////
Edge.prototype._PRINT = function (context) {
if (!this._id) {
if (!this._properties._id) {
context.output += "[deleted Edge]";
}
else if (this._properties._key !== undefined) {
@ -507,7 +507,7 @@ Vertex.prototype.properties = function () {
////////////////////////////////////////////////////////////////////////////////
Vertex.prototype._PRINT = function (context) {
if (! this._id) {
if (! this._properties._id) {
context.output += "[deleted Vertex]";
}
else if (this._properties._key !== undefined) {

View File

@ -90,7 +90,7 @@ function buildAssetContent (app, assets) {
match = reAll.exec(asset);
if (match !== null) {
throw "not implemented";
throw new Error("not implemented");
}
else {
files.push(fs.join(rootDir, asset));
@ -126,8 +126,9 @@ function installAssets (app, routes) {
var route;
desc = app._manifest;
if (! desc) {
throw "invalid application manifest";
throw new Error("invalid application manifest");
}
if (desc.hasOwnProperty('assets')) {
@ -195,32 +196,45 @@ function executeAppScript (app, name, mount, prefix) {
desc = app._manifest;
if (! desc) {
throw "invalid application manifest";
throw new Error("invalid application manifest, app " + internal.inspect(app));
}
var root;
if (app._id.substr(0,4) === "app:") {
root = module.appPath();
}
else if (app._id.substr(0,4) === "dev:") {
root = module.devAppPath();
}
else {
throw new Error("cannot extract root path for app '" + app._id + "', unknown type");
}
if (desc.hasOwnProperty(name)) {
var cp = appContext.collectionPrefix;
var context = {};
var cname = "";
if (cp !== "") {
context.appCollectionName = function (name) {
return cp + "_" + name;
cname = cp + "_";
}
var context = {};
context.app = {
collectionName: function (name) {
return cname + name;
},
path: function (name) {
return fs.join(root, app._path, name);
}
};
context.appCollection = function (name) {
return internal.db._collection(cp + "_" + name);
};
}
else {
context.appCollectionName = function (name) {
return name;
};
context.appCollection = function (name) {
return internal.db._collection(name);
};
}
app.loadAppScript(app.createAppModule(), desc[name], appContext, context);
}
}
@ -288,8 +302,8 @@ function installAalApp (app, mount, prefix, development) {
find = aal.firstExample({ type: "mount", mount: mount, active: true });
if (find !== null) {
throw "cannot use mount path '" + mount + "', already used by '"
+ find.app + "' (" + find._key + ")";
throw new Error("cannot use mount path '" + mount + "', already used by '"
+ find.app + "' (" + find._key + ")");
}
// .............................................................................
@ -339,7 +353,7 @@ function routingAalApp (app, mount, prefix) {
}
if (mount[0] !== "/") {
throw "mount point must be absolute";
throw new Error("mount point must be absolute");
}
// compute the collection prefix
@ -548,7 +562,7 @@ exports.installApp = function (appId, mount, options) {
app = module.createApp(appId);
if (app === null) {
throw "cannot find application '" + appId + "'";
throw new Error("cannot find application '" + appId + "'");
}
// .............................................................................
@ -559,8 +573,8 @@ exports.installApp = function (appId, mount, options) {
routes = routingAalApp(app, mount, prefix);
if (routes === null) {
throw "cannot compute the routing table for fox application '"
+ app._id + "', check the log file for errors!";
throw new Error("cannot compute the routing table for fox application '"
+ app._id + "', check the log file for errors!");
}
// .............................................................................
@ -604,7 +618,6 @@ exports.installDevApp = function (name, mount, options) {
'use strict';
var aal;
var app;
var desc;
var doc;
var prefix;
@ -619,7 +632,7 @@ exports.installDevApp = function (name, mount, options) {
var path = module.devAppPath();
if (typeof path === "undefined" || path === "") {
throw "dev-app-path is not set, cannot install development app '" + name + "'";
throw new Error("dev-app-path is not set, cannot install development app '" + name + "'");
}
var appId = null;
@ -628,11 +641,18 @@ exports.installDevApp = function (name, mount, options) {
if (fs.exists(filename)) {
appId = "dev:" + name + ":" + name;
}
else {
throw new Error("not manifest found at '" + filename + "'");
}
app = appId !== null && module.createApp(appId);
var app = null;
if (appId !== null) {
app = module.createApp(appId);
}
if (app === null) {
throw "cannot find development application '" + name + "'";
throw new Error("cannot find development application '" + appId + "'");
}
// .............................................................................
@ -680,7 +700,7 @@ exports.uninstallApp = function (key) {
}
if (doc === null) {
throw "key '" + key + "' is neither a mount id nor a mount point";
throw new Error("key '" + key + "' is neither a mount id nor a mount point");
}
var appId = doc.app;
@ -690,7 +710,7 @@ exports.uninstallApp = function (key) {
appDoc = aal.firstExample({ app: appId, type: "app" });
if (appDoc === null) {
throw "cannot find app '" + appId + "' in _aal collection";
throw new Error("cannot find app '" + appId + "' in _aal collection");
}
}

View File

@ -159,7 +159,7 @@ _.extend(Application.prototype, {
},
registerRepository: function (name, opts) {
this.routingInfo.repositories[name] = opts;
this.routingInfo.repositories[name] = opts || {};
},
////////////////////////////////////////////////////////////////////////////////

View File

@ -6,7 +6,7 @@ dnl ----------------------------------------------------------------------------
TRI_ZLIB_VERSION="1.2.7"
ZLIB_CPPFLAGS"=-I${srcdir}/3rdParty/zlib-${TRI_ZLIB_VERSION}/contrib/minizip"
ZLIB_CPPFLAGS="-I${srcdir}/3rdParty/zlib-${TRI_ZLIB_VERSION}/contrib/minizip"
ZLIB_LDFLAGS=""
ZLIB_LIBS="${srcdir}/3rdParty/zlib-${TRI_ZLIB_VERSION}/libz.a"

View File

@ -48,14 +48,12 @@ dnl ----------------------------------------------------------------------------
dnl check for header and library
dnl ----------------------------------------------------------------------------
ch_LIBEV="$tr_LIBEV"
tr_LIBEV="yes"
AC_CHECK_HEADERS(ev.h, [tr_LIBEV="yes"], [tr_LIBEV="no"])
AC_CHECK_HEADERS(ev.h, [], [tr_LIBEV="no"])
if test "x$tr_LIBEV" = xyes; then
AC_CHECK_LIB([rt], [clock_gettime], [LIBEV_LIBS="-lrt" LIBS="-lrt $LIBS"], )
AC_CHECK_LIB([libev], [ev_now], [LIBEV_LIBS="-lev $LIBEV_LIBS" tr_LIBEV="yes"], )
fi
AC_CHECK_LIB([rt], [clock_gettime], [LIBEV_LIBS="-lrt" LIBS="-lrt $LIBS"], [tr_LIBEV="no"])
AC_CHECK_LIB([ev], [ev_now], [LIBEV_LIBS="-lev $LIBEV_LIBS" tr_LIBEV="yes"], [tr_LIBEV="no"])
if test "x$tr_LIBEV" != xyes; then
AC_MSG_ERROR([Please install libev from http://software.schmorp.de/pkg/libev.html])