forked from Alex/Pterodactyl-Panel
paginate databases when viewing a host
This commit is contained in:
parent
e8cb441fc8
commit
c739f292e4
@ -7,6 +7,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||
### Fixed
|
||||
* Fixes application API keys being created as a client API key.
|
||||
|
||||
### Changed
|
||||
* Databases are now properly paginated when viewing a database host.
|
||||
|
||||
## v0.7.4-h1 (Derelict Dermodactylus)
|
||||
### Fixed
|
||||
* Being able to create servers is kind of a core aspect of the software, pushing releases late at night is not a great idea.
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
|
||||
interface DatabaseHostRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
@ -14,15 +13,4 @@ interface DatabaseHostRepositoryInterface extends RepositoryInterface
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getWithViewDetails(): Collection;
|
||||
|
||||
/**
|
||||
* Return a database host with the databases and associated servers
|
||||
* that are attached to said databases.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\DatabaseHost
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithServers(int $id): DatabaseHost;
|
||||
}
|
||||
|
@ -1,16 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Database;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
interface DatabaseRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
@ -39,6 +33,15 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
||||
*/
|
||||
public function getDatabasesForServer(int $server): Collection;
|
||||
|
||||
/**
|
||||
* Return all of the databases for a given host with the server relationship loaded.
|
||||
*
|
||||
* @param int $host
|
||||
* @param int $count
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Create a new database if it does not already exist on the host with
|
||||
* the provided details.
|
||||
|
@ -1,11 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
@ -19,6 +12,7 @@ use Pterodactyl\Services\Databases\Hosts\HostUpdateService;
|
||||
use Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest;
|
||||
use Pterodactyl\Services\Databases\Hosts\HostCreationService;
|
||||
use Pterodactyl\Services\Databases\Hosts\HostDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
||||
|
||||
@ -34,6 +28,11 @@ class DatabaseController extends Controller
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
|
||||
*/
|
||||
private $databaseRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\Hosts\HostDeletionService
|
||||
*/
|
||||
@ -59,6 +58,7 @@ class DatabaseController extends Controller
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
|
||||
* @param \Pterodactyl\Services\Databases\Hosts\HostCreationService $creationService
|
||||
* @param \Pterodactyl\Services\Databases\Hosts\HostDeletionService $deletionService
|
||||
* @param \Pterodactyl\Services\Databases\Hosts\HostUpdateService $updateService
|
||||
@ -67,6 +67,7 @@ class DatabaseController extends Controller
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
DatabaseHostRepositoryInterface $repository,
|
||||
DatabaseRepositoryInterface $databaseRepository,
|
||||
HostCreationService $creationService,
|
||||
HostDeletionService $deletionService,
|
||||
HostUpdateService $updateService,
|
||||
@ -74,6 +75,7 @@ class DatabaseController extends Controller
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->databaseRepository = $databaseRepository;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
@ -105,7 +107,8 @@ class DatabaseController extends Controller
|
||||
{
|
||||
return view('admin.databases.view', [
|
||||
'locations' => $this->locationRepository->getAllWithNodes(),
|
||||
'host' => $this->repository->getWithServers($host),
|
||||
'host' => $this->repository->find($host),
|
||||
'databases' => $this->databaseRepository->getDatabasesForHost($host),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,6 @@ namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
||||
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
||||
|
||||
class DatabaseHostRepository extends EloquentRepository implements DatabaseHostRepositoryInterface
|
||||
@ -30,22 +28,4 @@ class DatabaseHostRepository extends EloquentRepository implements DatabaseHostR
|
||||
{
|
||||
return $this->getBuilder()->withCount('databases')->with('node')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a database host with the databases and associated servers
|
||||
* that are attached to said databases.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\DatabaseHost
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithServers(int $id): DatabaseHost
|
||||
{
|
||||
try {
|
||||
return $this->getBuilder()->with('databases.server')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use Pterodactyl\Models\Database;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Database\DatabaseManager;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException;
|
||||
|
||||
@ -78,6 +79,20 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
||||
return $this->getBuilder()->where('server_id', $server)->get($this->getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the databases for a given host with the server relationship loaded.
|
||||
*
|
||||
* @param int $host
|
||||
* @param int $count
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator
|
||||
{
|
||||
return $this->getBuilder()->with('server')
|
||||
->where('database_host_id', $host)
|
||||
->paginate($count, $this->getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database if it does not already exist on the host with
|
||||
* the provided details.
|
||||
|
@ -101,14 +101,14 @@
|
||||
<th>Connections From</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@foreach($host->databases as $database)
|
||||
@foreach($databases as $database)
|
||||
<tr>
|
||||
<td class="middle"><a href="{{ route('admin.servers.view', $database->server->id) }}">{{ $database->server->name }}</a></td>
|
||||
<td class="middle"><a href="{{ route('admin.servers.view', $database->getRelation('server')->id) }}">{{ $database->getRelation('server')->name }}</a></td>
|
||||
<td class="middle">{{ $database->database }}</td>
|
||||
<td class="middle">{{ $database->username }}</td>
|
||||
<td class="middle">{{ $database->remote }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ route('admin.servers.view.database', $database->server->id) }}">
|
||||
<a href="{{ route('admin.servers.view.database', $database->getRelation('server')->id) }}">
|
||||
<button class="btn btn-xs btn-primary">Manage</button>
|
||||
</a>
|
||||
</td>
|
||||
@ -116,6 +116,11 @@
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
@if($databases->hasPages())
|
||||
<div class="box-footer with-border">
|
||||
<div class="col-md-12 text-center">{!! $databases->render() !!}</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user