public function postSettingsStartup(Request $request, $uuid) { $server = Models\Server::getByUUID($uuid); $this->authorize('edit-startup', $server); try { $repo = new ServerRepository(); $repo->updateStartup($server->id, $request->except(['_token'])); Alert::success('Server startup variables were successfully updated.')->flash(); } catch (DisplayException $ex) { Alert::danger($ex->getMessage())->flash(); } catch (\Exception $ex) { Log::error($ex); Alert::danger('An unhandled exception occured while attemping to update startup variables for this server. Please try again.')->flash(); } return redirect()->route('server.settings', ['uuid' => $uuid, 'tab' => 'tab_startup']); }
/** * [postSetConnection description] * @param Request $request * @param string $uuid * @return \Illuminate\Http\Response */ public function postSetConnection(Request $request, $uuid) { $server = Models\Server::getByUUID($uuid); $allocation = Models\Allocation::findOrFail($server->allocation); $this->authorize('set-connection', $server); if ($request->input('connection') === $allocation->ip . ':' . $allocation->port) { return response()->json(['error' => 'You are already using this as your default connection.'], 409); } 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 (DisplayValidationException $ex) { return response()->json(['error' => json_decode($ex->getMessage(), true)], 503); } catch (DisplayException $ex) { return response()->json(['error' => $ex->getMessage()], 503); } catch (\Exception $ex) { Log::error($ex); return response()->json(['error' => 'An unhandled exception occured while attemping to modify the default connection for this server.'], 503); } }
/** * Delete Server * * @Delete("/servers/{id}/{force}") * @Versions({"v1"}) * @Parameters({ * @Parameter("id", type="integer", required=true, description="The ID of the server."), * @Parameter("force", type="string", required=false, description="Use 'force' if the server should be removed regardless of daemon response."), * }) * @Response(204) */ public function delete(Request $request, $id, $force = null) { try { $server = new ServerRepository(); $server->deleteServer($id, $force); return $this->response->noContent(); } catch (DisplayException $ex) { throw new ResourceException($ex->getMessage()); } catch (\Exception $e) { throw new ServiceUnavailableHttpException('An error occured while attempting to delete this server.'); } }
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 (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']); } }