Skip to content

Commit 83c776f

Browse files
committed
Fix up most of the file manager
1 parent 042c28c commit 83c776f

File tree

17 files changed

+1261
-6
lines changed

17 files changed

+1261
-6
lines changed

app/Http/Controllers/Server/ServerController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public function getEditFile(Request $request, $uuid, $file)
142142
{
143143
$server = Models\Server::getByUUID($uuid);
144144
$this->authorize('edit-files', $server);
145+
$node = Models\Node::find($server->node);
145146

146147
$fileInfo = (object) pathinfo($file);
147148
$controller = new FileRepository($uuid);
@@ -159,9 +160,15 @@ public function getEditFile(Request $request, $uuid, $file)
159160
return redirect()->route('server.files.index', $uuid);
160161
}
161162

163+
Javascript::put([
164+
'server' => collect($server->makeVisible('daemonSecret'))->only(['uuid', 'uuidShort', 'daemonSecret', 'username']),
165+
'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'),
166+
'stat' => $fileContent['stat'],
167+
]);
168+
162169
return view('server.files.edit', [
163170
'server' => $server,
164-
'node' => Models\Node::find($server->node),
171+
'node' => $node,
165172
'file' => $file,
166173
'stat' => $fileContent['stat'],
167174
'contents' => $fileContent['file']->content,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"babel-preset-es2015": "6.18.0"
77
},
88
"scripts": {
9-
"build": "./node_modules/babel-cli/bin/babel.js public/js/files --source-maps --out-file public/js/filemanager.min.js"
9+
"build": "./node_modules/babel-cli/bin/babel.js public/themes/pterodactyl/js/frontend/files/src --source-maps --out-file public/themes/pterodactyl/js/frontend/files/filemanager.min.js"
1010
}
1111
}

public/themes/pterodactyl/css/pterodactyl.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,45 @@ code {
6161
.middle {
6262
vertical-align: middle !important;
6363
}
64+
65+
#fileOptionMenu.dropdown-menu > li > a {
66+
padding:3px 6px;
67+
}
68+
69+
.hasFileHover {
70+
border: 2px dashed #0087F7;
71+
border-top: 0 !important;
72+
border-radius: 5px;
73+
margin: 0;
74+
opacity: 0.5;
75+
}
76+
77+
.hasFileHover * {
78+
pointer-events: none;
79+
}
80+
81+
td.has-progress {
82+
padding: 0px !important;
83+
border-top: 0px !important;
84+
}
85+
86+
.progress.progress-table-bottom {
87+
margin: 0 !important;
88+
height:5px !important;
89+
padding:0;
90+
border:0;
91+
}
92+
93+
.muted {
94+
filter: alpha(opacity=20);
95+
opacity: 0.2;
96+
}
97+
98+
.muted-hover:hover {
99+
filter: alpha(opacity=100);
100+
opacity: 1;
101+
}
102+
103+
.use-pointer {
104+
cursor: pointer !important;
105+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in all
11+
// copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
// SOFTWARE.
20+
$(document).ready(function () {
21+
$('.server-files').addClass('active');
22+
const Editor = ace.edit('editor');
23+
const Modelist = ace.require('ace/ext/modelist')
24+
25+
Editor.setTheme('ace/theme/chrome');
26+
Editor.getSession().setMode(Modelist.getModeForPath(Pterodactyl.stat.name).mode);
27+
Editor.getSession().setUseWrapMode(true);
28+
Editor.setShowPrintMargin(false);
29+
30+
Editor.commands.addCommand({
31+
name: 'save',
32+
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
33+
exec: function(editor) {
34+
save();
35+
},
36+
readOnly: false
37+
});
38+
39+
$('#save_file').on('click', function (e) {
40+
e.preventDefault();
41+
save();
42+
});
43+
44+
function save() {
45+
var fileName = $('input[name="file"]').val();
46+
$('#save_file').html('<i class="fa fw-fw fa-spinner fa-spin"></i> Saving File').addClass('disabled');
47+
$.ajax({
48+
type: 'POST',
49+
url: Router.route('server.files.save', { server: Pterodactyl.server.uuidShort }),
50+
headers: {
51+
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content'),
52+
},
53+
data: {
54+
file: fileName,
55+
contents: Editor.getValue()
56+
}
57+
}).done(function (data) {
58+
$.notify({
59+
message: 'File was successfully saved.'
60+
}, {
61+
type: 'success'
62+
});
63+
}).fail(function (jqXHR) {
64+
$.notify({
65+
message: jqXHR.responseText
66+
}, {
67+
type: 'danger'
68+
});
69+
}).always(function () {
70+
$('#save_file').html('<i class="fa fa-fw fa-save"></i> &nbsp;Save File').removeClass('disabled');
71+
});
72+
}
73+
});

public/themes/pterodactyl/js/frontend/files/filemanager.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/themes/pterodactyl/js/frontend/files/filemanager.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)