Skip to content

Commit 1d747ec

Browse files
committed
Support for file copying
1 parent 5356ee3 commit 1d747ec

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@ This file is a running track of new features and fixes to each version of the pa
33

44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

6-
## v0.5.0 (Bodacious Boreopterus) [Unreleased]
6+
## v0.5.0-pre.2 (Bodacious Boreopterus)
7+
8+
### Added
9+
* Adds support for file copying through the file manager. [#127](https://github.com/Pterodactyl/Panel/issues/127)
10+
11+
### Changed
12+
* Support for sub-folders within the `getJavascript()` route for servers.
13+
14+
### Fixed
15+
* 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)
16+
* File manager actions would not trigger properly if text in a row was used to right-click from.
17+
* File manager rename field would not disappear when pressing the escape key in chrome. [#121](https://github.com/Pterodactyl/Panel/issues/121)
18+
19+
## v0.5.0-pre.1 (Bodacious Boreopterus)
720

821
### Added
922
* 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.

resources/views/server/js/filemanager/actions.blade.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,57 @@ class ActionsClass {
7676

7777
}
7878

79+
copy() {
80+
const nameBlock = $(this.element).find('td[data-identifier="name"]');
81+
const currentName = decodeURIComponent(nameBlock.attr('data-name'));
82+
const currentPath = decodeURIComponent(nameBlock.data('path'));
83+
84+
swal({
85+
type: 'input',
86+
title: 'Copy File',
87+
text: 'Please enter the new path for the copied file below.',
88+
showCancelButton: true,
89+
showConfirmButton: true,
90+
closeOnConfirm: false,
91+
showLoaderOnConfirm: true,
92+
inputValue: `${currentPath}${currentName}`,
93+
}, (val) => {
94+
$.ajax({
95+
type: 'POST',
96+
headers: {
97+
'X-Access-Token': '{{ $server->daemonSecret }}',
98+
'X-Access-Server': '{{ $server->uuid }}'
99+
},
100+
contentType: 'application/json; charset=utf-8',
101+
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/copy',
102+
timeout: 10000,
103+
data: JSON.stringify({
104+
from: `${currentPath}${currentName}`,
105+
to: `${val}`,
106+
}),
107+
}).done(data => {
108+
swal({
109+
type: 'success',
110+
title: '',
111+
text: 'File successfully copied.'
112+
});
113+
Files.list();
114+
}).fail(jqXHR => {
115+
console.error(jqXHR);
116+
var error = 'An error occured while trying to process this request.';
117+
if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') {
118+
error = jqXHR.responseJSON.error;
119+
}
120+
swal({
121+
type: 'error',
122+
title: '',
123+
text: error,
124+
});
125+
});
126+
});
127+
128+
}
129+
79130
download() {
80131
const nameBlock = $(this.element).find('td[data-identifier="name"]');
81132
const fileName = decodeURIComponent(nameBlock.attr('data-name'));

resources/views/server/js/filemanager/contextmenu.blade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ContextMenuClass {
3434
if (!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
3535
return '<ul id="fileOptionMenu" class="dropdown-menu" role="menu" style="display:none" > \
3636
<li data-action="move"><a tabindex="-1" href="#"><i class="fa fa-arrow-right"></i> Move</a></li> \
37+
<li data-action="copy"><a tabindex="-1" href="#"><i class="fa fa-clone"></i> Copy</a></li> \
3738
<li data-action="rename"><a tabindex="-1" href="#"><i class="fa fa-pencil-square-o"></i> Rename</a></li> \
3839
<li data-action="compress" class="hidden"><a tabindex="-1" href="#"><i class="fa fa-file-archive-o"></i> Compress</a></li> \
3940
<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 {
8182
Actions.move();
8283
});
8384

85+
$(menu).find('li[data-action="copy"]').unbind().on('click', e => {
86+
e.preventDefault();
87+
Actions.copy();
88+
});
89+
8490
$(menu).find('li[data-action="rename"]').unbind().on('click', e => {
8591
e.preventDefault();
8692
Actions.rename();

0 commit comments

Comments
 (0)