support for changing allocation on frontend

This commit is contained in:
Dane Everitt 2016-01-03 15:15:14 -05:00
parent fb77e23eb4
commit a7fdb9618c
4 changed files with 86 additions and 3 deletions

View file

@ -178,4 +178,38 @@ class AjaxController extends Controller
}
/**
* [postSetConnection description]
* @param Request $request
* @param string $uuid
* @return \Illuminate\Http\Response
*/
public function postSetConnection(Request $request, $uuid)
{
$server = Server::getByUUID($uuid);
$this->authorize('set-connection', $server);
try {
$repo = new Repositories\ServerRepository;
$repo->changeBuild($server->id, [
'default' => $request->input('connection'),
]);
return response('The default connection for this server has been updated. Please be aware that you will need to restart your server for this change to go into effect.');
} catch (\Exception $e) {
if ($e instanceof \Pterodactyl\Exceptions\DisplayException || $e instanceof \Pterodactyl\Exceptions\DisplayValidationException) {
return response()->json([
'error' => $e->getMessage(),
], 503);
} else {
Log::error($e);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify the default connection for this server.'
], 503);
}
}
}
}

View file

@ -18,6 +18,7 @@ class ServerRoutes {
// Ajax Routes
$router->group(['prefix' => 'ajax'], function ($server) use ($router) {
$router->get('status', [ 'uses' => 'Server\AjaxController@getStatus' ]);
$router->post('set-connection', [ 'uses' => 'Server\AjaxController@postSetConnection' ]);
$router->post('files/directory-list', [ 'uses' => 'Server\AjaxController@postDirectoryList' ]);
$router->post('files/save', [ 'uses' => 'Server\AjaxController@postSaveFile' ]);
});