Complete code for new file manager
This commit is contained in:
parent
4d922b6a0c
commit
9c7b753576
4 changed files with 111 additions and 11 deletions
|
@ -233,5 +233,16 @@ li.btn.btn-default.pill:active,li.btn.btn-default.pill:focus,li.btn.btn-default.
|
|||
.dropdown-menu > li.bg-default > a {
|
||||
padding-left: 11px !important;
|
||||
}
|
||||
/*.bg-danger:active,.bg-danger:focus,.bg-danger:hover{color:#fff;background-color:#d32a0e;border-color:#b1240c}
|
||||
.bg-danger.disabled,.bg-danger.disabled:active,.bg-danger.disabled:focus,.bg-danger.disabled:hover,.bg-danger[disabled]{background-color:#f04124;border-color:#ea2f10}*/
|
||||
|
||||
.success.pulsate {
|
||||
animation: pulse 3s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
background-color: #fff;
|
||||
}
|
||||
100% {
|
||||
background-color: #dff0d8;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class ActionsClass {
|
|||
'X-Access-Server': '{{ $server->uuid }}'
|
||||
},
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/files/rename',
|
||||
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/rename',
|
||||
timeout: 10000,
|
||||
data: JSON.stringify({
|
||||
from: `${currentPath}${currentName}`,
|
||||
|
@ -77,10 +77,11 @@ class ActionsClass {
|
|||
}
|
||||
|
||||
download() {
|
||||
var baseURL = $(this.menu).find('li[data-action="download"] a').attr('href');
|
||||
var toURL = baseURL + $(this.element).find('td[data-identifier="name"]').data('name');
|
||||
const nameBlock = $(this.element).find('td[data-identifier="name"]');
|
||||
const fileName = decodeURIComponent(nameBlock.attr('data-name'));
|
||||
const filePath = decodeURIComponent(nameBlock.data('path'));
|
||||
|
||||
window.location = toURL;
|
||||
window.location = `/server/{{ $server->uuidShort }}/files/download/${filePath}${fileName}`;
|
||||
}
|
||||
|
||||
rename() {
|
||||
|
@ -128,7 +129,7 @@ class ActionsClass {
|
|||
'X-Access-Server': '{{ $server->uuid }}'
|
||||
},
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/files/rename',
|
||||
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/rename',
|
||||
timeout: 10000,
|
||||
data: JSON.stringify({
|
||||
from: `${currentPath}${currentName}`,
|
||||
|
@ -184,7 +185,7 @@ class ActionsClass {
|
|||
}, () => {
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: `{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/${delPath}${delName}`,
|
||||
url: `{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/f/${delPath}${delName}`,
|
||||
headers: {
|
||||
'X-Access-Token': '{{ $server->daemonSecret }}',
|
||||
'X-Access-Server': '{{ $server->uuid }}'
|
||||
|
@ -206,4 +207,77 @@ class ActionsClass {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
decompress() {
|
||||
const nameBlock = $(this.element).find('td[data-identifier="name"]');
|
||||
const compPath = decodeURIComponent(nameBlock.data('path'));
|
||||
const compName = decodeURIComponent(nameBlock.data('name'));
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: `{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/decompress`,
|
||||
headers: {
|
||||
'X-Access-Token': '{{ $server->daemonSecret }}',
|
||||
'X-Access-Server': '{{ $server->uuid }}'
|
||||
},
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
data: JSON.stringify({
|
||||
files: `${compPath}${compName}`
|
||||
})
|
||||
}).done(data => {
|
||||
Files.list(compPath);
|
||||
}).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: 'Whoops!',
|
||||
html: true,
|
||||
text: error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
compress() {
|
||||
const nameBlock = $(this.element).find('td[data-identifier="name"]');
|
||||
const compPath = decodeURIComponent(nameBlock.data('path'));
|
||||
const compName = decodeURIComponent(nameBlock.data('name'));
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: `{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/compress`,
|
||||
headers: {
|
||||
'X-Access-Token': '{{ $server->daemonSecret }}',
|
||||
'X-Access-Server': '{{ $server->uuid }}'
|
||||
},
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
data: JSON.stringify({
|
||||
files: `${compPath}${compName}`,
|
||||
to: compPath.toString()
|
||||
})
|
||||
}).done(data => {
|
||||
Files.list(compPath, err => {
|
||||
if (err) return;
|
||||
const fileListing = $('#file_listing').find(`[data-name="${data.saved_as}"]`).parent();
|
||||
fileListing.addClass('success pulsate').delay(3000).queue(() => {
|
||||
fileListing.removeClass('success pulsate').dequeue();
|
||||
});
|
||||
});
|
||||
}).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: 'Whoops!',
|
||||
html: true,
|
||||
text: error
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class ContextMenuClass {
|
|||
<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> \
|
||||
<li class="divider"></li> \
|
||||
<li data-action="download" class="hidden"><a tabindex="-1" href="/server/{{ $server->uuidShort }}/files/download/"><i class="fa fa-download"></i> Download</a></li> \
|
||||
<li data-action="download" class="hidden"><a tabindex="-1" href="#"><i class="fa fa-download"></i> Download</a></li> \
|
||||
<li data-action="delete" class="bg-danger"><a tabindex="-1" href="#"><i class="fa fa-trash-o"></i> Delete</a></li> \
|
||||
</ul>';
|
||||
}
|
||||
|
@ -86,6 +86,16 @@ class ContextMenuClass {
|
|||
Actions.rename();
|
||||
});
|
||||
|
||||
$(menu).find('li[data-action="compress"]').unbind().on('click', e => {
|
||||
e.preventDefault();
|
||||
Actions.compress();
|
||||
});
|
||||
|
||||
$(menu).find('li[data-action="decompress"]').unbind().on('click', e => {
|
||||
e.preventDefault();
|
||||
Actions.decompress();
|
||||
});
|
||||
|
||||
$(menu).find('li[data-action="download"]').unbind().on('click', e => {
|
||||
e.preventDefault();
|
||||
Actions.download();
|
||||
|
|
|
@ -24,7 +24,7 @@ class FileManager {
|
|||
this.list(this.decodeHash());
|
||||
}
|
||||
|
||||
list(path, isError) {
|
||||
list(path, next) {
|
||||
if (_.isUndefined(path)) {
|
||||
path = this.decodeHash();
|
||||
}
|
||||
|
@ -43,16 +43,21 @@ class FileManager {
|
|||
this.loader(false);
|
||||
$('#load_files').slideUp().html(data).slideDown(100, () => {
|
||||
ContextMenu.run();
|
||||
if (_.isFunction(next)) {
|
||||
return next();
|
||||
}
|
||||
});
|
||||
$('#internal_alert').slideUp();
|
||||
}).fail(jqXHR => {
|
||||
this.loader(false);
|
||||
if (_.isFunction(next)) {
|
||||
return next(new Error('Failed to load file listing.'));
|
||||
}
|
||||
swal({
|
||||
type: 'error',
|
||||
title: 'File Error',
|
||||
text: 'An error occured while attempting to process this request. Please try again.',
|
||||
});
|
||||
if (!isError) this.list('/', true);
|
||||
console.log(jqXHR);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue