diff --git a/public/themes/default/css/pterodactyl.css b/public/themes/default/css/pterodactyl.css index b7819a85e..16c2e4663 100755 --- a/public/themes/default/css/pterodactyl.css +++ b/public/themes/default/css/pterodactyl.css @@ -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; + } +} diff --git a/resources/views/server/js/filemanager/actions.blade.php b/resources/views/server/js/filemanager/actions.blade.php index eb4089f04..597299696 100644 --- a/resources/views/server/js/filemanager/actions.blade.php +++ b/resources/views/server/js/filemanager/actions.blade.php @@ -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 + }); + }); + } } diff --git a/resources/views/server/js/filemanager/contextmenu.blade.php b/resources/views/server/js/filemanager/contextmenu.blade.php index 1ca934d41..ca74f4836 100644 --- a/resources/views/server/js/filemanager/contextmenu.blade.php +++ b/resources/views/server/js/filemanager/contextmenu.blade.php @@ -38,7 +38,7 @@ class ContextMenuClass { \ \
  • \ - \ + \
  • Delete
  • \ '; } @@ -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(); diff --git a/resources/views/server/js/filemanager/index.blade.php b/resources/views/server/js/filemanager/index.blade.php index e5386c016..2a84b64ba 100644 --- a/resources/views/server/js/filemanager/index.blade.php +++ b/resources/views/server/js/filemanager/index.blade.php @@ -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); }) }