Nest & Egg management working through the ACP now.
This commit is contained in:
parent
df87ea0867
commit
6b8464ea3a
32 changed files with 616 additions and 566 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue