From abed57546b7d6582d8284b0decf48c12a1bfbc1c Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 8 Jan 2016 20:08:20 -0500 Subject: [PATCH] Show nicer alerts for file deletion --- resources/views/server/files/index.blade.php | 46 +++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/resources/views/server/files/index.blade.php b/resources/views/server/files/index.blade.php index 764bb2605..dc6fba4a3 100644 --- a/resources/views/server/files/index.blade.php +++ b/resources/views/server/files/index.blade.php @@ -84,22 +84,36 @@ var clicked = $(this); var deleteItemPath = $(this).attr('href'); - if (!confirm('Are you sure you want to delete /home/container/' + deleteItemPath + '? There is no reversing this action.')) { - return; - } - - $.ajax({ - type: 'DELETE', - url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath, - headers: { - 'X-Access-Token': '{{ $server->daemonSecret }}', - 'X-Access-Server': '{{ $server->uuid }}' - } - }).done(function (data) { - clicked.parent().parent().parent().parent().fadeOut(); - }).fail(function (jqXHR) { - $("#internal_alert").html('
An error occured while attempting to delete /home/container/' + deleteItemPath + '. Please try again.
').show(); - console.log(jqXHR); + swal({ + type: 'warning', + title: 'Really Delete this File?', + showCancelButton: true, + showConfirmButton: true, + closeOnConfirm: false, + showLoaderOnConfirm: true + }, function () { + $.ajax({ + type: 'DELETE', + url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath, + headers: { + 'X-Access-Token': '{{ $server->daemonSecret }}', + 'X-Access-Server': '{{ $server->uuid }}' + } + }).done(function (data) { + clicked.parent().parent().parent().parent().fadeOut(); + swal({ + type: 'success', + title: 'File Deleted' + }); + }).fail(function (jqXHR) { + console.error(jqXHR); + swal({ + type: 'error', + title: 'Whoops!', + html: true, + text: 'An error occured while attempting to delete this file. Please try again.', + }); + }); }); });