Skip to content

Commit 5144e01

Browse files
committed
Add support for more server functionality
1 parent acbc525 commit 5144e01

File tree

16 files changed

+1049
-119
lines changed

16 files changed

+1049
-119
lines changed

app/Contracts/Repository/Daemon/ServerRepositoryInterface.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,32 @@ public function create($id, $overrides = [], $start = false);
4343
* @return \Psr\Http\Message\ResponseInterface
4444
*/
4545
public function update(array $data);
46+
47+
/**
48+
* Mark a server to be reinstalled on the system.
49+
*
50+
* @return \Psr\Http\Message\ResponseInterface
51+
*/
52+
public function reinstall();
53+
54+
/**
55+
* Mark a server as needing a container rebuild the next time the server is booted.
56+
*
57+
* @return \Psr\Http\Message\ResponseInterface
58+
*/
59+
public function rebuild();
60+
61+
/**
62+
* Suspend a server on the daemon.
63+
*
64+
* @return \Psr\Http\Message\ResponseInterface
65+
*/
66+
public function suspend();
67+
68+
/**
69+
* Un-suspend a server on the daemon.
70+
*
71+
* @return \Psr\Http\Message\ResponseInterface
72+
*/
73+
public function unsuspend();
4674
}

app/Contracts/Repository/LocationRepositoryInterface.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,21 @@ interface LocationRepositoryInterface extends RepositoryInterface, SearchableInt
3838
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
3939
*/
4040
public function deleteIfNoNodes($id);
41+
42+
/**
43+
* Return locations with a count of nodes and servers attached to it.
44+
*
45+
* @return mixed
46+
*/
47+
public function allWithDetails();
48+
49+
/**
50+
* Return all of the nodes and their respective count of servers for a location.
51+
*
52+
* @param int $id
53+
* @return mixed
54+
*
55+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
56+
*/
57+
public function getWithNodes($id);
4158
}

app/Http/Controllers/Admin/LocationController.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424

2525
namespace Pterodactyl\Http\Controllers\Admin;
2626

27+
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
2728
use Pterodactyl\Models\Location;
2829
use Prologue\Alerts\AlertsMessageBag;
2930
use Pterodactyl\Exceptions\DisplayException;
3031
use Pterodactyl\Http\Controllers\Controller;
3132
use Pterodactyl\Http\Requests\Admin\LocationRequest;
32-
use Pterodactyl\Services\Administrative\LocationService;
33+
use Pterodactyl\Services\LocationService;
3334

3435
class LocationController extends Controller
3536
{
@@ -39,29 +40,29 @@ class LocationController extends Controller
3940
protected $alert;
4041

4142
/**
42-
* @var \Pterodactyl\Models\Location
43+
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
4344
*/
44-
protected $locationModel;
45+
protected $repository;
4546

4647
/**
47-
* @var \Pterodactyl\Services\Administrative\\LocationService
48+
* @var \Pterodactyl\Services\\LocationService
4849
*/
4950
protected $service;
5051

5152
/**
5253
* LocationController constructor.
5354
*
54-
* @param \Prologue\Alerts\AlertsMessageBag $alert
55-
* @param \Pterodactyl\Models\Location $locationModel
56-
* @param \Pterodactyl\Services\Administrative\LocationService $service
55+
* @param \Prologue\Alerts\AlertsMessageBag $alert
56+
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
57+
* @param \Pterodactyl\Services\LocationService $service
5758
*/
5859
public function __construct(
5960
AlertsMessageBag $alert,
60-
Location $locationModel,
61+
LocationRepositoryInterface $repository,
6162
LocationService $service
6263
) {
6364
$this->alert = $alert;
64-
$this->locationModel = $locationModel;
65+
$this->repository = $repository;
6566
$this->service = $service;
6667
}
6768

@@ -73,21 +74,21 @@ public function __construct(
7374
public function index()
7475
{
7576
return view('admin.locations.index', [
76-
'locations' => $this->locationModel->withCount('nodes', 'servers')->get(),
77+
'locations' => $this->repository->allWithDetails(),
7778
]);
7879
}
7980

8081
/**
8182
* Return the location view page.
8283
*
83-
* @param \Pterodactyl\Models\Location $location
84+
* @param int $id
8485
* @return \Illuminate\View\View
8586
*/
86-
public function view(Location $location)
87+
public function view($id)
8788
{
88-
$location->load('nodes.servers');
89-
90-
return view('admin.locations.view', ['location' => $location]);
89+
return view('admin.locations.view', [
90+
'location' => $this->repository->getWithNodes($id),
91+
]);
9192
}
9293

9394
/**
@@ -132,7 +133,7 @@ public function update(LocationRequest $request, Location $location)
132133
/**
133134
* Delete a location from the system.
134135
*
135-
* @param \Pterodactyl\Models\Location $location
136+
* @param \Pterodactyl\Models\Location $location
136137
* @return \Illuminate\Http\RedirectResponse
137138
*
138139
* @throws \Exception

0 commit comments

Comments
 (0)