From f6600f447fed65097ca5b6a59b6c9c39a4865095 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 17 Jan 2017 19:30:27 -0500 Subject: [PATCH] Add Startup Params view Translations might be the end of us. --- .../Controllers/Server/ServerController.php | 48 +++++++++ app/Http/Routes/ServerRoutes.php | 6 +- resources/lang/en/auth.php | 1 + resources/lang/en/server.php | 17 ++++ resources/lang/en/strings.php | 3 + .../pterodactyl/layouts/master.blade.php | 4 +- .../server/settings/sftp.blade.php | 24 ++--- .../server/settings/startup.blade.php | 98 +++++++++++++++++++ 8 files changed, 186 insertions(+), 15 deletions(-) create mode 100644 resources/themes/pterodactyl/server/settings/startup.blade.php diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index e37c4880b..485ef4c20 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -247,6 +247,54 @@ class ServerController extends Controller ]); } + public function getStartup(Request $request, $uuid) + { + $server = Models\Server::getByUUID($uuid); + $this->authorize('view-startup', $server); + $node = Models\Node::find($server->node); + $allocation = Models\Allocation::findOrFail($server->allocation); + + Javascript::put([ + 'server' => collect($server->makeVisible('daemonSecret'))->only(['uuid', 'uuidShort', 'daemonSecret', 'username']), + 'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'), + ]); + + $variables = Models\ServiceVariables::select( + 'service_variables.*', + DB::raw('COALESCE(server_variables.variable_value, service_variables.default_value) as a_serverValue') + )->leftJoin('server_variables', 'server_variables.variable_id', '=', 'service_variables.id') + ->where('service_variables.option_id', $server->option) + ->where('server_variables.server_id', $server->id) + ->get(); + + $service = Models\Service::select( + DB::raw('IFNULL(service_options.executable, services.executable) as executable') + )->leftJoin('service_options', 'service_options.parent_service', '=', 'services.id') + ->where('service_options.id', $server->option) + ->where('services.id', $server->service) + ->first(); + + $serverVariables = [ + '{{SERVER_MEMORY}}' => $server->memory, + '{{SERVER_IP}}' => $allocation->ip, + '{{SERVER_PORT}}' => $allocation->port, + ]; + + $processed = str_replace(array_keys($serverVariables), array_values($serverVariables), $server->startup); + foreach ($variables as &$variable) { + $replace = ($variable->user_viewable === 1) ? $variable->a_serverValue : '**'; + $processed = str_replace('{{' . $variable->env_variable . '}}', $replace, $processed); + } + + return view('server.settings.startup', [ + 'server' => $server, + 'node' => Models\Node::find($server->node), + 'variables' => $variables->where('user_viewable', 1), + 'service' => $service, + 'processedStartup' => $processed, + ]); + } + public function getDatabases(Request $request, $uuid) { $server = Models\Server::getByUUID($uuid); diff --git a/app/Http/Routes/ServerRoutes.php b/app/Http/Routes/ServerRoutes.php index f6fd01ae6..065487896 100644 --- a/app/Http/Routes/ServerRoutes.php +++ b/app/Http/Routes/ServerRoutes.php @@ -65,8 +65,12 @@ class ServerRoutes 'uses' => 'Server\ServerController@postSettingsSFTP', ]); - $router->post('/settings/startup', [ + $router->get('/settings/startup', [ 'as' => 'server.settings.startup', + 'uses' => 'Server\ServerController@getStartup', + ]); + + $router->post('/settings/startup', [ 'uses' => 'Server\ServerController@postSettingsStartup', ]); diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 31e935052..0d2e305a8 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -1,6 +1,7 @@ 'You are not authorized to perform this action.', 'auth_error' => 'There was an error while attempting to login.', 'authentication_required' => 'Authentication is required in order to continue.', 'remember_me' => 'Remember Me', diff --git a/resources/lang/en/server.php b/resources/lang/en/server.php index 34e188e75..8db854001 100644 --- a/resources/lang/en/server.php +++ b/resources/lang/en/server.php @@ -6,4 +6,21 @@ return [ 'header' => 'Server Console', 'header_sub' => 'Control your server in real time.', ], + 'config' => [ + 'startup' => [ + 'header' => 'Start Configuration', + 'header_sub' => 'Control server startup arguments.', + 'command' => 'Startup Command', + 'edit_params' => 'Edit Parameters', + 'update' => 'Update Startup Parameters', + ], + 'sftp' => [ + 'header' => 'SFTP Configuration', + 'header_sub' => 'Account details for SFTP connections.', + 'change_pass' => 'Change SFTP Password', + 'details' => 'SFTP Details', + 'conn_addr' => 'Connection Address', + 'warning' => 'Ensure that your client is set to use SFTP and not FTP or FTPS for connections, there is a difference between the protocols.', + ], + ] ]; diff --git a/resources/lang/en/strings.php b/resources/lang/en/strings.php index 6a97203dd..301e40e4f 100644 --- a/resources/lang/en/strings.php +++ b/resources/lang/en/strings.php @@ -36,4 +36,7 @@ return [ 'never' => 'never', 'sign_out' => 'Sign out', 'admin_control' => 'Admin Control', + 'required' => 'Required', + 'port' => 'Port', + 'username' => 'Username', ]; diff --git a/resources/themes/pterodactyl/layouts/master.blade.php b/resources/themes/pterodactyl/layouts/master.blade.php index 048cd6db6..0baab1477 100644 --- a/resources/themes/pterodactyl/layouts/master.blade.php +++ b/resources/themes/pterodactyl/layouts/master.blade.php @@ -167,7 +167,7 @@
  • @@ -181,7 +181,7 @@
  • diff --git a/resources/themes/pterodactyl/server/settings/sftp.blade.php b/resources/themes/pterodactyl/server/settings/sftp.blade.php index 7f85c152a..47b96fb27 100644 --- a/resources/themes/pterodactyl/server/settings/sftp.blade.php +++ b/resources/themes/pterodactyl/server/settings/sftp.blade.php @@ -20,16 +20,16 @@ @extends('layouts.master') @section('title') - SFTP Settings + @lang('server.config.sftp.header') @endsection @section('content-header') -

    SFTP ConfigurationAccount details for SFTP connections.

    +

    @lang('server.config.sftp.header')@lang('server.config.sftp.header_sub')

    @endsection @@ -38,7 +38,7 @@
    -

    Change SFTP Password

    +

    @lang('server.config.sftp.change_pass')

    @can('reset-sftp', $server)
    @@ -59,7 +59,7 @@ @else
    -

    You are not authorized to perform this action.

    +

    @lang('auth.not_authorized')

    @endcan @@ -68,25 +68,25 @@
    -

    SFTP Details

    +

    @lang('server.config.sftp.details')

    - +
    - +
    - +
    @@ -101,7 +101,7 @@ @endcan
    diff --git a/resources/themes/pterodactyl/server/settings/startup.blade.php b/resources/themes/pterodactyl/server/settings/startup.blade.php new file mode 100644 index 000000000..4d48e2470 --- /dev/null +++ b/resources/themes/pterodactyl/server/settings/startup.blade.php @@ -0,0 +1,98 @@ +{{-- Copyright (c) 2015 - 2016 Dane Everitt --}} + +{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}} +{{-- of this software and associated documentation files (the "Software"), to deal --}} +{{-- in the Software without restriction, including without limitation the rights --}} +{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}} +{{-- copies of the Software, and to permit persons to whom the Software is --}} +{{-- furnished to do so, subject to the following conditions: --}} + +{{-- The above copyright notice and this permission notice shall be included in all --}} +{{-- copies or substantial portions of the Software. --}} + +{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}} +{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}} +{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}} +{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}} +{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}} +{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}} +{{-- SOFTWARE. --}} +@extends('layouts.master') + +@section('title') + @lang('server.config.startup.header') +@endsection + +@section('content-header') +

    @lang('server.config.startup.header')@lang('server.config.startup.header_sub')

    + +@endsection + +@section('content') +
    +
    +
    +
    +

    @lang('server.config.startup.command')

    +
    +
    +
    + {{ $service->executable }} + +
    +
    +
    +
    +
    +
    +
    +

    @lang('server.config.startup.edit_params')

    +
    + @can('edit-startup', $server) + +
    + @foreach($variables as $item) +
    + +
    + user_editable === 1) + name="{{ $item->env_variable }}" + @else + readonly="readonly" + @endif + class="form-control" value="{{ old($item->env_variable, $item->a_serverValue) }}" data-action="matchRegex" data-regex="{{ $item->regex }}" /> +
    +

    {!! $item->description !!}

    +
    + @endforeach +
    + + + @else +
    +
    +

    @lang('auth.not_authorized')

    +
    +
    + @endcan +
    +
    +
    +@endsection + +@section('footer-scripts') + @parent + {!! Theme::js('js/frontend/server.socket.js') !!} +@endsection