From 0bb44a49722d4547d36caa6c672af322ca374b87 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 25 Nov 2017 12:27:08 -0600 Subject: [PATCH] Fix server startup dropdown for egg being incorrect, fixes #778 --- CHANGELOG.md | 1 + app/Http/Controllers/Admin/ServersController.php | 7 ++++--- resources/lang/en/admin/server.php | 2 +- .../pterodactyl/admin/servers/view/startup.blade.php | 12 ++++++------ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75e72ef5..29257893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ## v0.7.0-beta.3 (Derelict Dermodactylus) ### Fixed * `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attemping to setup environment settings in certain instances. +* `[beta.2]` — Fixes a bug causing the dropdown menu for a server's egg to display the wrong selected value. ## v0.7.0-beta.2 (Derelict Dermodactylus) ### Fixed diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 0bf3610f..1cd63a20 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -319,14 +319,14 @@ class ServersController extends Controller /** * Display startup configuration page for a server. * - * @param int $server + * @param \Pterodactyl\Models\Server $server * @return \Illuminate\View\View * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function viewStartup($server) + public function viewStartup(Server $server) { - $parameters = $this->repository->getVariablesWithValues($server, true); + $parameters = $this->repository->getVariablesWithValues($server->id, true); if (! $parameters->server->installed) { abort(404); } @@ -334,6 +334,7 @@ class ServersController extends Controller $nests = $this->nestRepository->getWithEggs(); Javascript::put([ + 'server' => $server, 'nests' => $nests->map(function ($item) { return array_merge($item->toArray(), [ 'eggs' => $item->eggs->keyBy('id')->toArray(), diff --git a/resources/lang/en/admin/server.php b/resources/lang/en/admin/server.php index e93459a9..e0ccdba7 100644 --- a/resources/lang/en/admin/server.php +++ b/resources/lang/en/admin/server.php @@ -16,7 +16,7 @@ return [ 'default_allocation_not_found' => 'The requested default allocation was not found in this server\'s allocations.', ], 'alerts' => [ - 'startup_changed' => 'The startup configuration for this server has been updated. If this server\'s service or option was changed a reinstall will be occuring now.', + 'startup_changed' => 'The startup configuration for this server has been updated. If this server\'s nest or egg was changed a reinstall will be occuring now.', 'server_deleted' => 'Server has successfully been deleted from the system.', 'server_created' => 'Server was successfully created on the panel. Please allow the daemon a few minutes to completely install this server.', 'build_updated' => 'The build details for this server have been updated. Some changes may require a restart to take effect.', diff --git a/resources/themes/pterodactyl/admin/servers/view/startup.blade.php b/resources/themes/pterodactyl/admin/servers/view/startup.blade.php index 15bee661..ab2ac46f 100644 --- a/resources/themes/pterodactyl/admin/servers/view/startup.blade.php +++ b/resources/themes/pterodactyl/admin/servers/view/startup.blade.php @@ -148,7 +148,7 @@ text: item.name, }; }), - }).change(); + }).val(Pterodactyl.server.egg_id).change(); }); $('#pEggId').on('change', function (event) { @@ -157,8 +157,8 @@ $('#setDefaultImage').html(_.get(objectChain, 'docker_image', 'undefined')); $('#pDockerImage').val(_.get(objectChain, 'docker_image', 'undefined')); - if (objectChain.id === parseInt('{{ $server->egg_id }}')) { - $('#pDockerImage').val('{{ $server->image }}'); + if (objectChain.id === parseInt(Pterodactyl.server.egg_id)) { + $('#pDockerImage').val(Pterodactyl.server.image); } if (!_.get(objectChain, 'startup', false)) { @@ -178,9 +178,9 @@ ), }); - @if(! is_null($server->pack_id)) - $('#pPackId').val({{ $server->pack_id }}); - @endif + if (Pterodactyl.server.pack_id !== null) { + $('#pPackId').val(Pterodactyl.server.pack_id); + } $('#appendVariablesTo').html(''); $.each(_.get(objectChain, 'variables', []), function (i, item) {