1
0
Fork 0

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

This commit is contained in:
scottashton 2014-04-16 17:03:32 +02:00
commit eb1d0f5d28
10 changed files with 0 additions and 397 deletions

View File

@ -9,7 +9,6 @@
routes: {
"": "dashboard",
"dashboard": "dashboard",
"collection/:colid": "collection",
"collections": "collections",
"new": "newCollection",
"login": "login",
@ -151,15 +150,6 @@
});
},
collection: function (colid) {
if (!this.collectionView) {
this.collectionView = new window.CollectionView();
}
this.collectionView.setColId(colid);
this.collectionView.render();
this.naviView.selectMenuItem('collections-menu');
},
documents: function (colid, pageid) {
if (!window.documentsView) {
window.documentsView = new window.DocumentsView({

View File

@ -1,93 +0,0 @@
<script id="collectionView.ejs" type="text/template">
<div id="change-collection" class="modal hide fade change-collection" 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">Modify Collection</a>
</div>
<div class="modal-body">
<ul id="collectionTab" class="nav nav-tabs" style="display:none">
<li class="active"><a href="#main" data-toggle="tab" style="display:none">Main</a></li>
</ul>
<div class="tab-content" id="tab-content-collection-edit">
<div class="tab-pane active" id="main">
<table id="collectionEditTable">
<tr>
<th class="collectionTh">Name:</th>
<% if (isCoordinator) { %>
<th class="collectionTh"><input type="text" id="change-collection-name" name="name" value="" readonly="readonly" /></th>
<% } else { %>
<th class="collectionTh"><input type="text" id="change-collection-name" name="name" value=""/></th>
<% } %>
<th/>
</tr>
<tr id="collectionSizeBox" style="display:none">
<th class="collectionTh">Journal size:</th>
<th class="collectionTh"><input type="text" id="change-collection-size" name="size" value=""/></th>
<th>
<div>
<a class="modalTooltips" data-toggle="tooltip" data-placement="left" title="The maximal size of a journal or datafile (in MB). Must be at least 1.">
<span rel="tooltip" class="arangoicon icon_arangodb_info"></span>
</a>
</div>
</th>
</tr>
<tr id="collectionSyncBox" style="display:none">
<th class="collectionTh">Wait for sync:</th>
<th class="collectionTh">
<select id="change-collection-sync">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</th>
<th>
<div>
<a class="modalTooltips" data-toggle="tooltip" data-placement="left" title="Synchronise to disk before returning from a create or update of a document.">
<span class="arangoicon icon_arangodb_info"></span>
</a>
</div>
</th>
</tr>
<tr>
<th class="collectionTh">ID:</th>
<th class="collectionTh">
<div id="change-collection-id" class="modal-text"/>
<th>
</tr>
<tr>
<th class="collectionTh">Type:</th>
<th class="collectionTh">
<div id="change-collection-type" class="modal-text"/>
</th>
<th/>
</tr>
<tr>
<th class="collectionTh">Status:</th>
<th class="collectionTh">
<div id="change-collection-status" class="modal-text"/>
</th>
</tr>
</table>
</div>
<div class="tab-pane" id="editIndex">
</div>
</div>
</div>
<div id="colFooter" class="modal-footer">
<button id="delete-modified-collection" class="button-danger short-distance">Delete</button>
<button id="save-modified-collection" class="button-success">Save</button>
<button class="button-close large-distance" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
<div class="alert alert-error" style="display:none" id="reallyDeleteColDiv">
<strong>Really delete Collection?</strong>
<button id="confirmDeleteCollection" class="button-danger pull-right" style="margin-top: -4px; margin-right: -18px !important;">Yes</button>
<button id="abortDeleteCollection" class="button-neutral pull-right" style="margin-top: -4px; margin-right:10px;">No</button>
</div>
</div>
</script>

View File

@ -1,217 +0,0 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true, stupid: true */
/*global require, window, exports, Backbone, $, arangoHelper, templateEngine */
(function() {
"use strict";
window.CollectionView = Backbone.View.extend({
el: '#modalPlaceholder',
initialize: function () {
var self = this;
},
template: templateEngine.createTemplate("collectionView.ejs"),
render: function() {
var self = this;
$(this.el).html(this.template.render({
isCoordinator: window.isCoordinator()
}));
$('#change-collection').modal('show');
$('#change-collection').on('hidden', function () {
});
$('#change-collection').on('shown', function () {
if (! window.isCoordinator()) {
$('#change-collection-name').focus();
}
});
this.fillModal();
$("[data-toggle=tooltip]").tooltip();
return this;
},
events: {
"click #save-modified-collection" : "saveModifiedCollection",
"hidden #change-collection" : "hidden",
"click #delete-modified-collection" : "deleteCollection",
"click #load-modified-collection" : "loadCollection",
"click #unload-modified-collection" : "unloadCollection",
"click #confirmDeleteCollection" : "confirmDeleteCollection",
"click #abortDeleteCollection" : "abortDeleteCollection",
"keydown #change-collection-name" : "listenKey",
"keydown #change-collection-size" : "listenKey"
},
listenKey: function(e) {
if (e.keyCode === 13) {
this.saveModifiedCollection();
}
},
hidden: function () {
window.App.navigate("#collections", {trigger: true});
},
setColId: function(colId) {
this.options.colId = colId;
},
fillModal: function() {
try {
this.myCollection = window.arangoCollectionsStore.get(this.options.colId).attributes;
}
catch (e) {
// in case the collection cannot be found or something is not present (e.g. after a reload)
window.App.navigate("#");
return;
}
$('#change-collection-name').val(this.myCollection.name);
$('#change-collection-id').text(this.myCollection.id);
$('#change-collection-type').text(this.myCollection.type);
$('#change-collection-status').text(this.myCollection.status);
if (this.myCollection.status === 'unloaded') {
$('#colFooter').prepend(
'<button id="load-modified-collection" class="button-notification">Load</button>'
);
$('#collectionSizeBox').hide();
$('#collectionSyncBox').hide();
$('#tab-content-collection-edit tab-pane').css("border-top",0);
}
else if (this.myCollection.status === 'loaded') {
$('#colFooter').prepend(
'<button id="unload-modified-collection"'+
'class="button-notification">Unload</button>'
);
var data = window.arangoCollectionsStore.getProperties(this.options.colId, true);
this.fillLoadedModal(data);
}
},
fillLoadedModal: function (data) {
//show tabs & render figures tab-view
$('#change-collection .nav-tabs').css("visibility","visible");
$('#collectionSizeBox').show();
$('#collectionSyncBox').show();
if (data.waitForSync === false) {
$('#change-collection-sync').val('false');
}
else {
$('#change-collection-sync').val('true');
}
var calculatedSize = data.journalSize / 1024 / 1024;
$('#change-collection-size').val(calculatedSize);
$('#change-collection').modal('show');
},
saveModifiedCollection: function() {
var newname;
if (window.isCoordinator()) {
newname = this.myCollection.name;
}
else {
newname = $('#change-collection-name').val();
if (newname === '') {
arangoHelper.arangoError('No collection name entered!');
return 0;
}
}
var collid = this.getCollectionId();
var status = this.getCollectionStatus();
if (status === 'loaded') {
var result;
if (this.myCollection.name !== newname) {
result = window.arangoCollectionsStore.renameCollection(collid, newname);
}
var wfs = $('#change-collection-sync').val();
var journalSize;
try {
journalSize = JSON.parse($('#change-collection-size').val() * 1024 * 1024);
}
catch (e) {
arangoHelper.arangoError('Please enter a valid number');
return 0;
}
var changeResult = window.arangoCollectionsStore.changeCollection(collid, wfs, journalSize);
if (result !== true) {
if (result !== undefined) {
arangoHelper.arangoError("Collection error: " + result);
return 0;
}
}
if (changeResult !== true) {
arangoHelper.arangoNotification("Collection error", changeResult);
return 0;
}
if (changeResult === true) {
window.arangoCollectionsStore.fetch({
success: function () {
window.collectionsView.render();
}
});
this.hideModal();
}
}
else if (status === 'unloaded') {
if (this.myCollection.name !== newname) {
var result2 = window.arangoCollectionsStore.renameCollection(collid, newname);
if (result2 === true) {
window.arangoCollectionsStore.fetch({
success: function () {
window.collectionsView.render();
}
});
this.hideModal();
}
else {
arangoHelper.arangoError("Collection error: " + result2);
}
}
else {
this.hideModal();
}
}
},
getCollectionId: function () {
return this.myCollection.id;
},
getCollectionStatus: function () {
return this.myCollection.status;
},
unloadCollection: function () {
var collid = this.getCollectionId();
window.arangoCollectionsStore.unloadCollection(collid);
this.hideModal();
},
loadCollection: function () {
var collid = this.getCollectionId();
window.arangoCollectionsStore.loadCollection(collid);
this.hideModal();
},
hideModal: function () {
$('#change-collection').modal('hide');
},
deleteCollection: function () {
$('#reallyDeleteColDiv').show();
},
abortDeleteCollection: function() {
$('#reallyDeleteColDiv').hide();
},
confirmDeleteCollection: function () {
var self = this;
var collName = self.myCollection.name;
var returnval = window.arangoCollectionsStore.deleteCollection(collName);
if (returnval === false) {
arangoHelper.arangoError('Could not delete collection.');
}
self.hideModal();
}
});
}());

View File

@ -15,7 +15,6 @@
<!-- include scripts to check here -->
<script type="text/javascript" src="../js/views/aboutView.js"></script>
<script type="text/javascript" src="../js/views/collectionView.js"></script>
<script type="text/javascript" src="../js/views/collectionsItemView.js"></script>
<script type="text/javascript" src="../js/views/collectionsView.js"></script>
<script type="text/javascript" src="../js/views/dashboardView.js"></script>

View File

@ -146,7 +146,6 @@
"frontend/js/views/dashboardView.js",
"frontend/js/views/newDashboardView.js",
"frontend/js/views/collectionsView.js",
"frontend/js/views/collectionView.js",
"frontend/js/views/collectionsItemView.js",
"frontend/js/views/documentsView.js",
"frontend/js/views/documentView.js",
@ -250,7 +249,6 @@
"test/specs/views/appDocumentationViewSpec.js",
"test/specs/views/modalViewSpec.js",
"test/specs/views/editListEntryViewSpec.js",
"test/specs/views/collectionViewSpec.js",
"test/specs/views/collectionsViewSpec.js",
"test/specs/views/dbSelectionViewSpec.js",
"test/specs/views/navigationViewSpec.js",

View File

@ -156,7 +156,6 @@ module.exports = function(karma) {
'frontend/js/views/shellView.js',
'frontend/js/views/dashboardView.js',
'frontend/js/views/collectionsView.js',
'frontend/js/views/collectionView.js',
'frontend/js/views/collectionsItemView.js',
'frontend/js/views/documentsView.js',
'frontend/js/views/documentView.js',

View File

@ -96,7 +96,6 @@
<script src="../js/views/aboutView.js"></script>
<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/collectionsItemView.js"></script>
<script src="../js/views/documentsView.js"></script>
<script src="../js/views/documentView.js"></script>
@ -117,7 +116,6 @@
<!-- specs helper --!>
<script type="text/javascript" src="specs/arango/arangoSpec.js"></script>
<script type="text/javascript" src="specs/views/aboutViewSpec.js"></script>
<script type="text/javascript" src="specs/views/collectionViewSpec.js"></script>
<script type="text/javascript" src="specs/views/collectionsViewSpec.js"></script>
<!-- specs views -->
<!-- specs routers --!>

View File

@ -15,7 +15,6 @@
<!-- views -->
<script type="text/javascript" src="../js/views/aboutView.js"></script>
<script type="text/javascript" src="../js/views/collectionView.js"></script>
<script type="text/javascript" src="../js/views/collectionsItemView.js"></script>
<script type="text/javascript" src="../js/views/collectionsView.js"></script>
<script type="text/javascript" src="../js/views/dashboardView.js"></script>

View File

@ -377,7 +377,6 @@
expected = [
"",
"dashboard",
"collection/:colid",
"collections",
"new",
"login",
@ -425,22 +424,6 @@
expect(available).toDefineTheRoutes(expected);
});
it("should route to a collection", function () {
var colid = 5;
simpleNavigationCheck(
{
url: "collection/:colid",
params: [colid]
},
"CollectionView",
"collections-menu",
undefined,
{
setColId: colid
}
);
});
it("should route to documents", function () {
var colid = 5,
pageid = 6;

View File

@ -1,53 +0,0 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/
/*global describe, beforeEach, afterEach, it, spyOn, expect*/
/*global runs, waitsFor, jasmine*/
/*global $, arangoCollectionModel*/
(function() {
"use strict";
describe("Collection View", function() {
var myView, isCoordinator;
beforeEach(function() {
isCoordinator = false;
window.App = {
navigate: function() {
throw "This should be a spy";
}
};
spyOn(window.App, "navigate");
spyOn(window, "isCoordinator").andReturn(isCoordinator);
$('body').append('<div id="content" class="removeMe"></div>');
myView = new window.CollectionView({
model: arangoCollectionModel
});
});
afterEach(function() {
$('.removeMe').remove();
delete window.App;
});
describe("Collection Changes", function() {
it("Check if changes were submitted", function() {
var pressedEnter = false;
myView.render();
spyOn(myView, 'saveModifiedCollection').andCallFake(function(request) {
pressedEnter = true;
});
myView.saveModifiedCollection();
expect(pressedEnter).toBeTruthy();
});
});
});
}());