mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' into multiple_databases
This commit is contained in:
commit
7a476e9a13
|
@ -38,34 +38,37 @@ function ColourMapper() {
|
|||
self = this,
|
||||
nextColour = 0;
|
||||
|
||||
colours.push("navy");
|
||||
colours.push("green");
|
||||
colours.push("gold");
|
||||
colours.push("red");
|
||||
colours.push("saddlebrown");
|
||||
colours.push("skyblue");
|
||||
colours.push("olive");
|
||||
colours.push("deeppink");
|
||||
colours.push("orange");
|
||||
colours.push("silver");
|
||||
colours.push("blue");
|
||||
colours.push("yellowgreen");
|
||||
colours.push("firebrick");
|
||||
colours.push("rosybrown");
|
||||
colours.push("hotpink");
|
||||
colours.push("purple");
|
||||
colours.push("cyan");
|
||||
colours.push("teal");
|
||||
colours.push("peru");
|
||||
colours.push("maroon");
|
||||
colours.push({back: "navy", front: "white"});
|
||||
colours.push({back: "green", front: "white"});
|
||||
colours.push({back: "gold", front: "black"});
|
||||
colours.push({back: "red", front: "black"});
|
||||
colours.push({back: "saddlebrown", front: "white"});
|
||||
colours.push({back: "skyblue", front: "black"});
|
||||
colours.push({back: "olive", front: "black"});
|
||||
colours.push({back: "deeppink", front: "black"});
|
||||
colours.push({back: "orange", front: "black"});
|
||||
colours.push({back: "silver", front: "black"});
|
||||
colours.push({back: "blue", front: "white"});
|
||||
colours.push({back: "yellowgreen", front: "black"});
|
||||
colours.push({back: "firebrick", front: "black"});
|
||||
colours.push({back: "rosybrown", front: "black"});
|
||||
colours.push({back: "hotpink", front: "black"});
|
||||
colours.push({back: "purple", front: "white"});
|
||||
colours.push({back: "cyan", front: "black"});
|
||||
colours.push({back: "teal", front: "black"});
|
||||
colours.push({back: "peru", front: "black"});
|
||||
colours.push({back: "maroon", front: "white"});
|
||||
|
||||
this.getColour = function(value) {
|
||||
if (mapping[value] === undefined) {
|
||||
mapping[value] = colours[nextColour];
|
||||
if (reverseMapping[colours[nextColour]] === undefined) {
|
||||
reverseMapping[colours[nextColour]] = [];
|
||||
if (reverseMapping[colours[nextColour].back] === undefined) {
|
||||
reverseMapping[colours[nextColour].back] = {
|
||||
front: colours[nextColour].front,
|
||||
list: []
|
||||
};
|
||||
}
|
||||
reverseMapping[colours[nextColour]].push(value);
|
||||
reverseMapping[colours[nextColour].back].list.push(value);
|
||||
nextColour++;
|
||||
if (nextColour === colours.length) {
|
||||
nextColour = 0;
|
||||
|
@ -74,10 +77,30 @@ function ColourMapper() {
|
|||
if (listener !== undefined) {
|
||||
listener(self.getList());
|
||||
}
|
||||
return mapping[value];
|
||||
return mapping[value].back;
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.getForegroundColour = function(value) {
|
||||
if (mapping[value] === undefined) {
|
||||
mapping[value] = colours[nextColour];
|
||||
if (reverseMapping[colours[nextColour].back] === undefined) {
|
||||
reverseMapping[colours[nextColour].back] = {
|
||||
front: colours[nextColour].front,
|
||||
list: []
|
||||
};
|
||||
}
|
||||
reverseMapping[colours[nextColour].back].list.push(value);
|
||||
nextColour++;
|
||||
if (nextColour === colours.length) {
|
||||
nextColour = 0;
|
||||
}
|
||||
}
|
||||
if (listener !== undefined) {
|
||||
listener(self.getList());
|
||||
}
|
||||
return mapping[value].front;
|
||||
};
|
||||
|
||||
|
||||
this.reset = function() {
|
||||
mapping = {};
|
||||
|
|
|
@ -110,6 +110,7 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
addColor = noop,
|
||||
addShape = noop,
|
||||
addLabel = noop,
|
||||
addLabelColor = function() {return "black";},
|
||||
addCommunityShape = function(g) {
|
||||
g.append("polygon")
|
||||
.attr("points", "0,-25 -16,20 23,-10 -23,-10 16,20");
|
||||
|
@ -248,7 +249,9 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
.attr("width", width) // Set width
|
||||
.attr("height", height) // Set height
|
||||
.attr("x", translateX)
|
||||
.attr("y", translateY);
|
||||
.attr("y", translateY)
|
||||
.attr("rx", "8")
|
||||
.attr("ry", "8");
|
||||
};
|
||||
break;
|
||||
case undefined:
|
||||
|
@ -263,7 +266,7 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
addLabel = function (node) {
|
||||
var textN = node.append("text") // Append a label for the node
|
||||
.attr("text-anchor", "middle") // Define text-anchor
|
||||
.attr("fill", "black") // Force a black color
|
||||
.attr("fill", addLabelColor) // Force a black color
|
||||
.attr("stroke", "none"); // Make it readable
|
||||
textN.each(function(d) {
|
||||
var chunks = splitLabel(label(d));
|
||||
|
@ -283,7 +286,7 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
addLabel = function (node) {
|
||||
var textN = node.append("text") // Append a label for the node
|
||||
.attr("text-anchor", "middle") // Define text-anchor
|
||||
.attr("fill", "black") // Force a black color
|
||||
.attr("fill", addLabelColor) // Force a black color
|
||||
.attr("stroke", "none"); // Make it readable
|
||||
textN.each(function(d) {
|
||||
var chunks = splitLabel(d._data[label]);
|
||||
|
@ -320,6 +323,9 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
g.attr("stroke", color.stroke);
|
||||
g.attr("fill", color.fill);
|
||||
};
|
||||
addLabelColor = function (d) {
|
||||
return color.stroke;
|
||||
};
|
||||
break;
|
||||
case "expand":
|
||||
addColor = function (g) {
|
||||
|
@ -336,6 +342,9 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
return color.collapsed;
|
||||
});
|
||||
};
|
||||
addLabelColor = function (d) {
|
||||
return "black";
|
||||
};
|
||||
break;
|
||||
case "attribute":
|
||||
addColor = function (g) {
|
||||
|
@ -352,6 +361,13 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
return colourMapper.getColour(n._data[color.key]);
|
||||
});
|
||||
};
|
||||
addLabelColor = function (n) {
|
||||
if (n._data === undefined) {
|
||||
return colourMapper.getForegroundColour(undefined);
|
||||
}
|
||||
return colourMapper.getForegroundColour(n._data[color.key]);
|
||||
|
||||
};
|
||||
break;
|
||||
default:
|
||||
throw "Sorry given colour-scheme not known";
|
||||
|
|
|
@ -125,8 +125,8 @@
|
|||
|
||||
expect(_.keys(colorList).length).toEqual(3);
|
||||
_.each(_.values(colorList), function(v) {
|
||||
expect(v).toEqual(jasmine.any(Array));
|
||||
expect(v.length).toEqual(1);
|
||||
expect(v.list).toEqual(jasmine.any(Array));
|
||||
expect(v.list.length).toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
"use strict";
|
||||
|
||||
describe('Event Dispatcher UI', function () {
|
||||
var svg, dispatcher, dispatcherUI, list,
|
||||
var svg, dispatcherUI, list,
|
||||
nodeShaper, edgeShaper, layouter,
|
||||
nodes, edges, adapter,
|
||||
mousePointerbox,
|
||||
|
@ -149,6 +149,7 @@
|
|||
spyOn(nodeShaper, "changeTo").andCallThrough();
|
||||
spyOn(edgeShaper, "changeTo").andCallThrough();
|
||||
|
||||
|
||||
this.addMatchers({
|
||||
toBeTag: function(name) {
|
||||
var item = this.actual;
|
||||
|
@ -207,6 +208,57 @@
|
|||
}).toThrow("The EdgeShaper has to be given.");
|
||||
});
|
||||
|
||||
it('should be able to add a new node control to the list', function() {
|
||||
runs(function() {
|
||||
dispatcherUI.addControlNewNode();
|
||||
|
||||
expect($("#control_event_list #control_event_newnode").length).toEqual(1);
|
||||
|
||||
helper.simulateMouseEvent("click", "control_event_newnode");
|
||||
|
||||
expect(nodeShaper.changeTo).toHaveBeenCalledWith({
|
||||
actions: {
|
||||
reset: true
|
||||
}
|
||||
});
|
||||
|
||||
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
|
||||
actions: {
|
||||
reset: true
|
||||
}
|
||||
});
|
||||
|
||||
expect(mousePointerbox.className).toEqual("mousepointer icon-plus-sign");
|
||||
|
||||
helper.simulateMouseEvent("click", "svg");
|
||||
|
||||
expect($("#control_event_new_node_modal").length).toEqual(1);
|
||||
|
||||
//$("#control_event_node_edit_name_value").val("Bob");
|
||||
|
||||
helper.simulateMouseEvent("click", "control_event_new_node_submit");
|
||||
|
||||
expect(adapter.createNode).toHaveBeenCalledWith(
|
||||
{},
|
||||
jasmine.any(Function)
|
||||
);
|
||||
/*
|
||||
expect(adapter.createNode).toHaveBeenCalledWith(
|
||||
{
|
||||
name: "Bob"
|
||||
},
|
||||
jasmine.any(Function)
|
||||
);
|
||||
*/
|
||||
});
|
||||
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_event_node_edit_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
});
|
||||
|
||||
it('should be able to add a drag control to the list', function() {
|
||||
runs(function() {
|
||||
dispatcherUI.addControlDrag();
|
||||
|
@ -476,6 +528,7 @@
|
|||
expect($("#control_event_list #control_event_expand").length).toEqual(1);
|
||||
expect($("#control_event_list #control_event_delete").length).toEqual(1);
|
||||
expect($("#control_event_list #control_event_connect").length).toEqual(1);
|
||||
expect($("#control_event_list #control_event_newnode").length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -315,8 +315,8 @@
|
|||
|
||||
expect(_.keys(colorList).length).toEqual(3);
|
||||
_.each(_.values(colorList), function(v) {
|
||||
expect(v).toEqual(jasmine.any(Array));
|
||||
expect(v.length).toEqual(1);
|
||||
expect(v.list).toEqual(jasmine.any(Array));
|
||||
expect(v.list.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -736,6 +736,26 @@
|
|||
|
||||
});
|
||||
|
||||
it('should add rounded corners', function() {
|
||||
var nodes = [
|
||||
{_id: 1},
|
||||
{_id: 2}
|
||||
];
|
||||
shaper = new NodeShaper(d3.select("svg"),
|
||||
{
|
||||
shape: {
|
||||
type: NodeShaper.shapes.RECT
|
||||
}
|
||||
});
|
||||
shaper.drawNodes(nodes);
|
||||
|
||||
expect($("svg #1 rect").attr("rx")).toEqual("8");
|
||||
expect($("svg #2 rect").attr("rx")).toEqual("8");
|
||||
|
||||
expect($("svg #1 rect").attr("ry")).toEqual("8");
|
||||
expect($("svg #2 rect").attr("ry")).toEqual("8");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('configured for label', function () {
|
||||
|
@ -775,7 +795,7 @@
|
|||
textEl;
|
||||
shaper.drawNodes(node);
|
||||
textEl = $("svg .node text");
|
||||
expect(textEl.attr("fill")).toEqual("black");
|
||||
expect(textEl.attr("fill")).toEqual("#8AA051");
|
||||
expect(textEl.attr("stroke")).toEqual("none");
|
||||
});
|
||||
|
||||
|
|
|
@ -52,8 +52,14 @@
|
|||
spyOn(shaper, 'changeTo');
|
||||
spyOn(shaper, 'getColourMapping').andCallFake(function() {
|
||||
return {
|
||||
"blue": ["bl", "ue"],
|
||||
"green": ["gr", "een"]
|
||||
blue: {
|
||||
list: ["bl", "ue"],
|
||||
front: "white"
|
||||
},
|
||||
green: {
|
||||
list: ["gr", "een"],
|
||||
front: "black"
|
||||
}
|
||||
};
|
||||
});
|
||||
spyOn(shaper, "setColourMappingListener");
|
||||
|
|
|
@ -135,6 +135,32 @@ function EventDispatcherControls(list, cursorIconBox, nodeShaper, edgeShaper, di
|
|||
cursorIconBox.style.display = "block";
|
||||
});
|
||||
|
||||
this.addControlNewNode = function() {
|
||||
var prefix = "control_event_newnode",
|
||||
idprefix = prefix + "_",
|
||||
icon = "plus-sign",
|
||||
createCallback = function(n) {
|
||||
modalDialogHelper.createModalEditDialog(
|
||||
"Create New Node",
|
||||
"control_event_new_node_",
|
||||
{},
|
||||
function(data) {
|
||||
dispatcher.events.CREATENODE(data, function() {
|
||||
$("#control_event_new_node_modal").modal('hide');
|
||||
})();
|
||||
}
|
||||
);
|
||||
},
|
||||
callback = function() {
|
||||
setCursorIcon(icon);
|
||||
rebindNodes();
|
||||
rebindEdges();
|
||||
rebindSVG({click: createCallback});
|
||||
};
|
||||
createIcon(icon, "newnode", callback);
|
||||
};
|
||||
|
||||
|
||||
this.addControlDrag = function() {
|
||||
var prefix = "control_event_drag",
|
||||
idprefix = prefix + "_",
|
||||
|
@ -256,6 +282,7 @@ function EventDispatcherControls(list, cursorIconBox, nodeShaper, edgeShaper, di
|
|||
self.addControlExpand();
|
||||
self.addControlDelete();
|
||||
self.addControlConnect();
|
||||
self.addControlNewNode();
|
||||
};
|
||||
|
||||
}
|
|
@ -47,9 +47,12 @@ function NodeShaperControls(list, shaper) {
|
|||
}
|
||||
var list = document.createElement("ul");
|
||||
colourDiv.appendChild(list);
|
||||
_.each(mapping, function(els, col) {
|
||||
var li = document.createElement("li");
|
||||
_.each(mapping, function(obj, col) {
|
||||
var li = document.createElement("li"),
|
||||
els = obj.list,
|
||||
fore = obj.front;
|
||||
li.style.backgroundColor = col;
|
||||
li.style.color = fore;
|
||||
li.appendChild(document.createTextNode(els.join(", ")));
|
||||
list.appendChild(li);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue