Cleanup code, add basic functionality for Nests
This commit is contained in:
parent
6c85be72fa
commit
88ac1ce1fd
37 changed files with 331 additions and 159 deletions
|
@ -113,6 +113,6 @@ class ApiController extends Controller
|
||||||
{
|
{
|
||||||
$this->repository->deleteApplicationKey($request->user(), $identifier);
|
$this->repository->deleteApplicationKey($request->user(), $identifier);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ class MountController extends Controller
|
||||||
{
|
{
|
||||||
$mount->eggs()->detach($egg_id);
|
$mount->eggs()->detach($egg_id);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,6 +219,6 @@ class MountController extends Controller
|
||||||
{
|
{
|
||||||
$mount->nodes()->detach($node_id);
|
$mount->nodes()->detach($node_id);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ class NodesController extends Controller
|
||||||
{
|
{
|
||||||
$this->allocationDeletionService->handle($allocation);
|
$this->allocationDeletionService->handle($allocation);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,7 +222,7 @@ class NodesController extends Controller
|
||||||
$this->allocationRemoveSingle($node, $allocation);
|
$this->allocationRemoveSingle($node, $allocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,7 +261,7 @@ class NodesController extends Controller
|
||||||
'ip_alias' => (empty($request->input('alias'))) ? null : $request->input('alias'),
|
'ip_alias' => (empty($request->input('alias'))) ? null : $request->input('alias'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -395,7 +395,7 @@ class ServersController extends Controller
|
||||||
|
|
||||||
$this->databasePasswordService->handle($database);
|
$this->databasePasswordService->handle($database);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,7 +417,7 @@ class ServersController extends Controller
|
||||||
|
|
||||||
$this->databaseManagementService->delete($database);
|
$this->databaseManagementService->delete($database);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -112,7 +112,7 @@ class MailController extends Controller
|
||||||
|
|
||||||
$this->kernel->call('queue:restart');
|
$this->kernel->call('queue:restart');
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,6 +130,6 @@ class MailController extends Controller
|
||||||
return response($exception->getMessage(), 500);
|
return response($exception->getMessage(), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,9 @@ abstract class ApplicationApiController extends Controller
|
||||||
* Return an instance of an application transformer.
|
* Return an instance of an application transformer.
|
||||||
*
|
*
|
||||||
* @param string $abstract
|
* @param string $abstract
|
||||||
|
*
|
||||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function getTransformer(string $abstract)
|
public function getTransformer(string $abstract)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Http\Controllers\Api\Application\Locations;
|
namespace Pterodactyl\Http\Controllers\Api\Application\Locations;
|
||||||
|
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use Pterodactyl\Models\Location;
|
use Pterodactyl\Models\Location;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Spatie\QueryBuilder\QueryBuilder;
|
use Spatie\QueryBuilder\QueryBuilder;
|
||||||
|
@ -66,7 +65,9 @@ class LocationController extends ApplicationApiController
|
||||||
* Return all of the locations currently registered on the Panel.
|
* Return all of the locations currently registered on the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationsRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationsRequest $request
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetLocationsRequest $request): array
|
public function index(GetLocationsRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -84,11 +85,14 @@ class LocationController extends ApplicationApiController
|
||||||
* Return a single location.
|
* Return a single location.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest $request
|
||||||
|
* @param \Pterodactyl\Models\Location $location
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetLocationRequest $request): array
|
public function view(GetLocationRequest $request, Location $location): array
|
||||||
{
|
{
|
||||||
return $this->fractal->item($request->getModel(Location::class))
|
return $this->fractal->item($location)
|
||||||
->transformWith($this->getTransformer(LocationTransformer::class))
|
->transformWith($this->getTransformer(LocationTransformer::class))
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
@ -98,9 +102,11 @@ class LocationController extends ApplicationApiController
|
||||||
* new location attached.
|
* new location attached.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\StoreLocationRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\StoreLocationRequest $request
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function store(StoreLocationRequest $request): JsonResponse
|
public function store(StoreLocationRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -120,14 +126,17 @@ class LocationController extends ApplicationApiController
|
||||||
* Update a location on the Panel and return the updated record to the user.
|
* Update a location on the Panel and return the updated record to the user.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest $request
|
||||||
|
* @param \Pterodactyl\Models\Location $location
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function update(UpdateLocationRequest $request): array
|
public function update(UpdateLocationRequest $request, Location $location): array
|
||||||
{
|
{
|
||||||
$location = $this->updateService->handle($request->getModel(Location::class), $request->validated());
|
$location = $this->updateService->handle($location, $request->validated());
|
||||||
|
|
||||||
return $this->fractal->item($location)
|
return $this->fractal->item($location)
|
||||||
->transformWith($this->getTransformer(LocationTransformer::class))
|
->transformWith($this->getTransformer(LocationTransformer::class))
|
||||||
|
@ -138,14 +147,16 @@ class LocationController extends ApplicationApiController
|
||||||
* Delete a location from the Panel.
|
* Delete a location from the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\DeleteLocationRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\DeleteLocationRequest $request
|
||||||
* @return \Illuminate\Http\Response
|
* @param \Pterodactyl\Models\Location $location
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
|
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
|
||||||
*/
|
*/
|
||||||
public function delete(DeleteLocationRequest $request): Response
|
public function delete(DeleteLocationRequest $request, Location $location): JsonResponse
|
||||||
{
|
{
|
||||||
$this->deletionService->handle($request->getModel(Location::class));
|
$this->deletionService->handle($location);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,15 @@ class EggController extends ApplicationApiController
|
||||||
* Return all eggs that exist for a given nest.
|
* Return all eggs that exist for a given nest.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggsRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggsRequest $request
|
||||||
|
* @param \Pterodactyl\Models\Nest $nest
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetEggsRequest $request): array
|
public function index(GetEggsRequest $request, Nest $nest): array
|
||||||
{
|
{
|
||||||
$eggs = $this->repository->findWhere([
|
$eggs = $this->repository->findWhere([
|
||||||
['nest_id', '=', $request->getModel(Nest::class)->id],
|
['nest_id', '=', $nest->id],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->fractal->collection($eggs)
|
return $this->fractal->collection($eggs)
|
||||||
|
@ -50,11 +53,14 @@ class EggController extends ApplicationApiController
|
||||||
* Return a single egg that exists on the specified nest.
|
* Return a single egg that exists on the specified nest.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggRequest $request
|
||||||
|
* @param \Pterodactyl\Models\Egg $egg
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetEggRequest $request): array
|
public function view(GetEggRequest $request, Egg $egg): array
|
||||||
{
|
{
|
||||||
return $this->fractal->item($request->getModel(Egg::class))
|
return $this->fractal->item($egg)
|
||||||
->transformWith($this->getTransformer(EggTransformer::class))
|
->transformWith($this->getTransformer(EggTransformer::class))
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ class NestController extends ApplicationApiController
|
||||||
* Return all Nests that exist on the Panel.
|
* Return all Nests that exist on the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetNestsRequest $request): array
|
public function index(GetNestsRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -46,11 +48,14 @@ class NestController extends ApplicationApiController
|
||||||
* Return information about a single Nest model.
|
* Return information about a single Nest model.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
||||||
|
* @param \Pterodactyl\Models\Nest $nest
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetNestsRequest $request): array
|
public function view(GetNestsRequest $request, Nest $nest): array
|
||||||
{
|
{
|
||||||
return $this->fractal->item($request->getModel(Nest::class))
|
return $this->fractal->item($nest)
|
||||||
->transformWith($this->getTransformer(NestTransformer::class))
|
->transformWith($this->getTransformer(NestTransformer::class))
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,9 @@ class AllocationController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Allocations\GetAllocationsRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Allocations\GetAllocationsRequest $request
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetAllocationsRequest $request, Node $node): array
|
public function index(GetAllocationsRequest $request, Node $node): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,6 @@ class NodeConfigurationController extends ApplicationApiController
|
||||||
*/
|
*/
|
||||||
public function __invoke(GetNodeRequest $request, Node $node)
|
public function __invoke(GetNodeRequest $request, Node $node)
|
||||||
{
|
{
|
||||||
return JsonResponse::create($node->getConfiguration());
|
return new JsonResponse($node->getConfiguration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,9 @@ class NodeController extends ApplicationApiController
|
||||||
* Return all of the nodes currently available on the Panel.
|
* Return all of the nodes currently available on the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest $request
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetNodesRequest $request): array
|
public function index(GetNodesRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -84,7 +86,9 @@ class NodeController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetNodeRequest $request, Node $node): array
|
public function view(GetNodeRequest $request, Node $node): array
|
||||||
{
|
{
|
||||||
|
@ -98,9 +102,10 @@ class NodeController extends ApplicationApiController
|
||||||
* status response on success.
|
* status response on success.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\StoreNodeRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\StoreNodeRequest $request
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException*@throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function store(StoreNodeRequest $request): JsonResponse
|
public function store(StoreNodeRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -121,6 +126,7 @@ class NodeController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\UpdateNodeRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\UpdateNodeRequest $request
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
@ -142,6 +148,7 @@ class NodeController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\DeleteNodeRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\DeleteNodeRequest $request
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||||
|
|
|
@ -37,8 +37,9 @@ class RoleController extends ApplicationApiController
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Roles\GetRolesRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Roles\GetRolesRequest $request
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetRolesRequest $request)
|
public function index(GetRolesRequest $request): array
|
||||||
{
|
{
|
||||||
return $this->fractal->collection(AdminRole::all())
|
return $this->fractal->collection(AdminRole::all())
|
||||||
->transformWith($this->getTransformer(AdminRoleTransformer::class))
|
->transformWith($this->getTransformer(AdminRoleTransformer::class))
|
||||||
|
@ -52,6 +53,7 @@ class RoleController extends ApplicationApiController
|
||||||
* @param \Pterodactyl\Models\AdminRole $role
|
* @param \Pterodactyl\Models\AdminRole $role
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetRolesRequest $request, AdminRole $role): array
|
public function view(GetRolesRequest $request, AdminRole $role): array
|
||||||
{
|
{
|
||||||
|
@ -66,8 +68,9 @@ class RoleController extends ApplicationApiController
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Roles\StoreRoleRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Roles\StoreRoleRequest $request
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function store(StoreRoleRequest $request)
|
public function store(StoreRoleRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$role = AdminRole::query()->create($request->validated());
|
$role = AdminRole::query()->create($request->validated());
|
||||||
|
|
||||||
|
@ -83,8 +86,9 @@ class RoleController extends ApplicationApiController
|
||||||
* @param \Pterodactyl\Models\AdminRole $role
|
* @param \Pterodactyl\Models\AdminRole $role
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function update(UpdateRoleRequest $request, AdminRole $role)
|
public function update(UpdateRoleRequest $request, AdminRole $role): array
|
||||||
{
|
{
|
||||||
$role->update($request->validated());
|
$role->update($request->validated());
|
||||||
|
|
||||||
|
@ -101,7 +105,7 @@ class RoleController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function delete(DeleteRoleRequest $request, AdminRole $role)
|
public function delete(DeleteRoleRequest $request, AdminRole $role): JsonResponse
|
||||||
{
|
{
|
||||||
$this->repository->delete($role->id);
|
$this->repository->delete($role->id);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ class DatabaseController extends ApplicationApiController
|
||||||
DatabaseManagementService $databaseManagementService,
|
DatabaseManagementService $databaseManagementService,
|
||||||
DatabasePasswordService $databasePasswordService,
|
DatabasePasswordService $databasePasswordService,
|
||||||
DatabaseRepositoryInterface $repository
|
DatabaseRepositoryInterface $repository
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->databaseManagementService = $databaseManagementService;
|
$this->databaseManagementService = $databaseManagementService;
|
||||||
|
@ -58,7 +59,9 @@ class DatabaseController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetServerDatabasesRequest $request, Server $server): array
|
public function index(GetServerDatabasesRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
@ -73,7 +76,9 @@ class DatabaseController extends ApplicationApiController
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
* @param \Pterodactyl\Models\Database $database
|
* @param \Pterodactyl\Models\Database $database
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
|
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
|
||||||
{
|
{
|
||||||
|
@ -88,6 +93,7 @@ class DatabaseController extends ApplicationApiController
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
* @param \Pterodactyl\Models\Database $database
|
* @param \Pterodactyl\Models\Database $database
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
@ -96,7 +102,7 @@ class DatabaseController extends ApplicationApiController
|
||||||
{
|
{
|
||||||
$this->databasePasswordService->handle($database);
|
$this->databasePasswordService->handle($database);
|
||||||
|
|
||||||
return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,6 +110,7 @@ class DatabaseController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
@ -129,14 +136,16 @@ class DatabaseController extends ApplicationApiController
|
||||||
* Handle a request to delete a specific server database from the Panel.
|
* Handle a request to delete a specific server database from the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
||||||
* @return \Illuminate\Http\Response
|
* @param \Pterodactyl\Models\Database $database
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function delete(ServerDatabaseWriteRequest $request): Response
|
public function delete(ServerDatabaseWriteRequest $request, Database $database): JsonResponse
|
||||||
{
|
{
|
||||||
$this->databaseManagementService->delete($request->getModel(Database::class));
|
$this->databaseManagementService->delete($database);
|
||||||
|
|
||||||
return response('', 204);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,9 @@ class ExternalServerController extends ApplicationApiController
|
||||||
* Retrieve a specific server from the database using its external ID.
|
* Retrieve a specific server from the database using its external ID.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetExternalServerRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetExternalServerRequest $request
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetExternalServerRequest $request): array
|
public function index(GetExternalServerRequest $request): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,12 +22,10 @@ class ServerController extends ApplicationApiController
|
||||||
* @var \Pterodactyl\Services\Servers\ServerCreationService
|
* @var \Pterodactyl\Services\Servers\ServerCreationService
|
||||||
*/
|
*/
|
||||||
private $creationService;
|
private $creationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Pterodactyl\Services\Servers\ServerDeletionService
|
* @var \Pterodactyl\Services\Servers\ServerDeletionService
|
||||||
*/
|
*/
|
||||||
private $deletionService;
|
private $deletionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +42,8 @@ class ServerController extends ApplicationApiController
|
||||||
ServerCreationService $creationService,
|
ServerCreationService $creationService,
|
||||||
ServerDeletionService $deletionService,
|
ServerDeletionService $deletionService,
|
||||||
ServerRepositoryInterface $repository
|
ServerRepositoryInterface $repository
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->creationService = $creationService;
|
$this->creationService = $creationService;
|
||||||
|
@ -56,7 +55,9 @@ class ServerController extends ApplicationApiController
|
||||||
* Return all of the servers that currently exist on the Panel.
|
* Return all of the servers that currently exist on the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest $request
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetServersRequest $request): array
|
public function index(GetServersRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -74,12 +75,12 @@ class ServerController extends ApplicationApiController
|
||||||
* Create a new server on the system.
|
* Create a new server on the system.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\StoreServerRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\StoreServerRequest $request
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException
|
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
||||||
|
@ -97,22 +98,28 @@ class ServerController extends ApplicationApiController
|
||||||
* Show a single server transformed for the application API.
|
* Show a single server transformed for the application API.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest $request
|
||||||
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetServerRequest $request): array
|
public function view(GetServerRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
return $this->fractal->item($request->getModel(Server::class))
|
return $this->fractal->item($server)
|
||||||
->transformWith($this->getTransformer(ServerTransformer::class))
|
->transformWith($this->getTransformer(ServerTransformer::class))
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Deletes a server.
|
||||||
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
* @param string $force
|
* @param string $force
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
|
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,16 +42,17 @@ class ServerDetailsController extends ApplicationApiController
|
||||||
* Update the details for a specific server.
|
* Update the details for a specific server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest $request
|
||||||
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Throwable
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function details(UpdateServerDetailsRequest $request): array
|
public function details(UpdateServerDetailsRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
$server = $this->detailsModificationService->returnUpdatedModel()->handle(
|
$server = $this->detailsModificationService->returnUpdatedModel()->handle(
|
||||||
$request->getModel(Server::class), $request->validated()
|
$server, $request->validated()
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->fractal->item($server)
|
return $this->fractal->item($server)
|
||||||
|
@ -64,11 +65,11 @@ class ServerDetailsController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
|
* @throws \Throwable
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
|
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,7 @@ class ServerManagementController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
@ -58,6 +59,7 @@ class ServerManagementController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
@ -74,11 +76,10 @@ class ServerManagementController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Throwable
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function reinstall(ServerWriteRequest $request, Server $server): Response
|
public function reinstall(ServerWriteRequest $request, Server $server): Response
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,18 +32,16 @@ class StartupController extends ApplicationApiController
|
||||||
* Update the startup and environment settings for a specific server.
|
* Update the startup and environment settings for a specific server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest $request
|
||||||
* @return array
|
* @param \Pterodactyl\Models\Server $server
|
||||||
*
|
*
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @return array
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Throwable
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function index(UpdateServerStartupRequest $request): array
|
public function index(UpdateServerStartupRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
$server = $this->modificationService
|
$server = $this->modificationService
|
||||||
->setUserLevel(User::USER_LEVEL_ADMIN)
|
->setUserLevel(User::USER_LEVEL_ADMIN)
|
||||||
->handle($request->getModel(Server::class), $request->validated());
|
->handle($server, $request->validated());
|
||||||
|
|
||||||
return $this->fractal->item($server)
|
return $this->fractal->item($server)
|
||||||
->transformWith($this->getTransformer(ServerTransformer::class))
|
->transformWith($this->getTransformer(ServerTransformer::class))
|
||||||
|
|
|
@ -12,7 +12,9 @@ class ExternalUserController extends ApplicationApiController
|
||||||
* Retrieve a specific user from the database using their external ID.
|
* Retrieve a specific user from the database using their external ID.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetExternalUserRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetExternalUserRequest $request
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetExternalUserRequest $request): array
|
public function index(GetExternalUserRequest $request): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace Pterodactyl\Http\Controllers\Api\Application\Users;
|
namespace Pterodactyl\Http\Controllers\Api\Application\Users;
|
||||||
|
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Spatie\QueryBuilder\QueryBuilder;
|
use Spatie\QueryBuilder\QueryBuilder;
|
||||||
use Pterodactyl\Services\Users\UserUpdateService;
|
use Pterodactyl\Services\Users\UserUpdateService;
|
||||||
|
@ -52,7 +51,8 @@ class UserController extends ApplicationApiController
|
||||||
UserCreationService $creationService,
|
UserCreationService $creationService,
|
||||||
UserDeletionService $deletionService,
|
UserDeletionService $deletionService,
|
||||||
UserUpdateService $updateService
|
UserUpdateService $updateService
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->creationService = $creationService;
|
$this->creationService = $creationService;
|
||||||
|
@ -67,7 +67,9 @@ class UserController extends ApplicationApiController
|
||||||
* the request.
|
* the request.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest $request
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function index(GetUsersRequest $request): array
|
public function index(GetUsersRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -87,7 +89,9 @@ class UserController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest $request
|
||||||
* @param \Pterodactyl\Models\User $user
|
* @param \Pterodactyl\Models\User $user
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function view(GetUsersRequest $request, User $user): array
|
public function view(GetUsersRequest $request, User $user): array
|
||||||
{
|
{
|
||||||
|
@ -106,10 +110,12 @@ class UserController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\UpdateUserRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Users\UpdateUserRequest $request
|
||||||
* @param \Pterodactyl\Models\User $user
|
* @param \Pterodactyl\Models\User $user
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function update(UpdateUserRequest $request, User $user): array
|
public function update(UpdateUserRequest $request, User $user): array
|
||||||
{
|
{
|
||||||
|
@ -127,6 +133,7 @@ class UserController extends ApplicationApiController
|
||||||
* header on successful creation.
|
* header on successful creation.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest $request
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
@ -152,6 +159,7 @@ class UserController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\DeleteUserRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Users\DeleteUserRequest $request
|
||||||
* @param \Pterodactyl\Models\User $user
|
* @param \Pterodactyl\Models\User $user
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
|
|
|
@ -29,6 +29,7 @@ class GetExternalUserRequest extends ApplicationApiRequest
|
||||||
* Determine if the requested external user exists.
|
* Determine if the requested external user exists.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,15 +19,15 @@ class AdminRoleTransformer extends BaseTransformer
|
||||||
/**
|
/**
|
||||||
* Return a transformed User model that can be consumed by external services.
|
* Return a transformed User model that can be consumed by external services.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\AdminRole $role
|
* @param \Pterodactyl\Models\AdminRole $model
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform(AdminRole $role): array
|
public function transform(AdminRole $model): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $role->id,
|
'id' => $model->id,
|
||||||
'name' => $role->name,
|
'name' => $model->name,
|
||||||
'description' => $role->description,
|
'description' => $model->description,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,18 +29,19 @@ class AllocationTransformer extends BaseTransformer
|
||||||
/**
|
/**
|
||||||
* Return a generic transformed allocation array.
|
* Return a generic transformed allocation array.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Allocation $allocation
|
* @param \Pterodactyl\Models\Allocation $model
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform(Allocation $allocation)
|
public function transform(Allocation $model)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $allocation->id,
|
'id' => $model->id,
|
||||||
'ip' => $allocation->ip,
|
'ip' => $model->ip,
|
||||||
'alias' => $allocation->ip_alias,
|
'alias' => $model->ip_alias,
|
||||||
'port' => $allocation->port,
|
'port' => $model->port,
|
||||||
'notes' => $allocation->notes,
|
'notes' => $model->notes,
|
||||||
'assigned' => ! is_null($allocation->server_id),
|
'assigned' => ! is_null($model->server_id),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +49,10 @@ class AllocationTransformer extends BaseTransformer
|
||||||
* Load the node relationship onto a given transformation.
|
* Load the node relationship onto a given transformation.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Allocation $allocation
|
* @param \Pterodactyl\Models\Allocation $allocation
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeNode(Allocation $allocation)
|
public function includeNode(Allocation $allocation)
|
||||||
{
|
{
|
||||||
|
@ -66,8 +69,10 @@ class AllocationTransformer extends BaseTransformer
|
||||||
* Load the server relationship onto a given transformation.
|
* Load the server relationship onto a given transformation.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Allocation $allocation
|
* @param \Pterodactyl\Models\Allocation $allocation
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeServer(Allocation $allocation)
|
public function includeServer(Allocation $allocation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
* Set the HTTP request class being used for this request.
|
* Set the HTTP request class being used for this request.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\ApiKey $key
|
* @param \Pterodactyl\Models\ApiKey $key
|
||||||
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setKey(ApiKey $key)
|
public function setKey(ApiKey $key)
|
||||||
|
@ -69,6 +70,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
* models on a transformation request.
|
* models on a transformation request.
|
||||||
*
|
*
|
||||||
* @param string $resource
|
* @param string $resource
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorize(string $resource): bool
|
protected function authorize(string $resource): bool
|
||||||
|
@ -82,8 +84,10 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
*
|
*
|
||||||
* @param string $abstract
|
* @param string $abstract
|
||||||
* @param array $parameters
|
* @param array $parameters
|
||||||
|
*
|
||||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||||
*
|
*
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
*/
|
*/
|
||||||
protected function makeTransformer(string $abstract, array $parameters = [])
|
protected function makeTransformer(string $abstract, array $parameters = [])
|
||||||
|
@ -103,6 +107,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
* Return an ISO-8601 formatted timestamp to use in the API response.
|
* Return an ISO-8601 formatted timestamp to use in the API response.
|
||||||
*
|
*
|
||||||
* @param string $timestamp
|
* @param string $timestamp
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function formatTimestamp(string $timestamp): string
|
protected function formatTimestamp(string $timestamp): string
|
||||||
|
|
|
@ -30,6 +30,7 @@ class DatabaseHostTransformer extends BaseTransformer
|
||||||
* Transform database host into a representation for the application API.
|
* Transform database host into a representation for the application API.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\DatabaseHost $model
|
* @param \Pterodactyl\Models\DatabaseHost $model
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform(DatabaseHost $model)
|
public function transform(DatabaseHost $model)
|
||||||
|
@ -54,6 +55,7 @@ class DatabaseHostTransformer extends BaseTransformer
|
||||||
* Include the databases associated with this host.
|
* Include the databases associated with this host.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\DatabaseHost $model
|
* @param \Pterodactyl\Models\DatabaseHost $model
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,6 +34,7 @@ class EggTransformer extends BaseTransformer
|
||||||
* the application api.
|
* the application api.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Egg $model
|
* @param \Pterodactyl\Models\Egg $model
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform(Egg $model)
|
public function transform(Egg $model)
|
||||||
|
@ -74,8 +75,10 @@ class EggTransformer extends BaseTransformer
|
||||||
* Include the Nest relationship for the given Egg in the transformation.
|
* Include the Nest relationship for the given Egg in the transformation.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Egg $model
|
* @param \Pterodactyl\Models\Egg $model
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeNest(Egg $model)
|
public function includeNest(Egg $model)
|
||||||
{
|
{
|
||||||
|
@ -92,8 +95,10 @@ class EggTransformer extends BaseTransformer
|
||||||
* Include the Servers relationship for the given Egg in the transformation.
|
* Include the Servers relationship for the given Egg in the transformation.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Egg $model
|
* @param \Pterodactyl\Models\Egg $model
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeServers(Egg $model)
|
public function includeServers(Egg $model)
|
||||||
{
|
{
|
||||||
|
@ -111,6 +116,7 @@ class EggTransformer extends BaseTransformer
|
||||||
* extending another.
|
* extending another.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Egg $model
|
* @param \Pterodactyl\Models\Egg $model
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
*/
|
*/
|
||||||
public function includeConfig(Egg $model)
|
public function includeConfig(Egg $model)
|
||||||
|
@ -136,6 +142,7 @@ class EggTransformer extends BaseTransformer
|
||||||
* Egg is extending another.
|
* Egg is extending another.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Egg $model
|
* @param \Pterodactyl\Models\Egg $model
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
*/
|
*/
|
||||||
public function includeScript(Egg $model)
|
public function includeScript(Egg $model)
|
||||||
|
@ -160,8 +167,10 @@ class EggTransformer extends BaseTransformer
|
||||||
* Include the variables that are defined for this Egg.
|
* Include the variables that are defined for this Egg.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Egg $model
|
* @param \Pterodactyl\Models\Egg $model
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeVariables(Egg $model)
|
public function includeVariables(Egg $model)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,17 +27,17 @@ class LocationTransformer extends BaseTransformer
|
||||||
/**
|
/**
|
||||||
* Return a generic transformed location array.
|
* Return a generic transformed location array.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Location $location
|
* @param \Pterodactyl\Models\Location $model
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform(Location $location): array
|
public function transform(Location $model): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $location->id,
|
'id' => $model->id,
|
||||||
'short' => $location->short,
|
'short' => $model->short,
|
||||||
'long' => $location->long,
|
'long' => $model->long,
|
||||||
$location->getUpdatedAtColumn() => $this->formatTimestamp($location->updated_at),
|
$model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at),
|
||||||
$location->getCreatedAtColumn() => $this->formatTimestamp($location->created_at),
|
$model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,13 @@ class NodeTransformer extends BaseTransformer
|
||||||
* Return a node transformed into a format that can be consumed by the
|
* Return a node transformed into a format that can be consumed by the
|
||||||
* external administrative API.
|
* external administrative API.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $model
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform(Node $node): array
|
public function transform(Node $model): array
|
||||||
{
|
{
|
||||||
$response = collect($node->toArray())->mapWithKeys(function ($value, $key) {
|
$response = collect($model->toArray())->mapWithKeys(function ($value, $key) {
|
||||||
// I messed up early in 2016 when I named this column as poorly
|
// I messed up early in 2016 when I named this column as poorly
|
||||||
// as I did. This is the tragic result of my mistakes.
|
// as I did. This is the tragic result of my mistakes.
|
||||||
$key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key;
|
$key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key;
|
||||||
|
@ -41,10 +42,10 @@ class NodeTransformer extends BaseTransformer
|
||||||
return [snake_case($key) => $value];
|
return [snake_case($key) => $value];
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
$response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at);
|
$response[$model->getUpdatedAtColumn()] = $this->formatTimestamp($model->updated_at);
|
||||||
$response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at);
|
$response[$model->getCreatedAtColumn()] = $this->formatTimestamp($model->created_at);
|
||||||
|
|
||||||
$resources = $node->servers()->select(['memory', 'disk'])->get();
|
$resources = $model->servers()->select(['memory', 'disk'])->get();
|
||||||
|
|
||||||
$response['allocated_resources'] = [
|
$response['allocated_resources'] = [
|
||||||
'memory' => $resources->sum('memory'),
|
'memory' => $resources->sum('memory'),
|
||||||
|
@ -58,8 +59,10 @@ class NodeTransformer extends BaseTransformer
|
||||||
* Return the nodes associated with this location.
|
* Return the nodes associated with this location.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeAllocations(Node $node)
|
public function includeAllocations(Node $node)
|
||||||
{
|
{
|
||||||
|
@ -78,8 +81,10 @@ class NodeTransformer extends BaseTransformer
|
||||||
* Return the nodes associated with this location.
|
* Return the nodes associated with this location.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeLocation(Node $node)
|
public function includeLocation(Node $node)
|
||||||
{
|
{
|
||||||
|
@ -98,8 +103,10 @@ class NodeTransformer extends BaseTransformer
|
||||||
* Return the nodes associated with this location.
|
* Return the nodes associated with this location.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeServers(Node $node)
|
public function includeServers(Node $node)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,45 +54,46 @@ class ServerTransformer extends BaseTransformer
|
||||||
/**
|
/**
|
||||||
* Return a generic transformed server array.
|
* Return a generic transformed server array.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $model
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform(Server $server): array
|
public function transform(Server $model): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $server->getKey(),
|
'id' => $model->getKey(),
|
||||||
'external_id' => $server->external_id,
|
'external_id' => $model->external_id,
|
||||||
'uuid' => $server->uuid,
|
'uuid' => $model->uuid,
|
||||||
'identifier' => $server->uuidShort,
|
'identifier' => $model->uuidShort,
|
||||||
'name' => $server->name,
|
'name' => $model->name,
|
||||||
'description' => $server->description,
|
'description' => $model->description,
|
||||||
'suspended' => (bool) $server->suspended,
|
'suspended' => (bool) $model->suspended,
|
||||||
'limits' => [
|
'limits' => [
|
||||||
'memory' => $server->memory,
|
'memory' => $model->memory,
|
||||||
'swap' => $server->swap,
|
'swap' => $model->swap,
|
||||||
'disk' => $server->disk,
|
'disk' => $model->disk,
|
||||||
'io' => $server->io,
|
'io' => $model->io,
|
||||||
'cpu' => $server->cpu,
|
'cpu' => $model->cpu,
|
||||||
'threads' => $server->threads,
|
'threads' => $model->threads,
|
||||||
],
|
],
|
||||||
'feature_limits' => [
|
'feature_limits' => [
|
||||||
'databases' => $server->database_limit,
|
'databases' => $model->database_limit,
|
||||||
'allocations' => $server->allocation_limit,
|
'allocations' => $model->allocation_limit,
|
||||||
'backups' => $server->backup_limit,
|
'backups' => $model->backup_limit,
|
||||||
],
|
],
|
||||||
'user' => $server->owner_id,
|
'user' => $model->owner_id,
|
||||||
'node' => $server->node_id,
|
'node' => $model->node_id,
|
||||||
'allocation' => $server->allocation_id,
|
'allocation' => $model->allocation_id,
|
||||||
'nest' => $server->nest_id,
|
'nest' => $model->nest_id,
|
||||||
'egg' => $server->egg_id,
|
'egg' => $model->egg_id,
|
||||||
'container' => [
|
'container' => [
|
||||||
'startup_command' => $server->startup,
|
'startup_command' => $model->startup,
|
||||||
'image' => $server->image,
|
'image' => $model->image,
|
||||||
'installed' => (int) $server->installed === 1,
|
'installed' => (int) $model->installed === 1,
|
||||||
'environment' => $this->environmentService->handle($server),
|
'environment' => $this->environmentService->handle($model),
|
||||||
],
|
],
|
||||||
$server->getUpdatedAtColumn() => $this->formatTimestamp($server->updated_at),
|
$model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at),
|
||||||
$server->getCreatedAtColumn() => $this->formatTimestamp($server->created_at),
|
$model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +101,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array of allocations for this server.
|
* Return a generic array of allocations for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeAllocations(Server $server)
|
public function includeAllocations(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -119,9 +122,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array of data about subusers for this server.
|
* Return a generic array of data about subusers for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeSubusers(Server $server)
|
public function includeSubusers(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -138,9 +143,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array of data about subusers for this server.
|
* Return a generic array of data about subusers for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeUser(Server $server)
|
public function includeUser(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -157,9 +164,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array with nest information for this server.
|
* Return a generic array with nest information for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeNest(Server $server)
|
public function includeNest(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -176,9 +185,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array with egg information for this server.
|
* Return a generic array with egg information for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeEgg(Server $server)
|
public function includeEgg(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -195,9 +206,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array of data about subusers for this server.
|
* Return a generic array of data about subusers for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeVariables(Server $server)
|
public function includeVariables(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -214,9 +227,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array with location information for this server.
|
* Return a generic array with location information for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeLocation(Server $server)
|
public function includeLocation(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -233,9 +248,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array with node information for this server.
|
* Return a generic array with node information for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeNode(Server $server)
|
public function includeNode(Server $server)
|
||||||
{
|
{
|
||||||
|
@ -252,9 +269,11 @@ class ServerTransformer extends BaseTransformer
|
||||||
* Return a generic array with database information for this server.
|
* Return a generic array with database information for this server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function includeDatabases(Server $server)
|
public function includeDatabases(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ import React from 'react';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import tw from 'twin.macro';
|
import tw from 'twin.macro';
|
||||||
|
|
||||||
const Checkbox = styled(Input)`
|
export const TableCheckbox = styled(Input)`
|
||||||
&& {
|
&& {
|
||||||
${tw`border-neutral-500 bg-transparent`};
|
${tw`border-neutral-500 bg-transparent`};
|
||||||
|
|
||||||
|
@ -13,12 +13,14 @@ const Checkbox = styled(Input)`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default ({ name }: { name: string }) => {
|
export default ({ name, checked, onChange }: { name: string, checked: boolean, onChange(e: React.ChangeEvent<HTMLInputElement>): void }) => {
|
||||||
return (
|
return (
|
||||||
<Checkbox
|
<TableCheckbox
|
||||||
|
type={'checkbox'}
|
||||||
name={'selectedItems'}
|
name={'selectedItems'}
|
||||||
value={name}
|
value={name}
|
||||||
type={'checkbox'}
|
checked={checked}
|
||||||
|
onChange={onChange}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CSSTransition } from 'react-transition-group';
|
// import { CSSTransition } from 'react-transition-group';
|
||||||
import tw from 'twin.macro';
|
import tw from 'twin.macro';
|
||||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||||
|
|
||||||
const PageContentBlock: React.FC<{ showFlashKey?: string; className?: string }> = ({ children, showFlashKey }) => (
|
const PageContentBlock: React.FC<{ showFlashKey?: string; className?: string }> = ({ children, showFlashKey }) => (
|
||||||
<CSSTransition timeout={150} classNames={'fade'} appear in>
|
// <CSSTransition timeout={150} classNames={'fade'} appear in>
|
||||||
<>
|
<>
|
||||||
{showFlashKey &&
|
{showFlashKey &&
|
||||||
<FlashMessageRender byKey={showFlashKey} css={tw`mb-4`}/>
|
<FlashMessageRender byKey={showFlashKey} css={tw`mb-4`}/>
|
||||||
|
@ -12,7 +12,7 @@ const PageContentBlock: React.FC<{ showFlashKey?: string; className?: string }>
|
||||||
{children}
|
{children}
|
||||||
|
|
||||||
{/* <p css={tw`text-center text-neutral-500 text-xs mt-4`}>
|
{/* <p css={tw`text-center text-neutral-500 text-xs mt-4`}>
|
||||||
© 2015 - 2020
|
© 2015 - 2021
|
||||||
<a
|
<a
|
||||||
rel={'noopener nofollow noreferrer'}
|
rel={'noopener nofollow noreferrer'}
|
||||||
href={'https://pterodactyl.io'}
|
href={'https://pterodactyl.io'}
|
||||||
|
@ -23,7 +23,7 @@ const PageContentBlock: React.FC<{ showFlashKey?: string; className?: string }>
|
||||||
</a>
|
</a>
|
||||||
</p> */}
|
</p> */}
|
||||||
</>
|
</>
|
||||||
</CSSTransition>
|
// </CSSTransition>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default PageContentBlock;
|
export default PageContentBlock;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import AdminCheckbox from '@/components/admin/AdminCheckbox';
|
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import getNests from '@/api/admin/nests/getNests';
|
import getNests from '@/api/admin/nests/getNests';
|
||||||
import { httpErrorToHuman } from '@/api/http';
|
import { httpErrorToHuman } from '@/api/http';
|
||||||
|
@ -11,6 +10,27 @@ import { AdminContext } from '@/state/admin';
|
||||||
import { NavLink, useRouteMatch } from 'react-router-dom';
|
import { NavLink, useRouteMatch } from 'react-router-dom';
|
||||||
import tw from 'twin.macro';
|
import tw from 'twin.macro';
|
||||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||||
|
import AdminCheckbox, { TableCheckbox } from '@/components/admin/AdminCheckbox';
|
||||||
|
|
||||||
|
const RowCheckbox = ({ id }: { id: number}) => {
|
||||||
|
const isChecked = AdminContext.useStoreState(state => state.nests.selectedNests.indexOf(id) >= 0);
|
||||||
|
const appendSelectedNest = AdminContext.useStoreActions(actions => actions.nests.appendSelectedNest);
|
||||||
|
const removeSelectedNest = AdminContext.useStoreActions(actions => actions.nests.removeSelectedNest);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AdminCheckbox
|
||||||
|
name={id.toString()}
|
||||||
|
checked={isChecked}
|
||||||
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
if (e.currentTarget.checked) {
|
||||||
|
appendSelectedNest(name);
|
||||||
|
} else {
|
||||||
|
removeSelectedNest(name);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
|
@ -21,6 +41,9 @@ export default () => {
|
||||||
const nests = useDeepMemoize(AdminContext.useStoreState(state => state.nests.data));
|
const nests = useDeepMemoize(AdminContext.useStoreState(state => state.nests.data));
|
||||||
const setNests = AdminContext.useStoreActions(state => state.nests.setNests);
|
const setNests = AdminContext.useStoreActions(state => state.nests.setNests);
|
||||||
|
|
||||||
|
const setSelectedNests = AdminContext.useStoreActions(actions => actions.nests.setSelectedNests);
|
||||||
|
const selectedNestsLength = AdminContext.useStoreState(state => state.nests.selectedNests.length);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(!nests.length);
|
setLoading(!nests.length);
|
||||||
clearFlashes('nests');
|
clearFlashes('nests');
|
||||||
|
@ -34,6 +57,10 @@ export default () => {
|
||||||
.then(() => setLoading(false));
|
.then(() => setLoading(false));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const onSelectAllClick = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setSelectedNests(e.currentTarget.checked ? (nests?.map(nest => nest.id) || []) : []);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminContentBlock>
|
<AdminContentBlock>
|
||||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||||
|
@ -47,8 +74,8 @@ export default () => {
|
||||||
|
|
||||||
<FlashMessageRender byKey={'nests'} css={tw`mb-4`}/>
|
<FlashMessageRender byKey={'nests'} css={tw`mb-4`}/>
|
||||||
|
|
||||||
<div css={tw`w-full flex flex-col`}>
|
<div css={tw`flex flex-col w-full`}>
|
||||||
<div css={tw`w-full flex flex-col bg-neutral-700 rounded-lg shadow-md`}>
|
<div css={tw`rounded-lg shadow-md bg-neutral-700`}>
|
||||||
{ loading ?
|
{ loading ?
|
||||||
<div css={tw`w-full flex flex-col items-center justify-center`} style={{ height: '24rem' }}>
|
<div css={tw`w-full flex flex-col items-center justify-center`} style={{ height: '24rem' }}>
|
||||||
<Spinner size={'base'}/>
|
<Spinner size={'base'}/>
|
||||||
|
@ -66,7 +93,12 @@ export default () => {
|
||||||
<>
|
<>
|
||||||
<div css={tw`flex flex-row items-center h-12 px-6`}>
|
<div css={tw`flex flex-row items-center h-12 px-6`}>
|
||||||
<div css={tw`flex flex-row items-center`}>
|
<div css={tw`flex flex-row items-center`}>
|
||||||
<AdminCheckbox name={'selectAll'}/>
|
<TableCheckbox
|
||||||
|
type={'checkbox'}
|
||||||
|
name={'selectAll'}
|
||||||
|
checked={selectedNestsLength === (nests?.length === 0 ? -1 : nests?.length)}
|
||||||
|
onChange={onSelectAllClick}
|
||||||
|
/>
|
||||||
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" css={tw`w-4 h-4 ml-1 text-neutral-200`}>
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" css={tw`w-4 h-4 ml-1 text-neutral-200`}>
|
||||||
<path clipRule="evenodd" fillRule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"/>
|
<path clipRule="evenodd" fillRule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"/>
|
||||||
|
@ -138,16 +170,16 @@ export default () => {
|
||||||
nests.map(nest => (
|
nests.map(nest => (
|
||||||
<tr key={nest.id} css={tw`h-12 hover:bg-neutral-600`}>
|
<tr key={nest.id} css={tw`h-12 hover:bg-neutral-600`}>
|
||||||
<td css={tw`pl-6`}>
|
<td css={tw`pl-6`}>
|
||||||
<AdminCheckbox name={nest.id.toString()}/>
|
<RowCheckbox id={nest.id}/>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap pl-8`}>{nest.id}</td>
|
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{nest.id}</td>
|
||||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>
|
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>
|
||||||
<NavLink to={`${match.url}/${nest.id}`}>
|
<NavLink to={`${match.url}/${nest.id}`}>
|
||||||
{nest.name}
|
{nest.name}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</td>
|
</td>
|
||||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap pr-8`}>{nest.description}</td>
|
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{nest.description}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -168,35 +200,35 @@ export default () => {
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-medium leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-500 text-neutral-50 focus:z-10 focus:outline-none focus:border-primary-300`}>
|
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-normal leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-500 text-neutral-50 focus:z-10 focus:outline-none focus:border-primary-300`}>
|
||||||
1
|
1
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-medium leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-normal leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
||||||
2
|
2
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0)" css={tw`relative items-center hidden px-3 py-1 -ml-px text-sm font-medium leading-5 transition duration-150 ease-in-out border md:inline-flex border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
<a href="javascript:void(0)" css={tw`relative items-center hidden px-3 py-1 -ml-px text-sm font-normal leading-5 transition duration-150 ease-in-out border md:inline-flex border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
||||||
3
|
3
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<span css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-medium leading-5 border border-neutral-500 bg-neutral-600 text-neutral-200 cursor-default`}>
|
<span css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-normal leading-5 border border-neutral-500 bg-neutral-600 text-neutral-200 cursor-default`}>
|
||||||
...
|
...
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<a href="javascript:void(0)" css={tw`relative items-center hidden px-3 py-1 -ml-px text-sm font-medium leading-5 transition duration-150 ease-in-out border md:inline-flex border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
<a href="javascript:void(0)" css={tw`relative items-center hidden px-3 py-1 -ml-px text-sm font-normal leading-5 transition duration-150 ease-in-out border md:inline-flex border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
||||||
7
|
7
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-medium leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-normal leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
||||||
8
|
8
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-medium leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-3 py-1 -ml-px text-sm font-normal leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-600 text-neutral-200 hover:text-neutral-300 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-700`}>
|
||||||
9
|
9
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-1 py-1 text-sm font-medium leading-5 transition duration-150 ease-in-out border rounded-r-md border-neutral-500 bg-neutral-600 text-neutral-400 hover:text-neutral-200 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-500`} aria-label="Previous">
|
<a href="javascript:void(0)" css={tw`relative inline-flex items-center px-1 py-1 -ml-px text-sm font-medium leading-5 transition duration-150 ease-in-out border rounded-r-md border-neutral-500 bg-neutral-600 text-neutral-400 hover:text-neutral-200 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-500`} aria-label="Next">
|
||||||
<svg css={tw`w-5 h-5`} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
<svg css={tw`w-5 h-5`} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||||
<path clipRule="evenodd" fillRule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"/>
|
<path clipRule="evenodd" fillRule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
@ -165,7 +165,7 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => {
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
|
|
||||||
<div css={tw`h-full w-full flex flex-col items-center`}>
|
<div css={tw`h-full w-full flex flex-col items-center`}>
|
||||||
<div css={tw`min-h-screen w-full flex flex-col px-16 py-12 overflow-x-hidden`} style={{ maxWidth: '86rem' }}>
|
<div css={tw`min-h-screen w-full flex flex-col overflow-x-hidden`} style={{ maxWidth: '86rem' }}>
|
||||||
{/* <TransitionRouter> */}
|
{/* <TransitionRouter> */}
|
||||||
<Switch location={location}>
|
<Switch location={location}>
|
||||||
<Route path={`${match.path}`} component={OverviewContainer} exact/>
|
<Route path={`${match.path}`} component={OverviewContainer} exact/>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { createContextStore } from 'easy-peasy';
|
import { createContextStore } from 'easy-peasy';
|
||||||
import { composeWithDevTools } from 'redux-devtools-extension';
|
import { composeWithDevTools } from 'redux-devtools-extension';
|
||||||
|
|
||||||
import nests, { AdminNestStore } from '@/state/admin/nests';
|
import nests, { AdminNestStore } from '@/state/admin/nests';
|
||||||
import roles, { AdminRoleStore } from '@/state/admin/roles';
|
import roles, { AdminRoleStore } from '@/state/admin/roles';
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,20 @@ import { Nest } from '@/api/admin/nests/getNests';
|
||||||
|
|
||||||
export interface AdminNestStore {
|
export interface AdminNestStore {
|
||||||
data: Nest[];
|
data: Nest[];
|
||||||
|
selectedNests: number[];
|
||||||
|
|
||||||
setNests: Action<AdminNestStore, Nest[]>;
|
setNests: Action<AdminNestStore, Nest[]>;
|
||||||
appendNest: Action<AdminNestStore, Nest>;
|
appendNest: Action<AdminNestStore, Nest>;
|
||||||
removeNest: Action<AdminNestStore, number>;
|
removeNest: Action<AdminNestStore, number>;
|
||||||
|
|
||||||
|
setSelectedNests: Action<AdminNestStore, number[]>;
|
||||||
|
appendSelectedNest: Action<AdminNestStore, number>;
|
||||||
|
removeSelectedNest: Action<AdminNestStore, number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nests: AdminNestStore = {
|
const nests: AdminNestStore = {
|
||||||
data: [],
|
data: [],
|
||||||
|
selectedNests: [],
|
||||||
|
|
||||||
setNests: action((state, payload) => {
|
setNests: action((state, payload) => {
|
||||||
state.data = payload;
|
state.data = payload;
|
||||||
|
@ -26,6 +33,22 @@ const nests: AdminNestStore = {
|
||||||
removeNest: action((state, payload) => {
|
removeNest: action((state, payload) => {
|
||||||
state.data = [ ...state.data.filter(nest => nest.id !== payload) ];
|
state.data = [ ...state.data.filter(nest => nest.id !== payload) ];
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
setSelectedNests: action((state, payload) => {
|
||||||
|
state.selectedNests = payload;
|
||||||
|
}),
|
||||||
|
|
||||||
|
appendSelectedNest: action((state, payload) => {
|
||||||
|
if (state.selectedNests.find(id => id === payload)) {
|
||||||
|
state.selectedNests = state.selectedNests.map(id => id === payload ? payload : id);
|
||||||
|
} else {
|
||||||
|
state.selectedNests = [ ...state.selectedNests, payload ];
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
removeSelectedNest: action((state, payload) => {
|
||||||
|
state.selectedNests = [ ...state.selectedNests.filter(id => id !== payload) ];
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nests;
|
export default nests;
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Role } from '@/api/admin/roles/getRoles';
|
||||||
|
|
||||||
export interface AdminRoleStore {
|
export interface AdminRoleStore {
|
||||||
data: Role[];
|
data: Role[];
|
||||||
|
|
||||||
setRoles: Action<AdminRoleStore, Role[]>;
|
setRoles: Action<AdminRoleStore, Role[]>;
|
||||||
appendRole: Action<AdminRoleStore, Role>;
|
appendRole: Action<AdminRoleStore, Role>;
|
||||||
removeRole: Action<AdminRoleStore, number>;
|
removeRole: Action<AdminRoleStore, number>;
|
||||||
|
|
Loading…
Reference in a new issue