Begin updating UI
This commit is contained in:
parent
493c5888a3
commit
ae671e6b19
22 changed files with 182 additions and 102 deletions
|
@ -9,7 +9,9 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Service;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Services\ServiceUpdateService;
|
||||
|
@ -46,6 +48,15 @@ class ServiceController extends Controller
|
|||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* ServiceController constructor.
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Services\Services\ServiceCreationService $creationService
|
||||
* @param \Pterodactyl\Services\Services\ServiceDeletionService $deletionService
|
||||
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Services\Services\ServiceUpdateService $updateService
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
ServiceCreationService $creationService,
|
||||
|
@ -65,10 +76,10 @@ class ServiceController extends Controller
|
|||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.services.index', [
|
||||
'services' => $this->repository->getWithOptions(),
|
||||
'services' => $this->repository->getWithCounts(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -77,7 +88,7 @@ class ServiceController extends Controller
|
|||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
public function create(): View
|
||||
{
|
||||
return view('admin.services.new');
|
||||
}
|
||||
|
@ -88,7 +99,7 @@ class ServiceController extends Controller
|
|||
* @param int $service
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function view($service)
|
||||
public function view(int $service): View
|
||||
{
|
||||
return view('admin.services.view', [
|
||||
'service' => $this->repository->getWithOptionServers($service),
|
||||
|
@ -101,7 +112,7 @@ class ServiceController extends Controller
|
|||
* @param \Pterodactyl\Models\Service $service
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function viewFunctions(Service $service)
|
||||
public function viewFunctions(Service $service): View
|
||||
{
|
||||
return view('admin.services.functions', ['service' => $service]);
|
||||
}
|
||||
|
@ -114,7 +125,7 @@ class ServiceController extends Controller
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(ServiceFormRequest $request)
|
||||
public function store(ServiceFormRequest $request): RedirectResponse
|
||||
{
|
||||
$service = $this->creationService->handle($request->normalize());
|
||||
$this->alert->success(trans('admin/services.notices.service_created', ['name' => $service->name]))->flash();
|
||||
|
@ -132,7 +143,7 @@ class ServiceController extends Controller
|
|||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(ServiceFormRequest $request, Service $service)
|
||||
public function update(ServiceFormRequest $request, Service $service): RedirectResponse
|
||||
{
|
||||
$this->updateService->handle($service->id, $request->normalize());
|
||||
$this->alert->success(trans('admin/services.notices.service_updated'))->flash();
|
||||
|
@ -150,7 +161,7 @@ class ServiceController extends Controller
|
|||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function updateFunctions(ServiceFunctionsFormRequest $request, Service $service)
|
||||
public function updateFunctions(ServiceFunctionsFormRequest $request, Service $service): RedirectResponse
|
||||
{
|
||||
$this->updateService->handle($service->id, $request->normalize());
|
||||
$this->alert->success(trans('admin/services.notices.functions_updated'))->flash();
|
||||
|
@ -166,7 +177,7 @@ class ServiceController extends Controller
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function destroy(Service $service)
|
||||
public function destroy(Service $service): RedirectResponse
|
||||
{
|
||||
$this->deletionService->handle($service->id);
|
||||
$this->alert->success(trans('admin/services.notices.service_deleted'))->flash();
|
||||
|
|
|
@ -13,7 +13,12 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||
|
||||
abstract class AdminFormRequest extends FormRequest
|
||||
{
|
||||
abstract public function rules();
|
||||
/**
|
||||
* The rules to apply to the incoming form request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function rules(): array;
|
||||
|
||||
/**
|
||||
* Determine if the user is an admin and has permission to access this
|
||||
|
@ -21,7 +26,7 @@ abstract class AdminFormRequest extends FormRequest
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (is_null($this->user())) {
|
||||
return false;
|
||||
|
@ -37,7 +42,7 @@ abstract class AdminFormRequest extends FormRequest
|
|||
* @param array $only
|
||||
* @return array
|
||||
*/
|
||||
public function normalize($only = [])
|
||||
public function normalize($only = []): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->only($only),
|
||||
|
|
|
@ -16,22 +16,12 @@ class ServiceFormRequest extends AdminFormRequest
|
|||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'name' => 'required|string|min:1|max:255',
|
||||
'description' => 'required|nullable|string',
|
||||
'folder' => 'required|regex:/^[\w.-]{1,50}$/|unique:services,folder',
|
||||
'startup' => 'required|nullable|string',
|
||||
];
|
||||
|
||||
if ($this->method() === 'PATCH') {
|
||||
$service = $this->route()->parameter('service');
|
||||
$rules['folder'] = $rules['folder'] . ',' . $service->id;
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue