| @@ 94-115 (lines=22) @@ | ||
| 91 | * @param \Illuminate\Http\Request $request |
|
| 92 | * @return \Illuminate\Http\RedirectResponse |
|
| 93 | */ |
|
| 94 | public function store(Request $request) |
|
| 95 | { |
|
| 96 | $repo = new ServiceRepository; |
|
| 97 | ||
| 98 | try { |
|
| 99 | $service = $repo->create($request->intersect([ |
|
| 100 | 'name', 'description', 'folder', 'startup', |
|
| 101 | ])); |
|
| 102 | Alert::success('Successfully created new service!')->flash(); |
|
| 103 | ||
| 104 | return redirect()->route('admin.services.view', $service->id); |
|
| 105 | } catch (DisplayValidationException $ex) { |
|
| 106 | return redirect()->route('admin.services.new')->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 107 | } catch (DisplayException $ex) { |
|
| 108 | Alert::danger($ex->getMessage())->flash(); |
|
| 109 | } catch (\Exception $ex) { |
|
| 110 | Log::error($ex); |
|
| 111 | Alert::danger('An error occured while attempting to add a new service. This error has been logged.')->flash(); |
|
| 112 | } |
|
| 113 | ||
| 114 | return redirect()->route('admin.services.new')->withInput(); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Edits configuration for a specific service. |
|
| @@ 75-96 (lines=22) @@ | ||
| 72 | * @param \Illuminate\Http\Request $request |
|
| 73 | * @return \Illuminate\Http\RedirectResponse |
|
| 74 | */ |
|
| 75 | public function store(Request $request) |
|
| 76 | { |
|
| 77 | try { |
|
| 78 | $repo = new APIRepository($request->user()); |
|
| 79 | $secret = $repo->create($request->intersect([ |
|
| 80 | 'memo', 'allowed_ips', |
|
| 81 | 'admin_permissions', 'permissions', |
|
| 82 | ])); |
|
| 83 | Alert::success('An API Key-Pair has successfully been generated. The API secret for this public key is shown below and will not be shown again.<br /><br /><code>' . $secret . '</code>')->flash(); |
|
| 84 | ||
| 85 | return redirect()->route('account.api'); |
|
| 86 | } catch (DisplayValidationException $ex) { |
|
| 87 | return redirect()->route('account.api.new')->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 88 | } catch (DisplayException $ex) { |
|
| 89 | Alert::danger($ex->getMessage())->flash(); |
|
| 90 | } catch (\Exception $ex) { |
|
| 91 | Log::error($ex); |
|
| 92 | Alert::danger('An unhandled exception occured while attempting to add this API key.')->flash(); |
|
| 93 | } |
|
| 94 | ||
| 95 | return redirect()->route('account.api.new')->withInput(); |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * Handle revoking API key. |
|
| @@ 269-288 (lines=20) @@ | ||
| 266 | * @param int $id |
|
| 267 | * @return \Illuminate\Http\RedirectResponse |
|
| 268 | */ |
|
| 269 | public function setDetails(Request $request, $id) |
|
| 270 | { |
|
| 271 | $repo = new ServerRepository; |
|
| 272 | try { |
|
| 273 | $repo->updateDetails($id, $request->intersect([ |
|
| 274 | 'owner_id', 'name', 'description', 'reset_token', |
|
| 275 | ])); |
|
| 276 | ||
| 277 | Alert::success('Server details were successfully updated.')->flash(); |
|
| 278 | } catch (DisplayValidationException $ex) { |
|
| 279 | return redirect()->route('admin.servers.view.details', $id)->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 280 | } catch (DisplayException $ex) { |
|
| 281 | Alert::danger($ex->getMessage())->flash(); |
|
| 282 | } catch (\Exception $ex) { |
|
| 283 | Log::error($ex); |
|
| 284 | Alert::danger('An unhandled exception occured while attemping to update this server. This error has been logged.')->flash(); |
|
| 285 | } |
|
| 286 | ||
| 287 | return redirect()->route('admin.servers.view.details', $id)->withInput(); |
|
| 288 | } |
|
| 289 | ||
| 290 | /** |
|
| 291 | * Set the new docker container for a server. |
|