Skip to content

Commit fb77e23

Browse files
committed
Make server overview cleaner and easier to follow
Also adds allocation information tab, still need to make it so users can actually change their default connection address
1 parent 79214c2 commit fb77e23

File tree

4 files changed

+139
-81
lines changed

4 files changed

+139
-81
lines changed

app/Http/Controllers/Server/ServerController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Pterodactyl\Models\Server;
77
use Pterodactyl\Models\Node;
88
use Pterodactyl\Models\Download;
9+
use Pterodactyl\Models\Allocation;
910
use Debugbar;
1011
use Uuid;
1112
use Alert;
@@ -46,6 +47,7 @@ public function getIndex(Request $request)
4647
$server = Server::getByUUID($request->route()->server);
4748
return view('server.index', [
4849
'server' => $server,
50+
'allocations' => Allocation::where('assigned_to', $server->id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(),
4951
'node' => Node::find($server->node)
5052
]);
5153
}

resources/lang/en/server.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
'mem_limit' => 'Memory Limit',
2424
'disk_space' => 'Disk Space',
2525
'control' => 'Control Server',
26-
'info_use' => 'Information & Usage',
26+
'usage' => 'Usage',
27+
'allocation' => 'Allocation',
2728
'command' => 'Enter Console Command',
2829
],
2930
'files' => [

resources/views/admin/servers/view.blade.php

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@
140140
<div class="panel panel-default">
141141
<div class="panel-heading"></div>
142142
<div class="panel-body">
143+
<div class="row">
144+
<div class="col-md-12">
145+
<div class="alert alert-info">
146+
After editing any of the options below you will need to restart the server for changes to take effect. If the server is currently off, you just need to start it and the container will be rebuilt with the new settings.
147+
</div>
148+
</div>
149+
</div>
143150
<form action="/admin/servers/view/{{ $server->id }}/build" method="POST">
144151
<div class="row">
145152
<div class="col-md-6 form-group {{ $errors->has('memory') ? 'has-error' : '' }}">
@@ -244,18 +251,55 @@
244251
<div class="panel panel-default">
245252
<div class="panel-heading"></div>
246253
<div class="panel-body">
247-
<div class="col-md-12">
248-
<div class="col-md-4 text-center">
249-
<form action="/admin/servers/view/{{ $server->id }}/rebuild" method="POST">
250-
{!! csrf_field() !!}
251-
<button type="submit" class="btn btn-sm btn-primary">Rebuild Server Container</button>
252-
</form>
253-
</div>
254-
<div class="col-md-8">
255-
<p>This will trigger a rebuild of the server container when it next starts up. This is useful if you modified the server configuration file manually, or something just didn't work out correctly. Please be aware: if you manually updated the server's configuration file, you will need to restart the daemon before doing this, or it will be overwritten.</p>
256-
<div class="alert alert-info">A rebuild will automatically occur whenever you edit build configuration settings for the server.</div>
257-
</div>
258-
</div>
254+
<table class="table table-striped" style="margin-bottom: 0;">
255+
<tbody>
256+
<tr>
257+
<td class="text-center" style="vertical-align:middle;">
258+
<a href="/server/{{ $server->uuidShort }}/">
259+
<button type="submit" class="btn btn-sm btn-primary">Manage Server</button>
260+
</a>
261+
</td>
262+
<td>
263+
<p>This will take you to the server management page that users normally see and allow you to manage server files as well as check the console and data usage.</p>
264+
</td>
265+
</tr>
266+
<tr>
267+
<td class="text-center" style="vertical-align:middle;">
268+
<form action="/admin/servers/view/{{ $server->id }}/installed" method="POST">
269+
{!! csrf_field() !!}
270+
<button type="submit" class="btn btn-sm btn-primary">Toggle Install Status</button>
271+
</form>
272+
</td>
273+
<td>
274+
<p>This will toggle the install status for the server.</p>
275+
<div class="alert alert-warning">If you have just created this server it is ill advised to perform this action as the daemon will contact the panel when finished which could cause the install status to be wrongly set.</div>
276+
</td>
277+
</tr>
278+
<tr>
279+
<td class="text-center" style="vertical-align:middle;">
280+
<form action="/admin/servers/view/{{ $server->id }}/rebuild" method="POST">
281+
{!! csrf_field() !!}
282+
<button type="submit" class="btn btn-sm btn-primary">Rebuild Server Container</button>
283+
</form>
284+
</td>
285+
<td>
286+
<p>This will trigger a rebuild of the server container when it next starts up. This is useful if you modified the server configuration file manually, or something just didn't work out correctly. Please be aware: if you manually updated the server's configuration file, you will need to restart the daemon before doing this, or it will be overwritten.</p>
287+
<div class="alert alert-info">A rebuild will automatically occur whenever you edit build configuration settings for the server.</div>
288+
</td>
289+
</tr>
290+
<tr>
291+
<td class="text-center" style="vertical-align:middle;">
292+
<form action="/admin/servers/view/{{ $server->id }}/delete" method="POST">
293+
{!! csrf_field() !!}
294+
<button type="submit" class="btn btn-sm btn-danger">Delete Server</button>
295+
</form>
296+
</td>
297+
<td>
298+
<div class="alert alert-danger" style="margin-top:21px;">Deleting a server is an irreversible action. <strong>All data will be immediately removed relating to this server.</strong></div>
299+
</td>
300+
</tr>
301+
</tbody>
302+
</table>
259303
</div>
260304
</div>
261305
</div>

resources/views/server/index.blade.php

Lines changed: 79 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,86 @@
2020
</div>
2121
@endforeach
2222
@endforeach
23-
<ul class="nav nav-tabs" id="config_tabs">
24-
<li class="active"><a href="#stats" data-toggle="tab">{{ trans('server.index.info_use') }}</a></li>
25-
<li id="triggerConsoleView"><a href="#console" data-toggle="tab">{{ trans('server.index.control') }}</a></li>
26-
</ul><br />
23+
<ul class="nav nav-tabs tabs_with_panel" id="config_tabs">
24+
<li id="triggerConsoleView" class="active"><a href="#console" data-toggle="tab">{{ trans('server.index.control') }}</a></li>
25+
<li><a href="#stats" data-toggle="tab">{{ trans('server.index.usage') }}</a></li>
26+
<li><a href="#allocation" data-toggle="tab">{{ trans('server.index.allocation') }}</a></li>
27+
</ul>
2728
<div class="tab-content">
28-
<div class="tab-pane active" id="stats">
29-
<div class="row">
30-
<div class="col-md-12" id="chart_memory" style="height:250px;"></div>
31-
<div class="col-md-12" id="chart_cpu" style="height:250px;"></div>
32-
</div>
33-
<div class="row">
34-
<div class="col-md-12" id="stats_players">
35-
<h3 class="nopad">Active Players</h3><hr />
36-
<div id="players_notice" class="alert alert-info">
37-
<i class="fa fa-spinner fa-spin"></i> Waiting for response from server...
29+
<div class="tab-pane active" id="console">
30+
<div class="panel panel-default">
31+
<div class="panel-heading"></div>
32+
<div class="panel-body">
33+
<div class="row">
34+
<div class="col-md-12">
35+
<textarea id="live_console" class="form-control console" readonly="readonly">Loading Previous Content...</textarea>
36+
</div>
37+
<div class="col-md-6">
38+
<hr />
39+
<form action="#" method="post" id="console_command" style="display:none;">
40+
<fieldset>
41+
<div class="input-group">
42+
<input type="text" class="form-control" name="command" id="ccmd" placeholder="{{ trans('server.index.command') }}" />
43+
<span class="input-group-btn">
44+
<button id="sending_command" class="btn btn-primary btn-sm">&rarr;</button>
45+
</span>
46+
</div>
47+
</fieldset>
48+
</form>
49+
<div class="alert alert-danger" id="sc_resp" style="display:none;margin-top: 15px;"></div>
50+
</div>
51+
<div class="col-md-6" style="text-align:center;">
52+
<hr />
53+
<button class="btn btn-success btn-sm disabled" data-attr="power" data-action="start">Start</button>
54+
<button class="btn btn-primary btn-sm disabled" data-attr="power" data-action="restart">Restart</button>
55+
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="stop">Stop</button>
56+
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="kill"><i class="fa fa-ban" data-toggle="tooltip" data-placement="top" title="Kill Running Process"></i></button>
57+
<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#pauseConsole" id="pause_console"><small><i class="fa fa-pause fa-fw"></i></small></button>
58+
<div id="pw_resp" style="display:none;margin-top: 15px;"></div>
59+
</div>
60+
</div>
61+
<div class="row">
62+
<div class="col-md-12" id="stats_players">
63+
<h3>Active Players</h3><hr />
64+
<div id="players_notice" class="alert alert-info">
65+
<i class="fa fa-spinner fa-spin"></i> Waiting for response from server...
66+
</div>
67+
<span id="toggle_players" style="display:none;">
68+
<p class="text-muted">No players are online.</p>
69+
</span>
70+
</div>
3871
</div>
39-
<span id="toggle_players" style="display:none;">
40-
<p class="text-muted">No players are online.</p>
41-
</span>
42-
</div>
43-
<div class="col-md-12">
44-
<h3>{{ trans('server.index.server_info') }}</h3><hr />
45-
<table class="table table-striped table-bordered table-hover">
46-
<tbody>
47-
<tr>
48-
<td><strong>{{ trans('server.index.connection') }}</strong></td>
49-
<td><code>{{ $server->ip }}:{{ $server->port }}</code></td>
50-
</tr>
51-
<tr>
52-
<td><strong>{{ trans('strings.node') }}</strong></td>
53-
<td>{{ $node->name }}</td>
54-
</tr>
55-
<tr>
56-
<td><strong>{{ trans('server.index.mem_limit') }}</strong></td>
57-
<td>{{ $server->memory }} MB</td>
58-
</tr>
59-
<tr>
60-
<td><strong>{{ trans('server.index.disk_space') }}</strong></td>
61-
<td>{{ $server->disk }} MB</td>
62-
</tr>
63-
</tbody>
64-
</table>
6572
</div>
6673
</div>
6774
</div>
68-
<div class="tab-pane" id="console">
69-
<div class="row">
70-
<div class="col-md-12">
71-
<textarea id="live_console" class="form-control console" readonly="readonly">Loading Previous Content...</textarea>
72-
</div>
73-
<div class="col-md-6">
74-
<hr />
75-
<form action="#" method="post" id="console_command" style="display:none;">
76-
<fieldset>
77-
<div class="input-group">
78-
<input type="text" class="form-control" name="command" id="ccmd" placeholder="{{ trans('server.index.command') }}" />
79-
<span class="input-group-btn">
80-
<button id="sending_command" class="btn btn-primary btn-sm">&rarr;</button>
81-
</span>
82-
</div>
83-
</fieldset>
84-
</form>
85-
<div class="alert alert-danger" id="sc_resp" style="display:none;margin-top: 15px;"></div>
75+
<div class="tab-pane" id="stats">
76+
<div class="panel panel-default">
77+
<div class="panel-heading"></div>
78+
<div class="panel-body">
79+
<div class="row">
80+
<div class="col-xs-11 text-center" id="chart_memory" style="height:250px;"></div>
81+
<div class="col-xs-11 text-center" id="chart_cpu" style="height:250px;"></div>
82+
</div>
8683
</div>
87-
<div class="col-md-6" style="text-align:center;">
88-
<hr />
89-
<button class="btn btn-success btn-sm disabled" data-attr="power" data-action="start">Start</button>
90-
<button class="btn btn-primary btn-sm disabled" data-attr="power" data-action="restart">Restart</button>
91-
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="stop">Stop</button>
92-
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="kill"><i class="fa fa-ban" data-toggle="tooltip" data-placement="top" title="Kill Running Process"></i></button>
93-
<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#pauseConsole" id="pause_console"><small><i class="fa fa-pause fa-fw"></i></small></button>
94-
<div id="pw_resp" style="display:none;margin-top: 15px;"></div>
84+
</div>
85+
</div>
86+
<div class="tab-pane" id="allocation">
87+
<div class="panel panel-default">
88+
<div class="panel-heading"></div>
89+
<div class="panel-body">
90+
<div class="alert alert-info">Below is a listing of all avaliable IPs and Ports for your service. To change the default connection address for your server, simply click on the one you would like to make default below.</div>
91+
<ul class="nav nav-pills nav-stacked">
92+
@foreach ($allocations as $allocation)
93+
<li role="presentation" @if($allocation->ip === $server->ip && $allocation->port === $server->port) class="active" @endif><a href="#/set-connnection/{{ $allocation->ip }}:{{ $allocation->port }}" data-action="set-connection" data-connection="{{ $allocation->ip }}:{{ $allocation->port }}">{{ $allocation->ip }} <span class="badge">{{ $allocation->port }}</span></a></li>
94+
@endforeach
95+
</ul>
9596
</div>
9697
</div>
9798
</div>
9899
</div>
100+
<div class="row">
101+
<div class="col-xs-11" id="col11_setter"></div>
102+
</div>
99103
</div>
100104
<div class="modal fade" id="pauseConsole" tabindex="-1" role="dialog" aria-labelledby="PauseConsole" aria-hidden="true">
101105
<div class="modal-dialog">
@@ -124,11 +128,17 @@
124128
// -----------------+
125129
// Charting Methods |
126130
// -----------------+
131+
$(window).resize(function() {
132+
$('#chart_memory').highcharts().setSize($('#col11_setter').width(), 250);
133+
$('#chart_cpu').highcharts().setSize($('#col11_setter').width(), 250);
134+
});
127135
$('#chart_memory').highcharts({
128136
chart: {
129137
type: 'area',
130138
animation: Highcharts.svg,
131139
marginRight: 10,
140+
renderTo: 'container',
141+
width: $('#col11_setter').width()
132142
},
133143
colors: [
134144
'#113F8C',
@@ -196,6 +206,8 @@
196206
type: 'area',
197207
animation: Highcharts.svg,
198208
marginRight: 10,
209+
renderTo: 'container',
210+
width: $('#col11_setter').width()
199211
},
200212
colors: [
201213
'#113F8C',
@@ -365,6 +377,7 @@ function updatePlayerListVisibility(data) {
365377
$('#stats_players').hide();
366378
}
367379
}
380+
368381
@can('command', $server)
369382
// Send Command to Server
370383
$('#console_command').submit(function (event) {
@@ -442,8 +455,6 @@ function updateServerPowerControls (data) {
442455
}),
443456
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/power',
444457
timeout: 10000
445-
}).done(function(data) {
446-
$('#pw_resp').attr('class', 'alert alert-success').html('Server has been ' + action + 'ed successfully.').fadeIn().delay(5000).fadeOut();
447458
}).fail(function(jqXHR) {
448459
var error = 'An unknown error occured processing this request.';
449460
if (typeof jqXHR.responseJSON.error !== 'undefined') {

0 commit comments

Comments
 (0)