Add tables for almost every admin change, update composer dependencies
This commit is contained in:
parent
8f1a5bf0ab
commit
59de9576c9
42 changed files with 3327 additions and 1241 deletions
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Application\Databases;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Transformers\Api\Application\DatabaseHostTransformer;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Databases\GetDatabaseRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Databases\GetDatabasesRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Databases\StoreDatabaseRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Databases\UpdateDatabaseRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Databases\DeleteDatabaseRequest;
|
||||
|
||||
class DatabaseController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* DatabaseController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all database hosts.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Databases\GetDatabasesRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetDatabasesRequest $request): array
|
||||
{
|
||||
$perPage = $request->query('per_page', 10);
|
||||
if ($perPage < 1) {
|
||||
$perPage = 10;
|
||||
} else if ($perPage > 100) {
|
||||
throw new BadRequestHttpException('"per_page" query parameter must be below 100.');
|
||||
}
|
||||
|
||||
$databases = QueryBuilder::for(DatabaseHost::query())
|
||||
->allowedFilters(['name', 'host'])
|
||||
->allowedSorts(['id', 'name', 'host'])
|
||||
->paginate($perPage);
|
||||
|
||||
return $this->fractal->collection($databases)
|
||||
->transformWith($this->getTransformer(DatabaseHostTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single database host.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Databases\GetDatabaseRequest $request
|
||||
* @param \Pterodactyl\Models\DatabaseHost $databaseHost
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetDatabaseRequest $request, DatabaseHost $databaseHost): array
|
||||
{
|
||||
return $this->fractal->item($databaseHost)
|
||||
->transformWith($this->getTransformer(DatabaseHostTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new database host.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Databases\StoreDatabaseRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreDatabaseRequest $request): JsonResponse
|
||||
{
|
||||
$databaseHost = DatabaseHost::query()->create($request->validated());
|
||||
|
||||
return $this->fractal->item($databaseHost)
|
||||
->transformWith($this->getTransformer(DatabaseHostTransformer::class))
|
||||
->respond(JsonResponse::HTTP_CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a database host.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Databases\UpdateDatabaseRequest $request
|
||||
* @param \Pterodactyl\Models\DatabaseHost $databaseHost
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateDatabaseRequest $request, DatabaseHost $databaseHost): array
|
||||
{
|
||||
$databaseHost->update($request->validated());
|
||||
|
||||
return $this->fractal->item($databaseHost)
|
||||
->transformWith($this->getTransformer(DatabaseHostTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a database host.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Databases\DeleteDatabaseRequest $request
|
||||
* @param \Pterodactyl\Models\DatabaseHost $databaseHost
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(DeleteDatabaseRequest $request, DatabaseHost $databaseHost): JsonResponse
|
||||
{
|
||||
$databaseHost->delete();
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ use Pterodactyl\Services\Locations\LocationCreationService;
|
|||
use Pterodactyl\Services\Locations\LocationDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\LocationTransformer;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationsRequest;
|
||||
|
@ -71,10 +72,17 @@ class LocationController extends ApplicationApiController
|
|||
*/
|
||||
public function index(GetLocationsRequest $request): array
|
||||
{
|
||||
$perPage = $request->query('per_page', 10);
|
||||
if ($perPage < 1) {
|
||||
$perPage = 10;
|
||||
} else if ($perPage > 100) {
|
||||
throw new BadRequestHttpException('"per_page" query parameter must be below 100.');
|
||||
}
|
||||
|
||||
$locations = QueryBuilder::for(Location::query())
|
||||
->allowedFilters(['short', 'long'])
|
||||
->allowedSorts(['id'])
|
||||
->paginate(100);
|
||||
->paginate($perPage);
|
||||
|
||||
return $this->fractal->collection($locations)
|
||||
->transformWith($this->getTransformer(LocationTransformer::class))
|
||||
|
|
120
app/Http/Controllers/Api/Application/Mounts/MountController.php
Normal file
120
app/Http/Controllers/Api/Application/Mounts/MountController.php
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Application\Mounts;
|
||||
|
||||
use Pterodactyl\Models\Mount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Pterodactyl\Transformers\Api\Application\MountTransformer;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\GetMountRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\GetMountsRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\StoreMountRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\UpdateMountRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\DeleteMountRequest;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
|
||||
class MountController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* MountController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\GetMountsRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetMountsRequest $request): array
|
||||
{
|
||||
$perPage = $request->query('per_page', 10);
|
||||
if ($perPage < 1) {
|
||||
$perPage = 10;
|
||||
} elseif ($perPage > 100) {
|
||||
throw new BadRequestHttpException('"per_page" query parameter must be below 100.');
|
||||
}
|
||||
|
||||
$mounts = QueryBuilder::for(Mount::query())
|
||||
->allowedFilters(['name', 'host'])
|
||||
->allowedSorts(['id', 'name', 'host'])
|
||||
->paginate($perPage);
|
||||
|
||||
return $this->fractal->collection($mounts)
|
||||
->transformWith($this->getTransformer(MountTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\GetMountRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetMountRequest $request, Mount $mount): array
|
||||
{
|
||||
return $this->fractal->item($mount)
|
||||
->transformWith($this->getTransformer(MountTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\StoreMountRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreMountRequest $request): JsonResponse
|
||||
{
|
||||
$mount = Mount::query()->create($request->validated());
|
||||
|
||||
return $this->fractal->item($mount)
|
||||
->transformWith($this->getTransformer(MountTransformer::class))
|
||||
->respond(JsonResponse::HTTP_CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\UpdateMountRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateMountRequest $request, Mount $mount): array
|
||||
{
|
||||
$mount->update($request->validated());
|
||||
|
||||
return $this->fractal->item($mount)
|
||||
->transformWith($this->getTransformer(MountTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\DeleteMountRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(DeleteMountRequest $request, Mount $mount): JsonResponse
|
||||
{
|
||||
$mount->delete();
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ use Pterodactyl\Services\Nests\NestDeletionService;
|
|||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\NestTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestRequest;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\StoreNestRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\UpdateNestRequest;
|
||||
|
@ -71,7 +72,14 @@ class NestController extends ApplicationApiController
|
|||
*/
|
||||
public function index(GetNestsRequest $request): array
|
||||
{
|
||||
$nests = $this->repository->paginated(10);
|
||||
$perPage = $request->query('per_page', 10);
|
||||
if ($perPage < 1) {
|
||||
$perPage = 10;
|
||||
} else if ($perPage > 100) {
|
||||
throw new BadRequestHttpException('"per_page" query parameter must be below 100.');
|
||||
}
|
||||
|
||||
$nests = $this->repository->paginated($perPage);
|
||||
|
||||
return $this->fractal->collection($nests)
|
||||
->transformWith($this->getTransformer(NestTransformer::class))
|
||||
|
|
|
@ -11,6 +11,7 @@ use Pterodactyl\Services\Nodes\NodeDeletionService;
|
|||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\NodeTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nodes\StoreNodeRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nodes\DeleteNodeRequest;
|
||||
|
@ -71,10 +72,17 @@ class NodeController extends ApplicationApiController
|
|||
*/
|
||||
public function index(GetNodesRequest $request): array
|
||||
{
|
||||
$perPage = $request->query('per_page', 10);
|
||||
if ($perPage < 1) {
|
||||
$perPage = 10;
|
||||
} else if ($perPage > 100) {
|
||||
throw new BadRequestHttpException('"per_page" query parameter must be below 100.');
|
||||
}
|
||||
|
||||
$nodes = QueryBuilder::for(Node::query())
|
||||
->allowedFilters(['uuid', 'name', 'fqdn', 'daemon_token_id'])
|
||||
->allowedSorts(['id', 'uuid', 'memory', 'disk'])
|
||||
->paginate(100);
|
||||
->paginate($perPage);
|
||||
|
||||
return $this->fractal->collection($nodes)
|
||||
->transformWith($this->getTransformer(NodeTransformer::class))
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace Pterodactyl\Http\Controllers\Api\Application\Roles;
|
|||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Models\AdminRole;
|
||||
use Pterodactyl\Repositories\Eloquent\AdminRolesRepository;
|
||||
use Pterodactyl\Transformers\Api\Application\AdminRoleTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Roles\GetRoleRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Roles\GetRolesRequest;
|
||||
|
@ -16,20 +15,11 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
class RoleController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\AdminRolesRepository
|
||||
* RoleController constructor.
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* RolesController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Repositories\Eloquent\AdminRolesRepository $repository
|
||||
*/
|
||||
public function __construct(AdminRolesRepository $repository)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,10 +95,11 @@ class RoleController extends ApplicationApiController
|
|||
* @param \Pterodactyl\Models\AdminRole $role
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(DeleteRoleRequest $request, AdminRole $role): JsonResponse
|
||||
{
|
||||
$this->repository->delete($role->id);
|
||||
$role->delete();
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use Pterodactyl\Services\Servers\ServerCreationService;
|
|||
use Pterodactyl\Services\Servers\ServerDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\ServerTransformer;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest;
|
||||
|
@ -22,10 +23,12 @@ class ServerController extends ApplicationApiController
|
|||
* @var \Pterodactyl\Services\Servers\ServerCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
|
@ -42,8 +45,7 @@ class ServerController extends ApplicationApiController
|
|||
ServerCreationService $creationService,
|
||||
ServerDeletionService $deletionService,
|
||||
ServerRepositoryInterface $repository
|
||||
)
|
||||
{
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
|
@ -61,10 +63,17 @@ class ServerController extends ApplicationApiController
|
|||
*/
|
||||
public function index(GetServersRequest $request): array
|
||||
{
|
||||
$perPage = $request->query('per_page', 10);
|
||||
if ($perPage < 1) {
|
||||
$perPage = 10;
|
||||
} else if ($perPage > 100) {
|
||||
throw new BadRequestHttpException('"per_page" query parameter must be below 100.');
|
||||
}
|
||||
|
||||
$servers = QueryBuilder::for(Server::query())
|
||||
->allowedFilters(['uuid', 'name', 'image', 'external_id'])
|
||||
->allowedSorts(['id', 'uuid'])
|
||||
->paginate(100);
|
||||
->paginate($perPage);
|
||||
|
||||
return $this->fractal->collection($servers)
|
||||
->transformWith($this->getTransformer(ServerTransformer::class))
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Databases;
|
||||
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
class DeleteDatabaseRequest extends ApplicationApiRequest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permission = AdminAcl::WRITE;
|
||||
|
||||
/**
|
||||
* Determine if the requested database exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
$database = $this->route()->parameter('database');
|
||||
|
||||
return $database instanceof DatabaseHost && $database->exists;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Databases;
|
||||
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
|
||||
class GetDatabaseRequest extends GetDatabasesRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the requested database exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
$database = $this->route()->parameter('database');
|
||||
|
||||
return $database instanceof DatabaseHost && $database->exists;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Databases;
|
||||
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl as Acl;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
class GetDatabasesRequest extends ApplicationApiRequest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resource = Acl::RESOURCE_DATABASE_HOSTS;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permission = Acl::READ;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Databases;
|
||||
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
class StoreDatabaseRequest extends ApplicationApiRequest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permission = AdminAcl::WRITE;
|
||||
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
* @param array|null $rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
return $rules ?? DatabaseHost::getRules();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Databases;
|
||||
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
|
||||
class UpdateDatabaseRequest extends StoreDatabaseRequest
|
||||
{
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
* @param array|null $rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
return $rules ?? DatabaseHost::getRulesForUpdate($this->route()->parameter('database')->id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Mounts;
|
||||
|
||||
use Pterodactyl\Models\Mount;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
class DeleteMountRequest extends ApplicationApiRequest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resource = AdminAcl::RESOURCE_MOUNTS;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permission = AdminAcl::WRITE;
|
||||
|
||||
/**
|
||||
* Determine if the requested mount exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
$mount = $this->route()->parameter('mount');
|
||||
|
||||
return $mount instanceof Mount && $mount->exists;
|
||||
}
|
||||
}
|
20
app/Http/Requests/Api/Application/Mounts/GetMountRequest.php
Normal file
20
app/Http/Requests/Api/Application/Mounts/GetMountRequest.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Mounts;
|
||||
|
||||
use Pterodactyl\Models\Mount;
|
||||
|
||||
class GetMountRequest extends GetMountsRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the requested mount exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
$mount = $this->route()->parameter('mount');
|
||||
|
||||
return $mount instanceof Mount && $mount->exists;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Mounts;
|
||||
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl as Acl;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
class GetMountsRequest extends ApplicationApiRequest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resource = Acl::RESOURCE_MOUNTS;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permission = Acl::READ;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Mounts;
|
||||
|
||||
use Pterodactyl\Models\Mount;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
class StoreMountRequest extends ApplicationApiRequest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resource = AdminAcl::RESOURCE_MOUNTS;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $permission = AdminAcl::WRITE;
|
||||
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
* @param array|null $rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
return $rules ?? Mount::getRules();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Mounts;
|
||||
|
||||
use Pterodactyl\Models\Mount;
|
||||
|
||||
class UpdateMountRequest extends StoreMountRequest
|
||||
{
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
* @param array|null $rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
return $rules ?? Mount::getRulesForUpdate($this->route()->parameter('mount')->id);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ namespace Pterodactyl\Http\Requests\Api\Application\Roles;
|
|||
|
||||
use Pterodactyl\Models\AdminRole;
|
||||
|
||||
class GetRoleRequest extends GetRolesRequest
|
||||
class GetRoleRequest extends GetMountsRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the requested role exists on the Panel.
|
||||
|
|
|
@ -2,6 +2,19 @@
|
|||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $host
|
||||
* @property int $port
|
||||
* @property string $username
|
||||
* @property int $node_id
|
||||
* @property \Carbon\Carbon|null $created_at
|
||||
* @property \Carbon\Carbon|null $updated_at
|
||||
*
|
||||
* @property \Pterodactyl\Models\Node|null $node
|
||||
* @property \Pterodactyl\Models\Database[]|\Illuminate\Database\Eloquent\Collection $databases
|
||||
*/
|
||||
class DatabaseHost extends Model
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,7 @@ class AdminAcl
|
|||
const RESOURCE_DATABASE_HOSTS = 'database_hosts';
|
||||
const RESOURCE_SERVER_DATABASES = 'server_databases';
|
||||
const RESOURCE_ROLES = 'roles';
|
||||
const RESOURCE_MOUNTS = 'mounts';
|
||||
|
||||
/**
|
||||
* Determine if an API key has permission to perform a specific read/write operation.
|
||||
|
|
|
@ -17,7 +17,7 @@ class AdminRoleTransformer extends BaseTransformer
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a transformed User model that can be consumed by external services.
|
||||
* Return a transformed AdminRole model that can be consumed by external services.
|
||||
*
|
||||
* @param \Pterodactyl\Models\AdminRole $model
|
||||
* @return array
|
||||
|
|
|
@ -58,6 +58,7 @@ class DatabaseHostTransformer extends BaseTransformer
|
|||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeDatabases(DatabaseHost $model)
|
||||
{
|
||||
|
|
38
app/Transformers/Api/Application/MountTransformer.php
Normal file
38
app/Transformers/Api/Application/MountTransformer.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Transformers\Api\Application;
|
||||
|
||||
use Pterodactyl\Models\Mount;
|
||||
|
||||
class MountTransformer extends BaseTransformer
|
||||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return Mount::RESOURCE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a transformed Mount model that can be consumed by external services.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Mount $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Mount $model): array
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'uuid' => $model->uuid,
|
||||
'name' => $model->name,
|
||||
'description' => $model->description,
|
||||
'source' => $model->source,
|
||||
'target' => $model->target,
|
||||
'read_only' => $model->read_only,
|
||||
'user_mountable' => $model->user_mountable,
|
||||
];
|
||||
}
|
||||
}
|
|
@ -11,44 +11,45 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2",
|
||||
"php": "^7.4",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-pdo_mysql": "*",
|
||||
"ext-zip": "*",
|
||||
"appstract/laravel-blade-directives": "^1.8",
|
||||
"aws/aws-sdk-php": "^3.134",
|
||||
"appstract/laravel-blade-directives": "^1.10",
|
||||
"aws/aws-sdk-php": "^3.171",
|
||||
"cakephp/chronos": "^1.3",
|
||||
"doctrine/dbal": "^2.10",
|
||||
"fideloper/proxy": "^4.2",
|
||||
"doctrine/dbal": "^2.12",
|
||||
"fideloper/proxy": "^4.4",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"hashids/hashids": "^4.0",
|
||||
"laracasts/utilities": "^3.1",
|
||||
"laravel/framework": "^7.17",
|
||||
"laravel/helpers": "^1.2",
|
||||
"laravel/tinker": "^2.4",
|
||||
"laravel/ui": "^2.0",
|
||||
"lcobucci/jwt": "^3.3",
|
||||
"hashids/hashids": "^4.1",
|
||||
"laracasts/utilities": "^3.2",
|
||||
"laravel/framework": "^7.30",
|
||||
"laravel/helpers": "^1.4",
|
||||
"laravel/tinker": "^2.5",
|
||||
"laravel/ui": "^2.5",
|
||||
"lcobucci/jwt": "^3.4",
|
||||
"league/flysystem-aws-s3-v3": "^1.0",
|
||||
"league/flysystem-memory": "^1.0",
|
||||
"matriphe/iso-639": "^1.2",
|
||||
"pragmarx/google2fa": "^5.0",
|
||||
"predis/predis": "^1.1",
|
||||
"prologue/alerts": "^0.4",
|
||||
"psy/psysh": "^0.10.4",
|
||||
"psy/psysh": "^0.10.5",
|
||||
"s1lentium/iptools": "^1.1",
|
||||
"spatie/laravel-fractal": "^5.7",
|
||||
"spatie/laravel-fractal": "^5.8",
|
||||
"spatie/laravel-query-builder": "^2.8",
|
||||
"staudenmeir/belongs-to-through": "^2.10",
|
||||
"symfony/yaml": "^4.4",
|
||||
"webmozart/assert": "^1.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.3",
|
||||
"barryvdh/laravel-ide-helper": "^2.7",
|
||||
"barryvdh/laravel-debugbar": "^3.5",
|
||||
"barryvdh/laravel-ide-helper": "^2.8",
|
||||
"codedungeon/phpunit-result-printer": "^0.28.0",
|
||||
"friendsofphp/php-cs-fixer": "2.16.1",
|
||||
"fzaninotto/faker": "^1.9",
|
||||
"laravel/dusk": "^6.3",
|
||||
"laravel/dusk": "^6.11",
|
||||
"mockery/mockery": "^1.4",
|
||||
"php-mock/php-mock-phpunit": "^2.6",
|
||||
"phpunit/phpunit": "^8.5"
|
||||
|
|
2992
composer.lock
generated
2992
composer.lock
generated
File diff suppressed because it is too large
Load diff
45
resources/scripts/api/admin/databases/getDatabases.ts
Normal file
45
resources/scripts/api/admin/databases/getDatabases.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
|
||||
import { createContext, useContext } from 'react';
|
||||
import useSWR from 'swr';
|
||||
|
||||
export interface Database {
|
||||
id: number;
|
||||
name: string;
|
||||
host: string;
|
||||
port: number;
|
||||
username: string;
|
||||
maxDatabases: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export const rawDataToDatabase = ({ attributes }: FractalResponseData): Database => ({
|
||||
id: attributes.id,
|
||||
name: attributes.name,
|
||||
host: attributes.host,
|
||||
port: attributes.port,
|
||||
username: attributes.username,
|
||||
maxDatabases: attributes.max_databases,
|
||||
createdAt: new Date(attributes.created_at),
|
||||
updatedAt: new Date(attributes.updated_at),
|
||||
});
|
||||
|
||||
interface ctx {
|
||||
page: number;
|
||||
setPage: (value: number | ((s: number) => number)) => void;
|
||||
}
|
||||
|
||||
export const Context = createContext<ctx>({ page: 1, setPage: () => 1 });
|
||||
|
||||
export default () => {
|
||||
const { page } = useContext(Context);
|
||||
|
||||
return useSWR<PaginatedResult<Database>>([ 'databases', page ], async () => {
|
||||
const { data } = await http.get('/api/application/databases', { params: { page } });
|
||||
|
||||
return ({
|
||||
items: (data.data || []).map(rawDataToDatabase),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
});
|
||||
});
|
||||
};
|
39
resources/scripts/api/admin/locations/getLocations.ts
Normal file
39
resources/scripts/api/admin/locations/getLocations.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
|
||||
import { createContext, useContext } from 'react';
|
||||
import useSWR from 'swr';
|
||||
|
||||
export interface Location {
|
||||
id: number;
|
||||
short: string;
|
||||
long: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export const rawDataToLocation = ({ attributes }: FractalResponseData): Location => ({
|
||||
id: attributes.id,
|
||||
short: attributes.short,
|
||||
long: attributes.long,
|
||||
createdAt: new Date(attributes.created_at),
|
||||
updatedAt: new Date(attributes.updated_at),
|
||||
});
|
||||
|
||||
interface ctx {
|
||||
page: number;
|
||||
setPage: (value: number | ((s: number) => number)) => void;
|
||||
}
|
||||
|
||||
export const Context = createContext<ctx>({ page: 1, setPage: () => 1 });
|
||||
|
||||
export default () => {
|
||||
const { page } = useContext(Context);
|
||||
|
||||
return useSWR<PaginatedResult<Location>>([ 'locations', page ], async () => {
|
||||
const { data } = await http.get('/api/application/locations', { params: { page } });
|
||||
|
||||
return ({
|
||||
items: (data.data || []).map(rawDataToLocation),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
});
|
||||
});
|
||||
};
|
49
resources/scripts/api/admin/mounts/getMounts.ts
Normal file
49
resources/scripts/api/admin/mounts/getMounts.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
|
||||
import { createContext, useContext } from 'react';
|
||||
import useSWR from 'swr';
|
||||
|
||||
export interface Mount {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
description: string;
|
||||
source: string;
|
||||
target: string;
|
||||
readOnly: boolean;
|
||||
userMountable: boolean;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export const rawDataToMount = ({ attributes }: FractalResponseData): Mount => ({
|
||||
id: attributes.id,
|
||||
uuid: attributes.uuid,
|
||||
name: attributes.name,
|
||||
description: attributes.description,
|
||||
source: attributes.source,
|
||||
target: attributes.target,
|
||||
readOnly: attributes.read_only,
|
||||
userMountable: attributes.user_mountable,
|
||||
createdAt: new Date(attributes.created_at),
|
||||
updatedAt: new Date(attributes.updated_at),
|
||||
});
|
||||
|
||||
interface ctx {
|
||||
page: number;
|
||||
setPage: (value: number | ((s: number) => number)) => void;
|
||||
}
|
||||
|
||||
export const Context = createContext<ctx>({ page: 1, setPage: () => 1 });
|
||||
|
||||
export default () => {
|
||||
const { page } = useContext(Context);
|
||||
|
||||
return useSWR<PaginatedResult<Mount>>([ 'mounts', page ], async () => {
|
||||
const { data } = await http.get('/api/application/mounts', { params: { page } });
|
||||
|
||||
return ({
|
||||
items: (data.data || []).map(rawDataToMount),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
});
|
||||
});
|
||||
};
|
|
@ -1,23 +1,9 @@
|
|||
import NewApiKeyButton from '@/components/admin/api/NewApiKeyButton';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React from 'react';
|
||||
import tw from 'twin.macro';
|
||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||
import Spinner from '@/components/elements/Spinner';
|
||||
|
||||
interface Key {
|
||||
id: number,
|
||||
}
|
||||
import NewApiKeyButton from '@/components/admin/api/NewApiKeyButton';
|
||||
|
||||
export default () => {
|
||||
const [ loading, setLoading ] = useState<boolean>(true);
|
||||
const [ keys ] = useState<Key[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
return (
|
||||
<AdminContentBlock>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
|
@ -28,27 +14,6 @@ export default () => {
|
|||
|
||||
<NewApiKeyButton />
|
||||
</div>
|
||||
|
||||
<div css={tw`w-full flex flex-col`}>
|
||||
<div css={tw`w-full flex flex-col bg-neutral-700 rounded-lg shadow-md`}>
|
||||
{ loading ?
|
||||
<div css={tw`w-full flex flex-col items-center justify-center`} style={{ height: '24rem' }}>
|
||||
<Spinner size={'base'}/>
|
||||
</div>
|
||||
:
|
||||
keys.length < 1 ?
|
||||
<div css={tw`w-full flex flex-col items-center justify-center pb-6 py-2 sm:py-8 md:py-10 px-8`}>
|
||||
<div css={tw`h-64 flex`}>
|
||||
<img src={'/assets/svgs/not_found.svg'} alt={'No Items'} css={tw`h-full select-none`}/>
|
||||
</div>
|
||||
|
||||
<p css={tw`text-lg text-neutral-300 text-center font-normal sm:mt-8`}>No items could be found, it's almost like they are hiding.</p>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,12 +1,67 @@
|
|||
import React from 'react';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import getDatabases, { Context as DatabasesContext } from '@/api/admin/databases/getDatabases';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import useFlash from '@/plugins/useFlash';
|
||||
import { AdminContext } from '@/state/admin';
|
||||
import { NavLink, useRouteMatch } from 'react-router-dom';
|
||||
import tw from 'twin.macro';
|
||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||
import AdminCheckbox from '@/components/admin/AdminCheckbox';
|
||||
import AdminTable, { TableBody, TableHead, TableHeader, TableRow, Pagination, Loading, NoItems, ContentWrapper } from '@/components/admin/AdminTable';
|
||||
import Button from '@/components/elements/Button';
|
||||
|
||||
export default () => {
|
||||
const RowCheckbox = ({ id }: { id: number}) => {
|
||||
const isChecked = AdminContext.useStoreState(state => state.databases.selectedDatabases.indexOf(id) >= 0);
|
||||
const appendSelectedDatabase = AdminContext.useStoreActions(actions => actions.databases.appendSelectedDatabase);
|
||||
const removeSelectedDatabase = AdminContext.useStoreActions(actions => actions.databases.removeSelectedDatabase);
|
||||
|
||||
return (
|
||||
<AdminCheckbox
|
||||
name={id.toString()}
|
||||
checked={isChecked}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.currentTarget.checked) {
|
||||
appendSelectedDatabase(id);
|
||||
} else {
|
||||
removeSelectedDatabase(id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const DatabasesContainer = () => {
|
||||
const match = useRouteMatch();
|
||||
|
||||
const { page, setPage } = useContext(DatabasesContext);
|
||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||
const { data: databases, error, isValidating } = getDatabases();
|
||||
|
||||
useEffect(() => {
|
||||
if (!error) {
|
||||
clearFlashes('databases');
|
||||
return;
|
||||
}
|
||||
|
||||
clearAndAddHttpError({ error, key: 'databases' });
|
||||
}, [ error ]);
|
||||
|
||||
const length = databases?.items?.length || 0;
|
||||
|
||||
const setSelectedDatabases = AdminContext.useStoreActions(actions => actions.databases.setSelectedDatabases);
|
||||
const selectedDatabasesLength = AdminContext.useStoreState(state => state.databases.selectedDatabases.length);
|
||||
|
||||
const onSelectAllClick = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSelectedDatabases(e.currentTarget.checked ? (databases?.items?.map(database => database.id) || []) : []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedDatabases([]);
|
||||
}, [ page ]);
|
||||
|
||||
return (
|
||||
<AdminContentBlock>
|
||||
<div css={tw`w-full flex flex-row items-center`}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
<div css={tw`flex flex-col`}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>Databases</h2>
|
||||
<p css={tw`text-base text-neutral-400`}>Database hosts that servers can have databases created on.</p>
|
||||
|
@ -16,6 +71,64 @@ export default () => {
|
|||
New Database
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<FlashMessageRender byKey={'databases'} css={tw`mb-4`}/>
|
||||
|
||||
<AdminTable>
|
||||
{ databases === undefined || (error && isValidating) ?
|
||||
<Loading/>
|
||||
:
|
||||
length < 1 ?
|
||||
<NoItems/>
|
||||
:
|
||||
<ContentWrapper
|
||||
checked={selectedDatabasesLength === (length === 0 ? -1 : length)}
|
||||
onSelectAllClick={onSelectAllClick}
|
||||
>
|
||||
<Pagination data={databases} onPageSelect={setPage}>
|
||||
<div css={tw`overflow-x-auto`}>
|
||||
<table css={tw`w-full table-auto`}>
|
||||
<TableHead>
|
||||
<TableHeader name={'ID'}/>
|
||||
<TableHeader name={'Name'}/>
|
||||
<TableHeader name={'Address'}/>
|
||||
</TableHead>
|
||||
|
||||
<TableBody>
|
||||
{
|
||||
databases.items.map(database => (
|
||||
<TableRow key={database.id}>
|
||||
<td css={tw`pl-6`}>
|
||||
<RowCheckbox id={database.id}/>
|
||||
</td>
|
||||
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{database.id}</td>
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>
|
||||
<NavLink to={`${match.url}/${database.id}`} css={tw`text-primary-400 hover:text-primary-300`}>
|
||||
{database.name}
|
||||
</NavLink>
|
||||
</td>
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{database.host}:{database.port}</td>
|
||||
</TableRow>
|
||||
))
|
||||
}
|
||||
</TableBody>
|
||||
</table>
|
||||
</div>
|
||||
</Pagination>
|
||||
</ContentWrapper>
|
||||
}
|
||||
</AdminTable>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
||||
|
||||
export default () => {
|
||||
const [ page, setPage ] = useState<number>(1);
|
||||
|
||||
return (
|
||||
<DatabasesContext.Provider value={{ page, setPage }}>
|
||||
<DatabasesContainer/>
|
||||
</DatabasesContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,12 +1,67 @@
|
|||
import React from 'react';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import getLocations, { Context as LocationsContext } from '@/api/admin/locations/getLocations';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import useFlash from '@/plugins/useFlash';
|
||||
import { AdminContext } from '@/state/admin';
|
||||
import { NavLink, useRouteMatch } from 'react-router-dom';
|
||||
import tw from 'twin.macro';
|
||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||
import AdminCheckbox from '@/components/admin/AdminCheckbox';
|
||||
import AdminTable, { TableBody, TableHead, TableHeader, TableRow, Pagination, Loading, NoItems, ContentWrapper } from '@/components/admin/AdminTable';
|
||||
import Button from '@/components/elements/Button';
|
||||
|
||||
export default () => {
|
||||
const RowCheckbox = ({ id }: { id: number}) => {
|
||||
const isChecked = AdminContext.useStoreState(state => state.locations.selectedLocations.indexOf(id) >= 0);
|
||||
const appendSelectedLocation = AdminContext.useStoreActions(actions => actions.locations.appendSelectedLocation);
|
||||
const removeSelectedLocation = AdminContext.useStoreActions(actions => actions.locations.removeSelectedLocation);
|
||||
|
||||
return (
|
||||
<AdminCheckbox
|
||||
name={id.toString()}
|
||||
checked={isChecked}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.currentTarget.checked) {
|
||||
appendSelectedLocation(id);
|
||||
} else {
|
||||
removeSelectedLocation(id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const LocationsContainer = () => {
|
||||
const match = useRouteMatch();
|
||||
|
||||
const { page, setPage } = useContext(LocationsContext);
|
||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||
const { data: locations, error, isValidating } = getLocations();
|
||||
|
||||
useEffect(() => {
|
||||
if (!error) {
|
||||
clearFlashes('locations');
|
||||
return;
|
||||
}
|
||||
|
||||
clearAndAddHttpError({ error, key: 'locations' });
|
||||
}, [ error ]);
|
||||
|
||||
const length = locations?.items?.length || 0;
|
||||
|
||||
const setSelectedLocations = AdminContext.useStoreActions(actions => actions.locations.setSelectedLocations);
|
||||
const selectedLocationsLength = AdminContext.useStoreState(state => state.locations.selectedLocations.length);
|
||||
|
||||
const onSelectAllClick = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSelectedLocations(e.currentTarget.checked ? (locations?.items?.map(location => location.id) || []) : []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedLocations([]);
|
||||
}, [ page ]);
|
||||
|
||||
return (
|
||||
<AdminContentBlock>
|
||||
<div css={tw`w-full flex flex-row items-center`}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
<div css={tw`flex flex-col`}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>Locations</h2>
|
||||
<p css={tw`text-base text-neutral-400`}>All locations that nodes can be assigned to for easier categorization.</p>
|
||||
|
@ -16,6 +71,64 @@ export default () => {
|
|||
New Location
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<FlashMessageRender byKey={'locations'} css={tw`mb-4`}/>
|
||||
|
||||
<AdminTable>
|
||||
{ locations === undefined || (error && isValidating) ?
|
||||
<Loading/>
|
||||
:
|
||||
length < 1 ?
|
||||
<NoItems/>
|
||||
:
|
||||
<ContentWrapper
|
||||
checked={selectedLocationsLength === (length === 0 ? -1 : length)}
|
||||
onSelectAllClick={onSelectAllClick}
|
||||
>
|
||||
<Pagination data={locations} onPageSelect={setPage}>
|
||||
<div css={tw`overflow-x-auto`}>
|
||||
<table css={tw`w-full table-auto`}>
|
||||
<TableHead>
|
||||
<TableHeader name={'ID'}/>
|
||||
<TableHeader name={'Short Name'}/>
|
||||
<TableHeader name={'Long Name'}/>
|
||||
</TableHead>
|
||||
|
||||
<TableBody>
|
||||
{
|
||||
locations.items.map(location => (
|
||||
<TableRow key={location.id}>
|
||||
<td css={tw`pl-6`}>
|
||||
<RowCheckbox id={location.id}/>
|
||||
</td>
|
||||
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{location.id}</td>
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>
|
||||
<NavLink to={`${match.url}/${location.id}`} css={tw`text-primary-400 hover:text-primary-300`}>
|
||||
{location.short}
|
||||
</NavLink>
|
||||
</td>
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{location.long}</td>
|
||||
</TableRow>
|
||||
))
|
||||
}
|
||||
</TableBody>
|
||||
</table>
|
||||
</div>
|
||||
</Pagination>
|
||||
</ContentWrapper>
|
||||
}
|
||||
</AdminTable>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
||||
|
||||
export default () => {
|
||||
const [ page, setPage ] = useState<number>(1);
|
||||
|
||||
return (
|
||||
<LocationsContext.Provider value={{ page, setPage }}>
|
||||
<LocationsContainer/>
|
||||
</LocationsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,12 +1,67 @@
|
|||
import Button from '@/components/elements/Button';
|
||||
import React from 'react';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import getMounts, { Context as MountsContext } from '@/api/admin/mounts/getMounts';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import useFlash from '@/plugins/useFlash';
|
||||
import { AdminContext } from '@/state/admin';
|
||||
import { NavLink, useRouteMatch } from 'react-router-dom';
|
||||
import tw from 'twin.macro';
|
||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||
import AdminCheckbox from '@/components/admin/AdminCheckbox';
|
||||
import AdminTable, { TableBody, TableHead, TableHeader, TableRow, Pagination, Loading, NoItems, ContentWrapper } from '@/components/admin/AdminTable';
|
||||
import Button from '@/components/elements/Button';
|
||||
|
||||
const RowCheckbox = ({ id }: { id: number}) => {
|
||||
const isChecked = AdminContext.useStoreState(state => state.mounts.selectedMounts.indexOf(id) >= 0);
|
||||
const appendSelectedMount = AdminContext.useStoreActions(actions => actions.mounts.appendSelectedMount);
|
||||
const removeSelectedMount = AdminContext.useStoreActions(actions => actions.mounts.removeSelectedMount);
|
||||
|
||||
return (
|
||||
<AdminCheckbox
|
||||
name={id.toString()}
|
||||
checked={isChecked}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.currentTarget.checked) {
|
||||
appendSelectedMount(id);
|
||||
} else {
|
||||
removeSelectedMount(id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const MountsContainer = () => {
|
||||
const match = useRouteMatch();
|
||||
|
||||
const { page, setPage } = useContext(MountsContext);
|
||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||
const { data: mounts, error, isValidating } = getMounts();
|
||||
|
||||
useEffect(() => {
|
||||
if (!error) {
|
||||
clearFlashes('mounts');
|
||||
return;
|
||||
}
|
||||
|
||||
clearAndAddHttpError({ error, key: 'mounts' });
|
||||
}, [ error ]);
|
||||
|
||||
const length = mounts?.items?.length || 0;
|
||||
|
||||
const setSelectedMounts = AdminContext.useStoreActions(actions => actions.mounts.setSelectedMounts);
|
||||
const selectedMountsLength = AdminContext.useStoreState(state => state.mounts.selectedMounts.length);
|
||||
|
||||
const onSelectAllClick = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSelectedMounts(e.currentTarget.checked ? (mounts?.items?.map(mount => mount.id) || []) : []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedMounts([]);
|
||||
}, [ page ]);
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<AdminContentBlock>
|
||||
<div css={tw`w-full flex flex-row items-center`}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
<div css={tw`flex flex-col`}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>Mounts</h2>
|
||||
<p css={tw`text-base text-neutral-400`}>Configure and manage additional mount points for servers.</p>
|
||||
|
@ -16,6 +71,62 @@ export default () => {
|
|||
New Mount
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<FlashMessageRender byKey={'mounts'} css={tw`mb-4`}/>
|
||||
|
||||
<AdminTable>
|
||||
{ mounts === undefined || (error && isValidating) ?
|
||||
<Loading/>
|
||||
:
|
||||
length < 1 ?
|
||||
<NoItems/>
|
||||
:
|
||||
<ContentWrapper
|
||||
checked={selectedMountsLength === (length === 0 ? -1 : length)}
|
||||
onSelectAllClick={onSelectAllClick}
|
||||
>
|
||||
<Pagination data={mounts} onPageSelect={setPage}>
|
||||
<div css={tw`overflow-x-auto`}>
|
||||
<table css={tw`w-full table-auto`}>
|
||||
<TableHead>
|
||||
<TableHeader name={'ID'}/>
|
||||
<TableHeader name={'Name'}/>
|
||||
</TableHead>
|
||||
|
||||
<TableBody>
|
||||
{
|
||||
mounts.items.map(mount => (
|
||||
<TableRow key={mount.id}>
|
||||
<td css={tw`pl-6`}>
|
||||
<RowCheckbox id={mount.id}/>
|
||||
</td>
|
||||
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{mount.id}</td>
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>
|
||||
<NavLink to={`${match.url}/${mount.id}`} css={tw`text-primary-400 hover:text-primary-300`}>
|
||||
{mount.name}
|
||||
</NavLink>
|
||||
</td>
|
||||
</TableRow>
|
||||
))
|
||||
}
|
||||
</TableBody>
|
||||
</table>
|
||||
</div>
|
||||
</Pagination>
|
||||
</ContentWrapper>
|
||||
}
|
||||
</AdminTable>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
||||
|
||||
export default () => {
|
||||
const [ page, setPage ] = useState<number>(1);
|
||||
|
||||
return (
|
||||
<MountsContext.Provider value={{ page, setPage }}>
|
||||
<MountsContainer/>
|
||||
</MountsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,12 +1,67 @@
|
|||
import Button from '@/components/elements/Button';
|
||||
import React from 'react';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import getNodes, { Context as NodesContext } from '@/api/admin/nodes/getNodes';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import useFlash from '@/plugins/useFlash';
|
||||
import { AdminContext } from '@/state/admin';
|
||||
import { NavLink, useRouteMatch } from 'react-router-dom';
|
||||
import tw from 'twin.macro';
|
||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||
import AdminCheckbox from '@/components/admin/AdminCheckbox';
|
||||
import AdminTable, { TableBody, TableHead, TableHeader, TableRow, Pagination, Loading, NoItems, ContentWrapper } from '@/components/admin/AdminTable';
|
||||
import Button from '@/components/elements/Button';
|
||||
|
||||
const RowCheckbox = ({ id }: { id: number}) => {
|
||||
const isChecked = AdminContext.useStoreState(state => state.nodes.selectedNodes.indexOf(id) >= 0);
|
||||
const appendSelectedNode = AdminContext.useStoreActions(actions => actions.nodes.appendSelectedNode);
|
||||
const removeSelectedNode = AdminContext.useStoreActions(actions => actions.nodes.removeSelectedNode);
|
||||
|
||||
return (
|
||||
<AdminCheckbox
|
||||
name={id.toString()}
|
||||
checked={isChecked}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.currentTarget.checked) {
|
||||
appendSelectedNode(id);
|
||||
} else {
|
||||
removeSelectedNode(id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const NodesContainer = () => {
|
||||
const match = useRouteMatch();
|
||||
|
||||
const { page, setPage } = useContext(NodesContext);
|
||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||
const { data: nodes, error, isValidating } = getNodes();
|
||||
|
||||
useEffect(() => {
|
||||
if (!error) {
|
||||
clearFlashes('nodes');
|
||||
return;
|
||||
}
|
||||
|
||||
clearAndAddHttpError({ error, key: 'nodes' });
|
||||
}, [ error ]);
|
||||
|
||||
const length = nodes?.items?.length || 0;
|
||||
|
||||
const setSelectedNodes = AdminContext.useStoreActions(actions => actions.nodes.setSelectedNodes);
|
||||
const selectedNodesLength = AdminContext.useStoreState(state => state.nodes.selectedNodes.length);
|
||||
|
||||
const onSelectAllClick = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSelectedNodes(e.currentTarget.checked ? (nodes?.items?.map(node => node.id) || []) : []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedNodes([]);
|
||||
}, [ page ]);
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<AdminContentBlock>
|
||||
<div css={tw`w-full flex flex-row items-center`}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
<div css={tw`flex flex-col`}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>Nodes</h2>
|
||||
<p css={tw`text-base text-neutral-400`}>All nodes available on the system.</p>
|
||||
|
@ -16,6 +71,62 @@ export default () => {
|
|||
New Node
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<FlashMessageRender byKey={'nodes'} css={tw`mb-4`}/>
|
||||
|
||||
<AdminTable>
|
||||
{ nodes === undefined || (error && isValidating) ?
|
||||
<Loading/>
|
||||
:
|
||||
length < 1 ?
|
||||
<NoItems/>
|
||||
:
|
||||
<ContentWrapper
|
||||
checked={selectedNodesLength === (length === 0 ? -1 : length)}
|
||||
onSelectAllClick={onSelectAllClick}
|
||||
>
|
||||
<Pagination data={nodes} onPageSelect={setPage}>
|
||||
<div css={tw`overflow-x-auto`}>
|
||||
<table css={tw`w-full table-auto`}>
|
||||
<TableHead>
|
||||
<TableHeader name={'ID'}/>
|
||||
<TableHeader name={'Name'}/>
|
||||
</TableHead>
|
||||
|
||||
<TableBody>
|
||||
{
|
||||
nodes.items.map(node => (
|
||||
<TableRow key={node.id}>
|
||||
<td css={tw`pl-6`}>
|
||||
<RowCheckbox id={node.id}/>
|
||||
</td>
|
||||
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{node.id}</td>
|
||||
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>
|
||||
<NavLink to={`${match.url}/${node.id}`} css={tw`text-primary-400 hover:text-primary-300`}>
|
||||
{node.name}
|
||||
</NavLink>
|
||||
</td>
|
||||
</TableRow>
|
||||
))
|
||||
}
|
||||
</TableBody>
|
||||
</table>
|
||||
</div>
|
||||
</Pagination>
|
||||
</ContentWrapper>
|
||||
}
|
||||
</AdminTable>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
||||
|
||||
export default () => {
|
||||
const [ page, setPage ] = useState<number>(1);
|
||||
|
||||
return (
|
||||
<NodesContext.Provider value={{ page, setPage }}>
|
||||
<NodesContainer/>
|
||||
</NodesContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import React from 'react';
|
||||
import tw from 'twin.macro';
|
||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<AdminContentBlock>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
<div css={tw`flex flex-col`}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>Create Server</h2>
|
||||
<p css={tw`text-base text-neutral-400`}>Add a new server to the panel.</p>
|
||||
</div>
|
||||
</div>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
|
@ -68,9 +68,11 @@ const UsersContainer = () => {
|
|||
<p css={tw`text-base text-neutral-400`}>All servers available on the system.</p>
|
||||
</div>
|
||||
|
||||
<Button type={'button'} size={'large'} css={tw`h-10 ml-auto px-4 py-0`}>
|
||||
New Server
|
||||
</Button>
|
||||
<NavLink to={`${match.url}/new`} css={tw`ml-auto`}>
|
||||
<Button type={'button'} size={'large'} css={tw`h-10 px-4 py-0`}>
|
||||
New Server
|
||||
</Button>
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<FlashMessageRender byKey={'servers'} css={tw`mb-4`}/>
|
||||
|
|
|
@ -13,6 +13,7 @@ import DatabasesContainer from '@/components/admin/databases/DatabasesContainer'
|
|||
import NodesContainer from '@/components/admin/nodes/NodesContainer';
|
||||
import LocationsContainer from '@/components/admin/locations/LocationsContainer';
|
||||
import ServersContainer from '@/components/admin/servers/ServersContainer';
|
||||
import NewServerContainer from '@/components/admin/servers/NewServerContainer';
|
||||
import UsersContainer from '@/components/admin/users/UsersContainer';
|
||||
import RolesContainer from '@/components/admin/roles/RolesContainer';
|
||||
import RoleEditContainer from '@/components/admin/roles/RoleEditContainer';
|
||||
|
@ -175,7 +176,10 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => {
|
|||
<Route path={`${match.path}/databases`} component={DatabasesContainer} exact/>
|
||||
<Route path={`${match.path}/locations`} component={LocationsContainer} exact/>
|
||||
<Route path={`${match.path}/nodes`} component={NodesContainer} exact/>
|
||||
|
||||
<Route path={`${match.path}/servers`} component={ServersContainer} exact/>
|
||||
<Route path={`${match.path}/servers/new`} component={NewServerContainer} exact/>
|
||||
|
||||
<Route path={`${match.path}/users`} component={UsersContainer} exact/>
|
||||
|
||||
<Route path={`${match.path}/roles`} component={RolesContainer} exact/>
|
||||
|
|
27
resources/scripts/state/admin/databases.ts
Normal file
27
resources/scripts/state/admin/databases.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { action, Action } from 'easy-peasy';
|
||||
|
||||
export interface AdminDatabaseStore {
|
||||
selectedDatabases: number[];
|
||||
|
||||
setSelectedDatabases: Action<AdminDatabaseStore, number[]>;
|
||||
appendSelectedDatabase: Action<AdminDatabaseStore, number>;
|
||||
removeSelectedDatabase: Action<AdminDatabaseStore, number>;
|
||||
}
|
||||
|
||||
const databases: AdminDatabaseStore = {
|
||||
selectedDatabases: [],
|
||||
|
||||
setSelectedDatabases: action((state, payload) => {
|
||||
state.selectedDatabases = payload;
|
||||
}),
|
||||
|
||||
appendSelectedDatabase: action((state, payload) => {
|
||||
state.selectedDatabases = state.selectedDatabases.filter(id => id !== payload).concat(payload);
|
||||
}),
|
||||
|
||||
removeSelectedDatabase: action((state, payload) => {
|
||||
state.selectedDatabases = state.selectedDatabases.filter(id => id !== payload);
|
||||
}),
|
||||
};
|
||||
|
||||
export default databases;
|
|
@ -1,20 +1,32 @@
|
|||
import { createContextStore } from 'easy-peasy';
|
||||
import { composeWithDevTools } from 'redux-devtools-extension';
|
||||
|
||||
import databases, { AdminDatabaseStore } from '@/state/admin/databases';
|
||||
import locations, { AdminLocationStore } from '@/state/admin/locations';
|
||||
import mounts, { AdminMountStore } from '@/state/admin/mounts';
|
||||
import nests, { AdminNestStore } from '@/state/admin/nests';
|
||||
import nodes, { AdminNodeStore } from '@/state/admin/nodes';
|
||||
import roles, { AdminRoleStore } from '@/state/admin/roles';
|
||||
import servers, { AdminServerStore } from '@/state/admin/servers';
|
||||
import users, { AdminUserStore } from '@/state/admin/users';
|
||||
|
||||
interface AdminStore {
|
||||
databases: AdminDatabaseStore;
|
||||
locations: AdminLocationStore;
|
||||
mounts: AdminMountStore;
|
||||
nests: AdminNestStore;
|
||||
nodes: AdminNodeStore;
|
||||
roles: AdminRoleStore;
|
||||
servers: AdminServerStore;
|
||||
users: AdminUserStore;
|
||||
}
|
||||
|
||||
export const AdminContext = createContextStore<AdminStore>({
|
||||
databases,
|
||||
locations,
|
||||
mounts,
|
||||
nests,
|
||||
nodes,
|
||||
roles,
|
||||
servers,
|
||||
users,
|
||||
|
|
27
resources/scripts/state/admin/locations.ts
Normal file
27
resources/scripts/state/admin/locations.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { action, Action } from 'easy-peasy';
|
||||
|
||||
export interface AdminLocationStore {
|
||||
selectedLocations: number[];
|
||||
|
||||
setSelectedLocations: Action<AdminLocationStore, number[]>;
|
||||
appendSelectedLocation: Action<AdminLocationStore, number>;
|
||||
removeSelectedLocation: Action<AdminLocationStore, number>;
|
||||
}
|
||||
|
||||
const locations: AdminLocationStore = {
|
||||
selectedLocations: [],
|
||||
|
||||
setSelectedLocations: action((state, payload) => {
|
||||
state.selectedLocations = payload;
|
||||
}),
|
||||
|
||||
appendSelectedLocation: action((state, payload) => {
|
||||
state.selectedLocations = state.selectedLocations.filter(id => id !== payload).concat(payload);
|
||||
}),
|
||||
|
||||
removeSelectedLocation: action((state, payload) => {
|
||||
state.selectedLocations = state.selectedLocations.filter(id => id !== payload);
|
||||
}),
|
||||
};
|
||||
|
||||
export default locations;
|
27
resources/scripts/state/admin/mounts.ts
Normal file
27
resources/scripts/state/admin/mounts.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { action, Action } from 'easy-peasy';
|
||||
|
||||
export interface AdminMountStore {
|
||||
selectedMounts: number[];
|
||||
|
||||
setSelectedMounts: Action<AdminMountStore, number[]>;
|
||||
appendSelectedMount: Action<AdminMountStore, number>;
|
||||
removeSelectedMount: Action<AdminMountStore, number>;
|
||||
}
|
||||
|
||||
const mounts: AdminMountStore = {
|
||||
selectedMounts: [],
|
||||
|
||||
setSelectedMounts: action((state, payload) => {
|
||||
state.selectedMounts = payload;
|
||||
}),
|
||||
|
||||
appendSelectedMount: action((state, payload) => {
|
||||
state.selectedMounts = state.selectedMounts.filter(id => id !== payload).concat(payload);
|
||||
}),
|
||||
|
||||
removeSelectedMount: action((state, payload) => {
|
||||
state.selectedMounts = state.selectedMounts.filter(id => id !== payload);
|
||||
}),
|
||||
};
|
||||
|
||||
export default mounts;
|
27
resources/scripts/state/admin/nodes.ts
Normal file
27
resources/scripts/state/admin/nodes.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { action, Action } from 'easy-peasy';
|
||||
|
||||
export interface AdminNodeStore {
|
||||
selectedNodes: number[];
|
||||
|
||||
setSelectedNodes: Action<AdminNodeStore, number[]>;
|
||||
appendSelectedNode: Action<AdminNodeStore, number>;
|
||||
removeSelectedNode: Action<AdminNodeStore, number>;
|
||||
}
|
||||
|
||||
const nodes: AdminNodeStore = {
|
||||
selectedNodes: [],
|
||||
|
||||
setSelectedNodes: action((state, payload) => {
|
||||
state.selectedNodes = payload;
|
||||
}),
|
||||
|
||||
appendSelectedNode: action((state, payload) => {
|
||||
state.selectedNodes = state.selectedNodes.filter(id => id !== payload).concat(payload);
|
||||
}),
|
||||
|
||||
removeSelectedNode: action((state, payload) => {
|
||||
state.selectedNodes = state.selectedNodes.filter(id => id !== payload);
|
||||
}),
|
||||
};
|
||||
|
||||
export default nodes;
|
|
@ -4,23 +4,84 @@ use Illuminate\Support\Facades\Route;
|
|||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Controller Routes
|
||||
| Database Controller Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Endpoint: /api/application/users
|
||||
| Endpoint: /api/application/databases
|
||||
|
|
||||
*/
|
||||
Route::group(['prefix' => '/databases'], function () {
|
||||
Route::get('/', 'Databases\DatabaseController@index');
|
||||
Route::get('/{database}', 'Databases\DatabaseController@view');
|
||||
|
||||
Route::group(['prefix' => '/users'], function () {
|
||||
Route::get('/', 'Users\UserController@index')->name('api.application.users');
|
||||
Route::get('/{user}', 'Users\UserController@view')->name('api.application.users.view');
|
||||
Route::get('/external/{external_id}', 'Users\ExternalUserController@index')->name('api.application.users.external');
|
||||
Route::post('/', 'Databases\DatabaseController@store');
|
||||
|
||||
Route::post('/', 'Users\UserController@store');
|
||||
Route::patch('/{database}', 'Databases\DatabaseController@update');
|
||||
|
||||
Route::patch('/{user}', 'Users\UserController@update');
|
||||
Route::delete('/{database}', 'Databases\DatabaseController@delete');
|
||||
});
|
||||
|
||||
Route::delete('/{user}', 'Users\UserController@delete');
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Location Controller Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Endpoint: /api/application/locations
|
||||
|
|
||||
*/
|
||||
Route::group(['prefix' => '/locations'], function () {
|
||||
Route::get('/', 'Locations\LocationController@index')->name('api.applications.locations');
|
||||
Route::get('/{location}', 'Locations\LocationController@view')->name('api.application.locations.view');
|
||||
|
||||
Route::post('/', 'Locations\LocationController@store');
|
||||
|
||||
Route::patch('/{location}', 'Locations\LocationController@update');
|
||||
|
||||
Route::delete('/{location}', 'Locations\LocationController@delete');
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mount Controller Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Endpoint: /api/application/mounts
|
||||
|
|
||||
*/
|
||||
Route::group(['prefix' => '/mounts'], function () {
|
||||
Route::get('/', 'Mounts\MountController@index');
|
||||
Route::get('/{mount}', 'Mounts\MountController@view');
|
||||
|
||||
Route::post('/', 'Mounts\MountController@store');
|
||||
|
||||
Route::patch('/{mount}', 'Mounts\MountController@update');
|
||||
|
||||
Route::delete('/{mount}', 'Mounts\MountController@delete');
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Nest Controller Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Endpoint: /api/application/nests
|
||||
|
|
||||
*/
|
||||
Route::group(['prefix' => '/nests'], function () {
|
||||
Route::get('/', 'Nests\NestController@index')->name('api.application.nests');
|
||||
Route::get('/{nest}', 'Nests\NestController@view')->name('api.application.nests.view');
|
||||
|
||||
Route::post('/', 'Nests\NestController@store');
|
||||
|
||||
Route::patch('/{nest}', 'Nests\NestController@update');
|
||||
|
||||
Route::delete('/{nest}', 'Nests\NestController@delete');
|
||||
|
||||
// Egg Management Endpoint
|
||||
Route::group(['prefix' => '/{nest}/eggs'], function () {
|
||||
Route::get('/', 'Nests\EggController@index')->name('api.application.nests.eggs');
|
||||
Route::get('/{egg}', 'Nests\EggController@view')->name('api.application.nests.eggs.view');
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -49,25 +110,28 @@ Route::group(['prefix' => '/nodes'], function () {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Location Controller Routes
|
||||
| Role Controller Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Endpoint: /api/application/locations
|
||||
| Endpoint: /api/application/roles
|
||||
|
|
||||
*/
|
||||
Route::group(['prefix' => '/locations'], function () {
|
||||
Route::get('/', 'Locations\LocationController@index')->name('api.applications.locations');
|
||||
Route::get('/{location}', 'Locations\LocationController@view')->name('api.application.locations.view');
|
||||
|
||||
Route::post('/', 'Locations\LocationController@store');
|
||||
Route::group(['prefix' => '/roles'], function () {
|
||||
Route::get('/', 'Roles\RoleController@index');
|
||||
Route::get('/{role}', 'Roles\RoleController@view');
|
||||
|
||||
Route::patch('/{location}', 'Locations\LocationController@update');
|
||||
Route::post('/', 'Roles\RoleController@store');
|
||||
|
||||
Route::delete('/{location}', 'Locations\LocationController@delete');
|
||||
Route::patch('/{role}', 'Roles\RoleController@update');
|
||||
|
||||
Route::delete('/{role}', 'Roles\RoleController@delete');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Server Controller Routes
|
||||
|
@ -107,45 +171,21 @@ Route::group(['prefix' => '/servers'], function () {
|
|||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Nest Controller Routes
|
||||
| User Controller Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Endpoint: /api/application/nests
|
||||
|
|
||||
*/
|
||||
Route::group(['prefix' => '/nests'], function () {
|
||||
Route::get('/', 'Nests\NestController@index')->name('api.application.nests');
|
||||
Route::get('/{nest}', 'Nests\NestController@view')->name('api.application.nests.view');
|
||||
|
||||
Route::post('/', 'Nests\NestController@store');
|
||||
|
||||
Route::patch('/{nest}', 'Nests\NestController@update');
|
||||
|
||||
Route::delete('/{nest}', 'Nests\NestController@delete');
|
||||
|
||||
// Egg Management Endpoint
|
||||
Route::group(['prefix' => '/{nest}/eggs'], function () {
|
||||
Route::get('/', 'Nests\EggController@index')->name('api.application.nests.eggs');
|
||||
Route::get('/{egg}', 'Nests\EggController@view')->name('api.application.nests.eggs.view');
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Role Controller Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Endpoint: /api/application/roles
|
||||
| Endpoint: /api/application/users
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group(['prefix' => '/roles'], function () {
|
||||
Route::get('/', 'Roles\RoleController@index');
|
||||
Route::get('/{role}', 'Roles\RoleController@view');
|
||||
Route::group(['prefix' => '/users'], function () {
|
||||
Route::get('/', 'Users\UserController@index')->name('api.application.users');
|
||||
Route::get('/{user}', 'Users\UserController@view')->name('api.application.users.view');
|
||||
Route::get('/external/{external_id}', 'Users\ExternalUserController@index')->name('api.application.users.external');
|
||||
|
||||
Route::post('/', 'Roles\RoleController@store');
|
||||
Route::post('/', 'Users\UserController@store');
|
||||
|
||||
Route::patch('/{role}', 'Roles\RoleController@update');
|
||||
Route::patch('/{user}', 'Users\UserController@update');
|
||||
|
||||
Route::delete('/{role}', 'Roles\RoleController@delete');
|
||||
Route::delete('/{user}', 'Users\UserController@delete');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue