Added startup management, cleaned up code.

Refactored entire startup repository code block to be more efficient
and cleaner. Also includes modifications to front-end to make it match
backend name and design.
This commit is contained in:
Dane Everitt 2017-03-04 23:45:22 -05:00
parent d51ae5ec23
commit 349b36d38a
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 252 additions and 146 deletions

View file

@ -475,27 +475,34 @@ class ServersController extends Controller
return redirect()->route('admin.servers.view.delete', $id);
}
// //
// public function postUpdateServerStartup(Request $request, $id)
// {
// try {
// $server = new ServerRepository;
// $server->updateStartup($id, $request->except([
// '_token',
// ]), true);
// Alert::success('Server startup variables were successfully updated.')->flash();
// } 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 update startup variables for this server. Please try again.')->flash();
// } finally {
// return redirect()->route('admin.servers.view', [
// 'id' => $id,
// 'tab' => 'tab_startup',
// ])->withInput();
// }
// }
/**
* Update the startup command as well as variables.
*
* @param Request $request
* @param int $id
* @return \Illuminate\Response\RedirectResponse
*/
public function saveStartup(Request $request, $id)
{
$repo = new ServerRepository;
try {
$repo->updateStartup($id, $request->except('_token'), true);
Alert::success('Startup variables were successfully modified and assigned for this server.')->flash();
} catch(DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException occurred while attempting to update the startup for this server, please ensure the daemon is running. This error has been logged.')->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to update startup variables for this server. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.startup', $id);
}
//
// public function postDatabase(Request $request, $id)
// {

View file

@ -309,9 +309,7 @@ class ServerController extends Controller
try {
$repo = new ServerRepository;
$repo->updateStartup($server->id, $request->except([
'_token',
]));
$repo->updateStartup($server->id, $request->except('_token'));
Alert::success('Server startup variables were successfully updated.')->flash();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();

View file

@ -174,6 +174,10 @@ class AdminRoutes
'uses' => 'Admin\ServersController@viewStartup',
]);
$router->post('/view/{id}/startup', [
'uses' => 'Admin\ServersController@saveStartup',
]);
$router->get('/view/{id}/database', [
'as' => 'admin.servers.view.database',
'uses' => 'Admin\ServersController@viewDatabase',