Add file deletion support, fix renaming deleting URL hash
This commit is contained in:
parent
72a57604df
commit
cf9a70ddca
|
@ -116,4 +116,44 @@ class ActionsClass {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete() {
|
||||||
|
const nameBlock = $(this.element).find('td[data-identifier="name"]');
|
||||||
|
const delPath = decodeURIComponent(nameBlock.data('path'));
|
||||||
|
const delName = decodeURIComponent(nameBlock.data('name'));
|
||||||
|
|
||||||
|
swal({
|
||||||
|
type: 'warning',
|
||||||
|
title: '',
|
||||||
|
text: 'Are you sure you want to delete <code>' + delName + '</code>? There is <strong>no</strong> reversing this action.',
|
||||||
|
html: true,
|
||||||
|
showCancelButton: true,
|
||||||
|
showConfirmButton: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
showLoaderOnConfirm: true
|
||||||
|
}, () => {
|
||||||
|
$.ajax({
|
||||||
|
type: 'DELETE',
|
||||||
|
url: `{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/${delPath}${delName}`,
|
||||||
|
headers: {
|
||||||
|
'X-Access-Token': '{{ $server->daemonSecret }}',
|
||||||
|
'X-Access-Server': '{{ $server->uuid }}'
|
||||||
|
}
|
||||||
|
}).done(data => {
|
||||||
|
// nameBlock.parent().addClass('warning').delay(200).fadeOut();
|
||||||
|
swal({
|
||||||
|
type: 'success',
|
||||||
|
title: 'File Deleted'
|
||||||
|
});
|
||||||
|
}).fail(jqXHR => {
|
||||||
|
console.error(jqXHR);
|
||||||
|
swal({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Whoops!',
|
||||||
|
html: true,
|
||||||
|
text: 'An error occured while attempting to delete this file. Please try again.',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,10 +77,12 @@ class ContextMenuClass {
|
||||||
// Handle Events
|
// Handle Events
|
||||||
const Actions = new ActionsClass(parent, menu);
|
const Actions = new ActionsClass(parent, menu);
|
||||||
$(menu).find('li[data-action="move"]').unbind().on('click', e => {
|
$(menu).find('li[data-action="move"]').unbind().on('click', e => {
|
||||||
|
e.preventDefault();
|
||||||
Actions.move();
|
Actions.move();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(menu).find('li[data-action="rename"]').unbind().on('click', e => {
|
$(menu).find('li[data-action="rename"]').unbind().on('click', e => {
|
||||||
|
e.preventDefault();
|
||||||
Actions.rename();
|
Actions.rename();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,6 +91,11 @@ class ContextMenuClass {
|
||||||
Actions.download();
|
Actions.download();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(menu).find('li[data-action="delete"]').unbind().on('click', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
Actions.delete();
|
||||||
|
});
|
||||||
|
|
||||||
$(window).on('click', () => {
|
$(window).on('click', () => {
|
||||||
$(menu).remove();
|
$(menu).remove();
|
||||||
if(!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
|
if(!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
|
||||||
|
@ -103,7 +110,6 @@ class ContextMenuClass {
|
||||||
const path = $(this).parent().data('path') || '';
|
const path = $(this).parent().data('path') || '';
|
||||||
const name = $(this).parent().data('name') || '';
|
const name = $(this).parent().data('name') || '';
|
||||||
|
|
||||||
console.log('changing hash');
|
|
||||||
window.location.hash = encodeURIComponent(path + name);
|
window.location.hash = encodeURIComponent(path + name);
|
||||||
Files.list();
|
Files.list();
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,10 +24,6 @@ class FileManager {
|
||||||
this.list(this.decodeHash());
|
this.list(this.decodeHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
list(path, isError) {
|
list(path, isError) {
|
||||||
if (_.isUndefined(path)) {
|
if (_.isUndefined(path)) {
|
||||||
path = this.decodeHash();
|
path = this.decodeHash();
|
||||||
|
|
Loading…
Reference in New Issue