1
0
Fork 0

web ui - collections now using async loading mechanism

This commit is contained in:
hkernbach 2016-02-11 14:27:29 +01:00
parent ed3f635407
commit 711a7a3c4f
2 changed files with 31 additions and 9 deletions

View File

@ -144,25 +144,25 @@
}); });
}, },
loadCollection: function () { loadCollection: function (callback) {
var self = this;
window.progressView.showWithDelay(500, "Loading collection...");
$.ajax({ $.ajax({
async: true, async: true,
cache: false, cache: false,
type: 'PUT', type: 'PUT',
url: "/_api/collection/" + this.get("id") + "/load", url: "/_api/collection/" + this.get("id") + "/load",
success: function () { success: function () {
self.set("status", "loaded");
if (window.location.hash === "#collections") {
window.App.collectionsView.render();
}
window.progressView.hide(); window.progressView.hide();
callback(false);
}, },
error: function () { error: function () {
arangoHelper.arangoError('Collection error'); window.progressView.hide();
callback(true);
} }
}); });
callback();
}, },
unloadCollection: function () { unloadCollection: function () {

View File

@ -68,7 +68,29 @@
}, },
loadCollection: function () { loadCollection: function () {
this.model.loadCollection();
var loadCollectionCallback = function(error) {
if (error) {
arangoHelper.arangoError('Collection error');
}
else if (error === undefined) {
this.model.set("status", "loading");
this.render();
}
else {
if (window.location.hash === "#collections") {
this.model.set("status", "loaded");
this.render();
}
else {
arangoHelper.arangoNotification("Collection " + this.model.get("name") + " loaded.");
}
}
}.bind(this);
this.model.loadCollection(loadCollectionCallback);
window.modalView.hide(); window.modalView.hide();
}, },