Skip to content

Commit a9fa60a

Browse files
committed
Respect pagination settings on frontend
closes pterodactyl#1335
1 parent 8af50e1 commit a9fa60a

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
99
* TS3 egg updated to use CLI arguments correctly and have a more minimalistic installation script.
1010
* Terminal was not properly displaying longer lines leading to some visual inconsistency.
1111
* Assorted translation updates.
12+
* Pagination for server listing now properly respects configuration setting.
1213

1314
### Changed
1415
* Removed PhraseApp integration from Panel code as it is no longer used.

app/Contracts/Repository/ServerRepositoryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ public function getDaemonServiceData(Server $server, bool $refresh = false): arr
103103
*
104104
* @param \Pterodactyl\Models\User $user
105105
* @param int $level
106-
* @param bool $paginate
106+
* @param bool|int $paginate
107107
* @return \Illuminate\Pagination\LengthAwarePaginator|\Illuminate\Database\Eloquent\Collection
108108
*/
109-
public function filterUserAccessServers(User $user, int $level, bool $paginate = true);
109+
public function filterUserAccessServers(User $user, int $level, $paginate = 25);
110110

111111
/**
112112
* Return a server by UUID.

app/Http/Controllers/Api/Client/ClientController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(ServerRepositoryInterface $repository)
3535
*/
3636
public function index(GetServersRequest $request): array
3737
{
38-
$servers = $this->repository->filterUserAccessServers($request->user(), User::FILTER_LEVEL_SUBUSER);
38+
$servers = $this->repository->filterUserAccessServers($request->user(), User::FILTER_LEVEL_SUBUSER, config('pterodactyl.paginate.frontend.servers'));
3939

4040
return $this->fractal->collection($servers)
4141
->transformWith($this->getTransformer(ServerTransformer::class))

app/Http/Controllers/Base/IndexController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(
5656
public function getIndex(Request $request)
5757
{
5858
$servers = $this->repository->setSearchTerm($request->input('query'))->filterUserAccessServers(
59-
$request->user(), User::FILTER_LEVEL_ALL
59+
$request->user(), User::FILTER_LEVEL_ALL, config('pterodactyl.paginate.frontend.servers')
6060
);
6161

6262
return view('base.index', ['servers' => $servers]);

app/Repositories/Eloquent/ServerRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ public function getDaemonServiceData(Server $server, bool $refresh = false): arr
211211
*
212212
* @param \Pterodactyl\Models\User $user
213213
* @param int $level
214-
* @param bool $paginate
214+
* @param bool|int $paginate
215215
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Database\Eloquent\Collection
216216
*/
217-
public function filterUserAccessServers(User $user, int $level, bool $paginate = true)
217+
public function filterUserAccessServers(User $user, int $level, $paginate = 25)
218218
{
219219
$instance = $this->getBuilder()->select($this->getColumns())->with(['user', 'node', 'allocation']);
220220

@@ -240,7 +240,7 @@ public function filterUserAccessServers(User $user, int $level, bool $paginate =
240240

241241
$instance->search($this->getSearchTerm());
242242

243-
return $paginate ? $instance->paginate(25) : $instance->get();
243+
return $paginate ? $instance->paginate($paginate) : $instance->get();
244244
}
245245

246246
/**

0 commit comments

Comments
 (0)