1
0
Fork 0

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

This commit is contained in:
scottashton 2014-04-10 16:55:25 +02:00
commit fae1c057d5
17 changed files with 102 additions and 366 deletions

View File

@ -119,8 +119,22 @@
},
isSystemCollection: function (val) {
//return val && val.name && val.name.substr(0, 1) === '_';
return val.substr(0, 1) === '_';
var returnVal = false;
$.ajax({
type: "GET",
cache: false,
url: "/_api/collection/"+encodeURIComponent(val)+"/properties",
contentType: "application/json",
processData: false,
async: false,
success: function(data) {
returnVal = data.isSystem;
},
error: function(data) {
returnVal = false;
}
});
return returnVal;
},
collectionApiType: function (identifier, refresh) {
@ -150,7 +164,7 @@
type = "unknown";
}
if (val.name.substr(0, 1) === '_') {
if (this.isSystemCollection(val.name)) {
type += " (system)";
}

View File

@ -284,13 +284,6 @@
this.collectionInfoView.render();
this.naviView.selectMenuItem('collections-menu');
},
newCollection: function () {
if (!this.newCollectionView) {
this.newCollectionView = new window.newCollectionView({});
}
this.newCollectionView.render();
this.naviView.selectMenuItem('collections-menu');
},
documents: function (colid, pageid) {
if (!window.documentsView) {

View File

@ -1,76 +0,0 @@
<script id="graphManagementView1.ejs" type="text/template">
<div class="headerBar">
<div class="pull-left">
<a class="arangoHeader">Manage Graphs</a>
</div>
<div id="graphManagerToolbar" class="pagination pagination-small pagination-right" style="display:none;">
<ul><li class="enabled"><a id="filterGraphs"><span class="icon_arangodb icon_arangodb_filter" title="Filter graphs"></span></a></li></ul>
</div>
</div>
<div class="arangoDropdown">
<div id="filterHeader" style="display:none">
<div class="queryline">
<input id="attribute_name0" type="text" placeholder="Attribute name"><select name="operator" id="operator0">
<option value="==">==</option>
<option value="!=">!=</option>
<option value="&lt;">&lt;</option>
<option value="&lt;=">&lt;=</option>
<option value="&gt;">&gt;</option>
<option value="&gt;=">&gt;=</option>
</select><input id="attribute_value0" type="text" placeholder="Attribute value" class="filterValue">
<a id="addFilterItem"><i class="icon-plus"></i></a>
<button id="resetView" class="button-warning btn-old-padding">Reset</button>
<button id="filterSend" class="button-success btn-old-padding">Filter</button>
</div>
</div>
</div>
<div id="graphManagementDiv" class="contentDiv innerContent">
<div id="graphTable_wrapper" class="dataTables_wrapper" role="grid">
<table cellpadding="0" cellspacing="0" border="0" class="display arangoDataTable dataTable noPointer" id="graphsTable">
<thead>
<tr>
<th>Name</th>
<th>Vertices</th>
<th>Edges</th>
<th>
<a id="addGraphButton" class="pull-right addButton">
<span class="arangoicon icon_arangodb_roundplus" title="Add a graph"></span>
</a>
</th>
</tr>
</thead>
<tbody>
<%
var odd = true;
graphs.each(function(g) {
%>
<tr class="<%=odd?'odd':'even'%>">
<td><%=g.get("_key")%></td>
<td><%=g.get("vertices")%></td>
<td><%=g.get("edges")%></td>
<td class="docsThirdCol">
<a class="deleteButton" id="<%=g.get('_key')%>">
<span class="icon_arangodb_roundminus" data-original-title="Delete document"></span>
</a>
</td>
</tr>
<%
odd = !odd;
});
%>
</tbody>
</tbody>
</table>
</div>
<div id="documentsToolbarFL">
<div id="documentsToolbarF" class="pagination pagination-small pagination-centered">
</div>
</div>
</script>

View File

@ -90,8 +90,8 @@
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
<%=advancedContent.header%>
<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
<span><%=advancedContent.header%></span><span><b class="caret"></b></span>
</a>
</div>
<div id="collapseOne" class="accordion-body collapse out">

View File

@ -1,78 +0,0 @@
<script id="newCollectionView.ejs" type="text/template">
<div id="add-collection" class="modal hide fade addCollection" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display:none">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<a class="arangoHeader">New Collection</a>
</div>
<div class="modal-body">
<table>
<tr>
<th class="collectionTh">Name:</th>
<th class="collectionThSec"><input type="text" id="new-collection-name" name="name" value="" class="modalInput"/></th>
</tr>
<tr>
<th class="collectionTh">Type:</th>
<th class="collectionThSec">
<select id="new-collection-type" class="modalSelect">
<option value="2">Document</option>
<option value="3">Edge</option>
</select>
</th>
<th><a class="modalTooltips" title="The type of the collection to create."><span class="arangoicon icon_arangodb_info"></a></th>
</tr>
<% if (isCoordinator) { %>
<tr>
<th class="collectionTh">Shards:</th>
<th class="collectionThSec"><input type="text" id="new-collection-shards" name="shards" value="" class="modalInput" /></th>
<th><a class="modalTooltips" title="The number of shards to create. You cannot change this afterwards. Recommended: DBServers squared"><span class="arangoicon icon_arangodb_info"></a></th>
</tr>
<tr>
<th class="collectionTh">Shard by:</th>
<th class="collectionThSec"><input type="hidden" id="new-collection-shardBy" name="shardBy" placeholder="_key" class="modalInput"></input></th>
<th><a class="modalTooltips" title="The keys used to distribute documents on shards. Type the key and press return to add it."><span class="arangoicon icon_arangodb_info"></a></th>
</tr>
<% } %>
</table>
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
Advanced
</a>
</div>
<div id="collapseOne" class="accordion-body collapse out">
<div class="accordion-inner">
<table>
<tr>
<th class="collectionTh">Journal size:</th>
<th class="collectionThSec"><input class="modalInput" type="text" id="new-collection-size" name="size" value=""/></th>
<th><a class="modalTooltips" title="The maximal size of a journal or datafile (in MB). Must be at least 1."><span class="arangoicon icon_arangodb_info"></span></a></th>
</tr>
<tr>
<th class="collectionTh">Sync:</th>
<th class="collectionThSec">
<select id="new-collection-sync">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</th>
<th><a class="modalTooltips" title="Synchronise to disk before returning from a create or update of a document."><span class="arangoicon icon_arangodb_info"></span></a></th>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="button-close large-distance" data-dismiss="modal" aria-hidden="true">Close</button>
<button id="save-new-collection" class="button-success pull-right">Save</button>
</div>
</div>
</script>

View File

@ -171,7 +171,12 @@
journalSize = journalSize/(1024*1024);
tableContent.push(
window.modalView.createTextEntry(
"change-collection-size", "Journal size", journalSize, false, "", true
"change-collection-size",
"Journal size",
journalSize,
"The maximal size of a journal or datafile (in MB). Must be at least 1.",
"",
true
)
);

View File

@ -258,7 +258,13 @@
shardBy.push("_key");
}
}
var isSystem = (collName.substr(0, 1) === '_');
//no new system collections via webinterface
//var isSystem = (collName.substr(0, 1) === '_');
if (collName.substr(0, 1) === '_') {
arangoHelper.arangoError('No "_" allowed as first character!');
return 0;
}
var isSystem = false;
var wfs = (collSync === "true");
if (collSize > 0) {
try {

View File

@ -1,123 +0,0 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
/*global require, exports, Backbone, EJS, $, window, arangoHelper, templateEngine, _*/
(function (){
"use strict";
window.newCollectionView = Backbone.View.extend({
el: '#modalPlaceholder',
initialize: function () {
var self = this;
$.ajax("cluster/amICoordinator", {
async: false
}).done(function(d) {
self.isCoordinator = d;
});
},
template: templateEngine.createTemplate("newCollectionView.ejs"),
render: function() {
var self = this;
$(this.el).html(this.template.render({
isCoordinator: this.isCoordinator
}));
if (this.isCoordinator) {
$("#new-collection-shardBy").select2({
tags: [],
showSearchBox: false,
minimumResultsForSearch: -1,
width: "336px",
maximumSelectionSize: 8
});
}
$('#add-collection').modal('show');
$('#add-collection').on('hidden', function () {
self.hidden();
});
$('#add-collection').on('shown', function () {
$('#new-collection-name').focus();
});
$('#edgeFrom').hide();
$('#edgeTo').hide();
$('.modalTooltips').tooltip({
placement: "left"
});
return this;
},
events: {
"click #save-new-collection" : "saveNewCollection",
"keydown #new-collection-name": "listenKey",
"keydown #new-collection-size": "listenKey"
},
listenKey: function(e) {
if (e.keyCode === 13) {
this.saveNewCollection();
}
},
hidden: function () {
window.App.navigate("#collections", {trigger: true});
},
saveNewCollection: function(a) {
var self = this;
var collName = $('#new-collection-name').val();
var collSize = $('#new-collection-size').val();
var collType = $('#new-collection-type').val();
var collSync = $('#new-collection-sync').val();
var shards = 1;
var shardBy = [];
if (this.isCoordinator) {
shards = $('#new-collection-shards').val();
if (shards === "") {
shards = 1;
}
shards = parseInt(shards, 10);
if (shards < 1) {
arangoHelper.arangoError(
"Number of shards has to be an integer value greater or equal 1"
);
return 0;
}
shardBy = _.pluck($('#new-collection-shardBy').select2("data"), "text");
if (shardBy.length === 0) {
shardBy.push("_key");
}
}
var isSystem = (collName.substr(0, 1) === '_');
var wfs = (collSync === "true");
if (collSize > 0) {
try {
collSize = JSON.parse(collSize) * 1024 * 1024;
}
catch (e) {
arangoHelper.arangoError('Please enter a valid number');
return 0;
}
}
if (collName === '') {
arangoHelper.arangoError('No collection name entered!');
return 0;
}
var returnobj = window.arangoCollectionsStore.newCollection(
collName, wfs, isSystem, collSize, collType, shards, shardBy
);
if (returnobj.status === true) {
self.hidden();
$("#add-collection").modal('hide');
window.App.navigate("collection/" + collName + "/documents/1", {trigger: true});
}
else {
arangoHelper.arangoError(returnobj.errorMessage);
}
}
});
}());

View File

@ -56,7 +56,8 @@
}
.collapse {
position: inherit;
margin-right: -14px;
position: relative;
}
.accordion-inner {
@ -66,6 +67,30 @@
padding-right: 0;
}
.accordion-toggle {
span {
b.caret {
border-top-color: $c-black;
float: right;
margin-top: 5px;
}
}
&.collapsed {
span {
b.caret {
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
}
}
}
input {
width: 384px;
}

View File

@ -2580,12 +2580,21 @@ div.breadcrumb a.disabledBread {
.modal-body .icon-info-sign:hover {
opacity: 1; }
.modal-body .collapse {
position: inherit; }
margin-right: -14px;
position: relative; }
.modal-body .accordion-inner {
border-top: 0;
margin-left: 0;
padding-left: 0;
padding-right: 0; }
.modal-body .accordion-toggle span b.caret {
border-top-color: black;
float: right;
margin-top: 5px; }
.modal-body .accordion-toggle.collapsed span b.caret {
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg); }
.modal-body input {
width: 384px; }
.modal-body select {

View File

@ -25,7 +25,6 @@
<script type="text/javascript" src="../js/views/footerView.js"></script>
<script type="text/javascript" src="../js/views/logsView.js"></script>
<script type="text/javascript" src="../js/views/navigationView.js"></script>
<script type="text/javascript" src="../js/views/newCollectionView.js"></script>
<script type="text/javascript" src="../js/views/queryView.js"></script>
<script type="text/javascript" src="../js/views/shellView.js"></script>

View File

@ -147,7 +147,6 @@
"frontend/js/views/collectionsView.js",
"frontend/js/views/collectionView.js",
"frontend/js/views/collectionInfoView.js",
"frontend/js/views/newCollectionView.js",
"frontend/js/views/collectionsItemView.js",
"frontend/js/views/documentsView.js",
"frontend/js/views/documentView.js",

View File

@ -119,7 +119,7 @@ module.exports = function(karma) {
// Models
'frontend/js/models/currentDatabase.js',
'frontend/js/models/arangoCollection.js',
'../../frontend/js/models/arangoCollectionModel.js',
'frontend/js/models/arangoDatabase.js',
'frontend/js/models/arangoDocument.js',
'frontend/js/models/arangoLog.js',
@ -160,7 +160,6 @@ module.exports = function(karma) {
'frontend/js/views/collectionsView.js',
'frontend/js/views/collectionView.js',
'frontend/js/views/collectionInfoView.js',
'frontend/js/views/newCollectionView.js',
'frontend/js/views/collectionsItemView.js',
'frontend/js/views/documentsView.js',
'frontend/js/views/documentView.js',

View File

@ -97,7 +97,6 @@
<script src="../js/views/dashboardView.js"></script>
<script src="../js/views/collectionsView.js"></script>
<script src="../js/views/collectionView.js"></script>
<script src="../js/views/newCollectionView.js"></script>
<script src="../js/views/collectionsItemView.js"></script>
<script src="../js/views/documentsView.js"></script>
<script src="../js/views/documentView.js"></script>

View File

@ -25,7 +25,6 @@
<script type="text/javascript" src="../js/views/footerView.js"></script>
<script type="text/javascript" src="../js/views/logsView.js"></script>
<script type="text/javascript" src="../js/views/navigationView.js"></script>
<script type="text/javascript" src="../js/views/newCollectionView.js"></script>
<script type="text/javascript" src="../js/views/queryView.js"></script>
<script type="text/javascript" src="../js/views/shellView.js"></script>
@ -34,7 +33,7 @@
<!-- routers --!>
<script type="text/javascript" src="../js/routers/plannerRouter.js"></script>
<!-- models --!>
<script type="text/javascript" src="../js/models/arangoCollection.js"></script>
<script type="text/javascript" src="../js/models/arangoCollectionModel.js"></script>
<script type="text/javascript" src="../js/models/arangoDocument.js"></script>
<script type="text/javascript" src="../js/models/arangoLog.js"></script>
<script type="text/javascript" src="../js/models/arangoStatistics.js"></script>

View File

@ -731,15 +731,6 @@
);
});
it("should route to the new collection creation", function () {
simpleNavigationCheck(
"new",
"newCollectionView",
"collections-menu",
{}
);
});
it("should route to the api tab", function () {
simpleNavigationCheck(
"api",
@ -773,40 +764,6 @@
);
});
it("should offer the add new graph view", function () {
simpleNavigationCheck(
"graphManagement/add",
"AddNewGraphView",
"graphviewer-menu",
{
collection: storeDummy,
graphs: graphsDummy
}
);
});
/*
it("should offer the delete graph view", function () {
var name = "testGraph";
simpleNavigationCheck(
{
url: "graphManagement/delete/:name",
params: [name]
},
"DeleteGraphView",
"graphviewer-menu",
{
collection: graphsDummy
},
{
render: name
}
);
});
*/
it("should route to the applications tab", function () {
simpleNavigationCheck(
"applications",

View File

@ -1,7 +1,7 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/
/*global describe, beforeEach, afterEach, it, */
/*global spyOn, runs, expect, waitsFor*/
/*global GraphManagementView, _, $*/
/*global GraphManagementView, _, jasmine$*/
(function() {
"use strict";
@ -10,11 +10,16 @@
var view,
div,
modalDiv,
graphs,
collections,
v1, v2, e1, e2, sys1, cols;
beforeEach(function() {
modalDiv = document.createElement("div");
modalDiv.id = "modalPlaceholder";
document.body.appendChild(modalDiv);
window.modalView = new window.ModalView();
collections = new window.arangoCollections(cols);
graphs = new window.GraphCollection();
div = document.createElement("div");
@ -30,6 +35,7 @@
afterEach(function() {
document.body.removeChild(div);
document.body.removeChild(modalDiv);
});
it("should fetch the graphs on render", function () {
@ -82,32 +88,35 @@
describe("creating a new graph", function() {
it("should navigate to the graph adding view", function() {
spyOn(window.App, "navigate");
$("#createGraph").click();
expect(window.App.navigate).toHaveBeenCalledWith(
"graphManagement/add",
{
trigger: true
}
);
it("should create a new graph", function() {
runs(function() {
$("#createGraph").click();
});
waitsFor(function() {
return $("#modal-dialog").css("display") === "block";
});
runs (function() {
$("#createNewGraphName").val("newGraph");
$("#newGraphVertices").val("newVertices");
$("#newGraphEdges").val("newEdges");
spyOn($, "ajax").andCallFake(function(opts) {
expect(opts.type).toEqual("POST");
expect(opts.url).toEqual("/_api/graph");
expect(opts.data).toEqual(JSON.stringify({
_key: "newGraph",
vertices: "newVertices",
edges: "newEdges",
_id: "",
_rev: ""
}));
});
$("#modalButton1").click();
expect($.ajax).toHaveBeenCalled()
});
});
});
it("should navigate to graph delete view", function() {
spyOn(window.App, "navigate");
var lg = graphs.get("g3");
$("#" + g3._key + "_settings").click();
$("#deleteGraph").click();
expect(window.App.navigate).toHaveBeenCalledWith(
"graphManagement/delete/" + g3._key,
{
trigger: true
}
);
});
});
});