Skip to content

Commit f588582

Browse files
committed
1 parent eeeb4b7 commit f588582

File tree

8 files changed

+198
-103
lines changed

8 files changed

+198
-103
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1010
* `[beta.1]` — Fixes panel looking for an old compiled classfile that is no longer used. This was causing errors relating to `missing class DingoAPI` when trying to upgrade the panel.
1111
* `[beta.1]` — Should fix render issues when trying to edit some files via the panel file editor.
1212

13+
### Added
14+
* Ability to launch the console in a new window as an individual unit. https://s3.kelp.in/IrTyE.png
15+
1316
## v0.6.0-beta.1 (Courageous Carniadactylus)
1417
### Fixed
1518
* `[pre.7]` — Fixes bug with subuser checkbox display.

app/Http/Controllers/Server/ServerController.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@ public function getIndex(Request $request, $uuid)
6565
]);
6666
}
6767

68+
/**
69+
* Renders server console as an individual item.
70+
*
71+
* @param \Illuminate\Http\Request $request
72+
* @param string $uuid
73+
* @return \Illuminate\View\View
74+
*/
75+
public function getConsole(Request $request, $uuid)
76+
{
77+
\Debugbar::disable();
78+
$server = Models\Server::byUuid($uuid);
79+
80+
$server->js([
81+
'config' => [
82+
'console_count' => config('pterodactyl.console.count'),
83+
'console_freq' => config('pterodactyl.console.freq'),
84+
],
85+
]);
86+
87+
return view('server.console', [
88+
'server' => $server,
89+
'node' => $server->node,
90+
]);
91+
}
92+
6893
/**
6994
* Renders file overview page.
7095
*

public/themes/pterodactyl/js/frontend/console.js

Lines changed: 110 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ var InitialLogSent = false;
2424

2525
(function initConsole() {
2626
window.TerminalQueue = [];
27+
window.ConsoleServerStatus = 0;
2728
window.Terminal = $('#terminal').terminal(function (command, term) {
28-
Socket.emit('send command', command);
29+
Socket.emit((ConsoleServerStatus !== 0) ? 'send command' : 'set status', command);
2930
}, {
3031
greetings: '',
3132
name: Pterodactyl.server.uuid,
@@ -80,6 +81,7 @@ var InitialLogSent = false;
8081
(function setupSocketListeners() {
8182
// Update Listings on Initial Status
8283
Socket.on('initial status', function (data) {
84+
ConsoleServerStatus = data.status;
8385
if (! InitialLogSent) {
8486
updateServerPowerControls(data.status);
8587

@@ -91,6 +93,7 @@ var InitialLogSent = false;
9193

9294
// Update Listings on Status
9395
Socket.on('status', function (data) {
96+
ConsoleServerStatus = data.status;
9497
updateServerPowerControls(data.status);
9598
});
9699

@@ -134,112 +137,117 @@ $(document).ready(function () {
134137
}
135138
});
136139

137-
Socket.on('proc', function (proc) {
138-
if (CPUData.length > 10) {
139-
CPUData.shift();
140-
MemoryData.shift();
141-
TimeLabels.shift();
140+
(function setupChartElements() {
141+
if (typeof SkipConsoleCharts !== 'undefined') {
142+
return;
142143
}
143144

144-
var cpuUse = (Pterodactyl.server.cpu > 0) ? parseFloat(((proc.data.cpu.total / Pterodactyl.server.cpu) * 100).toFixed(3).toString()) : proc.data.cpu.total;
145-
CPUData.push(cpuUse);
146-
MemoryData.push(parseInt(proc.data.memory.total / (1024 * 1024)));
147-
148-
TimeLabels.push($.format.date(new Date(), 'HH:mm:ss'));
149-
150-
CPUChart.update();
151-
MemoryChart.update();
152-
});
153-
154-
155-
var ctc = $('#chart_cpu');
156-
var TimeLabels = [];
157-
var CPUData = [];
158-
var CPUChart = new Chart(ctc, {
159-
type: 'line',
160-
data: {
161-
labels: TimeLabels,
162-
datasets: [
163-
{
164-
label: "Percent Use",
165-
fill: false,
166-
lineTension: 0.03,
167-
backgroundColor: "#3c8dbc",
168-
borderColor: "#3c8dbc",
169-
borderCapStyle: 'butt',
170-
borderDash: [],
171-
borderDashOffset: 0.0,
172-
borderJoinStyle: 'miter',
173-
pointBorderColor: "#3c8dbc",
174-
pointBackgroundColor: "#fff",
175-
pointBorderWidth: 1,
176-
pointHoverRadius: 5,
177-
pointHoverBackgroundColor: "#3c8dbc",
178-
pointHoverBorderColor: "rgba(220,220,220,1)",
179-
pointHoverBorderWidth: 2,
180-
pointRadius: 1,
181-
pointHitRadius: 10,
182-
data: CPUData,
183-
spanGaps: false,
184-
}
185-
]
186-
},
187-
options: {
188-
title: {
189-
display: true,
190-
text: 'CPU Usage (as Percent Total)'
191-
},
192-
legend: {
193-
display: false,
194-
},
195-
animation: {
196-
duration: 1,
145+
Socket.on('proc', function (proc) {
146+
if (CPUData.length > 10) {
147+
CPUData.shift();
148+
MemoryData.shift();
149+
TimeLabels.shift();
197150
}
198-
}
199-
});
200151

201-
var ctm = $('#chart_memory');
202-
MemoryData = [];
203-
MemoryChart = new Chart(ctm, {
204-
type: 'line',
205-
data: {
206-
labels: TimeLabels,
207-
datasets: [
208-
{
209-
label: "Memory Use",
210-
fill: false,
211-
lineTension: 0.03,
212-
backgroundColor: "#3c8dbc",
213-
borderColor: "#3c8dbc",
214-
borderCapStyle: 'butt',
215-
borderDash: [],
216-
borderDashOffset: 0.0,
217-
borderJoinStyle: 'miter',
218-
pointBorderColor: "#3c8dbc",
219-
pointBackgroundColor: "#fff",
220-
pointBorderWidth: 1,
221-
pointHoverRadius: 5,
222-
pointHoverBackgroundColor: "#3c8dbc",
223-
pointHoverBorderColor: "rgba(220,220,220,1)",
224-
pointHoverBorderWidth: 2,
225-
pointRadius: 1,
226-
pointHitRadius: 10,
227-
data: MemoryData,
228-
spanGaps: false,
229-
}
230-
]
231-
},
232-
options: {
233-
title: {
234-
display: true,
235-
text: 'Memory Usage (in Megabytes)'
152+
var cpuUse = (Pterodactyl.server.cpu > 0) ? parseFloat(((proc.data.cpu.total / Pterodactyl.server.cpu) * 100).toFixed(3).toString()) : proc.data.cpu.total;
153+
CPUData.push(cpuUse);
154+
MemoryData.push(parseInt(proc.data.memory.total / (1024 * 1024)));
155+
156+
TimeLabels.push($.format.date(new Date(), 'HH:mm:ss'));
157+
158+
CPUChart.update();
159+
MemoryChart.update();
160+
});
161+
162+
var ctc = $('#chart_cpu');
163+
var TimeLabels = [];
164+
var CPUData = [];
165+
var CPUChart = new Chart(ctc, {
166+
type: 'line',
167+
data: {
168+
labels: TimeLabels,
169+
datasets: [
170+
{
171+
label: "Percent Use",
172+
fill: false,
173+
lineTension: 0.03,
174+
backgroundColor: "#3c8dbc",
175+
borderColor: "#3c8dbc",
176+
borderCapStyle: 'butt',
177+
borderDash: [],
178+
borderDashOffset: 0.0,
179+
borderJoinStyle: 'miter',
180+
pointBorderColor: "#3c8dbc",
181+
pointBackgroundColor: "#fff",
182+
pointBorderWidth: 1,
183+
pointHoverRadius: 5,
184+
pointHoverBackgroundColor: "#3c8dbc",
185+
pointHoverBorderColor: "rgba(220,220,220,1)",
186+
pointHoverBorderWidth: 2,
187+
pointRadius: 1,
188+
pointHitRadius: 10,
189+
data: CPUData,
190+
spanGaps: false,
191+
}
192+
]
236193
},
237-
legend: {
238-
display: false,
194+
options: {
195+
title: {
196+
display: true,
197+
text: 'CPU Usage (as Percent Total)'
198+
},
199+
legend: {
200+
display: false,
201+
},
202+
animation: {
203+
duration: 1,
204+
}
205+
}
206+
});
207+
208+
var ctm = $('#chart_memory');
209+
MemoryData = [];
210+
MemoryChart = new Chart(ctm, {
211+
type: 'line',
212+
data: {
213+
labels: TimeLabels,
214+
datasets: [
215+
{
216+
label: "Memory Use",
217+
fill: false,
218+
lineTension: 0.03,
219+
backgroundColor: "#3c8dbc",
220+
borderColor: "#3c8dbc",
221+
borderCapStyle: 'butt',
222+
borderDash: [],
223+
borderDashOffset: 0.0,
224+
borderJoinStyle: 'miter',
225+
pointBorderColor: "#3c8dbc",
226+
pointBackgroundColor: "#fff",
227+
pointBorderWidth: 1,
228+
pointHoverRadius: 5,
229+
pointHoverBackgroundColor: "#3c8dbc",
230+
pointHoverBorderColor: "rgba(220,220,220,1)",
231+
pointHoverBorderWidth: 2,
232+
pointRadius: 1,
233+
pointHitRadius: 10,
234+
data: MemoryData,
235+
spanGaps: false,
236+
}
237+
]
239238
},
240-
animation: {
241-
duration: 1,
239+
options: {
240+
title: {
241+
display: true,
242+
text: 'Memory Usage (in Megabytes)'
243+
},
244+
legend: {
245+
display: false,
246+
},
247+
animation: {
248+
duration: 1,
249+
}
242250
}
243-
}
244-
});
251+
});
252+
})();
245253
});

public/themes/pterodactyl/js/frontend/server.socket.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
// SOFTWARE.
20-
20+
$('#console-popout').on('click', function (event) {
21+
event.preventDefault();
22+
window.open($(this).attr('href'), 'Pterodactyl Console', 'width=800,height=400');
23+
});
2124
var Server = (function () {
2225

2326
function initSocket() {

resources/lang/en/navigation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'server' => [
1313
'header' => 'SERVER MANAGEMENT',
1414
'console' => 'Console',
15+
'console-pop' => 'Fullscreen Console',
1516
'file_management' => 'File Management',
1617
'file_browser' => 'File Browser',
1718
'create_file' => 'Create File',

resources/themes/pterodactyl/layouts/master.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@
126126
<li class="{{ Route::currentRouteName() !== 'server.index' ?: 'active' }}">
127127
<a href="{{ route('server.index', $server->uuidShort) }}">
128128
<i class="fa fa-terminal"></i> <span>@lang('navigation.server.console')</span>
129+
<span class="pull-right-container muted muted-hover" href="{{ route('server.console', $server->uuidShort) }}" id="console-popout">
130+
<span class="label label-default pull-right" style="padding: 3px 5px 2px 5px;">
131+
<i class="fa fa-external-link"></i>
132+
</span>
133+
</span>
129134
</a>
130135
</li>
131136
@can('list-files', $server)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{-- Copyright (c) 2015 - 2017 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+
<!DOCTYPE html>
21+
<html>
22+
<head>
23+
<title>{{ Settings::get('company', 'Pterodactyl') }} - Console &rarr; {{ $server->name }}</title>
24+
@include('layouts.scripts')
25+
{!! Theme::css('vendor/terminal/jquery.terminal.css') !!}
26+
</head>
27+
<body style="margin:0;width:100%;height:100%;">
28+
<div id="terminal" style="width:100%"></div>
29+
<div id="terminalNotify" class="terminal-notify hidden">
30+
<i class="fa fa-bell"></i>
31+
</div>
32+
</body>
33+
<script>window.SkipConsoleCharts = true</script>
34+
{!! Theme::js('js/laroute.js') !!}
35+
{!! Theme::js('vendor/jquery/jquery.min.js') !!}
36+
{!! Theme::js('vendor/socketio/socket.io.min.js') !!}
37+
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!}
38+
{!! Theme::js('js/frontend/server.socket.js') !!}
39+
{!! Theme::js('vendor/mousewheel/jquery.mousewheel-min.js') !!}
40+
{!! Theme::js('vendor/terminal/jquery.terminal.min.js') !!}
41+
{!! Theme::js('vendor/terminal/unix_formatting.js') !!}
42+
{!! Theme::js('js/frontend/console.js') !!}
43+
<script>
44+
Terminal.resize($(window).innerWidth() - 20, $(window).innerHeight() - 20);
45+
$(window).on('resize', function () {
46+
Terminal.resize($(window).innerWidth() - 20, $(window).innerHeight() - 20);
47+
});
48+
</script>
49+
</html>

routes/server.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424
Route::get('/', 'ServerController@getIndex')->name('server.index');
25+
Route::get('/console', 'ServerController@getConsole')->name('server.console');
2526

2627
/*
2728
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)