Add support for filtering servers in client list-all endpoint
closes #1608
This commit is contained in:
parent
47c12929c4
commit
fe9d86b66b
|
@ -16,6 +16,9 @@ error encountered during creation or update.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Server listing view now displays the total used disk space for each server.
|
* Server listing view now displays the total used disk space for each server.
|
||||||
|
* Client API endpoint to list all servers now supports an additional `?filter=subuser-of|all|admin|owner` parameter to
|
||||||
|
return different groupings of servers. The default value is `subuser-of` which will include all of the user's servers
|
||||||
|
that they are the owner of, as well as all servers they're a subuser of.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Updated Paper egg to not download `server.properties` each time. [parkervcp/eggs#260](https://github.com/parkervcp/eggs/issues/260)
|
* Updated Paper egg to not download `server.properties` each time. [parkervcp/eggs#260](https://github.com/parkervcp/eggs/issues/260)
|
||||||
|
|
|
@ -35,7 +35,26 @@ class ClientController extends ClientApiController
|
||||||
*/
|
*/
|
||||||
public function index(GetServersRequest $request): array
|
public function index(GetServersRequest $request): array
|
||||||
{
|
{
|
||||||
$servers = $this->repository->filterUserAccessServers($request->user(), User::FILTER_LEVEL_SUBUSER, config('pterodactyl.paginate.frontend.servers'));
|
// Check for the filter parameter on the request.
|
||||||
|
switch ($request->input('filter')) {
|
||||||
|
case 'all':
|
||||||
|
$filter = User::FILTER_LEVEL_ALL;
|
||||||
|
break;
|
||||||
|
case 'admin':
|
||||||
|
$filter = User::FILTER_LEVEL_ADMIN;
|
||||||
|
break;
|
||||||
|
case 'owner':
|
||||||
|
$filter = User::FILTER_LEVEL_OWNER;
|
||||||
|
break;
|
||||||
|
case 'subuser-of':
|
||||||
|
default:
|
||||||
|
$filter = User::FILTER_LEVEL_SUBUSER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$servers = $this->repository->filterUserAccessServers(
|
||||||
|
$request->user(), $filter, config('pterodactyl.paginate.frontend.servers')
|
||||||
|
);
|
||||||
|
|
||||||
return $this->fractal->collection($servers)
|
return $this->fractal->collection($servers)
|
||||||
->transformWith($this->getTransformer(ServerTransformer::class))
|
->transformWith($this->getTransformer(ServerTransformer::class))
|
||||||
|
|
Loading…
Reference in New Issue