mirror of https://gitee.com/bigwinds/arangodb
changes
This commit is contained in:
parent
bdc6a9baa4
commit
e7250325cb
|
@ -32,8 +32,42 @@ window.arangoCollections = Backbone.Collection.extend({
|
||||||
});
|
});
|
||||||
return data2;
|
return data2;
|
||||||
},
|
},
|
||||||
rename: function (id) {
|
checkCollectionName: function (name) {
|
||||||
|
|
||||||
|
},
|
||||||
|
renameCollection: function (id, name) {
|
||||||
|
$.ajax({
|
||||||
|
type: "PUT",
|
||||||
|
async: false, // sequential calls!
|
||||||
|
url: "/_api/collection/" + id + "/rename",
|
||||||
|
data: '{"name":"' + name + '"}',
|
||||||
|
contentType: "application/json",
|
||||||
|
processData: false,
|
||||||
|
success: function(data) {
|
||||||
|
alert("Collection renamed");
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
alert(getErrorMessage(data));
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
changeCollection: function (id, wfs, journalSize) {
|
||||||
|
$.ajax({
|
||||||
|
type: "PUT",
|
||||||
|
async: false, // sequential calls!
|
||||||
|
url: "/_api/collection/" + id + "/properties",
|
||||||
|
data: '{"waitForSync":' + wfs + ',"journalSize":' + JSON.stringify(journalSize) + '}',
|
||||||
|
contentType: "application/json",
|
||||||
|
processData: false,
|
||||||
|
success: function(data) {
|
||||||
|
alert("Saved collection properties");
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
alert(getErrorMessage(data));
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
deleteCollection: function (id) {
|
deleteCollection: function (id) {
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div id="documentsToolbar" class="arangoToolbar">
|
<div id="documentsToolbar" class="arangoToolbar">
|
||||||
<button class="enabled" id="documents_first"><img src="/_admin/html/img/rnd_br_last_icon16.png"></button>
|
|
||||||
<button class="enabled" id="documents_prev"><img src="/_admin/html/img/rnd_br_next_icon16.png"></button>
|
|
||||||
<button class="enabled" id="documents_next"><img src="/_admin/html/img/rnd_br_prev_icon16.png"></button>
|
|
||||||
<button class="enabled" id="documents_last"><img src="/_admin/html/img/rnd_br_first_icon16.png"></button>
|
<button class="enabled" id="documents_last"><img src="/_admin/html/img/rnd_br_first_icon16.png"></button>
|
||||||
|
<button class="enabled" id="documents_next"><img src="/_admin/html/img/rnd_br_prev_icon16.png"></button>
|
||||||
|
<button class="enabled" id="documents_prev"><img src="/_admin/html/img/rnd_br_next_icon16.png"></button>
|
||||||
|
<button class="enabled" id="documents_first"><img src="/_admin/html/img/rnd_br_last_icon16.png"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,18 +25,18 @@ var collectionView = Backbone.View.extend({
|
||||||
window.location.hash = "#";
|
window.location.hash = "#";
|
||||||
},
|
},
|
||||||
fillModal: function() {
|
fillModal: function() {
|
||||||
myCollection = window.arangoCollectionsStore.get(this.options.colId).attributes;
|
this.myCollection = window.arangoCollectionsStore.get(this.options.colId).attributes;
|
||||||
$('#change-collection-name').val(myCollection.name);
|
$('#change-collection-name').val(this.myCollection.name);
|
||||||
$('#change-collection-id').val(myCollection.id);
|
$('#change-collection-id').val(this.myCollection.id);
|
||||||
$('#change-collection-type').val(myCollection.type);
|
$('#change-collection-type').val(this.myCollection.type);
|
||||||
$('#change-collection-status').val(myCollection.status);
|
$('#change-collection-status').val(this.myCollection.status);
|
||||||
|
|
||||||
if (myCollection.status == 'unloaded') {
|
if (this.myCollection.status == 'unloaded') {
|
||||||
$('#colFooter').append('<button id="load-modified-collection" class="btn">Load</button>');
|
$('#colFooter').append('<button id="load-modified-collection" class="btn">Load</button>');
|
||||||
$('#collectionSizeBox').hide();
|
$('#collectionSizeBox').hide();
|
||||||
$('#collectionSyncBox').hide();
|
$('#collectionSyncBox').hide();
|
||||||
}
|
}
|
||||||
else if (myCollection.status == 'loaded') {
|
else if (this.myCollection.status == 'loaded') {
|
||||||
$('#colFooter').append('<button id="unload-modified-collection" class="btn">Unload</button>');
|
$('#colFooter').append('<button id="unload-modified-collection" class="btn">Unload</button>');
|
||||||
var data = window.arangoCollectionsStore.getProperties(this.options.colId, true);
|
var data = window.arangoCollectionsStore.getProperties(this.options.colId, true);
|
||||||
this.fillLoadedModal(data);
|
this.fillLoadedModal(data);
|
||||||
|
@ -51,19 +51,50 @@ var collectionView = Backbone.View.extend({
|
||||||
else {
|
else {
|
||||||
$('#change-collection-sync').val('true');
|
$('#change-collection-sync').val('true');
|
||||||
}
|
}
|
||||||
$('#change-collection-size').val(data.journalSize);
|
var calculatedSize = data.journalSize / 1024 / 1024;
|
||||||
|
$('#change-collection-size').val(calculatedSize);
|
||||||
$('#change-collection').modal('show')
|
$('#change-collection').modal('show')
|
||||||
},
|
},
|
||||||
saveModifiedCollection: function() {
|
saveModifiedCollection: function() {
|
||||||
|
var collid = this.getCollectionId();
|
||||||
|
var status = this.getCollectionStatus();
|
||||||
|
if (status === 'loaded') {
|
||||||
|
var newname = $('#change-collection-name').val();
|
||||||
|
if (this.myCollection.name !== newname) {
|
||||||
|
window.arangoCollectionsStore.renameCollection(collid, newname );
|
||||||
|
}
|
||||||
|
|
||||||
|
var wfs = $('#change-collection-sync').val();
|
||||||
|
var journalSize = JSON.parse($('#change-collection-size').val() * 1024 * 1024);
|
||||||
|
window.arangoCollectionsStore.changeCollection(collid, wfs, journalSize);
|
||||||
|
this.hideModal();
|
||||||
|
}
|
||||||
|
else if (status === 'unloaded') {
|
||||||
|
var newname = $('#change-collection-name').val();
|
||||||
|
if (this.myCollection.name !== newname) {
|
||||||
|
console.log("different name");
|
||||||
|
window.arangoCollectionsStore.renameCollection(collid, newname );
|
||||||
|
this.hideModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getCollectionId: function () {
|
||||||
|
return this.myCollection.id;
|
||||||
|
},
|
||||||
|
getCollectionStatus: function () {
|
||||||
|
return this.myCollection.status;
|
||||||
},
|
},
|
||||||
unloadCollection: function () {
|
unloadCollection: function () {
|
||||||
var collid = $('#change-collection-name').val();
|
var collid = this.getCollectionId();
|
||||||
window.arangoCollectionsStore.unloadCollection(collid);
|
window.arangoCollectionsStore.unloadCollection(collid);
|
||||||
$('#change-collection').modal('hide');
|
this.hideModal();
|
||||||
},
|
},
|
||||||
loadCollection: function () {
|
loadCollection: function () {
|
||||||
var collid = $('#change-collection-name').val();
|
var collid = this.getCollectionId();
|
||||||
window.arangoCollectionsStore.loadCollection(collid);
|
window.arangoCollectionsStore.loadCollection(collid);
|
||||||
|
this.hideModal();
|
||||||
|
},
|
||||||
|
hideModal: function () {
|
||||||
$('#change-collection').modal('hide');
|
$('#change-collection').modal('hide');
|
||||||
},
|
},
|
||||||
deleteCollection: function () {
|
deleteCollection: function () {
|
||||||
|
@ -74,10 +105,10 @@ var collectionView = Backbone.View.extend({
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
url: "/_api/collection/" + collName,
|
url: "/_api/collection/" + collName,
|
||||||
success: function () {
|
success: function () {
|
||||||
$('#change-collection').modal('hide');
|
self.hideModal();
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
$('#change-collection').modal('hide');
|
self.hideModal();
|
||||||
alert('Error');
|
alert('Error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue