Skip to content

Commit abed575

Browse files
committed
Show nicer alerts for file deletion
1 parent 54bef1e commit abed575

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

resources/views/server/files/index.blade.php

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,36 @@ function reloadActionDelete () {
8484
var clicked = $(this);
8585
var deleteItemPath = $(this).attr('href');
8686
87-
if (!confirm('Are you sure you want to delete /home/container/' + deleteItemPath + '? There is no reversing this action.')) {
88-
return;
89-
}
90-
91-
$.ajax({
92-
type: 'DELETE',
93-
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath,
94-
headers: {
95-
'X-Access-Token': '{{ $server->daemonSecret }}',
96-
'X-Access-Server': '{{ $server->uuid }}'
97-
}
98-
}).done(function (data) {
99-
clicked.parent().parent().parent().parent().fadeOut();
100-
}).fail(function (jqXHR) {
101-
$("#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();
102-
console.log(jqXHR);
87+
swal({
88+
type: 'warning',
89+
title: 'Really Delete this File?',
90+
showCancelButton: true,
91+
showConfirmButton: true,
92+
closeOnConfirm: false,
93+
showLoaderOnConfirm: true
94+
}, function () {
95+
$.ajax({
96+
type: 'DELETE',
97+
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath,
98+
headers: {
99+
'X-Access-Token': '{{ $server->daemonSecret }}',
100+
'X-Access-Server': '{{ $server->uuid }}'
101+
}
102+
}).done(function (data) {
103+
clicked.parent().parent().parent().parent().fadeOut();
104+
swal({
105+
type: 'success',
106+
title: 'File Deleted'
107+
});
108+
}).fail(function (jqXHR) {
109+
console.error(jqXHR);
110+
swal({
111+
type: 'error',
112+
title: 'Whoops!',
113+
html: true,
114+
text: 'An error occured while attempting to delete this file. Please try again.',
115+
});
116+
});
103117
});
104118
105119
});

0 commit comments

Comments
 (0)