diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index 485ef4c20..97d81d71f 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -71,7 +71,6 @@ class ServerController extends Controller return view('server.index', [ 'server' => $server, - 'allocations' => Models\Allocation::where('assigned_to', $server->id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(), 'node' => $node, ]); } @@ -196,54 +195,21 @@ class ServerController extends Controller return redirect($node->scheme . '://' . $node->fqdn . ':' . $node->daemonListen . '/server/file/download/' . $download->token); } - /** - * Renders server settings page. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Contracts\View\View - */ - public function getSettings(Request $request, $uuid) + public function getAllocation(Request $request, $uuid) { $server = Models\Server::getByUUID($uuid); - $allocation = Models\Allocation::findOrFail($server->allocation); + $this->authorize('view-allocation', $server); + $node = Models\Node::find($server->node); - $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(); + Javascript::put([ + 'server' => collect($server->makeVisible('daemonSecret'))->only(['uuid', 'uuidShort', 'daemonSecret', 'username']), + 'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'), + ]); - $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', [ + return view('server.settings.allocation', [ 'server' => $server, - 'databases' => Models\Database::select('databases.*', 'database_servers.host as a_host', 'database_servers.port as a_port') - ->where('server_id', $server->id) - ->join('database_servers', 'database_servers.id', '=', 'databases.db_server') - ->get(), - 'node' => Models\Node::find($server->node), - 'variables' => $variables->where('user_viewable', 1), - 'service' => $service, - 'processedStartup' => $processed, + 'allocations' => Models\Allocation::where('assigned_to', $server->id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(), + 'node' => $node, ]); } diff --git a/app/Http/Routes/ServerRoutes.php b/app/Http/Routes/ServerRoutes.php index 065487896..dd65110ac 100644 --- a/app/Http/Routes/ServerRoutes.php +++ b/app/Http/Routes/ServerRoutes.php @@ -74,6 +74,11 @@ class ServerRoutes 'uses' => 'Server\ServerController@postSettingsStartup', ]); + $router->get('/settings/allocation', [ + 'as' => 'server.settings.allocation', + 'uses' => 'Server\ServerController@getAllocation', + ]); + // File Manager Routes $router->get('/files', [ 'as' => 'server.files.index', diff --git a/app/Policies/ServerPolicy.php b/app/Policies/ServerPolicy.php index b5c29966c..6c1a864ee 100644 --- a/app/Policies/ServerPolicy.php +++ b/app/Policies/ServerPolicy.php @@ -498,6 +498,30 @@ class ServerPolicy return $this->checkPermission($user, $server, 'create-task'); } + /** + * Check if user has permission to view server allocations. + * + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server + * @return bool + */ + public function viewAllocation(User $user, Server $server) + { + return $this->checkPermission($user, $server, 'view-allocation'); + } + + /** + * Check if user has permission to set the default allocation. + * + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server + * @return bool + */ + public function setAllocation(User $user, Server $server) + { + return $this->checkPermission($user, $server, 'set-allocation'); + } + /** * Checks if the user has the given permission on/for the server. * diff --git a/public/themes/pterodactyl/css/pterodactyl.css b/public/themes/pterodactyl/css/pterodactyl.css index ae28049ce..2f1aeb11a 100644 --- a/public/themes/pterodactyl/css/pterodactyl.css +++ b/public/themes/pterodactyl/css/pterodactyl.css @@ -57,3 +57,7 @@ code { .table { font-size: 14px !important; } + +.middle { + vertical-align: middle !important; +} diff --git a/resources/lang/en/server.php b/resources/lang/en/server.php index 8aecda402..de1085940 100644 --- a/resources/lang/en/server.php +++ b/resources/lang/en/server.php @@ -31,5 +31,12 @@ return [ 'no_dbs' => 'There are no databases listed for this server.', 'add_db' => 'Add a new database.', ], + 'allocation' => [ + 'header' => 'Server Allocations', + 'header_sub' => 'Control the IPs and ports available on this server.', + 'available' => 'Available Allocations', + 'help' => 'Allocation Help', + 'help_text' => 'The list to the left includes all available IPs and ports that are open for your server to use for incoming connections.' + ], ], ]; diff --git a/resources/lang/en/strings.php b/resources/lang/en/strings.php index e6765463b..f3e4559e1 100644 --- a/resources/lang/en/strings.php +++ b/resources/lang/en/strings.php @@ -45,4 +45,8 @@ return [ 'create' => 'Create', 'select_all' => 'Select All', 'select_none' => 'Select None', + 'alias' => 'Alias', + 'primary' => 'Primary', + 'make_primary' => 'Make Primary', + 'none' => 'None', ]; diff --git a/resources/themes/pterodactyl/layouts/master.blade.php b/resources/themes/pterodactyl/layouts/master.blade.php index 220b823fe..95125aa66 100644 --- a/resources/themes/pterodactyl/layouts/master.blade.php +++ b/resources/themes/pterodactyl/layouts/master.blade.php @@ -167,7 +167,7 @@
  • @@ -179,7 +179,7 @@