Skip to content

Commit f6600f4

Browse files
committed
Add Startup Params view
Translations might be the end of us.
1 parent ffa1e46 commit f6600f4

File tree

8 files changed

+186
-15
lines changed

8 files changed

+186
-15
lines changed

app/Http/Controllers/Server/ServerController.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,54 @@ public function getSettings(Request $request, $uuid)
247247
]);
248248
}
249249

250+
public function getStartup(Request $request, $uuid)
251+
{
252+
$server = Models\Server::getByUUID($uuid);
253+
$this->authorize('view-startup', $server);
254+
$node = Models\Node::find($server->node);
255+
$allocation = Models\Allocation::findOrFail($server->allocation);
256+
257+
Javascript::put([
258+
'server' => collect($server->makeVisible('daemonSecret'))->only(['uuid', 'uuidShort', 'daemonSecret', 'username']),
259+
'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'),
260+
]);
261+
262+
$variables = Models\ServiceVariables::select(
263+
'service_variables.*',
264+
DB::raw('COALESCE(server_variables.variable_value, service_variables.default_value) as a_serverValue')
265+
)->leftJoin('server_variables', 'server_variables.variable_id', '=', 'service_variables.id')
266+
->where('service_variables.option_id', $server->option)
267+
->where('server_variables.server_id', $server->id)
268+
->get();
269+
270+
$service = Models\Service::select(
271+
DB::raw('IFNULL(service_options.executable, services.executable) as executable')
272+
)->leftJoin('service_options', 'service_options.parent_service', '=', 'services.id')
273+
->where('service_options.id', $server->option)
274+
->where('services.id', $server->service)
275+
->first();
276+
277+
$serverVariables = [
278+
'{{SERVER_MEMORY}}' => $server->memory,
279+
'{{SERVER_IP}}' => $allocation->ip,
280+
'{{SERVER_PORT}}' => $allocation->port,
281+
];
282+
283+
$processed = str_replace(array_keys($serverVariables), array_values($serverVariables), $server->startup);
284+
foreach ($variables as &$variable) {
285+
$replace = ($variable->user_viewable === 1) ? $variable->a_serverValue : '**';
286+
$processed = str_replace('{{' . $variable->env_variable . '}}', $replace, $processed);
287+
}
288+
289+
return view('server.settings.startup', [
290+
'server' => $server,
291+
'node' => Models\Node::find($server->node),
292+
'variables' => $variables->where('user_viewable', 1),
293+
'service' => $service,
294+
'processedStartup' => $processed,
295+
]);
296+
}
297+
250298
public function getDatabases(Request $request, $uuid)
251299
{
252300
$server = Models\Server::getByUUID($uuid);

app/Http/Routes/ServerRoutes.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ public function map(Router $router)
6565
'uses' => 'Server\ServerController@postSettingsSFTP',
6666
]);
6767

68-
$router->post('/settings/startup', [
68+
$router->get('/settings/startup', [
6969
'as' => 'server.settings.startup',
70+
'uses' => 'Server\ServerController@getStartup',
71+
]);
72+
73+
$router->post('/settings/startup', [
7074
'uses' => 'Server\ServerController@postSettingsStartup',
7175
]);
7276

resources/lang/en/auth.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
return [
4+
'not_authorized' => 'You are not authorized to perform this action.',
45
'auth_error' => 'There was an error while attempting to login.',
56
'authentication_required' => 'Authentication is required in order to continue.',
67
'remember_me' => 'Remember Me',

resources/lang/en/server.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,21 @@
66
'header' => 'Server Console',
77
'header_sub' => 'Control your server in real time.',
88
],
9+
'config' => [
10+
'startup' => [
11+
'header' => 'Start Configuration',
12+
'header_sub' => 'Control server startup arguments.',
13+
'command' => 'Startup Command',
14+
'edit_params' => 'Edit Parameters',
15+
'update' => 'Update Startup Parameters',
16+
],
17+
'sftp' => [
18+
'header' => 'SFTP Configuration',
19+
'header_sub' => 'Account details for SFTP connections.',
20+
'change_pass' => 'Change SFTP Password',
21+
'details' => 'SFTP Details',
22+
'conn_addr' => 'Connection Address',
23+
'warning' => 'Ensure that your client is set to use SFTP and not FTP or FTPS for connections, there is a difference between the protocols.',
24+
],
25+
]
926
];

resources/lang/en/strings.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@
3636
'never' => 'never',
3737
'sign_out' => 'Sign out',
3838
'admin_control' => 'Admin Control',
39+
'required' => 'Required',
40+
'port' => 'Port',
41+
'username' => 'Username',
3942
];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
</a>
168168
</li>
169169
<li class="treeview
170-
@if(in_array(Route::currentRouteName(), ['server.settings.sftp', 'server.settings.databases']))
170+
@if(in_array(Route::currentRouteName(), ['server.settings.sftp', 'server.settings.databases', 'server.settings.startup', 'server.settings.allocations']))
171171
active
172172
@endif
173173
">
@@ -181,7 +181,7 @@
181181
<ul class="treeview-menu">
182182
<li><a href=""><i class="fa fa-angle-right"></i> {{ trans('navigation.server.port_allocations') }}</a></li>
183183
<li class="{{ Route::currentRouteName() !== 'server.settings.sftp' ?: 'active' }}"><a href="{{ route('server.settings.sftp', $server->uuidShort) }}"><i class="fa fa-angle-right"></i> {{ trans('navigation.server.sftp_settings') }}</a></li>
184-
<li><a href=""><i class="fa fa-angle-right"></i> {{ trans('navigation.server.startup_parameters') }}</a></li>
184+
<li class="{{ Route::currentRouteName() !== 'server.settings.startup' ?: 'active' }}"><a href="{{ route('server.settings.startup', $server->uuidShort) }}"><i class="fa fa-angle-right"></i> {{ trans('navigation.server.startup_parameters') }}</a></li>
185185
<li class="{{ Route::currentRouteName() !== 'server.settings.databases' ?: 'active' }}"><a href="{{ route('server.settings.databases', $server->uuidShort) }}"><i class="fa fa-angle-right"></i> {{ trans('navigation.server.databases') }}</a></li>
186186
</ul>
187187
</li>

resources/themes/pterodactyl/server/settings/sftp.blade.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
@extends('layouts.master')
2121

2222
@section('title')
23-
SFTP Settings
23+
@lang('server.config.sftp.header')
2424
@endsection
2525

2626
@section('content-header')
27-
<h1>SFTP Configuration<small>Account details for SFTP connections.</small></h1>
27+
<h1>@lang('server.config.sftp.header')<small>@lang('server.config.sftp.header_sub')</small></h1>
2828
<ol class="breadcrumb">
29-
<li><a href="{{ route('index') }}">{{ trans('strings.home') }}</a></li>
29+
<li><a href="{{ route('index') }}">@lang('strings.home')</a></li>
3030
<li><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></li>
31-
<li>{{ trans('strings.configuration') }}</li>
32-
<li class="active">{{ trans('strings.sftp') }}</li>
31+
<li>@lang('navigation.server.configuration')</li>
32+
<li class="active">@lang('navigation.server.sftp_settings')</li>
3333
</ol>
3434
@endsection
3535

@@ -38,7 +38,7 @@
3838
<div class="col-sm-6">
3939
<div class="box">
4040
<div class="box-header with-border">
41-
<h3 class="box-title">Change SFTP Password</h3>
41+
<h3 class="box-title">@lang('server.config.sftp.change_pass')</h3>
4242
</div>
4343
@can('reset-sftp', $server)
4444
<form action="{{ route('server.settings.sftp', $server->uuidShort) }}" method="post">
@@ -59,7 +59,7 @@
5959
@else
6060
<div class="box-body">
6161
<div class="callout callout-warning callout-nomargin">
62-
<p>You are not authorized to perform this action.</p>
62+
<p>@lang('auth.not_authorized')</p>
6363
</div>
6464
</div>
6565
@endcan
@@ -68,25 +68,25 @@
6868
<div class="col-sm-6">
6969
<div class="box">
7070
<div class="box-header with-border">
71-
<h3 class="box-title">SFTP Details</h3>
71+
<h3 class="box-title">@lang('server.config.sftp.details')</h3>
7272
</div>
7373
<div class="box-body">
7474
<div class="row">
7575
<div class="form-group col-md-8">
76-
<label for="new_email" class="control-label">Connection Address</label>
76+
<label for="new_email" class="control-label">@lang('server.config.sftp.conn_addr')</label>
7777
<div>
7878
<input type="text" class="form-control" readonly value="{{ $node->fqdn }}" />
7979
</div>
8080
</div>
8181
<div class="form-group col-md-4">
82-
<label for="new_email" class="control-label">Port</label>
82+
<label for="new_email" class="control-label">@lang('strings.port')</label>
8383
<div>
8484
<input type="text" class="form-control" readonly value="{{ $node->daemonSFTP }}" />
8585
</div>
8686
</div>
8787
</div>
8888
<div class="form-group">
89-
<label for="password" class="control-label">Username</label>
89+
<label for="password" class="control-label">@lang('strings.username')</label>
9090
<div>
9191
<input type="text" class="form-control" readonly value="{{ $server->username }}" />
9292
</div>
@@ -101,7 +101,7 @@
101101
@endcan
102102
</div>
103103
<div class="box-footer">
104-
<p class="small text-muted">Ensure that your client is set to use <strong>SFTP</strong> and not FTP or FTPS for connections, there is a difference between the protocols.</p>
104+
<p class="small text-muted">@lang('server.config.sftp.warning')</p>
105105
</div>
106106
</div>
107107
</div>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
@extends('layouts.master')
21+
22+
@section('title')
23+
@lang('server.config.startup.header')
24+
@endsection
25+
26+
@section('content-header')
27+
<h1>@lang('server.config.startup.header')<small>@lang('server.config.startup.header_sub')</small></h1>
28+
<ol class="breadcrumb">
29+
<li><a href="{{ route('index') }}">@lang('strings.home')</a></li>
30+
<li><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></li>
31+
<li>@lang('navigation.server.configuration')</li>
32+
<li class="active">@lang('navigation.server.startup_parameters')</li>
33+
</ol>
34+
@endsection
35+
36+
@section('content')
37+
<div class="row">
38+
<div class="col-md-6">
39+
<div class="box">
40+
<div class="box-header with-border">
41+
<h3 class="box-title">@lang('server.config.startup.command')</h3>
42+
</div>
43+
<div class="box-body">
44+
<div class="input-group">
45+
<span class="input-group-addon">{{ $service->executable }}</span>
46+
<input type="text" class="form-control" readonly="readonly" value="{{ $processedStartup }}" />
47+
</div>
48+
</div>
49+
</div>
50+
</div>
51+
<div class="col-md-6">
52+
<div class="box">
53+
<div class="box-header with-border">
54+
<h3 class="box-title">@lang('server.config.startup.edit_params')</h3>
55+
</div>
56+
@can('edit-startup', $server)
57+
<form action="{{ route('server.settings.startup', $server->uuidShort) }}" method="POST">
58+
<div class="box-body">
59+
@foreach($variables as $item)
60+
<div class="form-group">
61+
<label class="control-label">
62+
@if($item->required === 1)<span class="label label-danger">@lang('strings.required')</span> @endif
63+
{{ $item->name }}
64+
</label>
65+
<div>
66+
<input type="text"
67+
@if($item->user_editable === 1)
68+
name="{{ $item->env_variable }}"
69+
@else
70+
readonly="readonly"
71+
@endif
72+
class="form-control" value="{{ old($item->env_variable, $item->a_serverValue) }}" data-action="matchRegex" data-regex="{{ $item->regex }}" />
73+
</div>
74+
<p class="text-muted"><small>{!! $item->description !!}</small></p>
75+
</div>
76+
@endforeach
77+
</div>
78+
<div class="box-footer">
79+
{!! csrf_field() !!}
80+
<input type="submit" class="btn btn-primary btn-sm" value="@lang('server.config.startup.update')" />
81+
</div>
82+
</form>
83+
@else
84+
<div class="box-body">
85+
<div class="callout callout-warning callout-nomargin">
86+
<p>@lang('auth.not_authorized')</p>
87+
</div>
88+
</div>
89+
@endcan
90+
</div>
91+
</div>
92+
</div>
93+
@endsection
94+
95+
@section('footer-scripts')
96+
@parent
97+
{!! Theme::js('js/frontend/server.socket.js') !!}
98+
@endsection

0 commit comments

Comments
 (0)