diff --git a/app/Http/Controllers/API/Remote/EggRetrievalController.php b/app/Http/Controllers/API/Remote/EggRetrievalController.php index 28a60c5b4..6e45ae346 100644 --- a/app/Http/Controllers/API/Remote/EggRetrievalController.php +++ b/app/Http/Controllers/API/Remote/EggRetrievalController.php @@ -47,11 +47,11 @@ class EggRetrievalController extends Controller */ public function index(): JsonResponse { - $options = $this->repository->getAllWithCopyAttributes(); + $eggs = $this->repository->getAllWithCopyAttributes(); $response = []; - $options->each(function ($option) use (&$response) { - $response[$option->uuid] = sha1(json_encode($this->configurationFileService->handle($option))); + $eggs->each(function ($egg) use (&$response) { + $response[$egg->uuid] = sha1(json_encode($this->configurationFileService->handle($egg))); }); return response()->json($response); diff --git a/app/Http/Controllers/Admin/Nests/EggShareController.php b/app/Http/Controllers/Admin/Nests/EggShareController.php index a9808d6cf..8a4e9e76d 100644 --- a/app/Http/Controllers/Admin/Nests/EggShareController.php +++ b/app/Http/Controllers/Admin/Nests/EggShareController.php @@ -11,14 +11,20 @@ namespace Pterodactyl\Http\Controllers\Admin\Nests; use Pterodactyl\Models\Egg; use Illuminate\Http\RedirectResponse; +use Prologue\Alerts\AlertsMessageBag; use Pterodactyl\Http\Controllers\Controller; use Symfony\Component\HttpFoundation\Response; use Pterodactyl\Services\Eggs\Sharing\EggExporterService; use Pterodactyl\Services\Eggs\Sharing\EggImporterService; -use Pterodactyl\Http\Requests\Admin\Service\OptionImportFormRequest; +use Pterodactyl\Http\Requests\Admin\Egg\EggImportFormRequest; class EggShareController extends Controller { + /** + * @var \Prologue\Alerts\AlertsMessageBag + */ + protected $alert; + /** * @var \Pterodactyl\Services\Eggs\Sharing\EggExporterService */ @@ -32,13 +38,16 @@ class EggShareController extends Controller /** * OptionShareController constructor. * + * @param \Prologue\Alerts\AlertsMessageBag $alert * @param \Pterodactyl\Services\Eggs\Sharing\EggExporterService $exporterService * @param \Pterodactyl\Services\Eggs\Sharing\EggImporterService $importerService */ public function __construct( + AlertsMessageBag $alert, EggExporterService $exporterService, EggImporterService $importerService ) { + $this->alert = $alert; $this->exporterService = $exporterService; $this->importerService = $importerService; } @@ -62,16 +71,17 @@ class EggShareController extends Controller /** * Import a new service option using an XML file. * - * @param \Pterodactyl\Http\Requests\Admin\Service\OptionImportFormRequest $request + * @param \Pterodactyl\Http\Requests\Admin\Egg\EggImportFormRequest $request * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileUploadException */ - public function import(OptionImportFormRequest $request): RedirectResponse + public function import(EggImportFormRequest $request): RedirectResponse { $egg = $this->importerService->handle($request->file('import_file'), $request->input('import_to_nest')); + $this->alert->success(trans('admin/nests.eggs.notices.imported'))->flash(); return redirect()->route('admin.nests.egg.view', ['egg' => $egg->id]); } diff --git a/app/Http/Requests/Admin/Service/OptionImportFormRequest.php b/app/Http/Requests/Admin/Egg/EggImportFormRequest.php similarity index 71% rename from app/Http/Requests/Admin/Service/OptionImportFormRequest.php rename to app/Http/Requests/Admin/Egg/EggImportFormRequest.php index 5c464c658..776c291e2 100644 --- a/app/Http/Requests/Admin/Service/OptionImportFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggImportFormRequest.php @@ -7,11 +7,11 @@ * https://opensource.org/licenses/MIT */ -namespace Pterodactyl\Http\Requests\Admin\Service; +namespace Pterodactyl\Http\Requests\Admin\Egg; use Pterodactyl\Http\Requests\Admin\AdminFormRequest; -class OptionImportFormRequest extends AdminFormRequest +class EggImportFormRequest extends AdminFormRequest { /** * @return array @@ -20,7 +20,7 @@ class OptionImportFormRequest extends AdminFormRequest { return [ 'import_file' => 'bail|required|file|max:1000|mimetypes:application/json,text/plain', - 'import_to_service' => 'bail|required|integer|exists:services,id', + 'import_to_nest' => 'bail|required|integer|exists:nests,id', ]; } } diff --git a/app/Http/Requests/Admin/Service/ServiceFunctionsFormRequest.php b/app/Http/Requests/Admin/Service/ServiceFunctionsFormRequest.php deleted file mode 100644 index 249593507..000000000 --- a/app/Http/Requests/Admin/Service/ServiceFunctionsFormRequest.php +++ /dev/null @@ -1,25 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Http\Requests\Admin\Service; - -use Pterodactyl\Http\Requests\Admin\AdminFormRequest; - -class ServiceFunctionsFormRequest extends AdminFormRequest -{ - /** - * @return array - */ - public function rules() - { - return [ - 'index_file' => 'required|nullable|string', - ]; - } -} diff --git a/app/Models/Egg.php b/app/Models/Egg.php index 76696ac7b..1c1b9e815 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -65,8 +65,10 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ protected static $applicationRules = [ 'nest_id' => 'required', + 'uuid' => 'required', 'name' => 'required', 'description' => 'required', + 'author' => 'required', 'docker_image' => 'required', 'startup' => 'required', 'config_from' => 'sometimes', @@ -84,6 +86,7 @@ class Egg extends Model implements CleansAttributes, ValidableContract 'uuid' => 'string|size:36', 'name' => 'string|max:255', 'description' => 'string', + 'author' => 'string|email', 'docker_image' => 'string|max:255', 'startup' => 'nullable|string', 'config_from' => 'bail|nullable|numeric|exists:eggs,id', diff --git a/app/Models/Nest.php b/app/Models/Nest.php index 1be898c05..3631bc6e3 100644 --- a/app/Models/Nest.php +++ b/app/Models/Nest.php @@ -49,7 +49,7 @@ class Nest extends Model implements CleansAttributes, ValidableContract * @var array */ protected static $dataIntegrityRules = [ - 'author' => 'email', + 'author' => 'string|email', 'name' => 'string|max:255', 'description' => 'nullable|string', ]; diff --git a/app/Services/Eggs/EggConfigurationService.php b/app/Services/Eggs/EggConfigurationService.php index b308ca1e5..a73e3f6a8 100644 --- a/app/Services/Eggs/EggConfigurationService.php +++ b/app/Services/Eggs/EggConfigurationService.php @@ -32,22 +32,22 @@ class EggConfigurationService /** * Return an Egg file to be used by the Daemon. * - * @param int|\Pterodactyl\Models\Egg $option + * @param int|\Pterodactyl\Models\Egg $egg * @return array * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function handle($option): array + public function handle($egg): array { - if (! $option instanceof Egg) { - $option = $this->repository->getWithCopyAttributes($option); + if (! $egg instanceof Egg) { + $egg = $this->repository->getWithCopyAttributes($egg); } return [ - 'startup' => json_decode($option->inherit_config_startup), - 'stop' => $option->inherit_config_stop, - 'configs' => json_decode($option->inherit_config_files), - 'log' => json_decode($option->inherit_config_logs), + 'startup' => json_decode($egg->inherit_config_startup), + 'stop' => $egg->inherit_config_stop, + 'configs' => json_decode($egg->inherit_config_files), + 'log' => json_decode($egg->inherit_config_logs), 'query' => 'none', ]; } diff --git a/app/Services/Eggs/Sharing/EggExporterService.php b/app/Services/Eggs/Sharing/EggExporterService.php index 82d68fe36..25a7131fa 100644 --- a/app/Services/Eggs/Sharing/EggExporterService.php +++ b/app/Services/Eggs/Sharing/EggExporterService.php @@ -51,6 +51,7 @@ class EggExporterService 'author' => $egg->author, 'description' => $egg->description, 'image' => $egg->docker_image, + 'startup' => $egg->startup, 'config' => [ 'files' => $egg->inherit_config_files, 'startup' => $egg->inherit_config_startup, diff --git a/app/Services/Eggs/Sharing/EggImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php index d42c51ccf..3155eefe8 100644 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -89,6 +89,7 @@ class EggImporterService $egg = $this->repository->create([ 'uuid' => Uuid::uuid4()->toString(), 'nest_id' => $nest->id, + 'author' => object_get($parsed, 'author'), 'name' => object_get($parsed, 'name'), 'description' => object_get($parsed, 'description'), 'docker_image' => object_get($parsed, 'image'), diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 78fee994a..b92191711 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -72,7 +72,7 @@ class ServerConfigurationStructureService ], 'keys' => [], 'service' => [ - 'option' => $server->option->uuid, + 'egg' => $server->egg->uuid, 'pack' => object_get($server, 'pack.uuid'), 'skip_scripts' => $server->skip_scripts, ], diff --git a/resources/lang/en/admin/nests.php b/resources/lang/en/admin/nests.php index 6ddb44fac..b78af4903 100644 --- a/resources/lang/en/admin/nests.php +++ b/resources/lang/en/admin/nests.php @@ -15,6 +15,7 @@ return [ ], 'eggs' => [ 'notices' => [ + 'imported' => 'Successfully imported this Egg and its associated variables.', 'deleted' => 'Successfully deleted the requested egg from the Panel.', 'updated' => 'Egg configuration has been updated successfully.', 'script_updated' => 'Egg install script has been updated and will run whenever servers are installed.', diff --git a/resources/themes/pterodactyl/admin/eggs/view.blade.php b/resources/themes/pterodactyl/admin/eggs/view.blade.php index dc99434eb..215273005 100644 --- a/resources/themes/pterodactyl/admin/eggs/view.blade.php +++ b/resources/themes/pterodactyl/admin/eggs/view.blade.php @@ -52,20 +52,30 @@

A simple, human-readable name to use as an identifier for this Egg.

- - -

A description of this Egg that will be displayed throughout the Panel as needed.

+ + +

This is the globally unique identifier for this Egg which the Daemon uses as an identifier.

+
+
+ + +

The author of this version of the Egg. Uploading a new Egg configuration from a different author will change this.

- -

The default docker image that should be used for new servers using this Egg. This can be changed per-server as needed.

+
+
+
+ + +

A description of this Egg that will be displayed throughout the Panel as needed.

+
- +

The default statup command that should be used for new servers using this Egg.

@@ -141,7 +151,7 @@ @endsection diff --git a/resources/themes/pterodactyl/admin/nests/view.blade.php b/resources/themes/pterodactyl/admin/nests/view.blade.php index 32e229579..2f30932fa 100644 --- a/resources/themes/pterodactyl/admin/nests/view.blade.php +++ b/resources/themes/pterodactyl/admin/nests/view.blade.php @@ -83,7 +83,7 @@ @foreach($nest->eggs as $egg) - {{ $egg->name }} + {{ $egg->name }} {!! $egg->description !!} {{ $egg->servers->count() }} @@ -105,7 +105,7 @@ @parent