Support for file copying
This commit is contained in:
parent
5356ee379e
commit
1d747ec647
3 changed files with 71 additions and 1 deletions
|
@ -76,6 +76,57 @@ class ActionsClass {
|
|||
|
||||
}
|
||||
|
||||
copy() {
|
||||
const nameBlock = $(this.element).find('td[data-identifier="name"]');
|
||||
const currentName = decodeURIComponent(nameBlock.attr('data-name'));
|
||||
const currentPath = decodeURIComponent(nameBlock.data('path'));
|
||||
|
||||
swal({
|
||||
type: 'input',
|
||||
title: 'Copy File',
|
||||
text: 'Please enter the new path for the copied file below.',
|
||||
showCancelButton: true,
|
||||
showConfirmButton: true,
|
||||
closeOnConfirm: false,
|
||||
showLoaderOnConfirm: true,
|
||||
inputValue: `${currentPath}${currentName}`,
|
||||
}, (val) => {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'X-Access-Token': '{{ $server->daemonSecret }}',
|
||||
'X-Access-Server': '{{ $server->uuid }}'
|
||||
},
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/copy',
|
||||
timeout: 10000,
|
||||
data: JSON.stringify({
|
||||
from: `${currentPath}${currentName}`,
|
||||
to: `${val}`,
|
||||
}),
|
||||
}).done(data => {
|
||||
swal({
|
||||
type: 'success',
|
||||
title: '',
|
||||
text: 'File successfully copied.'
|
||||
});
|
||||
Files.list();
|
||||
}).fail(jqXHR => {
|
||||
console.error(jqXHR);
|
||||
var error = 'An error occured while trying to process this request.';
|
||||
if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') {
|
||||
error = jqXHR.responseJSON.error;
|
||||
}
|
||||
swal({
|
||||
type: 'error',
|
||||
title: '',
|
||||
text: error,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
download() {
|
||||
const nameBlock = $(this.element).find('td[data-identifier="name"]');
|
||||
const fileName = decodeURIComponent(nameBlock.attr('data-name'));
|
||||
|
|
|
@ -34,6 +34,7 @@ class ContextMenuClass {
|
|||
if (!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
|
||||
return '<ul id="fileOptionMenu" class="dropdown-menu" role="menu" style="display:none" > \
|
||||
<li data-action="move"><a tabindex="-1" href="#"><i class="fa fa-arrow-right"></i> Move</a></li> \
|
||||
<li data-action="copy"><a tabindex="-1" href="#"><i class="fa fa-clone"></i> Copy</a></li> \
|
||||
<li data-action="rename"><a tabindex="-1" href="#"><i class="fa fa-pencil-square-o"></i> Rename</a></li> \
|
||||
<li data-action="compress" class="hidden"><a tabindex="-1" href="#"><i class="fa fa-file-archive-o"></i> Compress</a></li> \
|
||||
<li data-action="decompress" class="hidden"><a tabindex="-1" href="#"><i class="fa fa-expand"></i> Decompress</a></li> \
|
||||
|
@ -81,6 +82,11 @@ class ContextMenuClass {
|
|||
Actions.move();
|
||||
});
|
||||
|
||||
$(menu).find('li[data-action="copy"]').unbind().on('click', e => {
|
||||
e.preventDefault();
|
||||
Actions.copy();
|
||||
});
|
||||
|
||||
$(menu).find('li[data-action="rename"]').unbind().on('click', e => {
|
||||
e.preventDefault();
|
||||
Actions.rename();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue