diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index efa0c7d6e..a991ebab7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,9 +1,6 @@ name: Tests on: - push: - branches: - - '**' pull_request: branches: - '**' diff --git a/app/Contracts/Repository/EggRepositoryInterface.php b/app/Contracts/Repository/EggRepositoryInterface.php index 1e3af6c5b..948440285 100644 --- a/app/Contracts/Repository/EggRepositoryInterface.php +++ b/app/Contracts/Repository/EggRepositoryInterface.php @@ -30,9 +30,4 @@ interface EggRepositoryInterface extends RepositoryInterface * @throws \App\Exceptions\Repository\RecordNotFoundException */ public function getWithExportAttributes(int $id): Egg; - - /** - * Confirm a copy script belongs to the same nest as the item trying to use it. - */ - public function isCopyableScript(int $copyFromId, int $service): bool; } diff --git a/app/Contracts/Repository/NestRepositoryInterface.php b/app/Contracts/Repository/NestRepositoryInterface.php deleted file mode 100644 index 97e7a22a9..000000000 --- a/app/Contracts/Repository/NestRepositoryInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -view->make('admin.eggs.index', [ + 'eggs' => Egg::all(), + ]); + } + /** * Handle a request to display the Egg creation page. * @@ -38,10 +48,10 @@ class EggController extends Controller */ public function create(): View { - $nests = $this->nestRepository->getWithEggs(); - \JavaScript::put(['nests' => $nests->keyBy('id')]); + $eggs = Egg::all(); + \JavaScript::put(['eggs' => $eggs->keyBy('id')]); - return $this->view->make('admin.eggs.new', ['nests' => $nests]); + return $this->view->make('admin.eggs.new', ['eggs' => $eggs]); } /** @@ -56,9 +66,9 @@ class EggController extends Controller $data['docker_images'] = $this->normalizeDockerImages($data['docker_images'] ?? null); $egg = $this->creationService->handle($data); - $this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash(); + $this->alert->success(trans('admin/eggs.notices.egg_created'))->flash(); - return redirect()->route('admin.nests.egg.view', $egg->id); + return redirect()->route('admin.eggs.view', $egg->id); } /** @@ -89,9 +99,9 @@ class EggController extends Controller $data['docker_images'] = $this->normalizeDockerImages($data['docker_images'] ?? null); $this->updateService->handle($egg, $data); - $this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash(); + $this->alert->success(trans('admin/eggs.notices.updated'))->flash(); - return redirect()->route('admin.nests.egg.view', $egg->id); + return redirect()->route('admin.eggs.view', $egg->id); } /** @@ -103,9 +113,9 @@ class EggController extends Controller public function destroy(Egg $egg): RedirectResponse { $this->deletionService->handle($egg->id); - $this->alert->success(trans('admin/nests.eggs.notices.deleted'))->flash(); + $this->alert->success(trans('admin/eggs.notices.deleted'))->flash(); - return redirect()->route('admin.nests.view', $egg->nest_id); + return redirect()->route('admin.eggs.view', $egg->id); } /** diff --git a/app/Http/Controllers/Admin/Nests/EggScriptController.php b/app/Http/Controllers/Admin/Eggs/EggScriptController.php similarity index 84% rename from app/Http/Controllers/Admin/Nests/EggScriptController.php rename to app/Http/Controllers/Admin/Eggs/EggScriptController.php index 68018f9d7..13bcd103d 100644 --- a/app/Http/Controllers/Admin/Nests/EggScriptController.php +++ b/app/Http/Controllers/Admin/Eggs/EggScriptController.php @@ -1,6 +1,6 @@ repository->getWithCopyAttributes($egg); $copy = $this->repository->findWhere([ ['copy_script_from', '=', null], - ['nest_id', '=', $egg->nest_id], ['id', '!=', $egg], ]); @@ -53,13 +52,12 @@ class EggScriptController extends Controller * * @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Repository\RecordNotFoundException - * @throws \App\Exceptions\Service\Egg\InvalidCopyFromException */ public function update(EggScriptFormRequest $request, Egg $egg): RedirectResponse { $this->installScriptService->handle($egg, $request->normalize()); - $this->alert->success(trans('admin/nests.eggs.notices.script_updated'))->flash(); + $this->alert->success(trans('admin/eggs.notices.script_updated'))->flash(); - return redirect()->route('admin.nests.egg.scripts', $egg); + return redirect()->route('admin.eggs.scripts', $egg); } } diff --git a/app/Http/Controllers/Admin/Nests/EggShareController.php b/app/Http/Controllers/Admin/Eggs/EggShareController.php similarity index 82% rename from app/Http/Controllers/Admin/Nests/EggShareController.php rename to app/Http/Controllers/Admin/Eggs/EggShareController.php index 9ba727e6c..bc9ce5bcb 100644 --- a/app/Http/Controllers/Admin/Nests/EggShareController.php +++ b/app/Http/Controllers/Admin/Eggs/EggShareController.php @@ -1,6 +1,6 @@ importerService->handle($request->file('import_file'), $request->input('import_to_nest')); - $this->alert->success(trans('admin/nests.eggs.notices.imported'))->flash(); + $egg = $this->importerService->handle($request->file('import_file')); + $this->alert->success(trans('admin/eggs.notices.imported'))->flash(); - return redirect()->route('admin.nests.egg.view', ['egg' => $egg->id]); + return redirect()->route('admin.eggs.view', ['egg' => $egg->id]); } /** @@ -67,8 +67,8 @@ class EggShareController extends Controller public function update(EggImportFormRequest $request, Egg $egg): RedirectResponse { $this->updateImporterService->handle($egg, $request->file('import_file')); - $this->alert->success(trans('admin/nests.eggs.notices.updated_via_import'))->flash(); + $this->alert->success(trans('admin/eggs.notices.updated_via_import'))->flash(); - return redirect()->route('admin.nests.egg.view', ['egg' => $egg]); + return redirect()->route('admin.eggs.view', ['egg' => $egg]); } } diff --git a/app/Http/Controllers/Admin/Nests/EggVariableController.php b/app/Http/Controllers/Admin/Eggs/EggVariableController.php similarity index 83% rename from app/Http/Controllers/Admin/Nests/EggVariableController.php rename to app/Http/Controllers/Admin/Eggs/EggVariableController.php index 2002985cd..aa72d2868 100644 --- a/app/Http/Controllers/Admin/Nests/EggVariableController.php +++ b/app/Http/Controllers/Admin/Eggs/EggVariableController.php @@ -1,6 +1,6 @@ creationService->handle($egg->id, $request->normalize()); - $this->alert->success(trans('admin/nests.variables.notices.variable_created'))->flash(); + $this->alert->success(trans('admin/eggs.variables.notices.variable_created'))->flash(); - return redirect()->route('admin.nests.egg.variables', $egg->id); + return redirect()->route('admin.eggs.variables', $egg->id); } /** @@ -68,11 +68,11 @@ class EggVariableController extends Controller public function update(EggVariableFormRequest $request, Egg $egg, EggVariable $variable): RedirectResponse { $this->updateService->handle($variable, $request->normalize()); - $this->alert->success(trans('admin/nests.variables.notices.variable_updated', [ + $this->alert->success(trans('admin/eggs.variables.notices.variable_updated', [ 'variable' => $variable->name, ]))->flash(); - return redirect()->route('admin.nests.egg.variables', $egg->id); + return redirect()->route('admin.eggs.variables', $egg->id); } /** @@ -81,10 +81,10 @@ class EggVariableController extends Controller public function destroy(int $egg, EggVariable $variable): RedirectResponse { $this->variableRepository->delete($variable->id); - $this->alert->success(trans('admin/nests.variables.notices.variable_deleted', [ + $this->alert->success(trans('admin/eggs.variables.notices.variable_deleted', [ 'variable' => $variable->name, ]))->flash(); - return redirect()->route('admin.nests.egg.variables', $egg); + return redirect()->route('admin.eggs.variables', $egg); } } diff --git a/app/Http/Controllers/Admin/MountController.php b/app/Http/Controllers/Admin/MountController.php index 386bedfae..305ef19c2 100644 --- a/app/Http/Controllers/Admin/MountController.php +++ b/app/Http/Controllers/Admin/MountController.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers\Admin; +use App\Models\Egg; use Ramsey\Uuid\Uuid; use Illuminate\View\View; use Illuminate\Http\Request; -use App\Models\Nest; use Illuminate\Http\Response; use App\Models\Mount; use App\Models\Location; @@ -15,7 +15,6 @@ use Illuminate\View\Factory as ViewFactory; use App\Http\Controllers\Controller; use App\Http\Requests\Admin\MountFormRequest; use App\Repositories\Eloquent\MountRepository; -use App\Contracts\Repository\NestRepositoryInterface; use App\Contracts\Repository\LocationRepositoryInterface; class MountController extends Controller @@ -25,7 +24,6 @@ class MountController extends Controller */ public function __construct( protected AlertsMessageBag $alert, - protected NestRepositoryInterface $nestRepository, protected LocationRepositoryInterface $locationRepository, protected MountRepository $repository, protected ViewFactory $view @@ -49,12 +47,12 @@ class MountController extends Controller */ public function view(string $id): View { - $nests = Nest::query()->with('eggs')->get(); + $eggs = Egg::all(); $locations = Location::query()->with('nodes')->get(); return $this->view->make('admin.mounts.view', [ 'mount' => $this->repository->getWithRelations($id), - 'nests' => $nests, + 'eggs' => $eggs, 'locations' => $locations, ]); } diff --git a/app/Http/Controllers/Admin/Nests/NestController.php b/app/Http/Controllers/Admin/Nests/NestController.php deleted file mode 100644 index 198c1b2fd..000000000 --- a/app/Http/Controllers/Admin/Nests/NestController.php +++ /dev/null @@ -1,102 +0,0 @@ -view->make('admin.nests.index', [ - 'nests' => $this->repository->getWithCounts(), - ]); - } - - /** - * Render nest creation page. - */ - public function create(): View - { - return $this->view->make('admin.nests.new'); - } - - /** - * Handle the storage of a new nest. - * - * @throws \App\Exceptions\Model\DataValidationException - */ - public function store(StoreNestFormRequest $request): RedirectResponse - { - $nest = $this->nestCreationService->handle($request->normalize()); - $this->alert->success(trans('admin/nests.notices.created', ['name' => $nest->name]))->flash(); - - return redirect()->route('admin.nests.view', $nest->id); - } - - /** - * Return details about a nest including all the eggs and servers per egg. - * - * @throws \App\Exceptions\Repository\RecordNotFoundException - */ - public function view(int $nest): View - { - return $this->view->make('admin.nests.view', [ - 'nest' => $this->repository->getWithEggServers($nest), - ]); - } - - /** - * Handle request to update a nest. - * - * @throws \App\Exceptions\Model\DataValidationException - * @throws \App\Exceptions\Repository\RecordNotFoundException - */ - public function update(StoreNestFormRequest $request, int $nest): RedirectResponse - { - $this->nestUpdateService->handle($nest, $request->normalize()); - $this->alert->success(trans('admin/nests.notices.updated'))->flash(); - - return redirect()->route('admin.nests.view', $nest); - } - - /** - * Handle request to delete a nest. - * - * @throws \App\Exceptions\Service\HasActiveServersException - */ - public function destroy(int $nest): RedirectResponse - { - $this->nestDeletionService->handle($nest); - $this->alert->success(trans('admin/nests.notices.deleted'))->flash(); - - return redirect()->route('admin.nests'); - } -} diff --git a/app/Http/Controllers/Admin/Servers/CreateServerController.php b/app/Http/Controllers/Admin/Servers/CreateServerController.php index e2946132c..1bd83f378 100644 --- a/app/Http/Controllers/Admin/Servers/CreateServerController.php +++ b/app/Http/Controllers/Admin/Servers/CreateServerController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Admin\Servers; +use App\Models\Egg; use Illuminate\View\View; use App\Models\Node; use App\Models\Location; @@ -9,7 +10,6 @@ use Illuminate\Http\RedirectResponse; use Prologue\Alerts\AlertsMessageBag; use Illuminate\View\Factory as ViewFactory; use App\Http\Controllers\Controller; -use App\Repositories\Eloquent\NestRepository; use App\Repositories\Eloquent\NodeRepository; use App\Http\Requests\Admin\ServerFormRequest; use App\Services\Servers\ServerCreationService; @@ -21,7 +21,6 @@ class CreateServerController extends Controller */ public function __construct( private AlertsMessageBag $alert, - private NestRepository $nestRepository, private NodeRepository $nodeRepository, private ServerCreationService $creationService, private ViewFactory $view @@ -42,20 +41,16 @@ class CreateServerController extends Controller return redirect()->route('admin.nodes'); } - $nests = $this->nestRepository->getWithEggs(); + $eggs = Egg::with('variables')->get(); \JavaScript::put([ 'nodeData' => $this->nodeRepository->getNodesForServerCreation(), - 'nests' => $nests->map(function ($item) { - return array_merge($item->toArray(), [ - 'eggs' => $item->eggs->keyBy('id')->toArray(), - ]); - })->keyBy('id'), + 'eggs' => $eggs->keyBy('id'), ]); return $this->view->make('admin.servers.new', [ 'locations' => Location::all(), - 'nests' => $nests, + 'eggs' => $eggs, ]); } diff --git a/app/Http/Controllers/Admin/Servers/ServerViewController.php b/app/Http/Controllers/Admin/Servers/ServerViewController.php index ddc834f15..887fa1220 100644 --- a/app/Http/Controllers/Admin/Servers/ServerViewController.php +++ b/app/Http/Controllers/Admin/Servers/ServerViewController.php @@ -2,15 +2,15 @@ namespace App\Http\Controllers\Admin\Servers; +use App\Models\Egg; +use App\Repositories\Eloquent\EggRepository; use Illuminate\View\View; use Illuminate\Http\Request; -use App\Models\Nest; use App\Models\Server; use App\Exceptions\DisplayException; use App\Http\Controllers\Controller; use App\Services\Servers\EnvironmentService; use Illuminate\Contracts\View\Factory as ViewFactory; -use App\Repositories\Eloquent\NestRepository; use App\Repositories\Eloquent\NodeRepository; use App\Repositories\Eloquent\MountRepository; use App\Repositories\Eloquent\ServerRepository; @@ -29,7 +29,7 @@ class ServerViewController extends Controller private DatabaseHostRepository $databaseHostRepository, private LocationRepository $locationRepository, private MountRepository $mountRepository, - private NestRepository $nestRepository, + private EggRepository $eggRepository, private NodeRepository $nodeRepository, private ServerRepository $repository, private EnvironmentService $environmentService, @@ -74,20 +74,16 @@ class ServerViewController extends Controller */ public function startup(Request $request, Server $server): View { - $nests = $this->nestRepository->getWithEggs(); $variables = $this->environmentService->handle($server); + $eggs = Egg::all()->keyBy('id'); $this->plainInject([ 'server' => $server, 'server_variables' => $variables, - 'nests' => $nests->map(function (Nest $item) { - return array_merge($item->toArray(), [ - 'eggs' => $item->eggs->keyBy('id')->toArray(), - ]); - })->keyBy('id'), + 'eggs' => $eggs, ]); - return $this->view->make('admin.servers.view.startup', compact('server', 'nests')); + return $this->view->make('admin.servers.view.startup', compact('server', 'eggs')); } /** diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 568a6953c..e48906839 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -24,7 +24,6 @@ use App\Services\Servers\BuildModificationService; use App\Services\Databases\DatabasePasswordService; use App\Services\Servers\DetailsModificationService; use App\Services\Servers\StartupModificationService; -use App\Contracts\Repository\NestRepositoryInterface; use App\Repositories\Eloquent\DatabaseHostRepository; use App\Services\Databases\DatabaseManagementService; use Illuminate\Contracts\Config\Repository as ConfigRepository; @@ -54,7 +53,6 @@ class ServersController extends Controller protected ReinstallServerService $reinstallService, protected ServerRepositoryInterface $repository, protected MountRepository $mountRepository, - protected NestRepositoryInterface $nestRepository, protected ServerConfigurationStructureService $serverConfigurationStructureService, protected StartupModificationService $startupModificationService, protected SuspensionService $suspensionService diff --git a/app/Http/Controllers/Api/Application/Eggs/EggController.php b/app/Http/Controllers/Api/Application/Eggs/EggController.php new file mode 100644 index 000000000..a1b3ca9d0 --- /dev/null +++ b/app/Http/Controllers/Api/Application/Eggs/EggController.php @@ -0,0 +1,32 @@ +fractal->collection(Egg::all()) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toArray(); + } + + /** + * Return a single egg that exists + */ + public function view(GetEggRequest $request, Egg $egg): array + { + return $this->fractal->item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toArray(); + } +} diff --git a/app/Http/Controllers/Api/Application/Nests/EggController.php b/app/Http/Controllers/Api/Application/Nests/EggController.php deleted file mode 100644 index ff0a85ccf..000000000 --- a/app/Http/Controllers/Api/Application/Nests/EggController.php +++ /dev/null @@ -1,33 +0,0 @@ -fractal->collection($nest->eggs) - ->transformWith($this->getTransformer(EggTransformer::class)) - ->toArray(); - } - - /** - * Return a single egg that exists on the specified nest. - */ - public function view(GetEggRequest $request, Nest $nest, Egg $egg): array - { - return $this->fractal->item($egg) - ->transformWith($this->getTransformer(EggTransformer::class)) - ->toArray(); - } -} diff --git a/app/Http/Controllers/Api/Application/Nests/NestController.php b/app/Http/Controllers/Api/Application/Nests/NestController.php deleted file mode 100644 index 14c1fea30..000000000 --- a/app/Http/Controllers/Api/Application/Nests/NestController.php +++ /dev/null @@ -1,42 +0,0 @@ -repository->paginated($request->query('per_page') ?? 50); - - return $this->fractal->collection($nests) - ->transformWith($this->getTransformer(NestTransformer::class)) - ->toArray(); - } - - /** - * Return information about a single Nest model. - */ - public function view(GetNestsRequest $request, Nest $nest): array - { - return $this->fractal->item($nest) - ->transformWith($this->getTransformer(NestTransformer::class)) - ->toArray(); - } -} diff --git a/app/Http/Controllers/Api/Client/Servers/StartupController.php b/app/Http/Controllers/Api/Client/Servers/StartupController.php index 53f1d8e75..740c88145 100644 --- a/app/Http/Controllers/Api/Client/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Client/Servers/StartupController.php @@ -54,7 +54,6 @@ class StartupController extends ClientApiController { /** @var \App\Models\EggVariable $variable */ $variable = $server->variables()->where('env_variable', $request->input('key'))->first(); - $original = $variable->server_value; if (is_null($variable) || !$variable->user_viewable) { throw new BadRequestHttpException('The environment variable you are trying to edit does not exist.'); @@ -62,6 +61,8 @@ class StartupController extends ClientApiController throw new BadRequestHttpException('The environment variable you are trying to edit is read-only.'); } + $original = $variable->server_value; + // Revalidate the variable value using the egg variable specific validation rules for it. $this->validate($request, ['value' => $variable->rules]); diff --git a/app/Http/Requests/Admin/Egg/EggFormRequest.php b/app/Http/Requests/Admin/Egg/EggFormRequest.php index 02c290c8a..09f6e014b 100644 --- a/app/Http/Requests/Admin/Egg/EggFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggFormRequest.php @@ -22,10 +22,6 @@ class EggFormRequest extends AdminFormRequest 'config_files' => 'required_without:config_from|nullable|json', ]; - if ($this->method() === 'POST') { - $rules['nest_id'] = 'required|numeric|exists:nests,id'; - } - return $rules; } diff --git a/app/Http/Requests/Admin/Egg/EggImportFormRequest.php b/app/Http/Requests/Admin/Egg/EggImportFormRequest.php index e45f9cf85..81b455a7b 100644 --- a/app/Http/Requests/Admin/Egg/EggImportFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggImportFormRequest.php @@ -8,14 +8,8 @@ class EggImportFormRequest extends AdminFormRequest { public function rules(): array { - $rules = [ + return [ 'import_file' => 'bail|required|file|max:1000|mimetypes:application/json,text/plain', ]; - - if ($this->method() !== 'PUT') { - $rules['import_to_nest'] = 'bail|required|integer|exists:nests,id'; - } - - return $rules; } } diff --git a/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php b/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php deleted file mode 100644 index 3fcc55a9c..000000000 --- a/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php +++ /dev/null @@ -1,16 +0,0 @@ - 'required|string|min:1|max:191', - 'description' => 'string|nullable', - ]; - } -} diff --git a/app/Http/Requests/Api/Application/Nests/Eggs/GetEggRequest.php b/app/Http/Requests/Api/Application/Eggs/GetEggRequest.php similarity index 82% rename from app/Http/Requests/Api/Application/Nests/Eggs/GetEggRequest.php rename to app/Http/Requests/Api/Application/Eggs/GetEggRequest.php index efcb21897..c5249b2ce 100644 --- a/app/Http/Requests/Api/Application/Nests/Eggs/GetEggRequest.php +++ b/app/Http/Requests/Api/Application/Eggs/GetEggRequest.php @@ -1,9 +1,9 @@ 'int', 'r_' . AdminAcl::RESOURCE_EGGS => 'int', 'r_' . AdminAcl::RESOURCE_LOCATIONS => 'int', - 'r_' . AdminAcl::RESOURCE_NESTS => 'int', + 'r_' . AdminAcl::RESOURCE_EGGS => 'int', 'r_' . AdminAcl::RESOURCE_NODES => 'int', 'r_' . AdminAcl::RESOURCE_SERVERS => 'int', ]; @@ -150,7 +148,7 @@ class ApiKey extends Model 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_LOCATIONS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_NESTS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', ]; diff --git a/app/Models/Egg.php b/app/Models/Egg.php index 9739faa36..5ce9a3fde 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * @property int $id * @property string $uuid - * @property int $nest_id * @property string $author * @property string $name * @property string|null $description @@ -40,7 +39,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; * @property string|null $inherit_config_stop * @property string $inherit_file_denylist * @property array|null $inherit_features - * @property \App\Models\Nest $nest * @property \Illuminate\Database\Eloquent\Collection|\App\Models\Server[] $servers * @property \Illuminate\Database\Eloquent\Collection|\App\Models\EggVariable[] $variables * @property \App\Models\Egg|null $scriptFrom @@ -103,7 +101,6 @@ class Egg extends Model * Cast values to correct type. */ protected $casts = [ - 'nest_id' => 'integer', 'config_from' => 'integer', 'script_is_privileged' => 'boolean', 'force_outgoing_ip' => 'boolean', @@ -114,7 +111,6 @@ class Egg extends Model ]; public static array $validationRules = [ - 'nest_id' => 'required|bail|numeric|exists:nests,id', 'uuid' => 'required|string|size:36', 'name' => 'required|string|max:191', 'description' => 'string|nullable', @@ -257,14 +253,6 @@ class Egg extends Model return $this->configFrom->file_denylist; } - /** - * Gets nest associated with an egg. - */ - public function nest(): BelongsTo - { - return $this->belongsTo(Nest::class); - } - /** * Gets all servers associated with this egg. */ diff --git a/app/Models/Nest.php b/app/Models/Nest.php deleted file mode 100644 index f331d544c..000000000 --- a/app/Models/Nest.php +++ /dev/null @@ -1,60 +0,0 @@ - 'required|string|email', - 'name' => 'required|string|max:191', - 'description' => 'nullable|string', - ]; - - /** - * Gets all eggs associated with this service. - */ - public function eggs(): HasMany - { - return $this->hasMany(Egg::class); - } - - /** - * Gets all servers associated with this nest. - */ - public function servers(): HasMany - { - return $this->hasMany(Server::class); - } -} diff --git a/app/Models/Server.php b/app/Models/Server.php index ef63394e8..7a1f07915 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -33,7 +33,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @property string|null $threads * @property bool $oom_disabled * @property int $allocation_id - * @property int $nest_id * @property int $egg_id * @property string $startup * @property string $image @@ -55,7 +54,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @property \App\Models\Egg|null $egg * @property \Illuminate\Database\Eloquent\Collection|\App\Models\Mount[] $mounts * @property int|null $mounts_count - * @property \App\Models\Nest $nest * @property \App\Models\Node $node * @property \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications * @property int|null $notifications_count @@ -87,7 +85,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @method static \Illuminate\Database\Eloquent\Builder|Server whereIo($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereMemory($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereName($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereNestId($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereNodeId($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereOomDisabled($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereOwnerId($value) @@ -159,7 +156,6 @@ class Server extends Model 'oom_disabled' => 'sometimes|boolean', 'disk' => 'required|numeric|min:0', 'allocation_id' => 'required|bail|unique:servers|exists:allocations,id', - 'nest_id' => 'required|exists:nests,id', 'egg_id' => 'required|exists:eggs,id', 'startup' => 'required|string', 'skip_scripts' => 'sometimes|boolean', @@ -183,7 +179,6 @@ class Server extends Model 'cpu' => 'integer', 'oom_disabled' => 'boolean', 'allocation_id' => 'integer', - 'nest_id' => 'integer', 'egg_id' => 'integer', 'database_limit' => 'integer', 'allocation_limit' => 'integer', @@ -246,14 +241,6 @@ class Server extends Model return $this->hasMany(Allocation::class, 'server_id'); } - /** - * Gets information for the nest associated with this server. - */ - public function nest(): BelongsTo - { - return $this->belongsTo(Nest::class); - } - /** * Gets information for the egg associated with this server. */ @@ -263,7 +250,7 @@ class Server extends Model } /** - * Gets information for the service variables associated with this server. + * Gets information for the egg variables associated with this server. */ public function variables(): HasMany { diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 8945d559d..c7bff4ea4 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -4,7 +4,6 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; use App\Repositories\Eloquent\EggRepository; -use App\Repositories\Eloquent\NestRepository; use App\Repositories\Eloquent\NodeRepository; use App\Repositories\Eloquent\TaskRepository; use App\Repositories\Eloquent\UserRepository; @@ -19,7 +18,6 @@ use App\Repositories\Eloquent\SettingsRepository; use App\Repositories\Eloquent\AllocationRepository; use App\Contracts\Repository\EggRepositoryInterface; use App\Repositories\Eloquent\EggVariableRepository; -use App\Contracts\Repository\NestRepositoryInterface; use App\Contracts\Repository\NodeRepositoryInterface; use App\Contracts\Repository\TaskRepositoryInterface; use App\Contracts\Repository\UserRepositoryInterface; @@ -53,7 +51,6 @@ class RepositoryServiceProvider extends ServiceProvider $this->app->bind(EggRepositoryInterface::class, EggRepository::class); $this->app->bind(EggVariableRepositoryInterface::class, EggVariableRepository::class); $this->app->bind(LocationRepositoryInterface::class, LocationRepository::class); - $this->app->bind(NestRepositoryInterface::class, NestRepository::class); $this->app->bind(NodeRepositoryInterface::class, NodeRepository::class); $this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class); $this->app->bind(ServerRepositoryInterface::class, ServerRepository::class); diff --git a/app/Repositories/Eloquent/EggRepository.php b/app/Repositories/Eloquent/EggRepository.php index 90d0bddd1..603162101 100644 --- a/app/Repositories/Eloquent/EggRepository.php +++ b/app/Repositories/Eloquent/EggRepository.php @@ -72,15 +72,4 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface throw new RecordNotFoundException(); } } - - /** - * Confirm a copy script belongs to the same nest as the item trying to use it. - */ - public function isCopyableScript(int $copyFromId, int $service): bool - { - return $this->getBuilder()->whereNull('copy_script_from') - ->where('id', '=', $copyFromId) - ->where('nest_id', '=', $service) - ->exists(); - } } diff --git a/app/Repositories/Eloquent/NestRepository.php b/app/Repositories/Eloquent/NestRepository.php deleted file mode 100644 index e83021211..000000000 --- a/app/Repositories/Eloquent/NestRepository.php +++ /dev/null @@ -1,77 +0,0 @@ -getBuilder()->with('eggs', 'eggs.variables'); - - if (!is_null($id)) { - $instance = $instance->find($id, $this->getColumns()); - if (!$instance) { - throw new RecordNotFoundException(); - } - - return $instance; - } - - return $instance->get($this->getColumns()); - } - - /** - * Return a nest or all nests and the count of eggs and servers for that nest. - * - * @throws \App\Exceptions\Repository\RecordNotFoundException - */ - public function getWithCounts(int $id = null): Collection|Nest - { - $instance = $this->getBuilder()->withCount(['eggs', 'servers']); - - if (!is_null($id)) { - $instance = $instance->find($id, $this->getColumns()); - if (!$instance) { - throw new RecordNotFoundException(); - } - - return $instance; - } - - return $instance->get($this->getColumns()); - } - - /** - * Return a nest along with its associated eggs and the servers relation on those eggs. - * - * @throws \App\Exceptions\Repository\RecordNotFoundException - */ - public function getWithEggServers(int $id): Nest - { - $instance = $this->getBuilder()->with('eggs.servers')->find($id, $this->getColumns()); - if (!$instance) { - throw new RecordNotFoundException(); - } - - /* @var Nest $instance */ - return $instance; - } -} diff --git a/app/Repositories/Eloquent/ServerRepository.php b/app/Repositories/Eloquent/ServerRepository.php index 4dcf4a6a7..091e7e2e6 100644 --- a/app/Repositories/Eloquent/ServerRepository.php +++ b/app/Repositories/Eloquent/ServerRepository.php @@ -146,7 +146,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt try { /** @var \App\Models\Server $model */ $model = $this->getBuilder() - ->with('nest', 'node') + ->with('egg', 'node') ->where(function (Builder $query) use ($uuid) { $query->where('uuidShort', $uuid)->orWhere('uuid', $uuid); }) @@ -172,7 +172,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator { return $this->getBuilder() - ->with(['user', 'nest', 'egg']) + ->with(['user', 'egg']) ->where('node_id', '=', $node) ->paginate($limit); } diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index f88598056..f8b7c880e 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -29,7 +29,6 @@ class AdminAcl public const RESOURCE_ALLOCATIONS = 'allocations'; public const RESOURCE_USERS = 'users'; public const RESOURCE_LOCATIONS = 'locations'; - public const RESOURCE_NESTS = 'nests'; public const RESOURCE_EGGS = 'eggs'; public const RESOURCE_DATABASE_HOSTS = 'database_hosts'; public const RESOURCE_SERVER_DATABASES = 'server_databases'; diff --git a/app/Services/Eggs/EggCreationService.php b/app/Services/Eggs/EggCreationService.php index 57e7857d7..b3d910de5 100644 --- a/app/Services/Eggs/EggCreationService.php +++ b/app/Services/Eggs/EggCreationService.php @@ -18,7 +18,7 @@ class EggCreationService } /** - * Create a new service option and assign it to the given service. + * Create a new egg. * * @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Service\Egg\NoParentConfigurationFoundException @@ -28,12 +28,11 @@ class EggCreationService $data['config_from'] = array_get($data, 'config_from'); if (!is_null($data['config_from'])) { $results = $this->repository->findCountWhere([ - ['nest_id', '=', array_get($data, 'nest_id')], ['id', '=', array_get($data, 'config_from')], ]); if ($results !== 1) { - throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child')); + throw new NoParentConfigurationFoundException(trans('exceptions.egg.invalid_copy_id')); } } diff --git a/app/Services/Eggs/EggDeletionService.php b/app/Services/Eggs/EggDeletionService.php index 6b8ca59cf..550b8a9d8 100644 --- a/app/Services/Eggs/EggDeletionService.php +++ b/app/Services/Eggs/EggDeletionService.php @@ -28,12 +28,12 @@ class EggDeletionService { $servers = $this->serverRepository->findCountWhere([['egg_id', '=', $egg]]); if ($servers > 0) { - throw new HasActiveServersException(trans('exceptions.nest.egg.delete_has_servers')); + throw new HasActiveServersException(trans('exceptions.egg.delete_has_servers')); } $children = $this->repository->findCountWhere([['config_from', '=', $egg]]); if ($children > 0) { - throw new HasChildrenException(trans('exceptions.nest.egg.has_children')); + throw new HasChildrenException(trans('exceptions.egg.has_children')); } return $this->repository->delete($egg); diff --git a/app/Services/Eggs/EggUpdateService.php b/app/Services/Eggs/EggUpdateService.php index 2f27484ce..83b056b3c 100644 --- a/app/Services/Eggs/EggUpdateService.php +++ b/app/Services/Eggs/EggUpdateService.php @@ -16,7 +16,7 @@ class EggUpdateService } /** - * Update a service option. + * Update an egg. * * @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Repository\RecordNotFoundException @@ -26,12 +26,11 @@ class EggUpdateService { if (!is_null(array_get($data, 'config_from'))) { $results = $this->repository->findCountWhere([ - ['nest_id', '=', $egg->nest_id], ['id', '=', array_get($data, 'config_from')], ]); if ($results !== 1) { - throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child')); + throw new NoParentConfigurationFoundException(trans('exceptions.egg.invalid_copy_id')); } } diff --git a/app/Services/Eggs/Scripts/InstallScriptService.php b/app/Services/Eggs/Scripts/InstallScriptService.php index 9e4e7dd40..593419c5c 100644 --- a/app/Services/Eggs/Scripts/InstallScriptService.php +++ b/app/Services/Eggs/Scripts/InstallScriptService.php @@ -4,7 +4,6 @@ namespace App\Services\Eggs\Scripts; use App\Models\Egg; use App\Contracts\Repository\EggRepositoryInterface; -use App\Exceptions\Service\Egg\InvalidCopyFromException; class InstallScriptService { @@ -20,16 +19,9 @@ class InstallScriptService * * @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Repository\RecordNotFoundException - * @throws \App\Exceptions\Service\Egg\InvalidCopyFromException */ public function handle(Egg $egg, array $data): void { - if (!is_null(array_get($data, 'copy_script_from'))) { - if (!$this->repository->isCopyableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) { - throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id')); - } - } - $this->repository->withoutFreshModel()->update($egg->id, [ 'script_install' => array_get($data, 'script_install'), 'script_is_privileged' => array_get($data, 'script_is_privileged', 1), diff --git a/app/Services/Eggs/Sharing/EggImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php index 9cf1feac9..0a949474f 100644 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -5,7 +5,6 @@ namespace App\Services\Eggs\Sharing; use Ramsey\Uuid\Uuid; use Illuminate\Support\Arr; use App\Models\Egg; -use App\Models\Nest; use Illuminate\Http\UploadedFile; use App\Models\EggVariable; use Illuminate\Database\ConnectionInterface; @@ -22,17 +21,13 @@ class EggImporterService * * @throws \App\Exceptions\Service\InvalidFileUploadException|\Throwable */ - public function handle(UploadedFile $file, int $nest): Egg + public function handle(UploadedFile $file): Egg { $parsed = $this->parser->handle($file); - /** @var \App\Models\Nest $nest */ - $nest = Nest::query()->with('eggs', 'eggs.variables')->findOrFail($nest); - - return $this->connection->transaction(function () use ($nest, $parsed) { + return $this->connection->transaction(function () use ($parsed) { $egg = (new Egg())->forceFill([ 'uuid' => Uuid::uuid4()->toString(), - 'nest_id' => $nest->id, 'author' => Arr::get($parsed, 'author'), 'copy_script_from' => null, ]); diff --git a/app/Services/Nests/NestCreationService.php b/app/Services/Nests/NestCreationService.php deleted file mode 100644 index 51a0d7d8f..000000000 --- a/app/Services/Nests/NestCreationService.php +++ /dev/null @@ -1,33 +0,0 @@ -repository->create([ - 'uuid' => Uuid::uuid4()->toString(), - 'author' => $author ?? $this->config->get('panel.service.author'), - 'name' => array_get($data, 'name'), - 'description' => array_get($data, 'description'), - ], true, true); - } -} diff --git a/app/Services/Nests/NestDeletionService.php b/app/Services/Nests/NestDeletionService.php deleted file mode 100644 index 2f62c7d33..000000000 --- a/app/Services/Nests/NestDeletionService.php +++ /dev/null @@ -1,34 +0,0 @@ -serverRepository->findCountWhere([['nest_id', '=', $nest]]); - if ($count > 0) { - throw new HasActiveServersException(trans('exceptions.nest.delete_has_servers')); - } - - return $this->repository->delete($nest); - } -} diff --git a/app/Services/Nests/NestUpdateService.php b/app/Services/Nests/NestUpdateService.php deleted file mode 100644 index c8b7b0ec3..000000000 --- a/app/Services/Nests/NestUpdateService.php +++ /dev/null @@ -1,30 +0,0 @@ -repository->withoutFreshModel()->update($nest, $data); - } -} diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index a37106998..0d3a3d7ce 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -4,7 +4,6 @@ namespace App\Services\Servers; use Ramsey\Uuid\Uuid; use Illuminate\Support\Arr; -use App\Models\Egg; use App\Models\User; use Webmozart\Assert\Assert; use App\Models\Server; @@ -67,12 +66,6 @@ class ServerCreationService $data['node_id'] = Allocation::query()->findOrFail($data['allocation_id'])->node_id; } - if (empty($data['nest_id'])) { - Assert::false(empty($data['egg_id']), 'Expected a non-empty egg_id in server creation data.'); - - $data['nest_id'] = Egg::query()->findOrFail($data['egg_id'])->nest_id; - } - $eggVariableData = $this->validatorService ->setUserLevel(User::USER_LEVEL_ADMIN) ->handle(Arr::get($data, 'egg_id'), Arr::get($data, 'environment', [])); @@ -155,7 +148,6 @@ class ServerCreationService 'threads' => Arr::get($data, 'threads'), 'oom_disabled' => Arr::get($data, 'oom_disabled') ?? true, 'allocation_id' => Arr::get($data, 'allocation_id'), - 'nest_id' => Arr::get($data, 'nest_id'), 'egg_id' => Arr::get($data, 'egg_id'), 'startup' => Arr::get($data, 'startup'), 'image' => Arr::get($data, 'image'), diff --git a/app/Services/Servers/StartupModificationService.php b/app/Services/Servers/StartupModificationService.php index b51af340e..25f14d39d 100644 --- a/app/Services/Servers/StartupModificationService.php +++ b/app/Services/Servers/StartupModificationService.php @@ -75,7 +75,6 @@ class StartupModificationService $server = $server->forceFill([ 'egg_id' => $egg->id, - 'nest_id' => $egg->nest_id, ]); } diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index aebe7ed9f..75f4a59b1 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -21,7 +21,7 @@ class VariableValidatorService } /** - * Validate all of the passed data against the given service option variables. + * Validate all of the passed data against the given egg variables. * * @throws \Illuminate\Validation\ValidationException */ diff --git a/app/Traits/Services/ValidatesValidationRules.php b/app/Traits/Services/ValidatesValidationRules.php index fd8d203b5..ccb393a6f 100644 --- a/app/Traits/Services/ValidatesValidationRules.php +++ b/app/Traits/Services/ValidatesValidationRules.php @@ -23,7 +23,7 @@ trait ValidatesValidationRules } catch (\BadMethodCallException $exception) { $matches = []; if (preg_match('/Method \[(.+)\] does not exist\./', $exception->getMessage(), $matches)) { - throw new BadValidationRuleException(trans('exceptions.nest.variables.bad_validation_rule', ['rule' => Str::snake(str_replace('validate', '', array_get($matches, 1, 'unknownRule')))]), $exception); + throw new BadValidationRuleException(trans('exceptions.variables.bad_validation_rule', ['rule' => Str::snake(str_replace('validate', '', array_get($matches, 1, 'unknownRule')))]), $exception); } throw $exception; diff --git a/app/Transformers/Api/Application/EggTransformer.php b/app/Transformers/Api/Application/EggTransformer.php index 3f4005333..d23090324 100644 --- a/app/Transformers/Api/Application/EggTransformer.php +++ b/app/Transformers/Api/Application/EggTransformer.php @@ -4,7 +4,6 @@ namespace App\Transformers\Api\Application; use Illuminate\Support\Arr; use App\Models\Egg; -use App\Models\Nest; use App\Models\Server; use League\Fractal\Resource\Item; use App\Models\EggVariable; @@ -18,7 +17,6 @@ class EggTransformer extends BaseTransformer * Relationships that can be loaded onto this transformation. */ protected array $availableIncludes = [ - 'nest', 'servers', 'config', 'script', @@ -42,15 +40,11 @@ class EggTransformer extends BaseTransformer public function transform(Egg $model): array { $files = json_decode($model->config_files, true, 512, JSON_THROW_ON_ERROR); - if (empty($files)) { - $files = new \stdClass(); - } return [ 'id' => $model->id, 'uuid' => $model->uuid, 'name' => $model->name, - 'nest' => $model->nest_id, 'author' => $model->author, 'description' => $model->description, // "docker_image" is deprecated, but left here to avoid breaking too many things at once @@ -79,22 +73,6 @@ class EggTransformer extends BaseTransformer ]; } - /** - * Include the Nest relationship for the given Egg in the transformation. - * - * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeNest(Egg $model): Item|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) { - return $this->null(); - } - - $model->loadMissing('nest'); - - return $this->item($model->getRelation('nest'), $this->makeTransformer(NestTransformer::class), Nest::RESOURCE_NAME); - } - /** * Include the Servers relationship for the given Egg in the transformation. * diff --git a/app/Transformers/Api/Application/NestTransformer.php b/app/Transformers/Api/Application/NestTransformer.php deleted file mode 100644 index 9f6ea2609..000000000 --- a/app/Transformers/Api/Application/NestTransformer.php +++ /dev/null @@ -1,74 +0,0 @@ -toArray(); - - $response[$model->getUpdatedAtColumn()] = $this->formatTimestamp($model->updated_at); - $response[$model->getCreatedAtColumn()] = $this->formatTimestamp($model->created_at); - - return $response; - } - - /** - * Include the Eggs relationship on the given Nest model transformation. - * - * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeEggs(Nest $model): Collection|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { - return $this->null(); - } - - $model->loadMissing('eggs'); - - return $this->collection($model->getRelation('eggs'), $this->makeTransformer(EggTransformer::class), Egg::RESOURCE_NAME); - } - - /** - * Include the servers relationship on the given Nest model. - * - * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeServers(Nest $model): Collection|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { - return $this->null(); - } - - $model->loadMissing('servers'); - - return $this->collection($model->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), Server::RESOURCE_NAME); - } -} diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index a787baa7d..3be5aaf1d 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -20,7 +20,6 @@ class ServerTransformer extends BaseTransformer 'allocations', 'user', 'subusers', - 'nest', 'egg', 'variables', 'location', @@ -77,7 +76,6 @@ class ServerTransformer extends BaseTransformer 'user' => $server->owner_id, 'node' => $server->node_id, 'allocation' => $server->allocation_id, - 'nest' => $server->nest_id, 'egg' => $server->egg_id, 'container' => [ 'startup_command' => $server->startup, @@ -139,22 +137,6 @@ class ServerTransformer extends BaseTransformer return $this->item($server->getRelation('user'), $this->makeTransformer(UserTransformer::class), 'user'); } - /** - * Return a generic array with nest information for this server. - * - * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeNest(Server $server): Item|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) { - return $this->null(); - } - - $server->loadMissing('nest'); - - return $this->item($server->getRelation('nest'), $this->makeTransformer(NestTransformer::class), 'nest'); - } - /** * Return a generic array with egg information for this server. * diff --git a/database/Factories/NestFactory.php b/database/Factories/NestFactory.php deleted file mode 100644 index 896b920ae..000000000 --- a/database/Factories/NestFactory.php +++ /dev/null @@ -1,30 +0,0 @@ - Uuid::uuid4()->toString(), - 'author' => 'testauthor@example.com', - 'name' => $this->faker->word, - 'description' => null, - ]; - } -} diff --git a/database/Seeders/DatabaseSeeder.php b/database/Seeders/DatabaseSeeder.php index ae534fe6a..3a67335f8 100644 --- a/database/Seeders/DatabaseSeeder.php +++ b/database/Seeders/DatabaseSeeder.php @@ -11,7 +11,6 @@ class DatabaseSeeder extends Seeder */ public function run() { - $this->call(NestSeeder::class); $this->call(EggSeeder::class); } } diff --git a/database/Seeders/EggSeeder.php b/database/Seeders/EggSeeder.php index 74323fc95..efdfc8f04 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -3,7 +3,6 @@ namespace Database\Seeders; use App\Models\Egg; -use App\Models\Nest; use Exception; use Illuminate\Database\Seeder; use Illuminate\Http\UploadedFile; @@ -19,7 +18,7 @@ class EggSeeder extends Seeder /** * @var string[] */ - public static array $import = [ + public static array $imports = [ 'Minecraft', 'Source Engine', 'Voice Servers', @@ -42,22 +41,20 @@ class EggSeeder extends Seeder */ public function run() { - foreach (static::$import as $nest) { + foreach (static::$imports as $import) { /* @noinspection PhpParamsInspection */ - $this->parseEggFiles( - Nest::query()->where('author', 'panel@example.com')->where('name', $nest)->firstOrFail() - ); + $this->parseEggFiles($import); } } /** * Loop through the list of egg files and import them. */ - protected function parseEggFiles(Nest $nest) + protected function parseEggFiles($name) { - $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($nest->name))); + $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name))); - $this->command->alert('Updating Eggs for Nest: ' . $nest->name); + $this->command->alert('Updating Eggs for: ' . $name); /** @var \DirectoryIterator $file */ foreach ($files as $file) { if (!$file->isFile() || !$file->isReadable()) { @@ -72,7 +69,7 @@ class EggSeeder extends Seeder $file = new UploadedFile($file->getPathname(), $file->getFilename(), 'application/json'); - $egg = $nest->eggs() + $egg = Egg::query() ->where('author', $decoded['author']) ->where('name', $decoded['name']) ->first(); @@ -81,7 +78,7 @@ class EggSeeder extends Seeder $this->updateImporterService->handle($egg, $file); $this->command->info('Updated ' . $decoded['name']); } else { - $this->importerService->handle($file, $nest->id); + $this->importerService->handle($file); $this->command->comment('Created ' . $decoded['name']); } } diff --git a/database/Seeders/NestSeeder.php b/database/Seeders/NestSeeder.php deleted file mode 100644 index ec88d8580..000000000 --- a/database/Seeders/NestSeeder.php +++ /dev/null @@ -1,108 +0,0 @@ -creationService = $creationService; - $this->repository = $repository; - } - - /** - * Run the seeder to add missing nests to the Panel. - * - * @throws \App\Exceptions\Model\DataValidationException - */ - public function run() - { - $items = $this->repository->findWhere([ - 'author' => 'panel@example.com', - ])->keyBy('name')->toArray(); - - $this->createMinecraftNest(array_get($items, 'Minecraft')); - $this->createSourceEngineNest(array_get($items, 'Source Engine')); - $this->createVoiceServersNest(array_get($items, 'Voice Servers')); - $this->createRustNest(array_get($items, 'Rust')); - } - - /** - * Create the Minecraft nest to be used later on. - * - * @throws \App\Exceptions\Model\DataValidationException - */ - private function createMinecraftNest(array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Minecraft', - 'description' => 'Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!', - ], 'panel@example.com'); - } - } - - /** - * Create the Source Engine Games nest to be used later on. - * - * @throws \App\Exceptions\Model\DataValidationException - */ - private function createSourceEngineNest(array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Source Engine', - 'description' => 'Includes support for most Source Dedicated Server games.', - ], 'panel@example.com'); - } - } - - /** - * Create the Voice Servers nest to be used later on. - * - * @throws \App\Exceptions\Model\DataValidationException - */ - private function createVoiceServersNest(array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Voice Servers', - 'description' => 'Voice servers such as Mumble and Teamspeak 3.', - ], 'panel@example.com'); - } - } - - /** - * Create the Rust nest to be used later on. - * - * @throws \App\Exceptions\Model\DataValidationException - */ - private function createRustNest(array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Rust', - 'description' => 'Rust - A game where you must fight to survive.', - ], 'panel@example.com'); - } - } -} diff --git a/database/migrations/2024_03_12_154408_remove_nests_table.php b/database/migrations/2024_03_12_154408_remove_nests_table.php new file mode 100644 index 000000000..b363de80d --- /dev/null +++ b/database/migrations/2024_03_12_154408_remove_nests_table.php @@ -0,0 +1,60 @@ +dropForeign('service_options_nest_id_foreign'); + $table->dropColumn('nest_id'); + }); + + Schema::table('servers', function (Blueprint $table) { + $table->dropForeign('servers_nest_id_foreign'); + $table->dropColumn('nest_id'); + }); + + Schema::drop('nests'); + + Schema::table('api_keys', function (Blueprint $table) { + $table->dropColumn('r_nests'); + }); + } + + public function down(): void + { + Schema::table('api_keys', function (Blueprint $table) { + $table->unsignedTinyInteger('r_nests')->default(0); + }); + + Schema::create('nests', function (Blueprint $table) { + $table->increments('id'); + $table->char('uuid', 36)->unique(); + $table->string('author'); + $table->string('name'); + $table->text('description')->nullable(); + $table->timestamps(); + }); + + Schema::table('eggs', function (Blueprint $table) { + $table->mediumInteger('nest_id')->unsigned(); + $table->foreign(['nest_id'], 'service_options_nest_id_foreign'); + }); + + Schema::table('servers', function (Blueprint $table) { + $table->mediumInteger('nest_id')->unsigned(); + $table->foreign(['nest_id'], 'servers_nest_id_foreign'); + }); + + if (class_exists('Database\Seeders\NestSeeder')) { + Artisan::call('db:seed', [ + '--class' => 'NestSeeder', + ]); + } + } +}; diff --git a/public/js/laroute.js b/public/js/laroute.js deleted file mode 100644 index 1c287eb71..000000000 --- a/public/js/laroute.js +++ /dev/null @@ -1,195 +0,0 @@ -(function () { - - var laroute = (function () { - - var routes = { - - absolute: false, - rootUrl: 'http://panel.test', - routes : [{"host":null,"methods":["GET","HEAD"],"uri":"_debugbar\/open","name":"debugbar.openhandler","action":"Barryvdh\Debugbar\Controllers\OpenHandlerController@handle"},{"host":null,"methods":["GET","HEAD"],"uri":"_debugbar\/clockwork\/{id}","name":"debugbar.clockwork","action":"Barryvdh\Debugbar\Controllers\OpenHandlerController@clockwork"},{"host":null,"methods":["GET","HEAD"],"uri":"_debugbar\/assets\/stylesheets","name":"debugbar.assets.css","action":"Barryvdh\Debugbar\Controllers\AssetController@css"},{"host":null,"methods":["GET","HEAD"],"uri":"_debugbar\/assets\/javascript","name":"debugbar.assets.js","action":"Barryvdh\Debugbar\Controllers\AssetController@js"},{"host":null,"methods":["DELETE"],"uri":"_debugbar\/cache\/{key}\/{tags?}","name":"debugbar.cache.delete","action":"Barryvdh\Debugbar\Controllers\CacheController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"\/","name":"index","action":"App\Http\Controllers\Base\IndexController@getIndex"},{"host":null,"methods":["GET","HEAD"],"uri":"status\/{server}","name":"index.status","action":"App\Http\Controllers\Base\IndexController@status"},{"host":null,"methods":["GET","HEAD"],"uri":"account","name":"account","action":"App\Http\Controllers\Base\AccountController@index"},{"host":null,"methods":["POST"],"uri":"account","name":null,"action":"App\Http\Controllers\Base\AccountController@update"},{"host":null,"methods":["GET","HEAD"],"uri":"account\/api","name":"account.api","action":"App\Http\Controllers\Base\ClientApiController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"account\/api\/new","name":"account.api.new","action":"App\Http\Controllers\Base\ClientApiController@create"},{"host":null,"methods":["POST"],"uri":"account\/api\/new","name":null,"action":"App\Http\Controllers\Base\ClientApiController@store"},{"host":null,"methods":["DELETE"],"uri":"account\/api\/revoke\/{identifier}","name":"account.api.revoke","action":"App\Http\Controllers\Base\ClientApiController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"account\/security","name":"account.security","action":"App\Http\Controllers\Base\SecurityController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"account\/security\/revoke\/{id}","name":"account.security.revoke","action":"App\Http\Controllers\Base\SecurityController@revoke"},{"host":null,"methods":["PUT"],"uri":"account\/security\/totp","name":"account.security.totp","action":"App\Http\Controllers\Base\SecurityController@generateTotp"},{"host":null,"methods":["POST"],"uri":"account\/security\/totp","name":"account.security.totp.set","action":"App\Http\Controllers\Base\SecurityController@setTotp"},{"host":null,"methods":["DELETE"],"uri":"account\/security\/totp","name":"account.security.totp.disable","action":"App\Http\Controllers\Base\SecurityController@disableTotp"},{"host":null,"methods":["GET","HEAD"],"uri":"admin","name":"admin.index","action":"App\Http\Controllers\Admin\BaseController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/statistics","name":"admin.statistics","action":"App\Http\Controllers\Admin\StatisticsController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/api","name":"admin.api.index","action":"App\Http\Controllers\Admin\ApiController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/api\/new","name":"admin.api.new","action":"App\Http\Controllers\Admin\ApiController@create"},{"host":null,"methods":["POST"],"uri":"admin\/api\/new","name":null,"action":"App\Http\Controllers\Admin\ApiController@store"},{"host":null,"methods":["DELETE"],"uri":"admin\/api\/revoke\/{identifier}","name":"admin.api.delete","action":"App\Http\Controllers\Admin\ApiController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/locations","name":"admin.locations","action":"App\Http\Controllers\Admin\LocationController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/locations\/view\/{location}","name":"admin.locations.view","action":"App\Http\Controllers\Admin\LocationController@view"},{"host":null,"methods":["POST"],"uri":"admin\/locations","name":null,"action":"App\Http\Controllers\Admin\LocationController@create"},{"host":null,"methods":["PATCH"],"uri":"admin\/locations\/view\/{location}","name":null,"action":"App\Http\Controllers\Admin\LocationController@update"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/databases","name":"admin.databases","action":"App\Http\Controllers\Admin\DatabaseController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/databases\/view\/{host}","name":"admin.databases.view","action":"App\Http\Controllers\Admin\DatabaseController@view"},{"host":null,"methods":["POST"],"uri":"admin\/databases","name":null,"action":"App\Http\Controllers\Admin\DatabaseController@create"},{"host":null,"methods":["PATCH"],"uri":"admin\/databases\/view\/{host}","name":null,"action":"App\Http\Controllers\Admin\DatabaseController@update"},{"host":null,"methods":["DELETE"],"uri":"admin\/databases\/view\/{host}","name":null,"action":"App\Http\Controllers\Admin\DatabaseController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/settings","name":"admin.settings","action":"App\Http\Controllers\Admin\Settings\IndexController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/settings\/mail","name":"admin.settings.mail","action":"App\Http\Controllers\Admin\Settings\MailController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/settings\/mail\/test","name":"admin.settings.mail.test","action":"App\Http\Controllers\Admin\Settings\MailController@test"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/settings\/advanced","name":"admin.settings.advanced","action":"App\Http\Controllers\Admin\Settings\AdvancedController@index"},{"host":null,"methods":["PATCH"],"uri":"admin\/settings","name":null,"action":"App\Http\Controllers\Admin\Settings\IndexController@update"},{"host":null,"methods":["PATCH"],"uri":"admin\/settings\/mail","name":null,"action":"App\Http\Controllers\Admin\Settings\MailController@update"},{"host":null,"methods":["PATCH"],"uri":"admin\/settings\/advanced","name":null,"action":"App\Http\Controllers\Admin\Settings\AdvancedController@update"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users","name":"admin.users","action":"App\Http\Controllers\Admin\UserController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users\/accounts.json","name":"admin.users.json","action":"App\Http\Controllers\Admin\UserController@json"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users\/new","name":"admin.users.new","action":"App\Http\Controllers\Admin\UserController@create"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users\/view\/{user}","name":"admin.users.view","action":"App\Http\Controllers\Admin\UserController@view"},{"host":null,"methods":["POST"],"uri":"admin\/users\/new","name":null,"action":"App\Http\Controllers\Admin\UserController@store"},{"host":null,"methods":["PATCH"],"uri":"admin\/users\/view\/{user}","name":null,"action":"App\Http\Controllers\Admin\UserController@update"},{"host":null,"methods":["DELETE"],"uri":"admin\/users\/view\/{user}","name":null,"action":"App\Http\Controllers\Admin\UserController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers","name":"admin.servers","action":"App\Http\Controllers\Admin\ServersController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/new","name":"admin.servers.new","action":"App\Http\Controllers\Admin\ServersController@create"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{server}","name":"admin.servers.view","action":"App\Http\Controllers\Admin\ServersController@viewIndex"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{server}\/details","name":"admin.servers.view.details","action":"App\Http\Controllers\Admin\ServersController@viewDetails"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{server}\/build","name":"admin.servers.view.build","action":"App\Http\Controllers\Admin\ServersController@viewBuild"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{server}\/startup","name":"admin.servers.view.startup","action":"App\Http\Controllers\Admin\ServersController@viewStartup"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{server}\/database","name":"admin.servers.view.database","action":"App\Http\Controllers\Admin\ServersController@viewDatabase"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{server}\/manage","name":"admin.servers.view.manage","action":"App\Http\Controllers\Admin\ServersController@viewManage"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{server}\/delete","name":"admin.servers.view.delete","action":"App\Http\Controllers\Admin\ServersController@viewDelete"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/new","name":null,"action":"App\Http\Controllers\Admin\ServersController@store"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/build","name":null,"action":"App\Http\Controllers\Admin\ServersController@updateBuild"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/startup","name":null,"action":"App\Http\Controllers\Admin\ServersController@saveStartup"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/database","name":null,"action":"App\Http\Controllers\Admin\ServersController@newDatabase"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/manage\/toggle","name":"admin.servers.view.manage.toggle","action":"App\Http\Controllers\Admin\ServersController@toggleInstall"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/manage\/rebuild","name":"admin.servers.view.manage.rebuild","action":"App\Http\Controllers\Admin\ServersController@rebuildContainer"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/manage\/suspension","name":"admin.servers.view.manage.suspension","action":"App\Http\Controllers\Admin\ServersController@manageSuspension"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/manage\/reinstall","name":"admin.servers.view.manage.reinstall","action":"App\Http\Controllers\Admin\ServersController@reinstallServer"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{server}\/delete","name":null,"action":"App\Http\Controllers\Admin\ServersController@delete"},{"host":null,"methods":["PATCH"],"uri":"admin\/servers\/view\/{server}\/details","name":null,"action":"App\Http\Controllers\Admin\ServersController@setDetails"},{"host":null,"methods":["PATCH"],"uri":"admin\/servers\/view\/{server}\/database","name":null,"action":"App\Http\Controllers\Admin\ServersController@resetDatabasePassword"},{"host":null,"methods":["DELETE"],"uri":"admin\/servers\/view\/{server}\/database\/{database}\/delete","name":"admin.servers.view.database.delete","action":"App\Http\Controllers\Admin\ServersController@deleteDatabase"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes","name":"admin.nodes","action":"App\Http\Controllers\Admin\NodesController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes\/new","name":"admin.nodes.new","action":"App\Http\Controllers\Admin\NodesController@create"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes\/view\/{node}","name":"admin.nodes.view","action":"App\Http\Controllers\Admin\NodesController@viewIndex"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes\/view\/{node}\/settings","name":"admin.nodes.view.settings","action":"App\Http\Controllers\Admin\NodesController@viewSettings"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes\/view\/{node}\/configuration","name":"admin.nodes.view.configuration","action":"App\Http\Controllers\Admin\NodesController@viewConfiguration"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes\/view\/{node}\/allocation","name":"admin.nodes.view.allocation","action":"App\Http\Controllers\Admin\NodesController@viewAllocation"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes\/view\/{node}\/servers","name":"admin.nodes.view.servers","action":"App\Http\Controllers\Admin\NodesController@viewServers"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nodes\/view\/{node}\/settings\/token","name":"admin.nodes.view.configuration.token","action":"App\Http\Controllers\Admin\NodesController@setToken"},{"host":null,"methods":["POST"],"uri":"admin\/nodes\/new","name":null,"action":"App\Http\Controllers\Admin\NodesController@store"},{"host":null,"methods":["POST"],"uri":"admin\/nodes\/view\/{node}\/allocation","name":null,"action":"App\Http\Controllers\Admin\NodesController@createAllocation"},{"host":null,"methods":["POST"],"uri":"admin\/nodes\/view\/{node}\/allocation\/remove","name":"admin.nodes.view.allocation.removeBlock","action":"App\Http\Controllers\Admin\NodesController@allocationRemoveBlock"},{"host":null,"methods":["POST"],"uri":"admin\/nodes\/view\/{node}\/allocation\/alias","name":"admin.nodes.view.allocation.setAlias","action":"App\Http\Controllers\Admin\NodesController@allocationSetAlias"},{"host":null,"methods":["PATCH"],"uri":"admin\/nodes\/view\/{node}\/settings","name":null,"action":"App\Http\Controllers\Admin\NodesController@updateSettings"},{"host":null,"methods":["DELETE"],"uri":"admin\/nodes\/view\/{node}\/delete","name":"admin.nodes.view.delete","action":"App\Http\Controllers\Admin\NodesController@delete"},{"host":null,"methods":["DELETE"],"uri":"admin\/nodes\/view\/{node}\/allocation\/remove\/{allocation}","name":"admin.nodes.view.allocation.removeSingle","action":"App\Http\Controllers\Admin\NodesController@allocationRemoveSingle"},{"host":null,"methods":["DELETE"],"uri":"admin\/nodes\/view\/{node}\/allocations","name":"admin.nodes.view.allocation.removeMultiple","action":"App\Http\Controllers\Admin\NodesController@allocationRemoveMultiple"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests","name":"admin.nests","action":"App\Http\Controllers\Admin\Nests\NestController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests\/new","name":"admin.nests.new","action":"App\Http\Controllers\Admin\Nests\NestController@create"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests\/view\/{nest}","name":"admin.nests.view","action":"App\Http\Controllers\Admin\Nests\NestController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests\/egg\/new","name":"admin.nests.egg.new","action":"App\Http\Controllers\Admin\Nests\EggController@create"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests\/egg\/{egg}","name":"admin.nests.egg.view","action":"App\Http\Controllers\Admin\Nests\EggController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests\/egg\/{egg}\/export","name":"admin.nests.egg.export","action":"App\Http\Controllers\Admin\Nests\EggShareController@export"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests\/egg\/{egg}\/variables","name":"admin.nests.egg.variables","action":"App\Http\Controllers\Admin\Nests\EggVariableController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/nests\/egg\/{egg}\/scripts","name":"admin.nests.egg.scripts","action":"App\Http\Controllers\Admin\Nests\EggScriptController@index"},{"host":null,"methods":["POST"],"uri":"admin\/nests\/new","name":null,"action":"App\Http\Controllers\Admin\Nests\NestController@store"},{"host":null,"methods":["POST"],"uri":"admin\/nests\/import","name":"admin.nests.egg.import","action":"App\Http\Controllers\Admin\Nests\EggShareController@import"},{"host":null,"methods":["POST"],"uri":"admin\/nests\/egg\/new","name":null,"action":"App\Http\Controllers\Admin\Nests\EggController@store"},{"host":null,"methods":["POST"],"uri":"admin\/nests\/egg\/{egg}\/variables","name":null,"action":"App\Http\Controllers\Admin\Nests\EggVariableController@store"},{"host":null,"methods":["PUT"],"uri":"admin\/nests\/egg\/{egg}","name":null,"action":"App\Http\Controllers\Admin\Nests\EggShareController@update"},{"host":null,"methods":["PATCH"],"uri":"admin\/nests\/view\/{nest}","name":null,"action":"App\Http\Controllers\Admin\Nests\NestController@update"},{"host":null,"methods":["PATCH"],"uri":"admin\/nests\/egg\/{egg}","name":null,"action":"App\Http\Controllers\Admin\Nests\EggController@update"},{"host":null,"methods":["PATCH"],"uri":"admin\/nests\/egg\/{egg}\/scripts","name":null,"action":"App\Http\Controllers\Admin\Nests\EggScriptController@update"},{"host":null,"methods":["PATCH"],"uri":"admin\/nests\/egg\/{egg}\/variables\/{variable}","name":"admin.nests.egg.variables.edit","action":"App\Http\Controllers\Admin\Nests\EggVariableController@update"},{"host":null,"methods":["DELETE"],"uri":"admin\/nests\/view\/{nest}","name":null,"action":"App\Http\Controllers\Admin\Nests\NestController@destroy"},{"host":null,"methods":["DELETE"],"uri":"admin\/nests\/egg\/{egg}","name":null,"action":"App\Http\Controllers\Admin\Nests\EggController@destroy"},{"host":null,"methods":["DELETE"],"uri":"admin\/nests\/egg\/{egg}\/variables\/{variable}","name":null,"action":"App\Http\Controllers\Admin\Nests\EggVariableController@destroy"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/packs","name":"admin.packs","action":"App\Http\Controllers\Admin\PackController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/packs\/new","name":"admin.packs.new","action":"App\Http\Controllers\Admin\PackController@create"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/packs\/new\/template","name":"admin.packs.new.template","action":"App\Http\Controllers\Admin\PackController@newTemplate"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/packs\/view\/{pack}","name":"admin.packs.view","action":"App\Http\Controllers\Admin\PackController@view"},{"host":null,"methods":["POST"],"uri":"admin\/packs\/new","name":null,"action":"App\Http\Controllers\Admin\PackController@store"},{"host":null,"methods":["POST"],"uri":"admin\/packs\/view\/{pack}\/export\/{files?}","name":"admin.packs.view.export","action":"App\Http\Controllers\Admin\PackController@export"},{"host":null,"methods":["PATCH"],"uri":"admin\/packs\/view\/{pack}","name":null,"action":"App\Http\Controllers\Admin\PackController@update"},{"host":null,"methods":["DELETE"],"uri":"admin\/packs\/view\/{pack}","name":null,"action":"App\Http\Controllers\Admin\PackController@destroy"},{"host":null,"methods":["GET","HEAD"],"uri":"auth\/login","name":"auth.login","action":"App\Http\Controllers\Auth\LoginController@showLoginForm"},{"host":null,"methods":["GET","HEAD"],"uri":"auth\/login\/totp","name":"auth.totp","action":"App\Http\Controllers\Auth\LoginController@totp"},{"host":null,"methods":["GET","HEAD"],"uri":"auth\/password","name":"auth.password","action":"App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm"},{"host":null,"methods":["GET","HEAD"],"uri":"auth\/password\/reset\/{token}","name":"auth.reset","action":"App\Http\Controllers\Auth\ResetPasswordController@showResetForm"},{"host":null,"methods":["POST"],"uri":"auth\/login","name":null,"action":"App\Http\Controllers\Auth\LoginController@login"},{"host":null,"methods":["POST"],"uri":"auth\/login\/totp","name":null,"action":"App\Http\Controllers\Auth\LoginController@loginUsingTotp"},{"host":null,"methods":["POST"],"uri":"auth\/password","name":null,"action":"App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail"},{"host":null,"methods":["POST"],"uri":"auth\/password\/reset","name":"auth.reset.post","action":"App\Http\Controllers\Auth\ResetPasswordController@reset"},{"host":null,"methods":["POST"],"uri":"auth\/password\/reset\/{token}","name":null,"action":"App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail"},{"host":null,"methods":["GET","HEAD"],"uri":"auth\/logout","name":"auth.logout","action":"App\Http\Controllers\Auth\LoginController@logout"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}","name":"server.index","action":"App\Http\Controllers\Server\ConsoleController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/console","name":"server.console","action":"App\Http\Controllers\Server\ConsoleController@console"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/settings\/allocation","name":"server.settings.allocation","action":"App\Http\Controllers\Server\Settings\AllocationController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/settings\/name","name":"server.settings.name","action":"App\Http\Controllers\Server\Settings\NameController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/settings\/sftp","name":"server.settings.sftp","action":"App\Http\Controllers\Server\Settings\SftpController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/settings\/startup","name":"server.settings.startup","action":"App\Http\Controllers\Server\Settings\StartupController@index"},{"host":null,"methods":["PATCH"],"uri":"server\/{server}\/settings\/allocation","name":null,"action":"App\Http\Controllers\Server\Settings\AllocationController@update"},{"host":null,"methods":["PATCH"],"uri":"server\/{server}\/settings\/name","name":null,"action":"App\Http\Controllers\Server\Settings\NameController@update"},{"host":null,"methods":["PATCH"],"uri":"server\/{server}\/settings\/startup","name":null,"action":"App\Http\Controllers\Server\Settings\StartupController@update"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/databases","name":"server.databases.index","action":"App\Http\Controllers\Server\DatabaseController@index"},{"host":null,"methods":["POST"],"uri":"server\/{server}\/databases\/new","name":"server.databases.new","action":"App\Http\Controllers\Server\DatabaseController@store"},{"host":null,"methods":["PATCH"],"uri":"server\/{server}\/databases\/password","name":"server.databases.password","action":"App\Http\Controllers\Server\DatabaseController@update"},{"host":null,"methods":["DELETE"],"uri":"server\/{server}\/databases\/delete\/{database}","name":"server.databases.delete","action":"App\Http\Controllers\Server\DatabaseController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/files","name":"server.files.index","action":"App\Http\Controllers\Server\Files\FileActionsController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/files\/add","name":"server.files.add","action":"App\Http\Controllers\Server\Files\FileActionsController@create"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/files\/edit\/{file}","name":"server.files.edit","action":"App\Http\Controllers\Server\Files\FileActionsController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/files\/download\/{file}","name":"server.files.edit","action":"App\Http\Controllers\Server\Files\DownloadController@index"},{"host":null,"methods":["POST"],"uri":"server\/{server}\/files\/directory-list","name":"server.files.directory-list","action":"App\Http\Controllers\Server\Files\RemoteRequestController@directory"},{"host":null,"methods":["POST"],"uri":"server\/{server}\/files\/save","name":"server.files.save","action":"App\Http\Controllers\Server\Files\RemoteRequestController@store"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/users","name":"server.subusers","action":"App\Http\Controllers\Server\SubuserController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/users\/new","name":"server.subusers.new","action":"App\Http\Controllers\Server\SubuserController@create"},{"host":null,"methods":["POST"],"uri":"server\/{server}\/users\/new","name":null,"action":"App\Http\Controllers\Server\SubuserController@store"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/users\/view\/{subuser}","name":"server.subusers.view","action":"App\Http\Controllers\Server\SubuserController@view"},{"host":null,"methods":["PATCH"],"uri":"server\/{server}\/users\/view\/{subuser}","name":null,"action":"App\Http\Controllers\Server\SubuserController@update"},{"host":null,"methods":["DELETE"],"uri":"server\/{server}\/users\/view\/{subuser}","name":null,"action":"App\Http\Controllers\Server\SubuserController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/schedules","name":"server.schedules","action":"App\Http\Controllers\Server\Tasks\TaskManagementController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/schedules\/new","name":"server.schedules.new","action":"App\Http\Controllers\Server\Tasks\TaskManagementController@create"},{"host":null,"methods":["POST"],"uri":"server\/{server}\/schedules\/new","name":null,"action":"App\Http\Controllers\Server\Tasks\TaskManagementController@store"},{"host":null,"methods":["GET","HEAD"],"uri":"server\/{server}\/schedules\/view\/{schedule}","name":"server.schedules.view","action":"App\Http\Controllers\Server\Tasks\TaskManagementController@view"},{"host":null,"methods":["PATCH"],"uri":"server\/{server}\/schedules\/view\/{schedule}","name":null,"action":"App\Http\Controllers\Server\Tasks\TaskManagementController@update"},{"host":null,"methods":["POST"],"uri":"server\/{server}\/schedules\/view\/{schedule}\/toggle","name":"server.schedules.toggle","action":"App\Http\Controllers\Server\Tasks\ActionController@toggle"},{"host":null,"methods":["POST"],"uri":"server\/{server}\/schedules\/view\/{schedule}\/trigger","name":"server.schedules.trigger","action":"App\Http\Controllers\Server\Tasks\ActionController@trigger"},{"host":null,"methods":["DELETE"],"uri":"server\/{server}\/schedules\/view\/{schedule}","name":null,"action":"App\Http\Controllers\Server\Tasks\TaskManagementController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/users","name":"api.application.users","action":"App\Http\Controllers\Api\Application\Users\UserController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/users\/{user}","name":"api.application.users.view","action":"App\Http\Controllers\Api\Application\Users\UserController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/users\/external\/{external_id}","name":"api.application.users.external","action":"App\Http\Controllers\Api\Application\Users\ExternalUserController@index"},{"host":null,"methods":["POST"],"uri":"api\/application\/users","name":null,"action":"App\Http\Controllers\Api\Application\Users\UserController@store"},{"host":null,"methods":["PATCH"],"uri":"api\/application\/users\/{user}","name":null,"action":"App\Http\Controllers\Api\Application\Users\UserController@update"},{"host":null,"methods":["DELETE"],"uri":"api\/application\/users\/{user}","name":null,"action":"App\Http\Controllers\Api\Application\Users\UserController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/nodes","name":"api.application.nodes","action":"App\Http\Controllers\Api\Application\Nodes\NodeController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/nodes\/{node}","name":"api.application.nodes.view","action":"App\Http\Controllers\Api\Application\Nodes\NodeController@view"},{"host":null,"methods":["POST"],"uri":"api\/application\/nodes","name":null,"action":"App\Http\Controllers\Api\Application\Nodes\NodeController@store"},{"host":null,"methods":["PATCH"],"uri":"api\/application\/nodes\/{node}","name":null,"action":"App\Http\Controllers\Api\Application\Nodes\NodeController@update"},{"host":null,"methods":["DELETE"],"uri":"api\/application\/nodes\/{node}","name":null,"action":"App\Http\Controllers\Api\Application\Nodes\NodeController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/nodes\/{node}\/allocations","name":"api.application.allocations","action":"App\Http\Controllers\Api\Application\Nodes\AllocationController@index"},{"host":null,"methods":["POST"],"uri":"api\/application\/nodes\/{node}\/allocations","name":null,"action":"App\Http\Controllers\Api\Application\Nodes\AllocationController@store"},{"host":null,"methods":["DELETE"],"uri":"api\/application\/nodes\/{node}\/allocations\/{allocation}","name":"api.application.allocations.view","action":"App\Http\Controllers\Api\Application\Nodes\AllocationController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/locations","name":"api.applications.locations","action":"App\Http\Controllers\Api\Application\Locations\LocationController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/locations\/{location}","name":"api.application.locations.view","action":"App\Http\Controllers\Api\Application\Locations\LocationController@view"},{"host":null,"methods":["POST"],"uri":"api\/application\/locations","name":null,"action":"App\Http\Controllers\Api\Application\Locations\LocationController@store"},{"host":null,"methods":["PATCH"],"uri":"api\/application\/locations\/{location}","name":null,"action":"App\Http\Controllers\Api\Application\Locations\LocationController@update"},{"host":null,"methods":["DELETE"],"uri":"api\/application\/locations\/{location}","name":null,"action":"App\Http\Controllers\Api\Application\Locations\LocationController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/servers","name":"api.application.servers","action":"App\Http\Controllers\Api\Application\Servers\ServerController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/servers\/{server}","name":"api.application.servers.view","action":"App\Http\Controllers\Api\Application\Servers\ServerController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/servers\/external\/{external_id}","name":"api.application.servers.external","action":"App\Http\Controllers\Api\Application\Servers\ExternalServerController@index"},{"host":null,"methods":["PATCH"],"uri":"api\/application\/servers\/{server}\/details","name":"api.application.servers.details","action":"App\Http\Controllers\Api\Application\Servers\ServerDetailsController@details"},{"host":null,"methods":["PATCH"],"uri":"api\/application\/servers\/{server}\/build","name":"api.application.servers.build","action":"App\Http\Controllers\Api\Application\Servers\ServerDetailsController@build"},{"host":null,"methods":["PATCH"],"uri":"api\/application\/servers\/{server}\/startup","name":"api.application.servers.startup","action":"App\Http\Controllers\Api\Application\Servers\StartupController@index"},{"host":null,"methods":["POST"],"uri":"api\/application\/servers","name":null,"action":"App\Http\Controllers\Api\Application\Servers\ServerController@store"},{"host":null,"methods":["POST"],"uri":"api\/application\/servers\/{server}\/suspend","name":"api.application.servers.suspend","action":"App\Http\Controllers\Api\Application\Servers\ServerManagementController@suspend"},{"host":null,"methods":["POST"],"uri":"api\/application\/servers\/{server}\/unsuspend","name":"api.application.servers.unsuspend","action":"App\Http\Controllers\Api\Application\Servers\ServerManagementController@unsuspend"},{"host":null,"methods":["POST"],"uri":"api\/application\/servers\/{server}\/reinstall","name":"api.application.servers.reinstall","action":"App\Http\Controllers\Api\Application\Servers\ServerManagementController@reinstall"},{"host":null,"methods":["POST"],"uri":"api\/application\/servers\/{server}\/rebuild","name":"api.application.servers.rebuild","action":"App\Http\Controllers\Api\Application\Servers\ServerManagementController@rebuild"},{"host":null,"methods":["DELETE"],"uri":"api\/application\/servers\/{server}","name":null,"action":"App\Http\Controllers\Api\Application\Servers\ServerController@delete"},{"host":null,"methods":["DELETE"],"uri":"api\/application\/servers\/{server}\/{force?}","name":null,"action":"App\Http\Controllers\Api\Application\Servers\ServerController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/servers\/{server}\/databases","name":"api.application.servers.databases","action":"App\Http\Controllers\Api\Application\Servers\DatabaseController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/servers\/{server}\/databases\/{database}","name":"api.application.servers.databases.view","action":"App\Http\Controllers\Api\Application\Servers\DatabaseController@view"},{"host":null,"methods":["POST"],"uri":"api\/application\/servers\/{server}\/databases","name":null,"action":"App\Http\Controllers\Api\Application\Servers\DatabaseController@store"},{"host":null,"methods":["POST"],"uri":"api\/application\/servers\/{server}\/databases\/{database}\/reset-password","name":null,"action":"App\Http\Controllers\Api\Application\Servers\DatabaseController@resetPassword"},{"host":null,"methods":["DELETE"],"uri":"api\/application\/servers\/{server}\/databases\/{database}","name":null,"action":"App\Http\Controllers\Api\Application\Servers\DatabaseController@delete"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/nests","name":"api.application.nests","action":"App\Http\Controllers\Api\Application\Nests\NestController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/nests\/{nest}","name":"api.application.nests.view","action":"App\Http\Controllers\Api\Application\Nests\NestController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/nests\/{nest}\/eggs","name":"api.application.nests.eggs","action":"App\Http\Controllers\Api\Application\Nests\EggController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/application\/nests\/{nest}\/eggs\/{egg}","name":"api.application.nests.eggs.view","action":"App\Http\Controllers\Api\Application\Nests\EggController@view"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/client","name":"api.client.index","action":"App\Http\Controllers\Api\Client\ClientController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/client\/servers\/{server}","name":"api.client.servers.view","action":"App\Http\Controllers\Api\Client\Servers\ServerController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/client\/servers\/{server}\/utilization","name":"api.client.servers.resources","action":"App\Http\Controllers\Api\Client\Servers\ResourceUtilizationController@index"},{"host":null,"methods":["POST"],"uri":"api\/client\/servers\/{server}\/command","name":"api.client.servers.command","action":"App\Http\Controllers\Api\Client\Servers\CommandController@index"},{"host":null,"methods":["POST"],"uri":"api\/client\/servers\/{server}\/power","name":"api.client.servers.power","action":"App\Http\Controllers\Api\Client\Servers\PowerController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/remote\/authenticate\/{token}","name":"api.remote.authenticate","action":"App\Http\Controllers\Api\Remote\ValidateKeyController@index"},{"host":null,"methods":["POST"],"uri":"api\/remote\/download-file","name":"api.remote.download_file","action":"App\Http\Controllers\Api\Remote\FileDownloadController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/remote\/eggs","name":"api.remote.eggs","action":"App\Http\Controllers\Api\Remote\EggRetrievalController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/remote\/eggs\/{uuid}","name":"api.remote.eggs.download","action":"App\Http\Controllers\Api\Remote\EggRetrievalController@download"},{"host":null,"methods":["GET","HEAD"],"uri":"api\/remote\/scripts\/{uuid}","name":"api.remote.scripts","action":"App\Http\Controllers\Api\Remote\EggInstallController@index"},{"host":null,"methods":["POST"],"uri":"api\/remote\/sftp","name":"api.remote.sftp","action":"App\Http\Controllers\Api\Remote\SftpController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"daemon\/packs\/pull\/{uuid}","name":"daemon.pack.pull","action":"App\Http\Controllers\Daemon\PackController@pull"},{"host":null,"methods":["GET","HEAD"],"uri":"daemon\/packs\/pull\/{uuid}\/hash","name":"daemon.pack.hash","action":"App\Http\Controllers\Daemon\PackController@hash"},{"host":null,"methods":["GET","HEAD"],"uri":"daemon\/configure\/{token}","name":"daemon.configuration","action":"App\Http\Controllers\Daemon\ActionController@configuration"},{"host":null,"methods":["POST"],"uri":"daemon\/install","name":"daemon.install","action":"App\Http\Controllers\Daemon\ActionController@markInstall"}], - prefix: '', - - route : function (name, parameters, route) { - route = route || this.getByName(name); - - if ( ! route ) { - return undefined; - } - - return this.toRoute(route, parameters); - }, - - url: function (url, parameters) { - parameters = parameters || []; - - var uri = url + '/' + parameters.join('/'); - - return this.getCorrectUrl(uri); - }, - - toRoute : function (route, parameters) { - var uri = this.replaceNamedParameters(route.uri, parameters); - var qs = this.getRouteQueryString(parameters); - - if (this.absolute && this.isOtherHost(route)){ - return "//" + route.host + "/" + uri + qs; - } - - return this.getCorrectUrl(uri + qs); - }, - - isOtherHost: function (route){ - return route.host && route.host != window.location.hostname; - }, - - replaceNamedParameters : function (uri, parameters) { - uri = uri.replace(/\{(.*?)\??\}/g, function(match, key) { - if (parameters.hasOwnProperty(key)) { - var value = parameters[key]; - delete parameters[key]; - return value; - } else { - return match; - } - }); - - // Strip out any optional parameters that were not given - uri = uri.replace(/\/\{.*?\?\}/g, ''); - - return uri; - }, - - getRouteQueryString : function (parameters) { - var qs = []; - for (var key in parameters) { - if (parameters.hasOwnProperty(key)) { - qs.push(key + '=' + parameters[key]); - } - } - - if (qs.length < 1) { - return ''; - } - - return '?' + qs.join('&'); - }, - - getByName : function (name) { - for (var key in this.routes) { - if (this.routes.hasOwnProperty(key) && this.routes[key].name === name) { - return this.routes[key]; - } - } - }, - - getByAction : function(action) { - for (var key in this.routes) { - if (this.routes.hasOwnProperty(key) && this.routes[key].action === action) { - return this.routes[key]; - } - } - }, - - getCorrectUrl: function (uri) { - var url = this.prefix + '/' + uri.replace(/^\/?/, ''); - - if ( ! this.absolute) { - return url; - } - - return this.rootUrl.replace('/\/?$/', '') + url; - } - }; - - var getLinkAttributes = function(attributes) { - if ( ! attributes) { - return ''; - } - - var attrs = []; - for (var key in attributes) { - if (attributes.hasOwnProperty(key)) { - attrs.push(key + '="' + attributes[key] + '"'); - } - } - - return attrs.join(' '); - }; - - var getHtmlLink = function (url, title, attributes) { - title = title || url; - attributes = getLinkAttributes(attributes); - - return '' + title + ''; - }; - - return { - // Generate a url for a given controller action. - // Router.action('HomeController@getIndex', [params = {}]) - action : function (name, parameters) { - parameters = parameters || {}; - - return routes.route(name, parameters, routes.getByAction(name)); - }, - - // Generate a url for a given named route. - // Router.route('routeName', [params = {}]) - route : function (route, parameters) { - parameters = parameters || {}; - - return routes.route(route, parameters); - }, - - // Generate a fully qualified URL to the given path. - // Router.route('url', [params = {}]) - url : function (route, parameters) { - parameters = parameters || {}; - - return routes.url(route, parameters); - }, - - // Generate a html link to the given url. - // Router.link_to('foo/bar', [title = url], [attributes = {}]) - link_to : function (url, title, attributes) { - url = this.url(url); - - return getHtmlLink(url, title, attributes); - }, - - // Generate a html link to the given route. - // Router.link_to_route('route.name', [title=url], [parameters = {}], [attributes = {}]) - link_to_route : function (route, title, parameters, attributes) { - var url = this.route(route, parameters); - - return getHtmlLink(url, title, attributes); - }, - - // Generate a html link to the given controller action. - // Router.link_to_action('HomeController@getIndex', [title=url], [parameters = {}], [attributes = {}]) - link_to_action : function(action, title, parameters, attributes) { - var url = this.action(action, parameters); - - return getHtmlLink(url, title, attributes); - } - - }; - - }).call(this); - - /** - * Expose the class either via AMD, CommonJS or the global object - */ - if (typeof define === 'function' && define.amd) { - define(function () { - return laroute; - }); - } - else if (typeof module === 'object' && module.exports){ - module.exports = laroute; - } - else { - window.Router = laroute; - } - -}).call(this); - diff --git a/public/themes/panel/js/admin/new-server.js b/public/themes/panel/js/admin/new-server.js index b812d7f15..b366419db 100644 --- a/public/themes/panel/js/admin/new-server.js +++ b/public/themes/panel/js/admin/new-server.js @@ -1,11 +1,7 @@ $(document).ready(function() { - $('#pNestId').select2({ - placeholder: 'Select a Nest', - }).change(); - $('#pEggId').select2({ - placeholder: 'Select a Nest Egg', - }); + placeholder: 'Select an Egg', + }).change(); $('#pPackId').select2({ placeholder: 'Select a Service Pack', @@ -48,20 +44,8 @@ $('#pNodeId').on('change', function () { }); }); -$('#pNestId').on('change', function (event) { - $('#pEggId').html('').select2({ - data: $.map(_.get(Panel.nests, $(this).val() + '.eggs', []), function (item) { - return { - id: item.id, - text: item.name, - }; - }), - }).change(); -}); - $('#pEggId').on('change', function (event) { - let parentChain = _.get(Panel.nests, $('#pNestId').val(), null); - let objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null); + let objectChain = _.get(Panel.eggs, $('#pEggId').val(), null); const images = _.get(objectChain, 'docker_images', {}) $('#pDefaultContainer').html(''); @@ -73,11 +57,7 @@ $('#pEggId').on('change', function (event) { $('#pDefaultContainer').append(opt); } - if (!_.get(objectChain, 'startup', false)) { - $('#pStartup').val(_.get(parentChain, 'startup', 'ERROR: Startup Not Defined!')); - } else { - $('#pStartup').val(_.get(objectChain, 'startup')); - } + $('#pStartup').val(_.get(objectChain, 'startup')); $('#pPackId').html('').select2({ data: [{ id: 0, text: 'No Service Pack' }].concat( @@ -110,7 +90,7 @@ $('#pEggId').on('change', function (event) { // If you receive a warning on this line, it should be fine to ignore. this function is // defined in "resources/views/admin/servers/new.blade.php" near the bottom of the file. - serviceVariablesUpdated($('#pEggId').val(), variableIds); + eggVariablesUpdated($('#pEggId').val(), variableIds); }); $('#pAllocation').on('change', function () { diff --git a/resources/lang/en/admin/eggs.php b/resources/lang/en/admin/eggs.php new file mode 100644 index 000000000..ffd9b08e1 --- /dev/null +++ b/resources/lang/en/admin/eggs.php @@ -0,0 +1,19 @@ + [ + 'imported' => 'Successfully imported this Egg and its associated variables.', + 'updated_via_import' => 'This Egg has been updated using the file provided.', + '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.', + 'egg_created' => 'A new egg was laid successfully. You will need to restart any running daemons to apply this new egg.', + ], + 'variables' => [ + 'notices' => [ + 'variable_deleted' => 'The variable ":variable" has been deleted and will no longer be available to servers once rebuilt.', + 'variable_updated' => 'The variable ":variable" has been updated. You will need to rebuild any servers using this variable in order to apply changes.', + 'variable_created' => 'New variable has successfully been created and assigned to this egg.', + ], + ], +]; diff --git a/resources/lang/en/admin/nests.php b/resources/lang/en/admin/nests.php deleted file mode 100644 index 2a6f37707..000000000 --- a/resources/lang/en/admin/nests.php +++ /dev/null @@ -1,26 +0,0 @@ - [ - 'created' => 'A new nest, :name, has been successfully created.', - 'deleted' => 'Successfully deleted the requested nest from the Panel.', - 'updated' => 'Successfully updated the nest configuration options.', - ], - 'eggs' => [ - 'notices' => [ - 'imported' => 'Successfully imported this Egg and its associated variables.', - 'updated_via_import' => 'This Egg has been updated using the file provided.', - '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.', - 'egg_created' => 'A new egg was laid successfully. You will need to restart any running daemons to apply this new egg.', - ], - ], - 'variables' => [ - 'notices' => [ - 'variable_deleted' => 'The variable ":variable" has been deleted and will no longer be available to servers once rebuilt.', - 'variable_updated' => 'The variable ":variable" has been updated. You will need to rebuild any servers using this variable in order to apply changes.', - 'variable_created' => 'New variable has successfully been created and assigned to this egg.', - ], - ], -]; diff --git a/resources/lang/en/admin/server.php b/resources/lang/en/admin/server.php index 29cb72d18..057bd3ca5 100644 --- a/resources/lang/en/admin/server.php +++ b/resources/lang/en/admin/server.php @@ -9,7 +9,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 nest or egg was changed a reinstall will be occurring now.', + 'startup_changed' => 'The startup configuration for this server has been updated. If this server\'s egg was changed a reinstall will be occurring 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/lang/en/exceptions.php b/resources/lang/en/exceptions.php index 4d44c4ff9..3977c87c2 100644 --- a/resources/lang/en/exceptions.php +++ b/resources/lang/en/exceptions.php @@ -13,24 +13,20 @@ return [ 'cidr_out_of_range' => 'CIDR notation only allows masks between /25 and /32.', 'port_out_of_range' => 'Ports in an allocation must be greater than 1024 and less than or equal to 65535.', ], - 'nest' => [ - 'delete_has_servers' => 'A Nest with active servers attached to it cannot be deleted from the Panel.', - 'egg' => [ - 'delete_has_servers' => 'An Egg with active servers attached to it cannot be deleted from the Panel.', - 'invalid_copy_id' => 'The Egg selected for copying a script from either does not exist, or is copying a script itself.', - 'must_be_child' => 'The "Copy Settings From" directive for this Egg must be a child option for the selected Nest.', - 'has_children' => 'This Egg is a parent to one or more other Eggs. Please delete those Eggs before deleting this Egg.', - ], - 'variables' => [ - 'env_not_unique' => 'The environment variable :name must be unique to this Egg.', - 'reserved_name' => 'The environment variable :name is protected and cannot be assigned to a variable.', - 'bad_validation_rule' => 'The validation rule ":rule" is not a valid rule for this application.', - ], - 'importer' => [ - 'json_error' => 'There was an error while attempting to parse the JSON file: :error.', - 'file_error' => 'The JSON file provided was not valid.', - 'invalid_json_provided' => 'The JSON file provided is not in a format that can be recognized.', - ], + 'egg' => [ + 'delete_has_servers' => 'An Egg with active servers attached to it cannot be deleted from the Panel.', + 'invalid_copy_id' => 'The Egg selected for copying a script from either does not exist, or is copying a script itself.', + 'has_children' => 'This Egg is a parent to one or more other Eggs. Please delete those Eggs before deleting this Egg.', + ], + 'variables' => [ + 'env_not_unique' => 'The environment variable :name must be unique to this Egg.', + 'reserved_name' => 'The environment variable :name is protected and cannot be assigned to a variable.', + 'bad_validation_rule' => 'The validation rule ":rule" is not a valid rule for this application.', + ], + 'importer' => [ + 'json_error' => 'There was an error while attempting to parse the JSON file: :error.', + 'file_error' => 'The JSON file provided was not valid.', + 'invalid_json_provided' => 'The JSON file provided is not in a format that can be recognized.', ], 'subusers' => [ 'editing_self' => 'Editing your own subuser account is not permitted.', diff --git a/resources/views/admin/nests/index.blade.php b/resources/views/admin/eggs/index.blade.php similarity index 50% rename from resources/views/admin/nests/index.blade.php rename to resources/views/admin/eggs/index.blade.php index ea5a28dc6..9bcd7cd33 100644 --- a/resources/views/admin/nests/index.blade.php +++ b/resources/views/admin/eggs/index.blade.php @@ -1,33 +1,33 @@ @extends('layouts.admin') @section('title') - Nests + Eggs @endsection @section('content-header') -
panel@example.com
— unless you are absolutely sure of what you are doing.
+ {{ $nest->id }}
{{ $egg->id }}
{{ $egg->servers->count() }}