Show nicer alerts for file deletion

This commit is contained in:
Dane Everitt 2016-01-08 20:08:20 -05:00
parent 54bef1e7d5
commit abed57546b

View file

@ -84,10 +84,14 @@
var clicked = $(this); var clicked = $(this);
var deleteItemPath = $(this).attr('href'); var deleteItemPath = $(this).attr('href');
if (!confirm('Are you sure you want to delete /home/container/' + deleteItemPath + '? There is no reversing this action.')) { swal({
return; type: 'warning',
} title: 'Really Delete this File?',
showCancelButton: true,
showConfirmButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true
}, function () {
$.ajax({ $.ajax({
type: 'DELETE', type: 'DELETE',
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath, url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath,
@ -97,9 +101,19 @@
} }
}).done(function (data) { }).done(function (data) {
clicked.parent().parent().parent().parent().fadeOut(); clicked.parent().parent().parent().parent().fadeOut();
swal({
type: 'success',
title: 'File Deleted'
});
}).fail(function (jqXHR) { }).fail(function (jqXHR) {
$("#internal_alert").html('<div class="alert alert-danger">An error occured while attempting to delete <code>/home/container/' + deleteItemPath + '</code>. Please try again.</div>').show(); console.error(jqXHR);
console.log(jqXHR); swal({
type: 'error',
title: 'Whoops!',
html: true,
text: 'An error occured while attempting to delete this file. Please try again.',
});
});
}); });
}); });