Add support for suspension

This commit is contained in:
Dane Everitt 2016-09-01 21:16:38 -04:00
parent 3ca7e4d578
commit 38eae88bd0
9 changed files with 223 additions and 25 deletions

View file

@ -424,4 +424,42 @@ class ServersController extends Controller
])->withInput();
}
public function postSuspendServer(Request $request, $id)
{
try {
$repo = new ServerRepository;
$repo->suspend($id);
Alert::success('Server has been suspended on the system. All running processes have been stopped and will not be startable until it is un-suspended.');
} catch (\Pterodactyl\Exceptions\DisplayException $e) {
Alert::danger($e->getMessage())->flash();
} catch(\Exception $e) {
Log::error($e);
Alert::danger('An unhandled exception occured while attemping to suspend this server. Please try again.')->flash();
} finally {
return redirect()->route('admin.servers.view', [
'id' => $id,
'tab' => 'tab_manage'
]);
}
}
public function postUnsuspendServer(Request $request, $id)
{
try {
$repo = new ServerRepository;
$repo->unsuspend($id);
Alert::success('Server has been unsuspended on the system. Access has been re-enabled.');
} catch (\Pterodactyl\Exceptions\DisplayException $e) {
Alert::danger($e->getMessage())->flash();
} catch(\Exception $e) {
Log::error($e);
Alert::danger('An unhandled exception occured while attemping to unsuspend this server. Please try again.')->flash();
} finally {
return redirect()->route('admin.servers.view', [
'id' => $id,
'tab' => 'tab_manage'
]);
}
}
}

View file

@ -46,11 +46,15 @@ class CheckServer
$server = Server::getByUUID($request->route()->server);
if (!$server) {
return response()->view('errors.403', [], 403);
return response()->view('errors.404', [], 404);
}
if ($server->suspended === 1) {
return response()->view('errors.suspended', [], 403);
}
if ($server->installed !== 1) {
return response()->view('errors.installing', [], 503);
return response()->view('errors.installing', [], 403);
}
return $next($request);

View file

@ -129,21 +129,21 @@ class AdminRoutes {
]);
// Assorted Page Helpers
$router->post('/new/get-nodes', [
'uses' => 'Admin\ServersController@postNewServerGetNodes'
]);
$router->post('/new/get-nodes', [
'uses' => 'Admin\ServersController@postNewServerGetNodes'
]);
$router->post('/new/get-ips', [
'uses' => 'Admin\ServersController@postNewServerGetIps'
]);
$router->post('/new/get-ips', [
'uses' => 'Admin\ServersController@postNewServerGetIps'
]);
$router->post('/new/service-options', [
'uses' => 'Admin\ServersController@postNewServerServiceOptions'
]);
$router->post('/new/service-options', [
'uses' => 'Admin\ServersController@postNewServerServiceOptions'
]);
$router->post('/new/service-variables', [
'uses' => 'Admin\ServersController@postNewServerServiceVariables'
]);
$router->post('/new/service-variables', [
'uses' => 'Admin\ServersController@postNewServerServiceVariables'
]);
// End Assorted Page Helpers
// View Specific Server
@ -179,6 +179,16 @@ class AdminRoutes {
'uses' => 'Admin\ServersController@postUpdateServerUpdateBuild'
]);
// Suspend Server
$router->post('/view/{id}/suspend', [
'uses' => 'Admin\ServersController@postSuspendServer'
]);
// Unsuspend Server
$router->post('/view/{id}/unsuspend', [
'uses' => 'Admin\ServersController@postUnsuspendServer'
]);
// Change Install Status
$router->post('/view/{id}/installed', [
'uses' => 'Admin\ServersController@postToggleInstall'