Paginate server results when viewing a node, closes #1404
This commit is contained in:
parent
50eb2a10ad
commit
d9593b23ab
|
@ -16,6 +16,9 @@ a server through the API.
|
||||||
* The `PATCH` endpoint for `/api/applications/servers/{server}/build` now accepts an array called `limits` to match
|
* The `PATCH` endpoint for `/api/applications/servers/{server}/build` now accepts an array called `limits` to match
|
||||||
the response from the server `GET` endpoint.
|
the response from the server `GET` endpoint.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
* The server listing for a node is now paginated to 25 servers per page to improve performance on large nodes.
|
||||||
|
|
||||||
## v0.7.12 (Derelict Dermodactylus)
|
## v0.7.12 (Derelict Dermodactylus)
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fixes an issue with the locations API endpoint referencing an invalid namespace.
|
* Fixes an issue with the locations API endpoint referencing an invalid namespace.
|
||||||
|
|
|
@ -55,16 +55,6 @@ interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterfa
|
||||||
*/
|
*/
|
||||||
public function loadNodeAllocations(Node $node, bool $refresh = false): Node;
|
public function loadNodeAllocations(Node $node, bool $refresh = false): Node;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a node with all of the servers attached to that node.
|
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @return \Pterodactyl\Models\Node
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
|
||||||
public function getNodeServers(int $id): Node;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a collection of nodes for all locations to use in server creation UI.
|
* Return a collection of nodes for all locations to use in server creation UI.
|
||||||
*
|
*
|
||||||
|
|
|
@ -152,4 +152,14 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getSuspendedServersCount(): int;
|
public function getSuspendedServersCount(): int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all of the servers that exist for a given node in a paginated response.
|
||||||
|
*
|
||||||
|
* @param int $node
|
||||||
|
* @param int $limit
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||||
|
*/
|
||||||
|
public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ use Pterodactyl\Services\Allocations\AssignmentService;
|
||||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||||
use Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest;
|
use Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest;
|
||||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||||
use Pterodactyl\Http\Requests\Admin\Node\AllocationFormRequest;
|
use Pterodactyl\Http\Requests\Admin\Node\AllocationFormRequest;
|
||||||
use Pterodactyl\Services\Allocations\AllocationDeletionService;
|
use Pterodactyl\Services\Allocations\AllocationDeletionService;
|
||||||
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
||||||
|
@ -32,6 +33,11 @@ use Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest;
|
||||||
|
|
||||||
class NodesController extends Controller
|
class NodesController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var \Pterodactyl\Services\Allocations\AllocationDeletionService
|
||||||
|
*/
|
||||||
|
protected $allocationDeletionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Prologue\Alerts\AlertsMessageBag
|
* @var \Prologue\Alerts\AlertsMessageBag
|
||||||
*/
|
*/
|
||||||
|
@ -72,6 +78,11 @@ class NodesController extends Controller
|
||||||
*/
|
*/
|
||||||
protected $repository;
|
protected $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||||
|
*/
|
||||||
|
protected $serverRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Pterodactyl\Services\Nodes\NodeUpdateService
|
* @var \Pterodactyl\Services\Nodes\NodeUpdateService
|
||||||
*/
|
*/
|
||||||
|
@ -81,10 +92,6 @@ class NodesController extends Controller
|
||||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||||
*/
|
*/
|
||||||
protected $versionService;
|
protected $versionService;
|
||||||
/**
|
|
||||||
* @var \Pterodactyl\Services\Allocations\AllocationDeletionService
|
|
||||||
*/
|
|
||||||
private $allocationDeletionService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodesController constructor.
|
* NodesController constructor.
|
||||||
|
@ -98,6 +105,7 @@ class NodesController extends Controller
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService
|
* @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService
|
||||||
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
|
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
|
||||||
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
|
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
|
||||||
|
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService
|
* @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService
|
||||||
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
|
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
|
||||||
*/
|
*/
|
||||||
|
@ -111,6 +119,7 @@ class NodesController extends Controller
|
||||||
NodeDeletionService $deletionService,
|
NodeDeletionService $deletionService,
|
||||||
LocationRepositoryInterface $locationRepository,
|
LocationRepositoryInterface $locationRepository,
|
||||||
NodeRepositoryInterface $repository,
|
NodeRepositoryInterface $repository,
|
||||||
|
ServerRepositoryInterface $serverRepository,
|
||||||
NodeUpdateService $updateService,
|
NodeUpdateService $updateService,
|
||||||
SoftwareVersionService $versionService
|
SoftwareVersionService $versionService
|
||||||
) {
|
) {
|
||||||
|
@ -123,6 +132,7 @@ class NodesController extends Controller
|
||||||
$this->deletionService = $deletionService;
|
$this->deletionService = $deletionService;
|
||||||
$this->locationRepository = $locationRepository;
|
$this->locationRepository = $locationRepository;
|
||||||
$this->repository = $repository;
|
$this->repository = $repository;
|
||||||
|
$this->serverRepository = $serverRepository;
|
||||||
$this->updateService = $updateService;
|
$this->updateService = $updateService;
|
||||||
$this->versionService = $versionService;
|
$this->versionService = $versionService;
|
||||||
}
|
}
|
||||||
|
@ -178,8 +188,6 @@ class NodesController extends Controller
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Node $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
* @return \Illuminate\View\View
|
* @return \Illuminate\View\View
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function viewIndex(Node $node)
|
public function viewIndex(Node $node)
|
||||||
{
|
{
|
||||||
|
@ -235,19 +243,17 @@ class NodesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Shows the server listing page for a specific node.
|
* Shows the server listing page for a specific node.
|
||||||
*
|
*
|
||||||
* @param int $node
|
* @param \Pterodactyl\Models\Node $node
|
||||||
* @return \Illuminate\View\View
|
* @return \Illuminate\View\View
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function viewServers($node)
|
public function viewServers(Node $node)
|
||||||
{
|
{
|
||||||
$node = $this->repository->getNodeServers($node);
|
$servers = $this->serverRepository->loadAllServersForNode($node->id, 25);
|
||||||
Javascript::put([
|
Javascript::put([
|
||||||
'node' => collect($node->makeVisible('daemonSecret'))->only(['scheme', 'fqdn', 'daemonListen', 'daemonSecret']),
|
'node' => collect($node->makeVisible('daemonSecret'))->only(['scheme', 'fqdn', 'daemonListen', 'daemonSecret']),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return view('admin.nodes.view.servers', ['node' => $node]);
|
return view('admin.nodes.view.servers', ['node' => $node, 'servers' => $servers]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,10 +6,8 @@ use Generator;
|
||||||
use Pterodactyl\Models\Node;
|
use Pterodactyl\Models\Node;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Pterodactyl\Repositories\Concerns\Searchable;
|
use Pterodactyl\Repositories\Concerns\Searchable;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
|
||||||
|
|
||||||
class NodeRepository extends EloquentRepository implements NodeRepositoryInterface
|
class NodeRepository extends EloquentRepository implements NodeRepositoryInterface
|
||||||
{
|
{
|
||||||
|
@ -140,25 +138,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a node with all of the servers attached to that node.
|
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @return \Pterodactyl\Models\Node
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
||||||
*/
|
|
||||||
public function getNodeServers(int $id): Node
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return $this->getBuilder()->with([
|
|
||||||
'servers.user', 'servers.nest', 'servers.egg',
|
|
||||||
])->findOrFail($id, $this->getColumns());
|
|
||||||
} catch (ModelNotFoundException $exception) {
|
|
||||||
throw new RecordNotFoundException;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a collection of nodes for all locations to use in server creation UI.
|
* Return a collection of nodes for all locations to use in server creation UI.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Repositories\Eloquent;
|
namespace Pterodactyl\Repositories\Eloquent;
|
||||||
|
|
||||||
|
use Pterodactyl\Models\Node;
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
|
@ -338,4 +339,20 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
||||||
{
|
{
|
||||||
return $this->getBuilder()->where('suspended', true)->count();
|
return $this->getBuilder()->where('suspended', true)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all of the servers that exist for a given node in a paginated response.
|
||||||
|
*
|
||||||
|
* @param int $node
|
||||||
|
* @param int $limit
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||||
|
*/
|
||||||
|
public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator
|
||||||
|
{
|
||||||
|
return $this->getBuilder()
|
||||||
|
->with(['user', 'nest', 'egg'])
|
||||||
|
->where('node_id', '=', $node)
|
||||||
|
->paginate($limit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<th class="text-center">CPU</th>
|
<th class="text-center">CPU</th>
|
||||||
<th class="text-center">Status</th>
|
<th class="text-center">Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
@foreach($node->servers as $server)
|
@foreach($servers as $server)
|
||||||
<tr data-server="{{ $server->uuid }}">
|
<tr data-server="{{ $server->uuid }}">
|
||||||
<td><code>{{ $server->uuidShort }}</code></td>
|
<td><code>{{ $server->uuidShort }}</code></td>
|
||||||
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
|
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
|
||||||
|
@ -64,6 +64,11 @@
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
|
@if($servers->hasPages())
|
||||||
|
<div class="box-footer with-border">
|
||||||
|
<div class="col-md-12 text-center">{!! $servers->render() !!}</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue