mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-26 02:52:30 +01:00
Nest & Egg management working through the ACP now.
This commit is contained in:
parent
df87ea0867
commit
6b8464ea3a
@ -7,7 +7,7 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\ServiceOption;
|
||||
namespace Pterodactyl\Exceptions\Service\Egg;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
@ -7,10 +7,10 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\ServiceVariable;
|
||||
namespace Pterodactyl\Exceptions\Service\Egg;
|
||||
|
||||
use Exception;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
class ReservedVariableNameException extends Exception
|
||||
class InvalidCopyFromException extends DisplayException
|
||||
{
|
||||
}
|
@ -7,8 +7,10 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\ServiceOption;
|
||||
namespace Pterodactyl\Exceptions\Service\Egg;
|
||||
|
||||
class NoParentConfigurationFoundException extends \Exception
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
class NoParentConfigurationFoundException extends DisplayException
|
||||
{
|
||||
}
|
@ -7,8 +7,10 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\ServiceOption;
|
||||
namespace Pterodactyl\Exceptions\Service\Egg\Variable;
|
||||
|
||||
class InvalidCopyFromException extends \Exception
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
class ReservedVariableNameException extends DisplayException
|
||||
{
|
||||
}
|
@ -12,12 +12,12 @@ namespace Pterodactyl\Http\Controllers\API\Remote;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Services\Services\Options\OptionConfigurationFileService;
|
||||
use Pterodactyl\Services\Services\Options\EggConfigurationService;
|
||||
|
||||
class OptionRetrievalController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\OptionConfigurationFileService
|
||||
* @var \Pterodactyl\Services\Services\Options\EggConfigurationService
|
||||
*/
|
||||
protected $configurationFileService;
|
||||
|
||||
@ -29,12 +29,12 @@ class OptionRetrievalController extends Controller
|
||||
/**
|
||||
* OptionUpdateController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Services\Services\Options\OptionConfigurationFileService $configurationFileService
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Services\Services\Options\EggConfigurationService $configurationFileService
|
||||
*/
|
||||
public function __construct(
|
||||
EggRepositoryInterface $repository,
|
||||
OptionConfigurationFileService $configurationFileService
|
||||
EggConfigurationService $configurationFileService
|
||||
) {
|
||||
$this->configurationFileService = $configurationFileService;
|
||||
$this->repository = $repository;
|
||||
|
@ -9,24 +9,120 @@
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
use Javascript;
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Eggs\EggUpdateService;
|
||||
use Pterodactyl\Services\Eggs\EggCreationService;
|
||||
use Pterodactyl\Services\Eggs\EggDeletionService;
|
||||
use Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
|
||||
class EggController extends Controller
|
||||
{
|
||||
protected $alert;
|
||||
protected $creationService;
|
||||
protected $deletionService;
|
||||
protected $nestRepository;
|
||||
protected $repository;
|
||||
protected $updateService;
|
||||
|
||||
public function __construct(EggRepositoryInterface $repository)
|
||||
{
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
EggCreationService $creationService,
|
||||
EggDeletionService $deletionService,
|
||||
EggRepositoryInterface $repository,
|
||||
EggUpdateService $updateService,
|
||||
NestRepositoryInterface $nestRepository
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->nestRepository = $nestRepository;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a request to display the Egg creation page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
$nests = $this->nestRepository->getWithEggs();
|
||||
Javascript::put(['nests' => $nests->keyBy('id')]);
|
||||
|
||||
return view('admin.eggs.new', ['nests' => $nests]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request to store a new Egg.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
|
||||
*/
|
||||
public function store(EggFormRequest $request): RedirectResponse
|
||||
{
|
||||
$egg = $this->creationService->handle($request->normalize());
|
||||
$this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.egg.view', $egg->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request to view a single Egg.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function view(Egg $egg): View
|
||||
{
|
||||
return view('admin.eggs.view', [
|
||||
'egg' => $egg,
|
||||
]);
|
||||
return view('admin.eggs.view', ['egg' => $egg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request to update an Egg.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
|
||||
*/
|
||||
public function update(EggFormRequest $request, Egg $egg): RedirectResponse
|
||||
{
|
||||
$this->updateService->handle($egg, $request->normalize());
|
||||
$this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.egg.view', $egg->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request to destroy an egg.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\HasChildrenException
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function destroy(Egg $egg): RedirectResponse
|
||||
{
|
||||
$this->deletionService->handle($egg->id);
|
||||
$this->alert->success(trans('admin/nests.eggs.notices.deleted'))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.view', $egg->nest_id);
|
||||
}
|
||||
}
|
||||
|
98
app/Http/Controllers/Admin/Nests/EggScriptController.php
Normal file
98
app/Http/Controllers/Admin/Nests/EggScriptController.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Eggs\Scripts\InstallScriptService;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest;
|
||||
|
||||
class EggScriptController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Scripts\InstallScriptService
|
||||
*/
|
||||
protected $installScriptService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* EggScriptController constructor.
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Services\Eggs\Scripts\InstallScriptService $installScriptService
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
EggRepositoryInterface $repository,
|
||||
InstallScriptService $installScriptService
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->installScriptService = $installScriptService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle requests to render installation script for an Egg.
|
||||
*
|
||||
* @param int $egg
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(int $egg): View
|
||||
{
|
||||
$egg = $this->repository->getWithCopyAttributes($egg);
|
||||
$copy = $this->repository->findWhere([
|
||||
['copy_script_from', '=', null],
|
||||
['nest_id', '=', $egg->nest_id],
|
||||
['id', '!=', $egg],
|
||||
]);
|
||||
|
||||
$rely = $this->repository->findWhere([
|
||||
['copy_script_from', '=', $egg->id],
|
||||
]);
|
||||
|
||||
return view('admin.eggs.scripts', [
|
||||
'copyFromOptions' => $copy,
|
||||
'relyOnScript' => $rely,
|
||||
'egg' => $egg,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a request to update the installation script for an Egg.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest $request
|
||||
* @param int $egg
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException
|
||||
*/
|
||||
public function update(EggScriptFormRequest $request, int $egg): RedirectResponse
|
||||
{
|
||||
$this->installScriptService->handle($egg, $request->normalize());
|
||||
$this->alert->success(trans('admin/nests.eggs.notices.script_updated'))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.egg.scripts', $egg);
|
||||
}
|
||||
}
|
146
app/Http/Controllers/Admin/Nests/EggVariableController.php
Normal file
146
app/Http/Controllers/Admin/Nests/EggVariableController.php
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Services\Eggs\Variables\VariableUpdateService;
|
||||
use Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest;
|
||||
use Pterodactyl\Services\Eggs\Variables\VariableCreationService;
|
||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||
|
||||
class EggVariableController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Variables\VariableCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Variables\VariableUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
|
||||
*/
|
||||
protected $variableRepository;
|
||||
|
||||
/**
|
||||
* EggVariableController constructor.
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Services\Eggs\Variables\VariableCreationService $creationService
|
||||
* @param \Pterodactyl\Services\Eggs\Variables\VariableUpdateService $updateService
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $variableRepository
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
VariableCreationService $creationService,
|
||||
VariableUpdateService $updateService,
|
||||
EggRepositoryInterface $repository,
|
||||
EggVariableRepositoryInterface $variableRepository
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
$this->variableRepository = $variableRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request to view the variables attached to an Egg.
|
||||
*
|
||||
* @param int $egg
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view(int $egg): View
|
||||
{
|
||||
$egg = $this->repository->getWithVariables($egg);
|
||||
|
||||
return view('admin.eggs.variables', ['egg' => $egg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a request to create a new Egg variable.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
|
||||
*/
|
||||
public function store(EggVariableFormRequest $request, Egg $egg): RedirectResponse
|
||||
{
|
||||
$this->creationService->handle($egg->id, $request->normalize());
|
||||
$this->alert->success(trans('admin/nests.variables.notices.variable_created'))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.egg.variables', $egg->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a request to update an existing Egg variable.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
* @param \Pterodactyl\Models\EggVariable $variable
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
|
||||
*/
|
||||
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', [
|
||||
'variable' => $variable->name,
|
||||
]))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.egg.variables', $egg->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a request to delete an existing Egg variable from the Panel.
|
||||
*
|
||||
* @param int $egg
|
||||
* @param \Pterodactyl\Models\EggVariable $variable
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $egg, EggVariable $variable): RedirectResponse
|
||||
{
|
||||
$this->variableRepository->delete($variable->id);
|
||||
$this->alert->success(trans('admin/nests.variables.notices.variable_deleted', [
|
||||
'variable' => $variable->name,
|
||||
]))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.egg.variables', $egg);
|
||||
}
|
||||
}
|
@ -145,12 +145,12 @@ class NestController extends Controller
|
||||
/**
|
||||
* Handle request to delete a nest.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
* @param int $nest
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function destroy($nest): RedirectResponse
|
||||
public function destroy(int $nest): RedirectResponse
|
||||
{
|
||||
$this->nestDeletionService->handle($nest);
|
||||
$this->alert->success(trans('admin/nests.notices.deleted'))->flash();
|
||||
|
@ -14,16 +14,16 @@ use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Http\Request;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Http\Requests\Admin\Service\EggFormRequest;
|
||||
use Pterodactyl\Services\Services\Options\EggUpdateService;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
use Pterodactyl\Http\Requests\Admin\Service\EditOptionScript;
|
||||
use Pterodactyl\Services\Services\Options\OptionUpdateService;
|
||||
use Pterodactyl\Services\Services\Options\OptionCreationService;
|
||||
use Pterodactyl\Services\Services\Options\OptionDeletionService;
|
||||
use Pterodactyl\Http\Requests\Admin\Service\ServiceOptionFormRequest;
|
||||
use Pterodactyl\Services\Services\Options\InstallScriptUpdateService;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
|
||||
use Pterodactyl\Services\Services\Options\EggCreationService;
|
||||
use Pterodactyl\Services\Services\Options\EggDeletionService;
|
||||
use Pterodactyl\Services\Services\Options\InstallScriptService;
|
||||
use Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException;
|
||||
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
||||
|
||||
class OptionController extends Controller
|
||||
{
|
||||
@ -33,22 +33,22 @@ class OptionController extends Controller
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\InstallScriptUpdateService
|
||||
* @var \Pterodactyl\Services\Services\Options\InstallScriptService
|
||||
*/
|
||||
protected $installScriptUpdateService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\OptionCreationService
|
||||
* @var \Pterodactyl\Services\Services\Options\EggCreationService
|
||||
*/
|
||||
protected $optionCreationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\OptionDeletionService
|
||||
* @var \Pterodactyl\Services\Services\Options\EggDeletionService
|
||||
*/
|
||||
protected $optionDeletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\OptionUpdateService
|
||||
* @var \Pterodactyl\Services\Services\Options\EggUpdateService
|
||||
*/
|
||||
protected $optionUpdateService;
|
||||
|
||||
@ -65,20 +65,20 @@ class OptionController extends Controller
|
||||
/**
|
||||
* OptionController constructor.
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Services\Services\Options\InstallScriptUpdateService $installScriptUpdateService
|
||||
* @param \Pterodactyl\Services\Services\Options\OptionCreationService $optionCreationService
|
||||
* @param \Pterodactyl\Services\Services\Options\OptionDeletionService $optionDeletionService
|
||||
* @param \Pterodactyl\Services\Services\Options\OptionUpdateService $optionUpdateService
|
||||
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $serviceOptionRepository
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Services\Services\Options\InstallScriptService $installScriptUpdateService
|
||||
* @param \Pterodactyl\Services\Services\Options\EggCreationService $optionCreationService
|
||||
* @param \Pterodactyl\Services\Services\Options\EggDeletionService $optionDeletionService
|
||||
* @param \Pterodactyl\Services\Services\Options\EggUpdateService $optionUpdateService
|
||||
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $serviceOptionRepository
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
InstallScriptUpdateService $installScriptUpdateService,
|
||||
OptionCreationService $optionCreationService,
|
||||
OptionDeletionService $optionDeletionService,
|
||||
OptionUpdateService $optionUpdateService,
|
||||
InstallScriptService $installScriptUpdateService,
|
||||
EggCreationService $optionCreationService,
|
||||
EggDeletionService $optionDeletionService,
|
||||
EggUpdateService $optionUpdateService,
|
||||
NestRepositoryInterface $serviceRepository,
|
||||
EggRepositoryInterface $serviceOptionRepository
|
||||
) {
|
||||
@ -107,12 +107,12 @@ class OptionController extends Controller
|
||||
/**
|
||||
* Handle adding a new service option.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Service\ServiceOptionFormRequest $request
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Service\EggFormRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(ServiceOptionFormRequest $request)
|
||||
public function store(EggFormRequest $request)
|
||||
{
|
||||
try {
|
||||
$option = $this->optionCreationService->handle($request->normalize());
|
||||
|
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Services\NestUpdateService;
|
||||
use Pterodactyl\Services\Services\NestCreationService;
|
||||
use Pterodactyl\Services\Services\NestDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
use Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest;
|
||||
use Pterodactyl\Http\Requests\Admin\Service\ServiceFunctionsFormRequest;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\NestCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\NestDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\NestUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* ServiceController constructor.
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Services\Services\NestCreationService $creationService
|
||||
* @param \Pterodactyl\Services\Services\NestDeletionService $deletionService
|
||||
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Services\Services\NestUpdateService $updateService
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
NestCreationService $creationService,
|
||||
NestDeletionService $deletionService,
|
||||
NestRepositoryInterface $repository,
|
||||
NestUpdateService $updateService
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display service overview page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.services.index', [
|
||||
'services' => $this->repository->getWithCounts(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display create service page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('admin.services.new');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return base view for a service.
|
||||
*
|
||||
* @param int $service
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function view(int $service): View
|
||||
{
|
||||
return view('admin.services.view', [
|
||||
'service' => $this->repository->getWithOptionServers($service),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return function editing view for a service.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Nest $service
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function viewFunctions(Nest $service): View
|
||||
{
|
||||
return view('admin.services.functions', ['service' => $service]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle post action for new service.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(StoreNestFormRequest $request): RedirectResponse
|
||||
{
|
||||
$service = $this->creationService->handle($request->normalize());
|
||||
$this->alert->success(trans('admin/services.notices.service_created', ['name' => $service->name]))->flash();
|
||||
|
||||
return redirect()->route('admin.services.view', $service->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits configuration for a specific service.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $service
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(StoreNestFormRequest $request, Nest $service): RedirectResponse
|
||||
{
|
||||
$this->updateService->handle($service->id, $request->normalize());
|
||||
$this->alert->success(trans('admin/services.notices.service_updated'))->flash();
|
||||
|
||||
return redirect()->route('admin.services.view', $service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the functions file for a service.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Service\ServiceFunctionsFormRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $service
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function updateFunctions(ServiceFunctionsFormRequest $request, Nest $service): RedirectResponse
|
||||
{
|
||||
$this->updateService->handle($service->id, $request->normalize());
|
||||
$this->alert->success(trans('admin/services.notices.functions_updated'))->flash();
|
||||
|
||||
return redirect()->route('admin.services.view.functions', $service->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a service from the panel.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Nest $service
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function destroy(Nest $service): RedirectResponse
|
||||
{
|
||||
$this->deletionService->handle($service->id);
|
||||
$this->alert->success(trans('admin/services.notices.service_deleted'))->flash();
|
||||
|
||||
return redirect()->route('admin.services');
|
||||
}
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest;
|
||||
use Pterodactyl\Repositories\Eloquent\ServiceVariableRepository;
|
||||
use Pterodactyl\Services\Services\Variables\VariableUpdateService;
|
||||
use Pterodactyl\Services\Services\Variables\VariableCreationService;
|
||||
|
||||
class VariableController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Variables\VariableCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $serviceOptionRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServiceVariableRepository
|
||||
*/
|
||||
protected $serviceVariableRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Variables\VariableUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
EggRepositoryInterface $serviceOptionRepository,
|
||||
ServiceVariableRepository $serviceVariableRepository,
|
||||
VariableCreationService $creationService,
|
||||
VariableUpdateService $updateService
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->serviceOptionRepository = $serviceOptionRepository;
|
||||
$this->serviceVariableRepository = $serviceVariableRepository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles POST request to create a new option variable.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $option
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
|
||||
*/
|
||||
public function store(OptionVariableFormRequest $request, Egg $option)
|
||||
{
|
||||
$this->creationService->handle($option->id, $request->normalize());
|
||||
$this->alert->success(trans('admin/services.variables.notices.variable_created'))->flash();
|
||||
|
||||
return redirect()->route('admin.services.option.variables', $option->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display variable overview page for a service option.
|
||||
*
|
||||
* @param int $option
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function view($option)
|
||||
{
|
||||
$option = $this->serviceOptionRepository->getWithVariables($option);
|
||||
|
||||
return view('admin.services.options.variables', ['option' => $option]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles POST when editing a configration for a service variable.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $option
|
||||
* @param \Pterodactyl\Models\EggVariable $variable
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
|
||||
*/
|
||||
public function update(OptionVariableFormRequest $request, Egg $option, EggVariable $variable)
|
||||
{
|
||||
$this->updateService->handle($variable, $request->normalize());
|
||||
$this->alert->success(trans('admin/services.variables.notices.variable_updated', [
|
||||
'variable' => $variable->name,
|
||||
]))->flash();
|
||||
|
||||
return redirect()->route('admin.services.option.variables', $option->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a service variable from the system.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $option
|
||||
* @param \Pterodactyl\Models\EggVariable $variable
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function delete(Egg $option, EggVariable $variable)
|
||||
{
|
||||
$this->serviceVariableRepository->delete($variable->id);
|
||||
$this->alert->success(trans('admin/services.variables.notices.variable_deleted', [
|
||||
'variable' => $variable->name,
|
||||
]))->flash();
|
||||
|
||||
return redirect()->route('admin.services.option.variables', $option->id);
|
||||
}
|
||||
}
|
49
app/Http/Requests/Admin/Egg/EggFormRequest.php
Normal file
49
app/Http/Requests/Admin/Egg/EggFormRequest.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||
|
||||
class EggFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'required|string',
|
||||
'docker_image' => 'required|string|max:255',
|
||||
'startup' => 'required|string',
|
||||
'config_from' => 'sometimes|bail|nullable|numeric',
|
||||
'config_stop' => 'required_without:config_from|nullable|string|max:255',
|
||||
'config_startup' => 'required_without:config_from|nullable|json',
|
||||
'config_logs' => 'required_without:config_from|nullable|json',
|
||||
'config_files' => 'required_without:config_from|nullable|json',
|
||||
];
|
||||
|
||||
if ($this->method() === 'POST') {
|
||||
$rules['nest_id'] = 'required|numeric|exists:nests,id';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
*/
|
||||
public function withValidator($validator)
|
||||
{
|
||||
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
||||
return (int) $this->input('config_from') !== 0;
|
||||
});
|
||||
}
|
||||
}
|
@ -7,11 +7,11 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Service;
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||
|
||||
class EditOptionScript extends AdminFormRequest
|
||||
class EggScriptFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Return the rules to be used when validating the sent data in the request.
|
@ -7,11 +7,12 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin;
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||
|
||||
class OptionVariableFormRequest extends AdminFormRequest
|
||||
class EggVariableFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
@ -37,11 +38,9 @@ class OptionVariableFormRequest extends AdminFormRequest
|
||||
{
|
||||
$rules = $this->input('rules');
|
||||
if ($this->method() === 'PATCH') {
|
||||
$rules = $this->input('rules', $this->route()->parameter('variable')->rules);
|
||||
$rules = $this->input('rules', $this->route()->parameter('egg')->rules);
|
||||
}
|
||||
|
||||
$validator->sometimes('default_value', $rules, function ($input) {
|
||||
return $input->default_value;
|
||||
});
|
||||
$validator->addRules(['default_value' => $rules]);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Service;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||
|
||||
class ServiceOptionFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return Egg::getCreateRules();
|
||||
}
|
||||
}
|
@ -64,7 +64,7 @@ class Egg extends Model implements CleansAttributes, ValidableContract
|
||||
* @var array
|
||||
*/
|
||||
protected static $applicationRules = [
|
||||
'service_id' => 'required',
|
||||
'nest_id' => 'required',
|
||||
'name' => 'required',
|
||||
'description' => 'required',
|
||||
'docker_image' => 'required',
|
||||
@ -80,13 +80,13 @@ class Egg extends Model implements CleansAttributes, ValidableContract
|
||||
* @var array
|
||||
*/
|
||||
protected static $dataIntegrityRules = [
|
||||
'service_id' => 'bail|numeric|exists:services,id',
|
||||
'nest_id' => 'bail|numeric|exists:nests,id',
|
||||
'uuid' => 'string|size:36',
|
||||
'name' => 'string|max:255',
|
||||
'description' => 'string',
|
||||
'docker_image' => 'string|max:255',
|
||||
'startup' => 'nullable|string',
|
||||
'config_from' => 'bail|nullable|numeric|exists:service_options,id',
|
||||
'config_from' => 'bail|nullable|numeric|exists:eggs,id',
|
||||
'config_stop' => 'nullable|string|max:255',
|
||||
'config_startup' => 'nullable|json',
|
||||
'config_logs' => 'nullable|json',
|
||||
|
@ -7,17 +7,20 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Services\Options;
|
||||
namespace Pterodactyl\Services\Eggs;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
|
||||
class OptionConfigurationFileService
|
||||
class EggConfigurationService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* OptionConfigurationFileService constructor.
|
||||
* EggConfigurationService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
*/
|
||||
@ -27,7 +30,7 @@ class OptionConfigurationFileService
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a service configuration file to be used by the daemon.
|
||||
* Return an Egg file to be used by the Daemon.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\Egg $option
|
||||
* @return array
|
@ -7,15 +7,16 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Services\Options;
|
||||
namespace Pterodactyl\Services\Eggs;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
|
||||
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
||||
|
||||
class OptionCreationService
|
||||
// When a mommy and a daddy pterodactyl really like eachother...
|
||||
class EggCreationService
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
@ -28,7 +29,7 @@ class OptionCreationService
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* CreationService constructor.
|
||||
* EggCreationService constructor.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
@ -46,31 +47,25 @@ class OptionCreationService
|
||||
* @return \Pterodactyl\Models\Egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
|
||||
*/
|
||||
public function handle(array $data): Egg
|
||||
{
|
||||
if (! is_null(array_get($data, 'config_from'))) {
|
||||
$data['config_from'] = array_get($data, 'config_from');
|
||||
if (! is_null($data['config_from'])) {
|
||||
$results = $this->repository->findCountWhere([
|
||||
['service_id', '=', array_get($data, 'service_id')],
|
||||
['nest_id', '=', array_get($data, 'nest_id')],
|
||||
['id', '=', array_get($data, 'config_from')],
|
||||
]);
|
||||
|
||||
if ($results !== 1) {
|
||||
throw new NoParentConfigurationFoundException(trans('exceptions.service.options.must_be_child'));
|
||||
}
|
||||
} else {
|
||||
$data['config_from'] = null;
|
||||
}
|
||||
|
||||
if (count($parts = explode(':', array_get($data, 'tag'))) > 1) {
|
||||
$data['tag'] = $this->config->get('pterodactyl.service.author') . ':' . trim(array_pop($parts));
|
||||
} else {
|
||||
$data['tag'] = $this->config->get('pterodactyl.service.author') . ':' . trim(array_get($data, 'tag'));
|
||||
}
|
||||
|
||||
return $this->repository->create(array_merge($data, [
|
||||
'uuid' => Uuid::uuid4()->toString(),
|
||||
'author' => $this->config->get('pterodactyl.service.author'),
|
||||
]), true, true);
|
||||
}
|
||||
}
|
@ -7,14 +7,14 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Services\Options;
|
||||
namespace Pterodactyl\Services\Eggs;
|
||||
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\Egg\HasChildrenException;
|
||||
use Pterodactyl\Exceptions\Service\HasActiveServersException;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\HasChildrenException;
|
||||
|
||||
class OptionDeletionService
|
||||
class EggDeletionService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
@ -27,7 +27,7 @@ class OptionDeletionService
|
||||
protected $serverRepository;
|
||||
|
||||
/**
|
||||
* OptionDeletionService constructor.
|
||||
* EggDeletionService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
@ -41,26 +41,26 @@ class OptionDeletionService
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an option from the database if it has no active servers attached to it.
|
||||
* Delete an Egg from the database if it has no active servers attached to it.
|
||||
*
|
||||
* @param int $option
|
||||
* @param int $egg
|
||||
* @return int
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\HasChildrenException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\HasChildrenException
|
||||
*/
|
||||
public function handle(int $option): int
|
||||
public function handle(int $egg): int
|
||||
{
|
||||
$servers = $this->serverRepository->findCountWhere([['option_id', '=', $option]]);
|
||||
$servers = $this->serverRepository->findCountWhere([['egg_id', '=', $egg]]);
|
||||
if ($servers > 0) {
|
||||
throw new HasActiveServersException(trans('exceptions.service.options.delete_has_servers'));
|
||||
throw new HasActiveServersException(trans('exceptions.nest.egg.delete_has_servers'));
|
||||
}
|
||||
|
||||
$children = $this->repository->findCountWhere([['config_from', '=', $option]]);
|
||||
$children = $this->repository->findCountWhere([['config_from', '=', $egg]]);
|
||||
if ($children > 0) {
|
||||
throw new HasChildrenException(trans('exceptions.service.options.has_children'));
|
||||
throw new HasChildrenException(trans('exceptions.nest.egg.has_children'));
|
||||
}
|
||||
|
||||
return $this->repository->delete($option);
|
||||
return $this->repository->delete($egg);
|
||||
}
|
||||
}
|
@ -7,13 +7,13 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Services\Options;
|
||||
namespace Pterodactyl\Services\Eggs;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
|
||||
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
||||
|
||||
class OptionUpdateService
|
||||
class EggUpdateService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
@ -21,7 +21,7 @@ class OptionUpdateService
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* OptionUpdateService constructor.
|
||||
* EggUpdateService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
*/
|
||||
@ -33,30 +33,30 @@ class OptionUpdateService
|
||||
/**
|
||||
* Update a service option.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\Egg $option
|
||||
* @param int|\Pterodactyl\Models\Egg $egg
|
||||
* @param array $data
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
|
||||
*/
|
||||
public function handle($option, array $data)
|
||||
public function handle($egg, array $data)
|
||||
{
|
||||
if (! $option instanceof Egg) {
|
||||
$option = $this->repository->find($option);
|
||||
if (! $egg instanceof Egg) {
|
||||
$egg = $this->repository->find($egg);
|
||||
}
|
||||
|
||||
if (! is_null(array_get($data, 'config_from'))) {
|
||||
$results = $this->repository->findCountWhere([
|
||||
['service_id', '=', $option->service_id],
|
||||
['nest_id', '=', $egg->nest_id],
|
||||
['id', '=', array_get($data, 'config_from')],
|
||||
]);
|
||||
|
||||
if ($results !== 1) {
|
||||
throw new NoParentConfigurationFoundException(trans('exceptions.service.options.must_be_child'));
|
||||
throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->repository->withoutFresh()->update($option->id, $data);
|
||||
$this->repository->withoutFresh()->update($egg->id, $data);
|
||||
}
|
||||
}
|
@ -7,13 +7,13 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Services\Options;
|
||||
namespace Pterodactyl\Services\Eggs\Scripts;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException;
|
||||
use Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException;
|
||||
|
||||
class InstallScriptUpdateService
|
||||
class InstallScriptService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
@ -21,7 +21,7 @@ class InstallScriptUpdateService
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* InstallScriptUpdateService constructor.
|
||||
* InstallScriptService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
*/
|
||||
@ -31,30 +31,30 @@ class InstallScriptUpdateService
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the option install script for a given service option.
|
||||
* Modify the install script for a given Egg.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\Egg $option
|
||||
* @param int|\Pterodactyl\Models\Egg $egg
|
||||
* @param array $data
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException
|
||||
*/
|
||||
public function handle($option, array $data)
|
||||
public function handle($egg, array $data)
|
||||
{
|
||||
if (! $option instanceof Egg) {
|
||||
$option = $this->repository->find($option);
|
||||
if (! $egg instanceof Egg) {
|
||||
$egg = $this->repository->find($egg);
|
||||
}
|
||||
|
||||
if (! is_null(array_get($data, 'copy_script_from'))) {
|
||||
if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $option->service_id)) {
|
||||
throw new InvalidCopyFromException(trans('exceptions.service.options.invalid_copy_id'));
|
||||
if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $egg->service_id)) {
|
||||
throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->repository->withoutFresh()->update($option->id, [
|
||||
$this->repository->withoutFresh()->update($egg->id, [
|
||||
'script_install' => array_get($data, 'script_install'),
|
||||
'script_is_privileged' => array_get($data, 'script_is_privileged'),
|
||||
'script_is_privileged' => array_get($data, 'script_is_privileged', 1),
|
||||
'script_entry' => array_get($data, 'script_entry'),
|
||||
'script_container' => array_get($data, 'script_container'),
|
||||
'copy_script_from' => array_get($data, 'copy_script_from'),
|
@ -7,50 +7,51 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Services\Variables;
|
||||
namespace Pterodactyl\Services\Eggs\Variables;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException;
|
||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
|
||||
|
||||
class VariableCreationService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $serviceOptionRepository;
|
||||
protected $eggRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface
|
||||
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
|
||||
*/
|
||||
protected $serviceVariableRepository;
|
||||
protected $variableRepository;
|
||||
|
||||
/**
|
||||
* VariableCreationService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $eggRepository
|
||||
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $variableRepository
|
||||
*/
|
||||
public function __construct(
|
||||
EggRepositoryInterface $serviceOptionRepository,
|
||||
ServiceVariableRepositoryInterface $serviceVariableRepository
|
||||
EggRepositoryInterface $eggRepository,
|
||||
EggVariableRepositoryInterface $variableRepository
|
||||
) {
|
||||
$this->serviceOptionRepository = $serviceOptionRepository;
|
||||
$this->serviceVariableRepository = $serviceVariableRepository;
|
||||
$this->eggRepository = $eggRepository;
|
||||
$this->variableRepository = $variableRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new variable for a given service option.
|
||||
* Create a new variable for a given Egg.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\Egg $option
|
||||
* @param array $data
|
||||
* @param int $egg
|
||||
* @param array $data
|
||||
* @return \Pterodactyl\Models\EggVariable
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
|
||||
*/
|
||||
public function handle($option, array $data)
|
||||
public function handle(int $egg, array $data): EggVariable
|
||||
{
|
||||
if ($option instanceof Egg) {
|
||||
$option = $option->id;
|
||||
}
|
||||
|
||||
if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) {
|
||||
throw new ReservedVariableNameException(sprintf(
|
||||
'Cannot use the protected name %s for this environment variable.',
|
||||
@ -60,8 +61,8 @@ class VariableCreationService
|
||||
|
||||
$options = array_get($data, 'options', []);
|
||||
|
||||
return $this->serviceVariableRepository->create(array_merge([
|
||||
'option_id' => $option,
|
||||
return $this->variableRepository->create(array_merge([
|
||||
'egg_id' => $egg,
|
||||
'user_viewable' => in_array('user_viewable', $options),
|
||||
'user_editable' => in_array('user_editable', $options),
|
||||
], $data));
|
@ -7,32 +7,32 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Services\Variables;
|
||||
namespace Pterodactyl\Services\Eggs\Variables;
|
||||
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException;
|
||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
|
||||
|
||||
class VariableUpdateService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface
|
||||
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* VariableUpdateService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(ServiceVariableRepositoryInterface $repository)
|
||||
public function __construct(EggVariableRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a specific service variable.
|
||||
* Update a specific egg variable.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\EggVariable $variable
|
||||
* @param array $data
|
||||
@ -41,7 +41,7 @@ class VariableUpdateService
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
|
||||
*/
|
||||
public function handle($variable, array $data)
|
||||
{
|
||||
@ -58,7 +58,7 @@ class VariableUpdateService
|
||||
|
||||
$search = $this->repository->withColumns('id')->findCountWhere([
|
||||
['env_variable', '=', array_get($data, 'env_variable')],
|
||||
['option_id', '=', $variable->option_id],
|
||||
['egg_id', '=', $variable->egg_id],
|
||||
['id', '!=', $variable->id],
|
||||
]);
|
||||
|
||||
@ -71,9 +71,9 @@ class VariableUpdateService
|
||||
|
||||
$options = array_get($data, 'options', []);
|
||||
|
||||
return $this->repository->withoutFresh()->update($variable->id, array_merge([
|
||||
return $this->repository->withoutFresh()->update($variable->id, array_merge($data, [
|
||||
'user_viewable' => in_array('user_viewable', $options),
|
||||
'user_editable' => in_array('user_editable', $options),
|
||||
], $data));
|
||||
]));
|
||||
}
|
||||
}
|
@ -6,20 +6,20 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Service → New Option
|
||||
Nests → New Egg
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
<h1>New Option<small>Create a new service option to assign to servers.</small></h1>
|
||||
<h1>New Egg<small>Create a new Egg to assign to servers.</small></h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('admin.index') }}">Admin</a></li>
|
||||
<li><a href="{{ route('admin.services') }}">Service</a></li>
|
||||
<li class="active">New Service Option</li>
|
||||
<li><a href="{{ route('admin.nests') }}">Nests</a></li>
|
||||
<li class="active">New Egg</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<form action="{{ route('admin.services.option.new') }}" method="POST">
|
||||
<form action="{{ route('admin.nests.egg.new') }}" method="POST">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
@ -30,42 +30,37 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="pServiceId" class="form-label">Associated Service</label>
|
||||
<select name="service_id" id="pServiceId">
|
||||
@foreach($services as $service)
|
||||
<option value="{{ $service->id }}" {{ old('service_id') != $service->id ?: 'selected' }}>{{ $service->name }} <{{ $service->author }}></option>
|
||||
@endforeach
|
||||
</select>
|
||||
<label for="pNestId" class="form-label">Associated Nest</label>
|
||||
<div>
|
||||
<select name="nest_id" id="pNestId">
|
||||
@foreach($nests as $nest)
|
||||
<option value="{{ $nest->id }}" {{ old('nest_id') != $nest->id ?: 'selected' }}>{{ $nest->name }} <{{ $nest->author }}></option>
|
||||
@endforeach
|
||||
</select>
|
||||
<p class="text-muted small">Think of a Nest as a category. You can put multiple Eggs in a nest, but consider putting only Eggs that are related to eachother in each Nest.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pName" class="form-label">Option Name</label>
|
||||
<label for="pName" class="form-label">Name</label>
|
||||
<input type="text" id="pName" name="name" value="{{ old('name') }}" class="form-control" />
|
||||
<p class="text-muted small">A simple, human-readable name to use as an identifier for this service.</p>
|
||||
<p class="text-muted small">A simple, human-readable name to use as an identifier for this Egg. This is what users will see as thier gameserver type.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pDescription" class="form-label">Description</label>
|
||||
<textarea id="pDescription" name="description" class="form-control" rows="8">{{ old('description') }}</textarea>
|
||||
<p class="text-muted small">A description of this service that will be displayed throughout the panel as needed.</p>
|
||||
<p class="text-muted small">A description of this Egg.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="pTag" class="form-label">Option Tag</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{{ config('pterodactyl.service.author') }}:</span>
|
||||
<input type="text" id="pTag" name="tag" value="{{ old('tag') }}" class="form-control" />
|
||||
</div>
|
||||
<p class="text-muted small">This should be a unique identifer for this service option that is not used for any other service options. Must be alpha-numeric and no more than 60 characters in length.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pDockerImage" class="control-label">Docker Image <span class="field-optional"></span></label>
|
||||
<label for="pDockerImage" class="control-label">Docker Image</label>
|
||||
<input type="text" id="pDockerImage" name="docker_image" value="{{ old('docker_image') }}" placeholder="quay.io/pterodactyl/service" class="form-control" />
|
||||
<p class="text-muted small">The default docker image that should be used for new servers under this service option. This can be left blank to use the parent service's defined image, and can also be changed per-server.</p>
|
||||
<p class="text-muted small">The default docker image that should be used for new servers using this Egg. This can be changed per-server.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pStartup" class="control-label">Startup Command <span class="field-optional"></span></label>
|
||||
<textarea id="pStartup" name="startup" class="form-control" rows="4">{{ old('startup') }}</textarea>
|
||||
<p class="text-muted small">The default statup command that should be used for new servers under this service option. This can be left blank to use the parent service's startup, and can also be changed per-server.</p>
|
||||
<label for="pStartup" class="control-label">Startup Command</label>
|
||||
<textarea id="pStartup" name="startup" class="form-control" rows="14">{{ old('startup') }}</textarea>
|
||||
<p class="text-muted small">The default statup command that should be used for new servers created with this Egg. You can change this per-server as needed.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -90,7 +85,7 @@
|
||||
<select name="config_from" id="pConfigFrom" class="form-control">
|
||||
<option value="0">None</option>
|
||||
</select>
|
||||
<p class="text-muted small">If you would like to default to settings from another option select the option from the menu above.</p>
|
||||
<p class="text-muted small">If you would like to default to settings from another Egg select it from the dropdown above.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pConfigStop" class="form-label">Stop Command</label>
|
||||
@ -118,7 +113,7 @@
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
{!! csrf_field() !!}
|
||||
<button type="submit" class="btn btn-success btn-sm pull-right">Create Service</button>
|
||||
<button type="submit" class="btn btn-success btn-sm pull-right">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -131,15 +126,15 @@
|
||||
{!! Theme::js('vendor/lodash/lodash.js') !!}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#pServiceId').select2().change();
|
||||
$('#pNestId').select2().change();
|
||||
$('#pConfigFrom').select2();
|
||||
});
|
||||
$('#pServiceId').on('change', function (event) {
|
||||
$('#pNestId').on('change', function (event) {
|
||||
$('#pConfigFrom').html('<option value="">None</option>').select2({
|
||||
data: $.map(_.get(Pterodactyl.services, $(this).val() + '.options', []), function (item) {
|
||||
data: $.map(_.get(Pterodactyl.nests, $(this).val() + '.eggs', []), function (item) {
|
||||
return {
|
||||
id: item.id,
|
||||
text: item.name + ' <' + item.tag + '>',
|
||||
text: item.name + ' <' + item.author + '>',
|
||||
};
|
||||
}),
|
||||
});
|
@ -6,16 +6,16 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Service → Option: {{ $option->name }} → Scripts
|
||||
Nests → Egg: {{ $egg->name }} → Scripts
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
<h1>{{ $option->name }}<small>Manage install and upgrade scripts for this service option.</small></h1>
|
||||
<h1>{{ $egg->name }}<small>Manage install and upgrade scripts for this Egg.</small></h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('admin.index') }}">Admin</a></li>
|
||||
<li><a href="{{ route('admin.services') }}">Service</a></li>
|
||||
<li><a href="{{ route('admin.services.view', $option->service->id) }}">{{ $option->service->name }}</a></li>
|
||||
<li class="active">{{ $option->name }}</li>
|
||||
<li><a href="{{ route('admin.nests') }}">Service</a></li>
|
||||
<li><a href="{{ route('admin.nests.view', $egg->nest->id) }}">{{ $egg->nest->name }}</a></li>
|
||||
<li class="active">{{ $egg->name }}</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@ -24,29 +24,29 @@
|
||||
<div class="col-xs-12">
|
||||
<div class="nav-tabs-custom nav-tabs-floating">
|
||||
<ul class="nav nav-tabs">
|
||||
<li><a href="{{ route('admin.services.option.view', $option->id) }}">Configuration</a></li>
|
||||
<li><a href="{{ route('admin.services.option.variables', $option->id) }}">Variables</a></li>
|
||||
<li class="active"><a href="{{ route('admin.services.option.scripts', $option->id) }}">Scripts</a></li>
|
||||
<li><a href="{{ route('admin.nests.egg.view', $egg->id) }}">Configuration</a></li>
|
||||
<li><a href="{{ route('admin.nests.egg.variables', $egg->id) }}">Variables</a></li>
|
||||
<li class="active"><a href="{{ route('admin.nests.egg.scripts', $egg->id) }}">Scripts</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('admin.services.option.scripts', $option->id) }}" method="POST">
|
||||
<form action="{{ route('admin.nests.egg.scripts', $egg->id) }}" method="POST">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Install Script</h3>
|
||||
</div>
|
||||
@if(! is_null($option->copyFrom))
|
||||
@if(! is_null($egg->copyFrom))
|
||||
<div class="box-body">
|
||||
<div class="callout callout-warning no-margin">
|
||||
This service option is copying installation scripts and containe options from <a href="{{ route('admin.services.option.view', $option->copyFrom->id) }}">{{ $option->copyFrom->name }}</a>. Any changes you make to this script will not apply unless you select "None" from the dropdown box below.
|
||||
This service option is copying installation scripts and containe options from <a href="{{ route('admin.nests.egg.view', $egg->copyFrom->id) }}">{{ $egg->copyFrom->name }}</a>. Any changes you make to this script will not apply unless you select "None" from the dropdown box below.
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="box-body no-padding">
|
||||
<div id="editor_install"style="height:300px">{{ $option->script_install }}</div>
|
||||
<div id="editor_install"style="height:300px">{{ $egg->script_install }}</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@ -55,19 +55,19 @@
|
||||
<select id="pCopyScriptFrom" name="copy_script_from">
|
||||
<option value="0">None</option>
|
||||
@foreach($copyFromOptions as $opt)
|
||||
<option value="{{ $opt->id }}" {{ $option->copy_script_from !== $opt->id ?: 'selected' }}>{{ $opt->name }}</option>
|
||||
<option value="{{ $opt->id }}" {{ $egg->copy_script_from !== $opt->id ?: 'selected' }}>{{ $opt->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<p class="text-muted small">If selected, script above will be ignored and script from selected option will be used in place.</p>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label class="control-label">Script Container</label>
|
||||
<input type="text" name="script_container" class="form-control" value="{{ $option->script_container }}" />
|
||||
<input type="text" name="script_container" class="form-control" value="{{ $egg->script_container }}" />
|
||||
<p class="text-muted small">Docker container to use when running this script for the server.</p>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label class="control-label">Script Entrypoint Command</label>
|
||||
<input type="text" name="script_entry" class="form-control" value="{{ $option->script_entry }}" />
|
||||
<input type="text" name="script_entry" class="form-control" value="{{ $egg->script_entry }}" />
|
||||
<p class="text-muted small">The entrypoint command to use for this script.</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -76,8 +76,8 @@
|
||||
The following service options rely on this script:
|
||||
@if(count($relyOnScript) > 0)
|
||||
@foreach($relyOnScript as $rely)
|
||||
<a href="{{ route('admin.services.option.view', $rely->id) }}">
|
||||
<code>{{ $rely->name }}</code>
|
||||
<a href="{{ route('admin.nests.egg.view', $rely->id) }}">
|
||||
<code>{{ $rely->name }}</code>@if(!$loop->last), @endif
|
||||
</a>
|
||||
@endforeach
|
||||
@else
|
||||
@ -89,7 +89,7 @@
|
||||
<div class="box-footer">
|
||||
{!! csrf_field() !!}
|
||||
<textarea name="script_install" class="hidden"></textarea>
|
||||
<button type="submit" class="btn btn-primary btn-sm pull-right">Save Script</button>
|
||||
<button type="submit" name="_method" value="PATCH" class="btn btn-primary btn-sm pull-right">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -6,16 +6,16 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Service Options → {{ $option->name }} → Variables
|
||||
Egg → {{ $egg->name }} → Variables
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
<h1>{{ $option->name }}<small>Managing variables for this service option.</small></h1>
|
||||
<h1>{{ $egg->name }}<small>Managing variables for this Egg.</small></h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('admin.index') }}">Admin</a></li>
|
||||
<li><a href="{{ route('admin.services') }}">Service</a></li>
|
||||
<li><a href="{{ route('admin.services.view', $option->service->id) }}">{{ $option->service->name }}</a></li>
|
||||
<li><a href="{{ route('admin.services.option.view', $option->id) }}">{{ $option->name }}</a></li>
|
||||
<li><a href="{{ route('admin.nests') }}">Nests</a></li>
|
||||
<li><a href="{{ route('admin.nests.view', $egg->nest->id) }}">{{ $egg->nest->name }}</a></li>
|
||||
<li><a href="{{ route('admin.nests.egg.view', $egg->id) }}">{{ $egg->name }}</a></li>
|
||||
<li class="active">Variables</li>
|
||||
</ol>
|
||||
@endsection
|
||||
@ -25,22 +25,30 @@
|
||||
<div class="col-xs-12">
|
||||
<div class="nav-tabs-custom nav-tabs-floating">
|
||||
<ul class="nav nav-tabs">
|
||||
<li><a href="{{ route('admin.services.option.view', $option->id) }}">Configuration</a></li>
|
||||
<li class="active"><a href="{{ route('admin.services.option.variables', $option->id) }}">Variables</a></li>
|
||||
<li class="tab-success"><a href="#modal" data-toggle="modal" data-target="#newVariableModal">New Variable</a></li>
|
||||
<li><a href="{{ route('admin.services.option.scripts', $option->id) }}">Scripts</a></li>
|
||||
<li><a href="{{ route('admin.nests.egg.view', $egg->id) }}">Configuration</a></li>
|
||||
<li class="active"><a href="{{ route('admin.nests.egg.variables', $egg->id) }}">Variables</a></li>
|
||||
<li><a href="{{ route('admin.nests.egg.scripts', $egg->id) }}">Scripts</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@foreach($option->variables as $variable)
|
||||
<div class="col-xs-12">
|
||||
<div class="box no-border">
|
||||
<div class="box-body">
|
||||
<a href="#" class="btn btn-sm btn-success pull-right" data-toggle="modal" data-target="#newVariableModal">Create New Variable</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@foreach($egg->variables as $variable)
|
||||
<div class="col-sm-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ $variable->name }}</h3>
|
||||
</div>
|
||||
<form action="{{ route('admin.services.option.variables.edit', ['id' => $option->id, 'variable' => $variable->id]) }}" method="POST">
|
||||
<form action="{{ route('admin.nests.egg.variables.edit', ['id' => $egg->id, 'variable' => $variable->id]) }}" method="POST">
|
||||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Name</label>
|
||||
@ -93,7 +101,7 @@
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Create New Option Variable</h4>
|
||||
</div>
|
||||
<form action="{{ route('admin.services.option.variables', $option->id) }}" method="POST">
|
||||
<form action="{{ route('admin.nests.egg.variables', $egg->id) }}" method="POST">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Name</label>
|
@ -156,7 +156,7 @@ Route::group(['prefix' => 'nests'], function () {
|
||||
Route::get('/egg/{egg}', 'Nests\EggController@view')->name('admin.nests.egg.view');
|
||||
Route::get('/egg/{egg}/export', 'Nests\EggShareController@export')->name('admin.nests.egg.export');
|
||||
Route::get('/egg/{egg}/variables', 'Nests\EggVariableController@view')->name('admin.nests.egg.variables');
|
||||
Route::get('/egg/{egg}/scripts', 'Nests\EggScriptController@view')->name('admin.nests.egg.scripts');
|
||||
Route::get('/egg/{egg}/scripts', 'Nests\EggScriptController@index')->name('admin.nests.egg.scripts');
|
||||
|
||||
Route::post('/new', 'Nests\NestController@store');
|
||||
Route::post('/import', 'Nests\EggShareController@import')->name('admin.nests.egg.import');
|
||||
|
@ -14,7 +14,7 @@ use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Services\Services\Options\InstallScriptUpdateService;
|
||||
use Pterodactyl\Services\Services\Options\InstallScriptService;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException;
|
||||
|
||||
class InstallScriptUpdateServiceTest extends TestCase
|
||||
@ -41,7 +41,7 @@ class InstallScriptUpdateServiceTest extends TestCase
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\InstallScriptUpdateService
|
||||
* @var \Pterodactyl\Services\Services\Options\InstallScriptService
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
@ -55,7 +55,7 @@ class InstallScriptUpdateServiceTest extends TestCase
|
||||
$this->model = factory(Egg::class)->make();
|
||||
$this->repository = m::mock(EggRepositoryInterface::class);
|
||||
|
||||
$this->service = new InstallScriptUpdateService($this->repository);
|
||||
$this->service = new InstallScriptService($this->repository);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ use Ramsey\Uuid\Uuid;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Services\Services\Options\OptionCreationService;
|
||||
use Pterodactyl\Services\Services\Options\EggCreationService;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
|
||||
|
||||
class OptionCreationServiceTest extends TestCase
|
||||
@ -32,7 +32,7 @@ class OptionCreationServiceTest extends TestCase
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\OptionCreationService
|
||||
* @var \Pterodactyl\Services\Services\Options\EggCreationService
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
@ -52,7 +52,7 @@ class OptionCreationServiceTest extends TestCase
|
||||
$this->repository = m::mock(EggRepositoryInterface::class);
|
||||
$this->uuid = m::mock('overload:' . Uuid::class);
|
||||
|
||||
$this->service = new OptionCreationService($this->config, $this->repository);
|
||||
$this->service = new EggCreationService($this->config, $this->repository);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,8 +14,8 @@ use Tests\TestCase;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\HasActiveServersException;
|
||||
use Pterodactyl\Services\Services\Options\EggDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Services\Services\Options\OptionDeletionService;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\HasChildrenException;
|
||||
|
||||
class OptionDeletionServiceTest extends TestCase
|
||||
@ -31,7 +31,7 @@ class OptionDeletionServiceTest extends TestCase
|
||||
protected $serverRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\OptionDeletionService
|
||||
* @var \Pterodactyl\Services\Services\Options\EggDeletionService
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
@ -45,7 +45,7 @@ class OptionDeletionServiceTest extends TestCase
|
||||
$this->repository = m::mock(EggRepositoryInterface::class);
|
||||
$this->serverRepository = m::mock(ServerRepositoryInterface::class);
|
||||
|
||||
$this->service = new OptionDeletionService($this->serverRepository, $this->repository);
|
||||
$this->service = new EggDeletionService($this->serverRepository, $this->repository);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,8 +13,8 @@ use Exception;
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Services\Services\Options\EggUpdateService;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Services\Services\Options\OptionUpdateService;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
|
||||
|
||||
class OptionUpdateServiceTest extends TestCase
|
||||
@ -30,7 +30,7 @@ class OptionUpdateServiceTest extends TestCase
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Services\Options\OptionUpdateService
|
||||
* @var \Pterodactyl\Services\Services\Options\EggUpdateService
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
@ -44,7 +44,7 @@ class OptionUpdateServiceTest extends TestCase
|
||||
$this->model = factory(Egg::class)->make();
|
||||
$this->repository = m::mock(EggRepositoryInterface::class);
|
||||
|
||||
$this->service = new OptionUpdateService($this->repository);
|
||||
$this->service = new EggUpdateService($this->repository);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user