Merge branch 'master' of git.blender.org:pillar into elastic

This commit is contained in:
2017-12-29 12:19:47 +01:00
28 changed files with 529 additions and 217 deletions

View File

@@ -182,13 +182,13 @@ $( document ).ready(function() {
$('#item_delete').click(function(e){
e.preventDefault();
if (ProjectUtils.isProject()) {
// url = window.location.href.split('#')[0] + 'delete';
// window.location.replace(url);
$.post(urlProjectDelete, {project_id: ProjectUtils.projectId()},
function (data) {
// Feedback logic
}).done(function () {
window.location.replace('/p/');
$.post(urlProjectDelete, {project_id: ProjectUtils.projectId()})
.done(function () {
// Redirect to the /p/ URL that shows deleted projects.
window.location.replace('/p/?deleted=1');
})
.fail(function(err) {
toastr.error(xhrErrorResponseMessage(err), 'Project deletion failed');
});
} else {
$.post(urlNodeDelete, {node_id: ProjectUtils.nodeId()},

View File

@@ -361,6 +361,20 @@ function getNotificationsLoop() {
}, 30000);
}
/* Returns a more-or-less reasonable message given an error response object. */
function xhrErrorResponseMessage(err) {
if (typeof err.responseJSON == 'undefined')
return err.statusText;
if (typeof err.responseJSON._error != 'undefined' && typeof err.responseJSON._error.message != 'undefined')
return err.responseJSON._error.message;
if (typeof err.responseJSON._message != 'undefined')
return err.responseJSON._message
return err.statusText;
}
/* Notifications: Toastr Defaults */
toastr.options.showDuration = 50;
toastr.options.progressBar = true;