diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c87c0d8..2c96bb6f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ## 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) +* Added support for file copying through the file manager. [#127](https://github.com/Pterodactyl/Panel/issues/127) +* Added support for creating new files and folders directly from the right-click dropdown menu. ### Changed * Support for sub-folders within the `getJavascript()` route for servers. diff --git a/resources/views/server/files/list.blade.php b/resources/views/server/files/list.blade.php index ca5f78cd2..544d42a62 100644 --- a/resources/views/server/files/list.blade.php +++ b/resources/views/server/files/list.blade.php @@ -25,7 +25,7 @@
/home/container{{ $directory['header'] }}
diff --git a/resources/views/server/js/filemanager/actions.blade.php b/resources/views/server/js/filemanager/actions.blade.php
index 81b8f90b9..a2e74c565 100644
--- a/resources/views/server/js/filemanager/actions.blade.php
+++ b/resources/views/server/js/filemanager/actions.blade.php
@@ -29,6 +29,55 @@ class ActionsClass {
this.element = undefined;
}
+ folder() {
+ const nameBlock = $(this.element).find('td[data-identifier="name"]');
+ const currentName = decodeURIComponent(nameBlock.attr('data-name'));
+ const currentPath = decodeURIComponent(nameBlock.data('path'));
+
+ let inputValue = `${currentPath}${currentName}/`;
+ if ($(this.element).data('type') === 'file') {
+ inputValue = currentPath;
+ }
+ swal({
+ type: 'input',
+ title: 'Create Folder',
+ text: 'Please enter the path and folder name below.',
+ showCancelButton: true,
+ showConfirmButton: true,
+ closeOnConfirm: false,
+ showLoaderOnConfirm: true,
+ inputValue: inputValue
+ }, (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/folder',
+ timeout: 10000,
+ data: JSON.stringify({
+ path: val,
+ }),
+ }).done(data => {
+ swal.close();
+ 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,
+ });
+ });
+ });
+ }
+
move() {
const nameBlock = $(this.element).find('td[data-identifier="name"]');
const currentName = 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 5e46b6aa0..5ad1a7140 100644
--- a/resources/views/server/js/filemanager/contextmenu.blade.php
+++ b/resources/views/server/js/filemanager/contextmenu.blade.php
@@ -29,9 +29,17 @@ class ContextMenuClass {
this.rightClick();
}
- makeMenu() {
+ makeMenu(parent) {
$(document).find('#fileOptionMenu').remove();
if (!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
+
+ let newFilePath = $('#headerTableRow').attr('data-currentDir');
+ if (parent.data('type') === 'folder') {
+ const nameBlock = parent.find('td[data-identifier="name"]');
+ const currentName = decodeURIComponent(nameBlock.attr('data-name'));
+ const currentPath = decodeURIComponent(nameBlock.data('path'));
+ newFilePath = `${currentPath}${currentName}`;
+ }
return ' ';
@@ -48,7 +59,7 @@ class ContextMenuClass {
$('#file_listing > tbody td').on('contextmenu', event => {
const parent = $(event.target).closest('tr');
- const menu = $(this.makeMenu());
+ const menu = $(this.makeMenu(parent));
if (parent.data('type') === 'disabled') return;
event.preventDefault();
@@ -102,6 +113,11 @@ class ContextMenuClass {
Actions.decompress();
});
+ $(menu).find('li[data-action="folder"]').unbind().on('click', e => {
+ e.preventDefault();
+ Actions.folder();
+ });
+
$(menu).find('li[data-action="download"]').unbind().on('click', e => {
e.preventDefault();
Actions.download();