From e42547a1ff8b5e7df4e8c022c5da74005d3ea542 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 20 Feb 2016 15:59:37 -0500 Subject: [PATCH] add support for editing service options --- .../Controllers/Admin/ServiceController.php | 14 ++- app/Repositories/ServiceRepository/Option.php | 24 +++++ .../admin/services/options/view.blade.php | 101 ++++++++++++++---- 3 files changed, 116 insertions(+), 23 deletions(-) diff --git a/app/Http/Controllers/Admin/ServiceController.php b/app/Http/Controllers/Admin/ServiceController.php index 981a8b326..ed475660a 100644 --- a/app/Http/Controllers/Admin/ServiceController.php +++ b/app/Http/Controllers/Admin/ServiceController.php @@ -107,7 +107,19 @@ class ServiceController extends Controller public function postOption(Request $request, $option) { - // editing option + try { + $repo = new ServiceRepository\Option; + $repo->update($option, $request->except([ + '_token' + ])); + Alert::success('Option settings successfully updated.')->flash(); + } catch (DisplayValidationException $ex) { + return redirect()->route('admin.services.option', $option)->withErrors(json_decode($ex->getMessage()))->withInput(); + } catch (\Exception $ex) { + Log::error($ex); + Alert::danger('An error occured while attempting to modify this option.')->flash(); + } + return redirect()->route('admin.services.option', $option)->withInput(); } public function postOptionVariable(Request $request, $option, $variable) diff --git a/app/Repositories/ServiceRepository/Option.php b/app/Repositories/ServiceRepository/Option.php index 0b4d705c8..92c4dd369 100644 --- a/app/Repositories/ServiceRepository/Option.php +++ b/app/Repositories/ServiceRepository/Option.php @@ -42,7 +42,31 @@ class Option public function update($id, array $data) { + $option = Models\ServiceOptions::findOrFail($id); + $validator = Validator::make($data, [ + 'name' => 'sometimes|required|string|max:255', + 'description' => 'sometimes|required|string|min:1', + 'tag' => 'sometimes|required|string|max:255', + 'executable' => 'sometimes|string|max:255', + 'docker_image' => 'sometimes|required|string|max:255', + 'startup' => 'sometimes|string' + ]); + + if ($validator->fails()) { + throw new DisplayValidationException($validator->errors()); + } + + if (isset($data['executable']) && empty($data['executable'])) { + $data['executable'] = null; + } + + if (isset($data['startup']) && empty($data['startup'])) { + $data['startup'] = null; + } + + $option->fill($data); + $option->save(); } } diff --git a/resources/views/admin/services/options/view.blade.php b/resources/views/admin/services/options/view.blade.php index 1eb51173f..aca4d83e1 100644 --- a/resources/views/admin/services/options/view.blade.php +++ b/resources/views/admin/services/options/view.blade.php @@ -31,28 +31,64 @@
  • {{ $service->name }}
  • {{ $option->name }}
  • -

    Servers

    - - - - - - - - - - - @foreach ($servers as $server) - - - - - - - @endforeach - -
    NameOwnerConnectionUpdated
    {{ $server->name }}{{ $server->a_ownerEmail }}{{ $server->ip }}:{{ $server->port }}{{ $server->updated_at }}
    -

    Option Variables


    +
    Warning! This page contains advanced settings that the panel and daemon use to control servers. Modifying information on this page is not recommended unless you are absolutely sure of what you are doing.
    +

    Settings


    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +

    Leave blank to use parent executable.

    +
    +
    +
    + +
    + +

    Changing the docker image will only effect servers created or modified after this point.

    +
    +
    +
    +
    +
    + +
    + +

    To use the default startup of the parent service simply leave this field blank.

    +
    +
    +
    +
    +
    +
    + {!! csrf_field() !!} + +
    +
    +
    +
    +

    Variables


    @foreach($variables as $variable)
    @@ -128,6 +164,27 @@
    @endforeach +

    Servers


    + + + + + + + + + + + @foreach ($servers as $server) + + + + + + + @endforeach + +
    NameOwnerConnectionUpdated
    {{ $server->name }}{{ $server->a_ownerEmail }}{{ $server->ip }}:{{ $server->port }}{{ $server->updated_at }}