1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
Jan Steemann 2015-06-08 16:16:21 +02:00
commit ba7dbbea17
8 changed files with 133 additions and 342 deletions

View File

@ -289,7 +289,7 @@ pack-win64:
$(MAKE) pack-winXX BITS=64 TARGET="Visual Studio 12 Win64"
pack-win32-relative:
$(MAKE) pack-winXX BITS=32 TARGET="Visual Studio 12" MOREOPTS='-D "USE_RELATIVE=ON"'
$(MAKE) pack-winXX BITS=32 TARGET="Visual Studio 12" MOREOPTS='-D "USE_RELATIVE=ON" -D "USER_MAINTAINER_MODE=ON" -D "USE_BACKTRACE=ON"'
pack-win64-relative:
$(MAKE) pack-winXX BITS=64 TARGET="Visual Studio 12 Win64" MOREOPTS='-D "USE_RELATIVE=ON" -D "USER_MAINTAINER_MODE=ON" -D "USE_BACKTRACE=ON"'

View File

@ -2517,6 +2517,8 @@ div .tile, div .bigtile {
div .tile {
height: 100px;
width: 228px; }
div .tile-graph .tile-icon:hover {
cursor: pointer; }
div .bigtile {
height: 309px;
width: 456px; }
@ -5112,6 +5114,8 @@ div .tile, div .bigtile {
div .tile {
height: 100px;
width: 228px; }
div .tile-graph .tile-icon:hover {
cursor: pointer; }
div .bigtile {
height: 309px;
width: 456px; }

View File

@ -270,8 +270,8 @@ function GharialAdapter(nodes, edges, viewer, config) {
self.NODES_TO_DISPLAY = 30;
self.TOTAL_NODES = 0;
self.customNodes = [];
self.extraNodes = [];
self.definedNodes = [];
self.randomNodes = [];
self.loadRandomNode = function(callback) {
var collections = _.shuffle(self.getNodeCollections()), i;
@ -282,7 +282,7 @@ function GharialAdapter(nodes, edges, viewer, config) {
if (list.length > 0) {
var counter = 0;
_.each(list, function(node) {
self.extraNodes.push(node);
self.randomNodes.push(node);
});
self.loadInitialNode(list[0]._id, callback);
return;
@ -298,18 +298,19 @@ function GharialAdapter(nodes, edges, viewer, config) {
self.loadNode(nodeId, insertInitialCallback(callback));
};
self.addCustomNodes = function () {
self.getRandomNodes = function () {
var nodeArray = [];
var nodes = [];
//if no extra nodes available, get "NODES_TO_DISPLAY"-random nodes
if (self.customNodes.length > 0) {
nodes = self.customNodes;
if (self.definedNodes.length > 0) {
_.each(self.definedNodes, function(node) {
nodes.push(node);
});
}
//else: get defined nodes
else if (self.extraNodes.length > 0) {
nodes = self.extraNodes;
if (self.randomNodes.length > 0) {
_.each(self.randomNodes, function(node) {
nodes.push(node);
});
}
var counter = 0;
@ -335,16 +336,28 @@ function GharialAdapter(nodes, edges, viewer, config) {
example: nodeId
}, function(res) {
_.each(self.addCustomNodes(), function(node) {
sendQuery(queries.traversal, {
example: node.vertex._id
}, function(res2) {
_.each(res2[0][0], function(obj) {
res[0][0].push(obj);
var nodes = [];
nodes = self.getRandomNodes();
if (nodes.length > 0) {
_.each(nodes, function(node) {
sendQuery(queries.traversal, {
example: node.vertex._id
}, function(res2) {
_.each(res2[0][0], function(obj) {
res[0][0].push(obj);
});
parseResultOfTraversal(res, callback);
});
});
}
else {
sendQuery(queries.traversal, {
example: nodeId
}, function(res) {
parseResultOfTraversal(res, callback);
});
});
}
});
};
@ -359,6 +372,35 @@ function GharialAdapter(nodes, edges, viewer, config) {
});
};
self.getNodeExampleFromTreeByAttributeValue = function(attribute, value, callback) {
var example = {};
example[attribute] = value;
sendQuery(queries.traversal, {
example: example
}, function(res) {
if (res[0][0] === undefined) {
throw "No suitable nodes have been found.";
}
else {
_.each(res[0][0], function(node) {
var nodeToAdd = {};
nodeToAdd._key = node.vertex._key;
nodeToAdd._id = node.vertex._id;
nodeToAdd._rev = node.vertex._rev;
absAdapter.insertNode(nodeToAdd);
callback(nodeToAdd);
});
}
});
};
self.loadAdditionalNodeByAttributeValue = function(attribute, value, callback) {
self.getNodeExampleFromTreeByAttributeValue(attribute, value, callback);
};
self.loadInitialNodeByAttributeValue = function(attribute, value, callback) {
absAdapter.cleanUp();
self.loadNodeFromTreeByAttributeValue(attribute, value, insertInitialCallback(callback));

View File

@ -191,7 +191,7 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
//expand all wanted nodes
if (expand) {
_.each(nodes, function(node) {
_.each(adapter.extraNodes, function(compare) {
_.each(adapter.randomNodes, function(compare) {
if (node._id === compare._id) {
node._expanded = true;
}
@ -234,13 +234,33 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
});
};
this.loadGraphWithAdditionalNode = function(attribute, value, callback) {
adapter.loadAdditionalNodeByAttributeValue(attribute, value, function (node) {
if (node.errorCode) {
callback(node);
return;
}
node._expanded = true;
self.start();
if (_.isFunction(callback)) {
callback();
}
});
};
this.loadGraphWithAttributeValue = function(attribute, value, callback) {
//clear random and defined nodes
adapter.randomNodes = [];
adapter.definedNodes = [];
adapter.loadInitialNodeByAttributeValue(attribute, value, function (node) {
if (node.errorCode) {
callback(node);
return;
}
node._expanded = true;
self.start();
if (_.isFunction(callback)) {
callback();

View File

@ -52,8 +52,6 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
edgeShaperUI,
adapterUI,
slider,
searchAttrField,
searchAttrField2,
searchAttrExampleList,
searchAttrExampleList2,
//mousePointerBox = document.createElement("div"),
@ -79,6 +77,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
searchValueField = document.createElement("input"),
searchStart = document.createElement("img"),
equalsField = document.createElement("span"),
searchAttrField,
showSpinner = function() {
$(background).css("cursor", "progress");
@ -128,7 +127,6 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
searchAttrDiv.className = "pull-left input-append searchByAttribute";
searchAttrField.id = "attribute";
//searchAttrField.className = "input";
searchAttrField.type = "text";
searchAttrField.placeholder = "Attribute name";
searchAttrExampleToggle.id = "attribute_example_toggle";
@ -183,6 +181,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
searchValueField2 = document.createElement("input"),
searchStart2 = document.createElement("img"),
equalsField2 = document.createElement("span"),
searchAttrField2,
showSpinner = function() {
$(background).css("cursor", "progress");
@ -196,7 +195,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
window.alert(msg);
},
resultCB = function(res) {
resultCB2 = function(res) {
hideSpinner();
if (res && res.errorCode && res.errorCode === 404) {
alertError("Sorry could not find a matching node.");
@ -205,19 +204,13 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
return;
},
searchFunction = function() {
addCustomNode = function() {
showSpinner();
if (searchAttrField.value === ""
|| searchAttrField.value === undefined) {
graphViewer.loadGraph(
searchValueField.value,
resultCB
);
} else {
graphViewer.loadGraphWithAttributeValue(
searchAttrField.value,
searchValueField.value,
resultCB
if (searchAttrField2.value !== "") {
graphViewer.loadGraphWithAdditionalNode(
searchAttrField2.value,
searchValueField2.value,
resultCB2
);
}
};
@ -234,7 +227,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
searchAttrField2.id = "attribute";
searchAttrField2.type = "text";
searchAttrField2.placeholder = "Attribute name";
searchAttrExampleToggle2.id = "attribute_example_toggle";
searchAttrExampleToggle2.id = "attribute_example_toggle2";
searchAttrExampleToggle2.className = "button-neutral gv_example_toggle";
searchAttrExampleCaret2.className = "caret gv_caret";
searchAttrExampleList2.className = "gv-dropdown-menu";
@ -259,10 +252,15 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
queryLine2.appendChild(searchValueField2);
queryLine2.appendChild(searchStart2);
searchStart2.onclick = searchFunction;
updateAttributeExamples(searchAttrExampleList2);
//searchAttrExampleList2.onclick = function() {
// updateAttributeExamples(searchAttrExampleList2);
//};
searchStart2.onclick = addCustomNode;
$(searchValueField2).keypress(function(e) {
if (e.keyCode === 13 || e.which === 13) {
searchFunction();
addCustomNode();
return false;
}
});
@ -344,7 +342,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
aNode.className = "headerButton";
spanNode = document.createElement("span");
spanNode.className = "fa fa-search-plus";
$(spanNode).attr("title", "Show custom nodes");
$(spanNode).attr("title", "Show additional nodes");
ul.appendChild(liNode);
liNode.appendChild(aNode);
@ -480,32 +478,37 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
$("#control_event_expand").click();
},
updateAttributeExamples = function() {
searchAttrExampleList.innerHTML = "";
searchAttrExampleList2.innerHTML = "";
updateAttributeExamples = function(e) {
var element;
if (e) {
element = $(e);
}
else {
element = $(searchAttrExampleList);
}
element.innerHTML = "";
var throbber = document.createElement("li"),
throbberImg = document.createElement("img");
throbber.appendChild(throbberImg);
$(throbber).append(throbberImg);
throbberImg.className = "gv-throbber";
searchAttrExampleList.appendChild(throbber);
searchAttrExampleList2.appendChild(throbber);
element.append(throbber);
graphViewer.adapter.getAttributeExamples(function(res) {
searchAttrExampleList.innerHTML = "";
searchAttrExampleList2.innerHTML = "";
$(element).html('');
_.each(res, function(r) {
var entry = document.createElement("li"),
link = document.createElement("a"),
lbl = document.createElement("label");
entry.appendChild(link);
link.appendChild(lbl);
lbl.appendChild(document.createTextNode(r));
$(entry).append(link);
$(link).append(lbl);
$(lbl).append(document.createTextNode(r));
lbl.className = "gv_dropdown_label";
searchAttrExampleList.appendChild(entry);
searchAttrExampleList2.appendChild(entry);
element.append(entry);
entry.onclick = function() {
searchAttrField.value = r;
$(searchAttrExampleList).slideToggle(200);
$(searchAttrExampleList2).slideToggle(200);
element.value = r;
$(element).parent().find('input').val(r);
$(element).slideToggle(200);
};
});
});

View File

@ -26,8 +26,7 @@
"click #deleteDocumentButton" : "deleteDocumentModal",
"click #confirmDeleteDocument" : "deleteDocument",
"click #document-from" : "navigateToDocument",
"click #document-to" : "navigateToDocument",
"dblclick #documentEditor tr" : "addProperty"
"click #document-to" : "navigateToDocument"
},
editor: 0,
@ -157,42 +156,6 @@
return this;
},
addProperty: function (e) {
var node, searchResult;
try {
node = e.currentTarget.cells[2].childNodes[0].
childNodes[0].childNodes[0].childNodes[1].
childNodes[0].textContent;
} catch (ex) {
}
if (node) {
if (node === "object") {
if (_.isEmpty(this.editor.get())) {
this.editor.set({
"": ""
});
this.editor.node.childs[0].focus("field");
} else {
this.editor.node.childs[0]._onInsertBefore(undefined, undefined, "auto");
}
return;
}
searchResult = this.editor.node.search(node);
var breakLoop = false;
searchResult.forEach(function (s) {
if (breakLoop) {
return;
}
if (s.elem === "field" ) {
s.node._onInsertAfter(undefined, undefined, "auto");
breakLoop = true;
}
});
}
},
removeReadonlyKeys: function (object) {
return _.omit(object, ["_key", "_id", "_from", "_to", "_rev"]);
},

View File

@ -229,6 +229,12 @@ div {
width: $tile-width - 12px;
}
& .tile-graph {
.tile-icon:hover {
cursor:pointer;
}
}
& .bigtile {
@extend %clickable;
@extend %tile;

View File

@ -50,8 +50,7 @@
"click #deleteDocumentButton" : "deleteDocumentModal",
"click #confirmDeleteDocument" : "deleteDocument",
"click #document-from" : "navigateToDocument",
"click #document-to" : "navigateToDocument",
"dblclick #documentEditor tr" : "addProperty"
"click #document-to" : "navigateToDocument"
});
});
@ -285,252 +284,6 @@
expect(view.escaped('&<>"\'')).toEqual("&amp;&lt;&gt;&quot;&#39;");
});
it("should addProperty in existing json document", function () {
var eDummy = {
currentTarget : {
cells : [
"",
"",
{
childNodes : [
{
childNodes : [
{
childNodes : [
{
childNodes : [
"",
{
childNodes : [
{
textContent : "bla"
}
]
}
]
}
]
}
]
}
]
}
]
}
}, editorDummy = {
node : {
search : function () {
}
}
}, nodeDummy1 = {elem : "value", node : {_onInsertAfter : function () {}}},
nodeDummy2 = {elem : "field", node : {_onInsertAfter : function () {}}} ;
spyOn(editorDummy.node, "search").andReturn([
nodeDummy1,
nodeDummy2,
nodeDummy1
]);
spyOn(nodeDummy1.node, "_onInsertAfter");
spyOn(nodeDummy2.node, "_onInsertAfter");
view.editor = editorDummy;
view.addProperty(eDummy);
expect(editorDummy.node.search).toHaveBeenCalledWith("bla");
expect(nodeDummy1.node._onInsertAfter).not.toHaveBeenCalled();
expect(nodeDummy2.node._onInsertAfter).toHaveBeenCalledWith(
undefined, undefined, "auto");
});
it("should addProperty in existing json document in first position", function () {
var eDummy = {
currentTarget : {
cells : [
"",
"",
{
childNodes : [
{
childNodes : [
{
childNodes : [
{
childNodes : [
"",
{
childNodes : [
{
textContent : "object"
}
]
}
]
}
]
}
]
}
]
}
]
}
}, editorDummy = {
node : {
search : function () {
},
childs : [
{
focus : function () {},
_onInsertBefore : function () {
}
}
]
},
get : function () {
},
set : function () {
}
}, nodeDummy1 = {elem : "value", _onInsertAfter : function () {}},
nodeDummy2 = {elem : "value", _onInsertAfter : function () {}} ;
spyOn(editorDummy.node, "search").andReturn([
nodeDummy1,
nodeDummy2,
nodeDummy1
]);
spyOn(nodeDummy1, "_onInsertAfter");
spyOn(nodeDummy2, "_onInsertAfter");
spyOn(editorDummy, "get").andReturn([
nodeDummy1,
nodeDummy2,
nodeDummy1
]);
spyOn(editorDummy, "set");
spyOn(editorDummy.node.childs[0], "_onInsertBefore");
spyOn(editorDummy.node.childs[0], "focus");
view.editor = editorDummy;
view.addProperty(eDummy);
expect(editorDummy.node.search).not.toHaveBeenCalled();
expect(editorDummy.node.childs[0].focus).not.toHaveBeenCalled();
expect(editorDummy.node.childs[0]._onInsertBefore).toHaveBeenCalledWith(
undefined, undefined, "auto");
expect(editorDummy.get).toHaveBeenCalled();
expect(editorDummy.set).not.toHaveBeenCalled();
});
it("should addProperty in new json document in first position", function () {
var eDummy = {
currentTarget : {
cells : [
"",
"",
{
childNodes : [
{
childNodes : [
{
childNodes : [
{
childNodes : [
"",
{
childNodes : [
{
textContent : "object"
}
]
}
]
}
]
}
]
}
]
}
]
}
}, editorDummy = {
node : {
search : function () {
},
childs : [
{
focus : function () {},
_onInsertBefore : function () {
}
}
]
},
get : function () {
},
set : function () {
}
}, nodeDummy1 = {elem : "value", _onInsertAfter : function () {}},
nodeDummy2 = {elem : "value", _onInsertAfter : function () {}} ;
spyOn(editorDummy.node, "search").andReturn([
nodeDummy1,
nodeDummy2,
nodeDummy1
]);
spyOn(nodeDummy1, "_onInsertAfter");
spyOn(nodeDummy2, "_onInsertAfter");
spyOn(editorDummy, "get").andReturn(undefined);
spyOn(editorDummy, "set");
spyOn(editorDummy.node.childs[0], "_onInsertBefore");
spyOn(editorDummy.node.childs[0], "focus");
view.editor = editorDummy;
view.addProperty(eDummy);
expect(editorDummy.node.search).not.toHaveBeenCalled();
expect(editorDummy.node.childs[0].focus).toHaveBeenCalledWith("field");
expect(editorDummy.node.childs[0]._onInsertBefore).not.toHaveBeenCalled();
expect(editorDummy.get).toHaveBeenCalled();
expect(editorDummy.set).toHaveBeenCalledWith({
"": ""
});
});
});