mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel
This commit is contained in:
commit
a872e09869
|
@ -118,16 +118,16 @@ Furthermore you can describe your API by chaining the following methods onto you
|
|||
#### Describing a queryParam
|
||||
@copydetails JSF_foxx_RequestContext_queryParam
|
||||
|
||||
### Documenting the nickname of a route
|
||||
#### Documenting the nickname of a route
|
||||
@copydetails JSF_foxx_RequestContext_nickname
|
||||
|
||||
### Documenting the summary of a route
|
||||
#### Documenting the summary of a route
|
||||
@copydetails JSF_foxx_RequestContext_summary
|
||||
|
||||
### Documenting the notes of a route
|
||||
#### Documenting the notes of a route
|
||||
@copydetails JSF_foxx_RequestContext_notes
|
||||
|
||||
### Documenting the error response of a route
|
||||
#### Documenting the error response of a route
|
||||
@copydetails JSF_foxx_RequestContext_errorResponse
|
||||
|
||||
### Before and After Hooks
|
||||
|
@ -218,10 +218,11 @@ A Foxx Model can be initialized with an object of attributes and their values.
|
|||
@copydetails JSF_foxx_model_has
|
||||
|
||||
#### Foxx.Model#attributes
|
||||
@copydetails JSF_foxx_model_attributes
|
||||
|
||||
The attributes property is the internal hash containing the model's state.
|
||||
|
||||
#### Foxx.Model#toJSON
|
||||
@copydetails JSF_foxx_model_toJSON
|
||||
@copydetails jsf_foxx_model_toJSON
|
||||
|
||||
## Foxx.Repository
|
||||
|
||||
|
@ -237,17 +238,17 @@ A repository is a gateway to the database. It gets data from the database, updat
|
|||
#### new Foxx.Repository
|
||||
@copydetails JSF_foxx_repository_initializer
|
||||
|
||||
#### Foxx.Repository.extend
|
||||
@copydetails JSF_foxx_repository_extend
|
||||
|
||||
#### Foxx.Repository#collection
|
||||
@copydetails JSF_foxx_repository_collection
|
||||
|
||||
The collection object.
|
||||
|
||||
#### Foxx.Repository#prefix
|
||||
@copydetails JSF_foxx_repository_prefix
|
||||
|
||||
The prefix of the application.
|
||||
|
||||
#### Foxx.Repository#modelPrototype
|
||||
@copydetails JSF_foxx_repository_modelPrototype
|
||||
|
||||
The prototype of the according model.
|
||||
|
||||
#### Foxx.Repository#save
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<script src="../lib/jquery-1.8.3.js"></script>
|
||||
<script type="text/javascript" src="../lib/bootstrap.js"></script>
|
||||
<script src="../lib/jquery.livequery.js"></script>
|
||||
<script src="graph/colourMapper.js"></script>
|
||||
<script src="graph/forceLayouter.js"></script>
|
||||
<script src="graph/eventLibrary.js"></script>
|
||||
<script src="graph/eventDispatcher.js"></script>
|
||||
|
|
|
@ -38,7 +38,7 @@ function ColourMapper() {
|
|||
colours.push("navy");
|
||||
colours.push("green");
|
||||
colours.push("gold");
|
||||
colours.push("indigo");
|
||||
colours.push("red");
|
||||
colours.push("saddlebrown");
|
||||
colours.push("skyblue");
|
||||
colours.push("olive");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global _, $, d3*/
|
||||
/*global ColourMapper*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
|
@ -55,6 +56,7 @@ function EdgeShaper(parent, flags, idfunc) {
|
|||
noop = function (line, g) {
|
||||
|
||||
},
|
||||
colourMapper = new ColourMapper(),
|
||||
events = {
|
||||
click: noop,
|
||||
dblclick: noop,
|
||||
|
@ -181,11 +183,11 @@ function EdgeShaper(parent, flags, idfunc) {
|
|||
.select("defs")
|
||||
.append("marker")
|
||||
.attr("id", "arrow")
|
||||
.attr("viewBox", "0 0 10 10")
|
||||
.attr("refX", "0")
|
||||
.attr("refX", "22")
|
||||
.attr("refY", "5")
|
||||
.attr("markerUnits", "strokeWidth")
|
||||
.attr("markerHeight", "3")
|
||||
.attr("markerHeight", "10")
|
||||
.attr("markerWidth", "10")
|
||||
.attr("orient", "auto")
|
||||
.append("path")
|
||||
.attr("d", "M 0 0 L 10 5 L 0 10 z");
|
||||
|
@ -200,12 +202,14 @@ function EdgeShaper(parent, flags, idfunc) {
|
|||
addLabel = function (line, g) {
|
||||
g.append("text") // Append a label for the edge
|
||||
.attr("text-anchor", "middle") // Define text-anchor
|
||||
.attr("stroke", "black")
|
||||
.text(label);
|
||||
};
|
||||
} else {
|
||||
addLabel = function (line, g) {
|
||||
g.append("text") // Append a label for the edge
|
||||
.attr("text-anchor", "middle") // Define text-anchor
|
||||
.attr("stroke", "black")
|
||||
.text(function(d) {
|
||||
return d[label] !== undefined ? d[label] : ""; // Which value should be used as label
|
||||
});
|
||||
|
@ -232,7 +236,7 @@ function EdgeShaper(parent, flags, idfunc) {
|
|||
switch (color.type) {
|
||||
case "single":
|
||||
addColor = function (line, g) {
|
||||
line.attr("stroke", color.value);
|
||||
line.attr("stroke", color.stroke);
|
||||
};
|
||||
break;
|
||||
case "gradient":
|
||||
|
@ -261,6 +265,11 @@ function EdgeShaper(parent, flags, idfunc) {
|
|||
};
|
||||
break;
|
||||
case "attribute":
|
||||
addColor = function (line, g) {
|
||||
g.attr("stroke", function(e) {
|
||||
return colourMapper.getColour(e[color.key]);
|
||||
});
|
||||
};
|
||||
break;
|
||||
default:
|
||||
throw "Sorry given colour-scheme not known";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global $, _, d3*/
|
||||
/*global ColourMapper*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
|
@ -66,6 +67,7 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
noop = function (node) {
|
||||
|
||||
},
|
||||
colourMapper = new ColourMapper(),
|
||||
events = {
|
||||
click: noop,
|
||||
dblclick: noop,
|
||||
|
@ -187,12 +189,16 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
addLabel = function (node) {
|
||||
node.append("text") // Append a label for the node
|
||||
.attr("text-anchor", "middle") // Define text-anchor
|
||||
.attr("fill", "black")
|
||||
.attr("stroke", "black")
|
||||
.text(label);
|
||||
};
|
||||
} else {
|
||||
addLabel = function (node) {
|
||||
node.append("text") // Append a label for the node
|
||||
.attr("text-anchor", "middle") // Define text-anchor
|
||||
.attr("fill", "black")
|
||||
.attr("stroke", "black")
|
||||
.text(function(d) {
|
||||
return d[label] !== undefined ? d[label] : ""; // Which value should be used as label
|
||||
});
|
||||
|
@ -225,6 +231,11 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
};
|
||||
break;
|
||||
case "attribute":
|
||||
addColor = function (g) {
|
||||
g.attr("fill", function(n) {
|
||||
return colourMapper.getColour(n[color.key]);
|
||||
});
|
||||
};
|
||||
break;
|
||||
default:
|
||||
throw "Sorry given colour-scheme not known";
|
||||
|
@ -251,7 +262,26 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
|
||||
if (flags !== undefined) {
|
||||
parseConfig(flags);
|
||||
}
|
||||
/*
|
||||
flags = {
|
||||
color: {
|
||||
type: "single",
|
||||
stroke: "#FF8F35",
|
||||
fill: "#8AA051"
|
||||
}
|
||||
};
|
||||
*/
|
||||
}
|
||||
/*
|
||||
if (flags.color === undefined) {
|
||||
flags.color = {
|
||||
type: "single",
|
||||
stroke: "#FF8F35",
|
||||
fill: "#8AA051"
|
||||
};
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
if (_.isFunction(idfunc)) {
|
||||
idFunction = idfunc;
|
||||
|
|
|
@ -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();
|
||||
*/
|
||||
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
<script type="text/javascript" src="helper/eventHelper.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../graph/colourMapper.js"></script>
|
||||
<script type="text/javascript" src="../graph/edgeShaper.js"></script>
|
||||
<script type="text/javascript" src="../ui/modalDialogHelper.js"></script>
|
||||
<script type="text/javascript" src="../ui/edgeShaperControls.js"></script>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
<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="../ui/modalDialogHelper.js"></script>
|
||||
<script type="text/javascript" src="../ui/nodeShaperControls.js"></script>
|
||||
|
|
|
@ -265,7 +265,7 @@
|
|||
{
|
||||
color: {
|
||||
type: "single",
|
||||
value: "#123456"
|
||||
stroke: "#123456"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -301,17 +301,17 @@
|
|||
{
|
||||
color: {
|
||||
type: "attribute",
|
||||
value: "label"
|
||||
key: "label"
|
||||
}
|
||||
}
|
||||
),
|
||||
c1,c2,c3,c4;
|
||||
shaper.drawEdges(edges);
|
||||
|
||||
c1 = $("#1-2 line").attr("stroke");
|
||||
c2 = $("#2-3 line").attr("stroke");
|
||||
c3 = $("#3-4 line").attr("stroke");
|
||||
c4 = $("#4-1 line").attr("stroke");
|
||||
c1 = $("#1-2").attr("stroke");
|
||||
c2 = $("#2-3").attr("stroke");
|
||||
c3 = $("#3-4").attr("stroke");
|
||||
c4 = $("#4-1").attr("stroke");
|
||||
|
||||
expect(c1).toBeDefined();
|
||||
expect(c2).toBeDefined();
|
||||
|
@ -539,6 +539,13 @@
|
|||
expect($("#2-3 text")[0].textContent).toEqual("second");
|
||||
expect($("#3-4 text")[0].textContent).toEqual("third");
|
||||
expect($("#4-1 text")[0].textContent).toEqual("fourth");
|
||||
|
||||
// All labels should be printed in black
|
||||
expect($("#1-2 text").attr("stroke")).toEqual("black");
|
||||
expect($("#2-3 text").attr("stroke")).toEqual("black");
|
||||
expect($("#3-4 text").attr("stroke")).toEqual("black");
|
||||
expect($("#4-1 text").attr("stroke")).toEqual("black");
|
||||
|
||||
});
|
||||
|
||||
it('should display the label at the correct position', function() {
|
||||
|
@ -735,7 +742,7 @@
|
|||
expect($("svg #3-4")[0]).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should be able to add some edges and remove other egdes', function () {
|
||||
it('should be able to add some edges and remove other edges', function () {
|
||||
edges.splice(2, 1);
|
||||
edges.splice(0, 1);
|
||||
edges.push(
|
||||
|
|
|
@ -120,12 +120,93 @@
|
|||
|
||||
});
|
||||
|
||||
it('should be able to add a switch single colour control to the list', function() {
|
||||
runs(function() {
|
||||
shaperUI.addControlOpticSingleColour();
|
||||
|
||||
expect($("#control_list #control_singlecolour").length).toEqual(1);
|
||||
|
||||
helper.simulateMouseEvent("click", "control_singlecolour");
|
||||
$("#control_singlecolour_stroke").attr("value", "#123456");
|
||||
helper.simulateMouseEvent("click", "control_singlecolour_submit");
|
||||
|
||||
expect(shaper.changeTo).toHaveBeenCalledWith({
|
||||
color: {
|
||||
type: "single",
|
||||
stroke: "#123456"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_singlecolour_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
});
|
||||
|
||||
it('should be able to add a switch colour on attribute control to the list', function() {
|
||||
runs(function() {
|
||||
shaperUI.addControlOpticAttributeColour();
|
||||
|
||||
expect($("#control_list #control_attributecolour").length).toEqual(1);
|
||||
|
||||
helper.simulateMouseEvent("click", "control_attributecolour");
|
||||
$("#control_attributecolour_key").attr("value", "label");
|
||||
helper.simulateMouseEvent("click", "control_attributecolour_submit");
|
||||
|
||||
expect(shaper.changeTo).toHaveBeenCalledWith({
|
||||
color: {
|
||||
type: "attribute",
|
||||
key: "label"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_attributecolour_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
});
|
||||
|
||||
it('should be able to add a switch colour to gradient control to the list', function() {
|
||||
runs(function() {
|
||||
shaperUI.addControlOpticGradientColour();
|
||||
|
||||
expect($("#control_list #control_gradientcolour").length).toEqual(1);
|
||||
|
||||
helper.simulateMouseEvent("click", "control_gradientcolour");
|
||||
$("#control_gradientcolour_source").attr("value", "#123456");
|
||||
$("#control_gradientcolour_target").attr("value", "#654321");
|
||||
helper.simulateMouseEvent("click", "control_gradientcolour_submit");
|
||||
|
||||
expect(shaper.changeTo).toHaveBeenCalledWith({
|
||||
color: {
|
||||
type: "gradient",
|
||||
source: "#123456",
|
||||
target: "#654321"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_gradientcolour_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
it('should be able to add all optic controls to the list', function () {
|
||||
shaperUI.addAllOptics();
|
||||
|
||||
expect($("#control_list #control_none").length).toEqual(1);
|
||||
expect($("#control_list #control_arrow").length).toEqual(1);
|
||||
expect($("#control_list #control_label").length).toEqual(1);
|
||||
expect($("#control_list #control_singlecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_attributecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_gradientcolour").length).toEqual(1);
|
||||
|
||||
});
|
||||
|
||||
|
@ -140,6 +221,9 @@
|
|||
expect($("#control_list #control_none").length).toEqual(1);
|
||||
expect($("#control_list #control_arrow").length).toEqual(1);
|
||||
expect($("#control_list #control_label").length).toEqual(1);
|
||||
expect($("#control_list #control_singlecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_attributecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_gradientcolour").length).toEqual(1);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -89,6 +89,17 @@
|
|||
|
||||
describe('testing for colours', function() {
|
||||
|
||||
it('should have a default colouring of no colour flag is given', function() {
|
||||
var nodes = [{_id: 1}, {_id: 2}],
|
||||
shaper = new NodeShaper(d3.select("svg"));
|
||||
shaper.drawNodes(nodes);
|
||||
|
||||
expect($("#1").attr("fill")).toEqual("#8AA051");
|
||||
expect($("#1").attr("stroke")).toEqual("#FF8F35");
|
||||
expect($("#2").attr("fill")).toEqual("#8AA051");
|
||||
expect($("#2").attr("stroke")).toEqual("#FF8F35");
|
||||
});
|
||||
|
||||
it('should be able to use the same colour for all nodes', function() {
|
||||
var nodes = [{_id: 1}, {_id: 2}],
|
||||
shaper = new NodeShaper(d3.select("svg"),
|
||||
|
@ -503,6 +514,8 @@
|
|||
expect($("svg .node text")[0]).toBeDefined();
|
||||
expect($("svg .node text").length).toEqual(1);
|
||||
expect($("svg .node text")[0].textContent).toEqual("MyLabel");
|
||||
expect($("svg .node text").attr("stroke")).toEqual("black");
|
||||
expect($("svg .node text").attr("fill")).toEqual("black");
|
||||
});
|
||||
|
||||
it('should ignore other attributes', function () {
|
||||
|
|
|
@ -155,6 +155,83 @@
|
|||
|
||||
});
|
||||
|
||||
it('should be able to add a switch single colour control to the list', function() {
|
||||
runs(function() {
|
||||
shaperUI.addControlOpticSingleColour();
|
||||
|
||||
expect($("#control_list #control_singlecolour").length).toEqual(1);
|
||||
|
||||
helper.simulateMouseEvent("click", "control_singlecolour");
|
||||
$("#control_singlecolour_fill").attr("value", "#123456");
|
||||
$("#control_singlecolour_stroke").attr("value", "#654321");
|
||||
helper.simulateMouseEvent("click", "control_singlecolour_submit");
|
||||
|
||||
expect(shaper.changeTo).toHaveBeenCalledWith({
|
||||
color: {
|
||||
type: "single",
|
||||
fill: "#123456",
|
||||
stroke: "#654321"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_singlecolour_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
});
|
||||
|
||||
it('should be able to add a switch colour on attribute control to the list', function() {
|
||||
runs(function() {
|
||||
shaperUI.addControlOpticAttributeColour();
|
||||
|
||||
expect($("#control_list #control_attributecolour").length).toEqual(1);
|
||||
|
||||
helper.simulateMouseEvent("click", "control_attributecolour");
|
||||
$("#control_attributecolour_key").attr("value", "label");
|
||||
helper.simulateMouseEvent("click", "control_attributecolour_submit");
|
||||
|
||||
expect(shaper.changeTo).toHaveBeenCalledWith({
|
||||
color: {
|
||||
type: "attribute",
|
||||
key: "label"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_attributecolour_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
});
|
||||
|
||||
it('should be able to add a switch colour on expand status control to the list', function() {
|
||||
runs(function() {
|
||||
shaperUI.addControlOpticExpandColour();
|
||||
|
||||
expect($("#control_list #control_expandcolour").length).toEqual(1);
|
||||
|
||||
helper.simulateMouseEvent("click", "control_expandcolour");
|
||||
$("#control_expandcolour_expanded").attr("value", "#123456");
|
||||
$("#control_expandcolour_collapsed").attr("value", "#654321");
|
||||
helper.simulateMouseEvent("click", "control_expandcolour_submit");
|
||||
|
||||
expect(shaper.changeTo).toHaveBeenCalledWith({
|
||||
color: {
|
||||
type: "expand",
|
||||
expanded: "#123456",
|
||||
collapsed: "#654321"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#control_expandcolour_modal").length === 0;
|
||||
}, 2000, "The modal dialog should disappear.");
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should be able to add all optic controls to the list', function () {
|
||||
shaperUI.addAllOptics();
|
||||
|
||||
|
@ -162,7 +239,9 @@
|
|||
expect($("#control_list #control_circle").length).toEqual(1);
|
||||
expect($("#control_list #control_rect").length).toEqual(1);
|
||||
expect($("#control_list #control_label").length).toEqual(1);
|
||||
|
||||
expect($("#control_list #control_singlecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_attributecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_expandcolour").length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should be able to add all action controls to the list', function () {
|
||||
|
@ -177,7 +256,9 @@
|
|||
expect($("#control_list #control_circle").length).toEqual(1);
|
||||
expect($("#control_list #control_rect").length).toEqual(1);
|
||||
expect($("#control_list #control_label").length).toEqual(1);
|
||||
|
||||
expect($("#control_list #control_singlecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_attributecolour").length).toEqual(1);
|
||||
expect($("#control_list #control_expandcolour").length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -8,24 +8,19 @@
|
|||
stroke: url("#edgegradient");
|
||||
}
|
||||
|
||||
.node circle {
|
||||
.node {
|
||||
cursor: pointer;
|
||||
fill: #ccc;
|
||||
stroke: #fff;
|
||||
stroke-width: 1px;
|
||||
}
|
||||
|
||||
circle.expanded {
|
||||
fill: #8AA051;
|
||||
}
|
||||
|
||||
circle.collapsed {
|
||||
fill: #FF8F35;
|
||||
}
|
||||
|
||||
text {
|
||||
font: 10px sans-serif;
|
||||
pointer-events: none;
|
||||
stroke: #fff;
|
||||
stroke-width: 1px;
|
||||
}
|
||||
marker#arrow {
|
||||
fill: #666;
|
||||
|
|
|
@ -101,10 +101,102 @@ function EdgeShaperControls(list, shaper) {
|
|||
button.onclick = callback;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
this.addControlOpticSingleColour = function() {
|
||||
var prefix = "control_singlecolour",
|
||||
idprefix = prefix + "_",
|
||||
callback = function() {
|
||||
modalDialogHelper.createModalDialog("Switch to Colour",
|
||||
idprefix, [{
|
||||
type: "text",
|
||||
id: "stroke"
|
||||
}], function () {
|
||||
var stroke = $("#" + idprefix + "stroke").attr("value");
|
||||
shaper.changeTo({
|
||||
color: {
|
||||
type: "single",
|
||||
stroke: stroke
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
button = document.createElement("li");
|
||||
button.className = "graph_control " + prefix;
|
||||
button.id = prefix;
|
||||
button.appendChild(document.createTextNode("Single Colour"));
|
||||
list.appendChild(button);
|
||||
button.onclick = callback;
|
||||
};
|
||||
|
||||
this.addControlOpticAttributeColour = function() {
|
||||
var prefix = "control_attributecolour",
|
||||
idprefix = prefix + "_",
|
||||
callback = function() {
|
||||
modalDialogHelper.createModalDialog("Display colour by attribute",
|
||||
idprefix, [{
|
||||
type: "text",
|
||||
id: "key"
|
||||
}], function () {
|
||||
var key = $("#" + idprefix + "key").attr("value");
|
||||
shaper.changeTo({
|
||||
color: {
|
||||
type: "attribute",
|
||||
key: key
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
button = document.createElement("li");
|
||||
button.className = "graph_control " + prefix;
|
||||
button.id = prefix;
|
||||
button.appendChild(document.createTextNode("Colour by Attribute"));
|
||||
list.appendChild(button);
|
||||
button.onclick = callback;
|
||||
};
|
||||
|
||||
this.addControlOpticGradientColour = function() {
|
||||
var prefix = "control_gradientcolour",
|
||||
idprefix = prefix + "_",
|
||||
callback = function() {
|
||||
modalDialogHelper.createModalDialog("Change colours for gradient",
|
||||
idprefix, [{
|
||||
type: "text",
|
||||
id: "source"
|
||||
},{
|
||||
type: "text",
|
||||
id: "target"
|
||||
}], function () {
|
||||
var source = $("#" + idprefix + "source").attr("value"),
|
||||
target = $("#" + idprefix + "target").attr("value");
|
||||
shaper.changeTo({
|
||||
color: {
|
||||
type: "gradient",
|
||||
source: source,
|
||||
target: target
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
button = document.createElement("li");
|
||||
button.className = "graph_control " + prefix;
|
||||
button.id = prefix;
|
||||
button.appendChild(document.createTextNode("Gradient Colour"));
|
||||
list.appendChild(button);
|
||||
button.onclick = callback;
|
||||
};
|
||||
|
||||
this.addAllOptics = function () {
|
||||
self.addControlOpticShapeNone();
|
||||
self.addControlOpticShapeArrow();
|
||||
self.addControlOpticLabel();
|
||||
self.addControlOpticSingleColour();
|
||||
self.addControlOpticAttributeColour();
|
||||
self.addControlOpticGradientColour();
|
||||
};
|
||||
|
||||
this.addAllActions = function () {
|
||||
|
|
|
@ -140,11 +140,109 @@ function NodeShaperControls(list, shaper) {
|
|||
button.onclick = callback;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Colour Buttons
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
this.addControlOpticSingleColour = function() {
|
||||
var prefix = "control_singlecolour",
|
||||
idprefix = prefix + "_",
|
||||
callback = function() {
|
||||
modalDialogHelper.createModalDialog("Switch to Colour",
|
||||
idprefix, [{
|
||||
type: "text",
|
||||
id: "fill"
|
||||
},{
|
||||
type: "text",
|
||||
id: "stroke"
|
||||
}], function () {
|
||||
var fill = $("#" + idprefix + "fill").attr("value"),
|
||||
stroke = $("#" + idprefix + "stroke").attr("value");
|
||||
shaper.changeTo({
|
||||
color: {
|
||||
type: "single",
|
||||
fill: fill,
|
||||
stroke: stroke
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
button = document.createElement("li");
|
||||
button.className = "graph_control " + prefix;
|
||||
button.id = prefix;
|
||||
button.appendChild(document.createTextNode("Single Colour"));
|
||||
list.appendChild(button);
|
||||
button.onclick = callback;
|
||||
};
|
||||
|
||||
this.addControlOpticAttributeColour = function() {
|
||||
var prefix = "control_attributecolour",
|
||||
idprefix = prefix + "_",
|
||||
callback = function() {
|
||||
modalDialogHelper.createModalDialog("Display colour by attribute",
|
||||
idprefix, [{
|
||||
type: "text",
|
||||
id: "key"
|
||||
}], function () {
|
||||
var key = $("#" + idprefix + "key").attr("value");
|
||||
shaper.changeTo({
|
||||
color: {
|
||||
type: "attribute",
|
||||
key: key
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
button = document.createElement("li");
|
||||
button.className = "graph_control " + prefix;
|
||||
button.id = prefix;
|
||||
button.appendChild(document.createTextNode("Colour by Attribute"));
|
||||
list.appendChild(button);
|
||||
button.onclick = callback;
|
||||
};
|
||||
|
||||
this.addControlOpticExpandColour = function() {
|
||||
var prefix = "control_expandcolour",
|
||||
idprefix = prefix + "_",
|
||||
callback = function() {
|
||||
modalDialogHelper.createModalDialog("Display colours for expansion",
|
||||
idprefix, [{
|
||||
type: "text",
|
||||
id: "expanded"
|
||||
},{
|
||||
type: "text",
|
||||
id: "collapsed"
|
||||
}], function () {
|
||||
var expanded = $("#" + idprefix + "expanded").attr("value"),
|
||||
collapsed = $("#" + idprefix + "collapsed").attr("value");
|
||||
shaper.changeTo({
|
||||
color: {
|
||||
type: "expand",
|
||||
expanded: expanded,
|
||||
collapsed: collapsed
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
button = document.createElement("li");
|
||||
button.className = "graph_control " + prefix;
|
||||
button.id = prefix;
|
||||
button.appendChild(document.createTextNode("Expansion Colour"));
|
||||
list.appendChild(button);
|
||||
button.onclick = callback;
|
||||
};
|
||||
|
||||
this.addAllOptics = function () {
|
||||
self.addControlOpticShapeNone();
|
||||
self.addControlOpticShapeCircle();
|
||||
self.addControlOpticShapeRect();
|
||||
self.addControlOpticLabel();
|
||||
self.addControlOpticSingleColour();
|
||||
self.addControlOpticAttributeColour();
|
||||
self.addControlOpticExpandColour();
|
||||
};
|
||||
|
||||
this.addAllActions = function () {
|
||||
|
|
|
@ -33,17 +33,25 @@
|
|||
"use strict";
|
||||
|
||||
// Initialise a new FoxxApplication called app under the urlPrefix: "foxxes".
|
||||
var FoxxApplication = require("org/arangodb/foxx").FoxxApplication,
|
||||
var FoxxApplication = require("org/arangodb/foxx").Application,
|
||||
app = new FoxxApplication();
|
||||
|
||||
app.requiresModels = {
|
||||
foxxes: "foxxes",
|
||||
swagger: "swagger"
|
||||
};
|
||||
|
||||
app.registerRepository(
|
||||
"foxxes",
|
||||
{
|
||||
repository: "repositories/foxxes"
|
||||
}
|
||||
);
|
||||
|
||||
app.registerRepository(
|
||||
"docus",
|
||||
{
|
||||
repository: "repositories/swagger"
|
||||
}
|
||||
);
|
||||
|
||||
app.del("/foxxes/:key", function (req, res) {
|
||||
res.json(foxxes.uninstall(req.params("key")));
|
||||
res.json(repositories.foxxes.uninstall(req.params("key")));
|
||||
}).pathParam("key", {
|
||||
description: "The _key attribute, where the information of this Foxx-Install is stored.",
|
||||
dataType: "string",
|
||||
|
@ -58,9 +66,9 @@
|
|||
active = content.active;
|
||||
// TODO: Other changes applied to foxx! e.g. Mount
|
||||
if (active) {
|
||||
res.json(foxxes.activate());
|
||||
res.json(repositories.foxxes.activate());
|
||||
} else {
|
||||
res.json(foxxes.deactivate());
|
||||
res.json(repositories.foxxes.deactivate());
|
||||
}
|
||||
}).pathParam("key", {
|
||||
description: "The _key attribute, where the information of this Foxx-Install is stored.",
|
||||
|
@ -74,20 +82,20 @@
|
|||
|
||||
|
||||
app.get('/foxxes', function (req, res) {
|
||||
res.json(foxxes.viewAll());
|
||||
res.json(repositories.foxxes.viewAll());
|
||||
}).nickname("foxxes")
|
||||
.summary("Update a foxx.")
|
||||
.notes("Used to either activate/deactivate a foxx, or change the mount point.");
|
||||
|
||||
app.get('/swagger', function (req, res) {
|
||||
res.json(swagger.list());
|
||||
app.get('/docus', function (req, res) {
|
||||
res.json(repositories.docus.list());
|
||||
}).nickname("swaggers")
|
||||
.summary("List of all foxxes.")
|
||||
.notes("This function simply returns the list of all running"
|
||||
+ " foxxes and supplies the paths for the swagger documentation");
|
||||
|
||||
app.get('/swagger/:appname', function(req, res) {
|
||||
res.json(swagger.show(req.params("appname")))
|
||||
app.get('/docus/:appname', function(req, res) {
|
||||
res.json(repositories.docus.show(req.params("appname")))
|
||||
}).pathParam("appname", {
|
||||
description: "The mount point of the App the documentation should be requested for",
|
||||
dataType: "string",
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
var List = Backbone.Collection.extend({
|
||||
model: Item
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Aardvark</title>
|
||||
<link rel="stylesheet" href="css/aardvark.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/template" id="foxx-template">
|
||||
<div class="foxx">
|
||||
<h4><%= attributes.title %></h4>
|
||||
<label>Mount-Point:</label><%=attributes.mount %>
|
||||
<label>Version:</label><%=attributes.version %>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="foxxList-template">
|
||||
<div class="foxxList" id="foxxList">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="lib/underscore.js"></script>
|
||||
<script type="text/javascript" src="lib/jquery.js"></script>
|
||||
<script type="text/javascript" src="lib/backbone.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="collections/foxxCollection.js"></script>
|
||||
<script type="text/javascript" src="models/foxx.js"></script>
|
||||
<script type="text/javascript" src="views/foxxListView.js"></script>
|
||||
<script type="text/javascript" src="views/foxxView.js"></script>
|
||||
<script type="text/javascript" src="router/router.js"></script>
|
||||
<script type="text/javascript" src="app.js"></script>
|
||||
<!--<script src="app.js"></script>-->
|
||||
<header>
|
||||
Header
|
||||
</header>
|
||||
<section id="contentSection">
|
||||
</section>
|
||||
<footer>
|
||||
Footer
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +0,0 @@
|
|||
var Item = Backbone.Model.extend({
|
||||
defaults: {
|
||||
|
||||
}
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
var ItemView = Backbone.View.extend({
|
||||
tagName: 'li',
|
||||
|
||||
events: {
|
||||
// 'click button#add': 'callback'
|
||||
},
|
||||
|
||||
initialize: function(){
|
||||
_.bindAll(this, 'render');
|
||||
},
|
||||
|
||||
render: function(){
|
||||
$(this.el);
|
||||
return this;
|
||||
}
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
var ItemView = Backbone.View.extend({
|
||||
tagName: 'li',
|
||||
|
||||
events: {
|
||||
// 'click button#add': 'callback'
|
||||
},
|
||||
|
||||
initialize: function(){
|
||||
_.bindAll(this, 'render');
|
||||
},
|
||||
|
||||
render: function(){
|
||||
$(this.el);
|
||||
return this;
|
||||
}
|
||||
});
|
|
@ -4,110 +4,5 @@
|
|||
|
||||
"apps": {
|
||||
"/": "aardvark.js"
|
||||
},
|
||||
|
||||
"assets": {
|
||||
"index.html": {
|
||||
"files": [
|
||||
"index.html"
|
||||
]
|
||||
},
|
||||
|
||||
"app.js": {
|
||||
"files": [
|
||||
"../../../html/admin/js/lib/jquery-1.8.3.js",
|
||||
"../../../html/admin/js/lib/jquery-ui-1.9.2.custom.js",
|
||||
"../../../html/admin/js/lib/jquery.dataTables.js",
|
||||
"../../../html/admin/js/lib/jquery.autogrow.js",
|
||||
"../../../html/admin/js/lib/jquery.jeditable.js",
|
||||
"../../../html/admin/js/lib/jquery.jeditable.autogrow.js",
|
||||
"../../../html/admin/js/lib/jquery.snippet.js",
|
||||
"../../../html/admin/js/lib/jquery.gritter.js",
|
||||
"../../../html/admin/js/lib/jquery.slideto.min.js",
|
||||
"../../../html/admin/js/lib/jquery.wiggle.min.js",
|
||||
"../../../html/admin/js/lib/jquery.ba-bbq.min.js",
|
||||
"../../../html/admin/js/lib/handlebars-1.0.rc.1.js",
|
||||
"../../../html/admin/js/lib/underscore.js",
|
||||
"../../../html/admin/js/lib/backbone-1.0.0.js",
|
||||
"../../../html/admin/js/lib/d3.v3.js",
|
||||
"../../../html/admin/js/lib/nv.d3.js",
|
||||
"../../../html/admin/js/lib/ColVis.js",
|
||||
"../../../html/admin/js/lib/ejs_fulljslint.js",
|
||||
"../../../html/admin/js/lib/ejs_0.9_alpha_1_production.js",
|
||||
"../../../html/admin/js/lib/bootstrap.js",
|
||||
"../../../html/admin/js/lib/bootstrap-pagination.js",
|
||||
"../../../html/admin/src/ace.js",
|
||||
"../../../html/admin/js/lib/jqconsole.min.js",
|
||||
"../../../html/admin/js/lib/splitter.js",
|
||||
"../../../html/admin/js/lib/swagger.js",
|
||||
"../../../html/admin/js/lib/swagger-ui.js",
|
||||
"../../../html/admin/js/lib/highlight.7.3.pack.js",
|
||||
"../../../html/admin/js/arango/arango.js",
|
||||
"../../../html/admin/js/shell/browser.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-collection-common.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-collection.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-database.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-error-common.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-error.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-query-cursor.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-statement-common.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arango-statement.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/arangosh.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/graph-common.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/graph.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/mimetypes.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/simple-query-common.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/simple-query.js",
|
||||
"../../../html/admin/js/modules/org/arangodb/graph/traversal.js",
|
||||
"../../../html/admin/js/modules/org/arangodb-common.js",
|
||||
"../../../html/admin/js/modules/org/arangodb.js",
|
||||
"../../../html/admin/js/bootstrap/errors.js",
|
||||
"../../../html/admin/js/bootstrap/monkeypatches.js",
|
||||
"../../../html/admin/js/bootstrap/module-internal.js",
|
||||
"../../../html/admin/js/client/bootstrap/module-internal.js",
|
||||
"../../../html/admin/js/client/client.js",
|
||||
"../../../html/admin/js/models/**",
|
||||
"../../../html/admin/js/collections/**",
|
||||
"../../../html/admin/js/views/**",
|
||||
"../../../html/admin/js/routers/**"
|
||||
]
|
||||
},
|
||||
|
||||
"css/style.css": {
|
||||
"files": [
|
||||
"../../../html/admin/css/swagger/hightlight.default.css",
|
||||
"../../../html/admin/css/swagger/screen.css",
|
||||
"../../../html/admin/css/bootstrap.css",
|
||||
"../../../html/admin/css/jquery-ui-1.9.2.custom.css",
|
||||
"../../../html/admin/css/layout.css",
|
||||
"../../../html/admin/css/jquery.dataTables.css",
|
||||
"../../../html/admin/css/nv.d3.css",
|
||||
"../../../html/admin/css/navigationView.css",
|
||||
"../../../html/admin/css/footerView.css",
|
||||
"../../../html/admin/css/shellView.css",
|
||||
"../../../html/admin/css/queryView.css",
|
||||
"../../../html/admin/css/dashboardView.css",
|
||||
"../../../html/admin/css/logsView.css",
|
||||
"../../../html/admin/css/collectionsView.css",
|
||||
"../../../html/admin/css/collectionsItemView.css",
|
||||
"../../../html/admin/css/collectionView.css",
|
||||
"../../../html/admin/css/documentsView.css",
|
||||
"../../../html/admin/css/documentView.css",
|
||||
"../../../html/admin/css/documentSourceView.css",
|
||||
"../../../html/admin/css/swaggerView.css",
|
||||
"../../../html/admin/css/foxxView.css",
|
||||
"../../../html/admin/css/jquery.snippet.css",
|
||||
"../../../html/admin/css/jquery.gritter.css",
|
||||
"../../../html/admin/css/modal.css",
|
||||
"../../../html/admin/css/ansi.css"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"files": {
|
||||
"/img" : "../../../html/admin/img",
|
||||
"/js/templates" : "../../../html/admin/js/templates"
|
||||
},
|
||||
|
||||
"models": "models"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true, unparam: true */
|
||||
/*global exports, appCollection*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief A TODO-List Foxx-Application written for ArangoDB
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2013 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";
|
||||
|
||||
|
||||
// Define the functionality to receive the documentation.
|
||||
// And transform it into swagger format.
|
||||
exports.list = function() {
|
||||
var result = {},
|
||||
apis = [],
|
||||
key,
|
||||
pathes,
|
||||
routes = require("internal").db._collection("_routing"),
|
||||
res = require("internal").db._collection("_aal").byExample({"type": "mount"});
|
||||
result.swaggerVersion = "1.1";
|
||||
result.basePath = "http://127.0.0.1:8529/aardvark/swagger/";
|
||||
result.apis = apis;
|
||||
while (res.hasNext()) {
|
||||
apis.push({path: res.next().mount});
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.show = function(appname) {
|
||||
var result = {},
|
||||
apis = [],
|
||||
key,
|
||||
pathes,
|
||||
routes = require("internal").db._collection("_routing"),
|
||||
key = require("internal").db._collection("_aal").firstExample({"mount": "/" + appname})._key;
|
||||
var app = routes.firstExample({"foxxMount": key});
|
||||
result.swaggerVersion = "1.1";
|
||||
result.basePath = app.urlPrefix;
|
||||
result.apis = apis;
|
||||
pathes = app.routes;
|
||||
for (var i in pathes) {
|
||||
if (pathes[i].url.methods !== undefined) {
|
||||
var url = pathes[i].url.match;
|
||||
var regex = /(:)([^\/]*)/;
|
||||
var api = {};
|
||||
var ops = [];
|
||||
url = url.replace(regex, "{$2}");
|
||||
api.path = url;
|
||||
ops.push(pathes[i].docs);
|
||||
api.operations = ops;
|
||||
apis.push(api);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
}());
|
|
@ -31,37 +31,50 @@
|
|||
(function () {
|
||||
"use strict";
|
||||
|
||||
// Define the functionality to create a new foxx
|
||||
/*
|
||||
exports.store = function (content) {
|
||||
throw "To be implemented.";
|
||||
};
|
||||
*/
|
||||
// Define the Repository
|
||||
var Foxx = require("org/arangodb/foxx");
|
||||
|
||||
// Define the functionality to uninstall an installed foxx
|
||||
exports.uninstall = function (key) {
|
||||
return require("org/arangodb/foxx").uninstallApp(key);
|
||||
};
|
||||
|
||||
exports.deactivate = function (key) {
|
||||
// Sorry not implemented yet
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.activate = function (key) {
|
||||
// Sorry not implemented yet
|
||||
return false;
|
||||
};
|
||||
|
||||
// Define the functionality to display all foxxes
|
||||
exports.viewAll = function () {
|
||||
return require("internal").db._collection("_aal").toArray();
|
||||
};
|
||||
|
||||
// Define the functionality to update one foxx.
|
||||
/*
|
||||
exports.update = function (id, content) {
|
||||
throw "To be implemented.";
|
||||
};
|
||||
*/
|
||||
exports.repository = Foxx.Repository.extend({
|
||||
// Define the functionality to create a new foxx
|
||||
store = function (content) {
|
||||
throw {
|
||||
code: 501,
|
||||
message: "To be implemented."
|
||||
};
|
||||
},
|
||||
|
||||
// Define the functionality to uninstall an installed foxx
|
||||
uninstall: function (key) {
|
||||
return Foxx.uninstallApp(key);
|
||||
},
|
||||
|
||||
// Define the functionality to deactivate an installed foxx.
|
||||
deactivate: function (key) {
|
||||
throw {
|
||||
code: 501,
|
||||
message: "To be implemented."
|
||||
};
|
||||
},
|
||||
|
||||
// Define the functionality to activate an installed foxx.
|
||||
activate: function (key) {
|
||||
throw {
|
||||
code: 501,
|
||||
message: "To be implemented."
|
||||
};
|
||||
},
|
||||
|
||||
// Define the functionality to display all foxxes
|
||||
viewAll: function () {
|
||||
return require("internal").db._collection("_aal").toArray();
|
||||
},
|
||||
|
||||
// Define the functionality to update one foxx.
|
||||
update: function (id, content) {
|
||||
throw {
|
||||
code: 501,
|
||||
message: "To be implemented."
|
||||
};
|
||||
};
|
||||
});
|
||||
}());
|
|
@ -0,0 +1,91 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true, unparam: true */
|
||||
/*global exports, appCollection*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief A TODO-List Foxx-Application written for ArangoDB
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2013 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";
|
||||
|
||||
// Define the Repository
|
||||
var Foxx = require("org/arangodb/foxx"),
|
||||
db = require("internal").db;
|
||||
|
||||
|
||||
// Define the functionality to receive the documentation.
|
||||
// And transform it into swagger format.
|
||||
exports.repository = Foxx.Repository.extend({
|
||||
|
||||
// Get the overview of all installed foxxes.
|
||||
list: function() {
|
||||
var result = {},
|
||||
apis = [],
|
||||
routes = db._collection("_routing"),
|
||||
res = db._collection("_aal").byExample({"type": "mount"});
|
||||
result.swaggerVersion = "1.1";
|
||||
result.basePath = "http://127.0.0.1:8529/aardvark/docus/";
|
||||
result.apis = apis;
|
||||
while (res.hasNext()) {
|
||||
apis.push({path: res.next().mount});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
// Get details of one specific installed foxx.
|
||||
show = function(appname) {
|
||||
var result = {},
|
||||
apis = [],
|
||||
key,
|
||||
pathes,
|
||||
regex = /(:)([^\/]*)/,
|
||||
i,
|
||||
url,
|
||||
api,
|
||||
ops,
|
||||
routes = db._collection("_routing"),
|
||||
key = db._collection("_aal").firstExample({"mount": "/" + appname})._key,
|
||||
app = routes.firstExample({"foxxMount": key});
|
||||
result.swaggerVersion = "1.1";
|
||||
result.basePath = app.urlPrefix;
|
||||
result.apis = apis;
|
||||
pathes = app.routes;
|
||||
for (i in pathes) {
|
||||
if (pathes[i].url.methods !== undefined) {
|
||||
url = pathes[i].url.match;
|
||||
api = {};
|
||||
ops = [];
|
||||
url = url.replace(regex, "{$2}");
|
||||
api.path = url;
|
||||
ops.push(pathes[i].docs);
|
||||
api.operations = ops;
|
||||
apis.push(api);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -43,17 +43,23 @@ var Application,
|
|||
foxxManager = require("org/arangodb/foxx-manager"),
|
||||
internal = {};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoAPI
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_createUrlObject
|
||||
/// @brief create a new url object
|
||||
///
|
||||
/// This creates a new `UrlObject`.
|
||||
/// ArangoDB uses a certain structure we refer to as `UrlObject`.
|
||||
/// With the following function (which is only internal, and not
|
||||
/// exported) you can create an UrlObject with a given URL,
|
||||
/// a constraint and a method. For example:
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// internal.createUrlObject('/lecker/gans', null, 'get')
|
||||
/// internal.createUrlObject('/lecker/gans', null, 'get');
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
internal.createUrlObject = function (url, constraint, method) {
|
||||
|
@ -78,8 +84,7 @@ internal.createUrlObject = function (url, constraint, method) {
|
|||
/// @fn JSF_foxx_application_initializer
|
||||
/// @brief Create a new Application
|
||||
///
|
||||
/// And that's Application. It's a constructor, so call it like this:
|
||||
/// It takes two optional arguments as displayed above:
|
||||
/// This creates a new Application. It takes two optional arguments as displayed above:
|
||||
/// * **The URL Prefix:** All routes you define within will be prefixed with it
|
||||
/// * **The Template Collection:** More information in the template section
|
||||
///
|
||||
|
@ -169,6 +174,7 @@ _.extend(Application.prototype, {
|
|||
/// //handle the request
|
||||
/// });
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
handleRequest: function (method, route, callback) {
|
||||
'use strict';
|
||||
var newRoute = {
|
||||
|
@ -278,7 +284,7 @@ _.extend(Application.prototype, {
|
|||
/// See above for the arguments you can give.
|
||||
/// **A word of warning:** Do not forget that `delete` is
|
||||
/// a reserved word in JavaScript and therefore needs to be
|
||||
/// called as `app['delete']`. There is also an alias `del`
|
||||
/// called as app['delete']. There is also an alias `del`
|
||||
/// for this very reason.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
|
@ -290,6 +296,7 @@ _.extend(Application.prototype, {
|
|||
/// // Take this request and deal with it!
|
||||
/// });
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
'delete': function (route, callback) {
|
||||
'use strict';
|
||||
return this.handleRequest("delete", route, callback);
|
||||
|
@ -316,6 +323,7 @@ _.extend(Application.prototype, {
|
|||
/// //Do some crazy request logging
|
||||
/// });
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
before: function (path, func) {
|
||||
'use strict';
|
||||
if (_.isUndefined(func)) {
|
||||
|
@ -346,6 +354,7 @@ _.extend(Application.prototype, {
|
|||
/// //Do some crazy response logging
|
||||
/// });
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
after: function (path, func) {
|
||||
'use strict';
|
||||
if (_.isUndefined(func)) {
|
||||
|
@ -366,16 +375,17 @@ _.extend(Application.prototype, {
|
|||
/// @brief The ViewHelper concept
|
||||
///
|
||||
/// If you want to use a function inside your templates, the ViewHelpers
|
||||
/// will come to rescue you. Define them on your app like this:
|
||||
/// will come to rescue you. Define them on your app like in the example.
|
||||
///
|
||||
/// Then you can just call this function in your template's JavaScript
|
||||
/// blocks.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// app.helper("link_to", function (identifier) {
|
||||
/// return urlRepository[identifier];
|
||||
/// });
|
||||
///
|
||||
/// Then you can just call this function in your template's JavaScript
|
||||
/// blocks.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
helper: function (name, func) {
|
||||
'use strict';
|
||||
this.helperCollection[name] = func;
|
||||
|
@ -385,12 +395,14 @@ _.extend(Application.prototype, {
|
|||
/// @fn JSF_foxx_application_accepts
|
||||
/// @brief Shortform for using the FormatMiddleware
|
||||
///
|
||||
/// Shortform for using the FormatMiddleware
|
||||
/// More information about the FormatMiddleware in the corresponding section.
|
||||
/// This is a shortcut to add the middleware to your application:
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// app.accepts(["json"], "json");
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
accepts: function (allowedFormats, defaultFormat) {
|
||||
'use strict';
|
||||
|
||||
|
@ -409,6 +421,7 @@ _.extend(Application.prototype, {
|
|||
///
|
||||
/// Used for documenting and constraining the routes.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RequestContext = function (route) {
|
||||
'use strict';
|
||||
this.route = route;
|
||||
|
@ -423,6 +436,7 @@ _.extend(RequestContext.prototype, {
|
|||
/// @fn JSF_foxx_RequestContext_pathParam
|
||||
/// @brief Describe a Path Parameter
|
||||
///
|
||||
/// Describe a Path Paramter:
|
||||
/// If you defined a route "/foxx/:id", you can constrain which format the id
|
||||
/// can have by giving a type. We currently support the following types:
|
||||
///
|
||||
|
@ -439,6 +453,7 @@ _.extend(RequestContext.prototype, {
|
|||
/// dataType: "int"
|
||||
/// });
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pathParam: function (paramName, attributes) {
|
||||
'use strict';
|
||||
var url = this.route.url,
|
||||
|
@ -462,6 +477,7 @@ _.extend(RequestContext.prototype, {
|
|||
/// @fn JSF_foxx_RequestContext_queryParam
|
||||
/// @brief Describe a Query Parameter
|
||||
///
|
||||
/// Describe a Query Parameter:
|
||||
/// If you defined a route "/foxx", you can constrain which format a query
|
||||
/// parameter (`/foxx?a=12`) can have by giving it a type.
|
||||
/// We currently support the following types:
|
||||
|
@ -499,7 +515,7 @@ _.extend(RequestContext.prototype, {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_RequestContext_nickname
|
||||
/// @brief Set the nickname for this route in the documentation
|
||||
/// Set the nickname for this route in the documentation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nickname: function (nickname) {
|
||||
|
@ -515,6 +531,7 @@ _.extend(RequestContext.prototype, {
|
|||
/// @fn JSF_foxx_RequestContext_summary
|
||||
/// @brief Set the summary for this route in the documentation
|
||||
///
|
||||
/// Set the summary for this route in the documentation
|
||||
/// Can't be longer than 60 characters
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -530,6 +547,8 @@ _.extend(RequestContext.prototype, {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_RequestContext_notes
|
||||
/// @brief Set the notes for this route in the documentation
|
||||
///
|
||||
/// Set the notes for this route in the documentation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
notes: function (notes) {
|
||||
|
@ -563,6 +582,7 @@ _.extend(RequestContext.prototype, {
|
|||
/// The `BaseMiddleware` manipulates the request and response
|
||||
/// objects to give you a nicer API.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BaseMiddleware = function (templateCollection, helperCollection) {
|
||||
'use strict';
|
||||
var middleware = function (request, response, options, next) {
|
||||
|
@ -577,6 +597,7 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
|||
///
|
||||
/// Get the body of the request
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
body: function () {
|
||||
return this.requestBody;
|
||||
},
|
||||
|
@ -594,6 +615,7 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
|||
/// So for example if the user requested `/test?a=2`, the call
|
||||
/// `params("a")` will return `2`.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
params: function (key) {
|
||||
var ps = {};
|
||||
_.extend(ps, this.urlParameters);
|
||||
|
@ -626,14 +648,14 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
|||
/// response.set("Content-Length", 123);
|
||||
/// response.set("Content-Type", "text/plain");
|
||||
///
|
||||
/// or alternatively:
|
||||
/// // or alternatively:
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// response.set({
|
||||
/// "Content-Length": "123",
|
||||
/// "Content-Type": "text/plain"
|
||||
/// });
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
set: function (key, value) {
|
||||
var attributes = {};
|
||||
if (_.isUndefined(value)) {
|
||||
|
@ -663,6 +685,7 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
|||
/// @EXAMPLES
|
||||
/// response.json({'born': 'December 12, 1915'});
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
json: function (obj) {
|
||||
this.contentType = "application/json";
|
||||
this.body = JSON.stringify(obj);
|
||||
|
@ -676,7 +699,6 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
|||
/// you're in luck now.
|
||||
/// It expects documents in the following form in this collection:
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// {
|
||||
/// path: "high/way",
|
||||
/// content: "hallo <%= username %>",
|
||||
|
@ -693,8 +715,6 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
|||
/// into the this collection and search by the path attribute.
|
||||
/// It will then render the template with the given data:
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// response.render("high/way", {username: 'Application'})
|
||||
///
|
||||
/// Which would set the body of the response to `hello Application` with the
|
||||
/// template defined above. It will also set the `contentType` to
|
||||
|
@ -703,6 +723,9 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
|||
/// In addition to the attributes you provided, you also have access to
|
||||
/// all your view helpers. How to define them? Read above in the
|
||||
/// ViewHelper section.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// response.render("high/way", {username: 'Application'})
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
render: function (templatePath, data) {
|
||||
var template;
|
||||
|
@ -834,13 +857,10 @@ FormatMiddleware = function (allowedFormats, defaultFormat) {
|
|||
/// a: 1
|
||||
/// });
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Model = function (attributes) {
|
||||
'use strict';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_model_attributes
|
||||
/// @brief The attributes property is the internal hash containing the model's state.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
this.attributes = attributes || {};
|
||||
};
|
||||
|
||||
|
@ -849,6 +869,7 @@ _.extend(Model.prototype, {
|
|||
/// @fn JSF_foxx_model_get
|
||||
/// @brief Get the value of an attribute
|
||||
///
|
||||
/// Get the value of an attribute
|
||||
/// @EXAMPLES
|
||||
/// instance = new Model({
|
||||
/// a: 1
|
||||
|
@ -856,6 +877,7 @@ _.extend(Model.prototype, {
|
|||
///
|
||||
/// instance.get("a");
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
get: function (attributeName) {
|
||||
return this.attributes[attributeName];
|
||||
},
|
||||
|
@ -864,6 +886,7 @@ _.extend(Model.prototype, {
|
|||
/// @fn JSF_foxx_model_set
|
||||
/// @brief Set the value of an attribute
|
||||
///
|
||||
/// Set the value of an attribute
|
||||
/// @EXAMPLES
|
||||
/// instance = new Model({
|
||||
/// a: 1
|
||||
|
@ -871,6 +894,7 @@ _.extend(Model.prototype, {
|
|||
///
|
||||
/// instance.set("a", 2);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
set: function (attributeName, value) {
|
||||
this.attributes[attributeName] = value;
|
||||
},
|
||||
|
@ -879,6 +903,7 @@ _.extend(Model.prototype, {
|
|||
/// @fn JSF_foxx_model_has
|
||||
/// @brief Returns true if the attribute is set to a non-null or non-undefined value.
|
||||
///
|
||||
/// Returns true if the attribute is set to a non-null or non-undefined value.
|
||||
/// @EXAMPLES
|
||||
/// instance = new Model({
|
||||
/// a: 1
|
||||
|
@ -887,6 +912,7 @@ _.extend(Model.prototype, {
|
|||
/// instance.has("a"); //=> true
|
||||
/// instance.has("b"); //=> false
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
has: function (attributeName) {
|
||||
return !(_.isUndefined(this.attributes[attributeName]) ||
|
||||
_.isNull(this.attributes[attributeName]));
|
||||
|
@ -894,8 +920,12 @@ _.extend(Model.prototype, {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_model_toJSON
|
||||
/// @brief Return a copy of the model which can be saved into ArangoDB (or send to the client).
|
||||
/// @brief Return a copy of the model which can be saved into ArangoDB
|
||||
///
|
||||
/// Return a copy of the model which can be saved into ArangoDB
|
||||
/// (or send to the client).
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
toJSON: function () {
|
||||
return this.attributes;
|
||||
}
|
||||
|
@ -904,45 +934,39 @@ _.extend(Model.prototype, {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_model_extend
|
||||
/// @brief Extend the Model prototype to add or overwrite methods.
|
||||
///
|
||||
/// Extend the Model prototype to add or overwrite methods.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Model.extend = backbone_helpers.extend;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_repository_initializer
|
||||
/// @brief Create a new instance of Repository
|
||||
///
|
||||
/// Create a new instance of Repository
|
||||
/// A Foxx Repository is always initialized with the prefix, the collection and the modelPrototype.
|
||||
/// If you initialize a model, you can give it initial data as an object.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// instance = new Repository(prefix, collection, modelPrototype);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Repository = function (prefix, collection, modelPrototype) {
|
||||
'use strict';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_repository_prefix
|
||||
/// @brief The prefix of the application.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
this.prefix = prefix;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_repository_collection
|
||||
/// @brief The collection object.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
this.collection = collection;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_repository_modelPrototype
|
||||
/// @brief The prototype of the according model.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
this.modelPrototype = modelPrototype;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_repository_extend
|
||||
/// @brief Extend the Repository prototype to add or overwrite methods.
|
||||
///
|
||||
/// Extend the Repository prototype to add or overwrite methods.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Repository.extend = backbone_helpers.extend;
|
||||
|
||||
exports.Application = Application;
|
||||
|
|
Loading…
Reference in New Issue