From 1d747ec6476eca6f9b1132811de53af9a9d43bb6 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 6 Oct 2016 19:15:40 -0400 Subject: [PATCH] Support for file copying --- CHANGELOG.md | 15 +++++- .../server/js/filemanager/actions.blade.php | 51 +++++++++++++++++++ .../js/filemanager/contextmenu.blade.php | 6 +++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5035d638..d3c87c0d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,20 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. -## v0.5.0 (Bodacious Boreopterus) [Unreleased] +## v0.5.0-pre.2 (Bodacious Boreopterus) + +### Added +* Adds support for file copying through the file manager. [#127](https://github.com/Pterodactyl/Panel/issues/127) + +### Changed +* Support for sub-folders within the `getJavascript()` route for servers. + +### Fixed +* File manager would do multiple up-down-up-down loading actions if you escaped renaming a file. Fixed the binding issue. [#122](https://github.com/Pterodactyl/Panel/issues/122) +* File manager actions would not trigger properly if text in a row was used to right-click from. +* File manager rename field would not disappear when pressing the escape key in chrome. [#121](https://github.com/Pterodactyl/Panel/issues/121) + +## v0.5.0-pre.1 (Bodacious Boreopterus) ### Added * Support for creating server without having to assign a node and allocation manually. Simply select the checkbox or pass `auto_deploy=true` to the API to auto-select a node and allocation given a location. diff --git a/resources/views/server/js/filemanager/actions.blade.php b/resources/views/server/js/filemanager/actions.blade.php index 36ca2ef41..81b8f90b9 100644 --- a/resources/views/server/js/filemanager/actions.blade.php +++ b/resources/views/server/js/filemanager/actions.blade.php @@ -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')); diff --git a/resources/views/server/js/filemanager/contextmenu.blade.php b/resources/views/server/js/filemanager/contextmenu.blade.php index a58726535..5e46b6aa0 100644 --- a/resources/views/server/js/filemanager/contextmenu.blade.php +++ b/resources/views/server/js/filemanager/contextmenu.blade.php @@ -34,6 +34,7 @@ class ContextMenuClass { if (!_.isNull(this.activeLine)) this.activeLine.removeClass('active'); return '