@@ 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. |
@@ 240-260 (lines=21) @@ | ||
237 | * @param int $id |
|
238 | * @return \Illuminate\Response\RedirectResponse |
|
239 | */ |
|
240 | public function updateScripts(Request $request, $id) |
|
241 | { |
|
242 | $repo = new OptionRepository; |
|
243 | ||
244 | try { |
|
245 | $repo->scripts($id, $request->only([ |
|
246 | 'script_install', 'script_entry', |
|
247 | 'script_container', 'copy_script_from', |
|
248 | ])); |
|
249 | Alert::success('Successfully updated option scripts to be run when servers are installed.')->flash(); |
|
250 | } catch (DisplayValidationException $ex) { |
|
251 | return redirect()->route('admin.services.option.scripts', $id)->withErrors(json_decode($ex->getMessage())); |
|
252 | } catch (DisplayException $ex) { |
|
253 | Alert::danger($ex->getMessage())->flash(); |
|
254 | } catch (\Exception $ex) { |
|
255 | Log::error($ex); |
|
256 | Alert::danger('An unhandled exception was encountered while attempting to process that request. This error has been logged.')->flash(); |
|
257 | } |
|
258 | ||
259 | return redirect()->route('admin.services.option.scripts', $id); |
|
260 | } |
|
261 | } |
|
262 |
@@ 272-294 (lines=23) @@ | ||
269 | * @param int $id |
|
270 | * @return \Illuminate\Http\RedirectResponse |
|
271 | */ |
|
272 | public function setDetails(Request $request, $id) |
|
273 | { |
|
274 | $repo = new ServerRepository; |
|
275 | try { |
|
276 | $repo->updateDetails($id, array_merge( |
|
277 | $request->only('description'), |
|
278 | $request->intersect([ |
|
279 | 'owner_id', 'name', 'reset_token', |
|
280 | ]) |
|
281 | )); |
|
282 | ||
283 | Alert::success('Server details were successfully updated.')->flash(); |
|
284 | } catch (DisplayValidationException $ex) { |
|
285 | return redirect()->route('admin.servers.view.details', $id)->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
286 | } catch (DisplayException $ex) { |
|
287 | Alert::danger($ex->getMessage())->flash(); |
|
288 | } catch (\Exception $ex) { |
|
289 | Log::error($ex); |
|
290 | Alert::danger('An unhandled exception occured while attemping to update this server. This error has been logged.')->flash(); |
|
291 | } |
|
292 | ||
293 | return redirect()->route('admin.servers.view.details', $id)->withInput(); |
|
294 | } |
|
295 | ||
296 | /** |
|
297 | * Set the new docker container for a server. |