]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6479
authorsoufiane <soufiane@cubedesigners.com>
Mon, 27 Nov 2023 13:27:08 +0000 (14:27 +0100)
committersoufiane <soufiane@cubedesigners.com>
Mon, 27 Nov 2023 13:27:08 +0000 (14:27 +0100)
app/Models/FluidbookExternalInstallServer.php
resources/views/vendor/backpack/crud/edit-external-server.blade.php
resources/views/vendor/backpack/crud/inc/form_save_buttons.blade.php
resources/views/vendor/backpack/crud/list-fluidbook.blade.php [new file with mode: 0644]

index cefbe5ba7ca208bab4bde12519b4936e4ef2a355..32022e19e2727ee9dbe74c839d4d586a9a8e0495 100644 (file)
@@ -26,6 +26,8 @@ class FluidbookExternalInstallServer extends ExternalServer
 
     protected $_operations = [ServerOperation::class];
 
+    private static $id;
+
     protected static function _getOneServer($server)
     {
         return array_merge(parent::_getOneServer($server), ['allows_root' => $server->allows_root]);
@@ -105,7 +107,6 @@ class FluidbookExternalInstallServer extends ExternalServer
         ];
 
         $result = static::find($id)->getTransferDriver()->checkConnexion($data);
-        //dump($result);
         if($result === true) {
             $result_['success'] = true;
         } else {
@@ -115,10 +116,10 @@ class FluidbookExternalInstallServer extends ExternalServer
         return $result_;
     }
 
-    public function listFluidbook()
+    public static function getListFluidbook($id)
     {
-        $id = $this->id;
-        $results = DB::table('fluidbook_publication')
+        $id = strval($id);
+        return DB::table('fluidbook_publication')
             ->whereJsonContains('settings->install_online->server', $id)
             ->get()
             ->toArray();
index b15eb674f1236934e439c7f926ea5283c6b34bd9..8019a33362d94ca1daded592dbd47dca35363ccf 100644 (file)
@@ -10,9 +10,6 @@
                 window.location.href = $(this).attr('href') + document.location.hash;
             });
 
-            //$("#saveActions").prepend("<button id='verifyconnection' class='btn btn-primary mr-3'>Tester la connexion</button>")
-            $("#saveActions").prepend("<a id='verifyconnection' class='btn btn-primary mr-3' href='verifyconnection'>Tester la connexion</a>")
-
             function removeBtn() {
                 setTimeout(() => {
                     $("#message").remove()
 @endpush
 
 @include('cubist_back::when')
-@include('crud::edit')
 
+@php
+
+    start_measure('Render edit form');
+@endphp
+
+@extends(backpack_view('blank'))
+@include('cubist_back::form.additional_edit_views')
+
+@push('crud_fields_scripts')
+    <script>
+        jQuery(document).ready(function ($) {
+
+            // When clicking on a locale link in the dropdown menu, it doesn't preserve
+            // the current tab because this is stored in the hash and managed by JS.
+            // To overcome this, we catch the locale links and append the hash to them...
+            $(document).on('click', '.dropdown-menu a[href*="?_locale="]', function (event) {
+                event.preventDefault();
+                window.location.href = $(this).attr('href') + document.location.hash;
+            });
+
+        });
+    </script>
+@endpush
+
+@push('after_styles')
+    <link rel="stylesheet" href="{{ vendor_asset('vendor/cubist/cms-back/form.css') }}">
+@endpush
+
+@include('cubist_back::when')
+
+@php
+    $defaultBreadcrumbs = [
+      trans('backpack::crud.admin') => backpack_url('dashboard'),
+      $crud->entity_name_plural => url($crud->route),
+      trans('backpack::crud.edit') => false,
+    ];
+
+    // if breadcrumbs aren't defined in the CrudController, use the default breadcrumbs
+    $breadcrumbs = $breadcrumbs ?? $defaultBreadcrumbs;
+@endphp
+
+@section('header')
+    <section class="container-fluid">
+        <h2>
+            <span class="text-capitalize">{!! $crud->getHeading() ?? $crud->entity_name_plural !!}</span>
+            <small>{!! $crud->getSubheading() ?? trans('backpack::crud.edit').' '.$crud->entity_name !!}.</small>
+
+            @if ($crud->hasAccess('list'))
+                <small><a href="{{ url($crud->route) }}" class="d-print-none font-sm"><i
+                            class="la la-angle-double-{{ config('backpack.base.html_direction') == 'rtl' ? 'right' : 'left' }}"></i> {{ trans('backpack::crud.back_to_all') }}
+                        <span>{{ $crud->entity_name_plural }}</span></a></small>
+            @endif
+        </h2>
+    </section>
+@endsection
+
+@section('content')
+    <div class="row">
+        <div class="{{ $crud->getEditContentClass() }}">
+            {{-- Default box --}}
+
+            @include('crud::inc.grouped_errors')
+
+            <form method="post"
+                  action="{{ url($crud->route.'/'.$entry->getKey()) }}"
+                  @if ($crud->hasUploadFields('update', $entry->getKey()))
+                      enctype="multipart/form-data"
+                @endif
+            >
+                {!! csrf_field() !!}
+                {!! method_field('PUT') !!}
+
+                @if ($crud->model->translationEnabled())
+                    <div class="mb-2 text-right">
+                        {{-- Single button --}}
+                        <div class="btn-group">
+                            <button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown"
+                                    aria-haspopup="true" aria-expanded="false">
+                                {{trans('backpack::crud.language')}}
+                                : {{ $crud->model->getAvailableLocales()[request()->input('_locale')?request()->input('_locale'):App::getLocale()] }}
+                                &nbsp; <span class="caret"></span>
+                            </button>
+                            <ul class="dropdown-menu">
+                                @foreach ($crud->model->getAvailableLocales() as $key => $locale)
+                                    <a class="dropdown-item"
+                                       href="{{ url($crud->route.'/'.$entry->getKey().'/edit') }}?_locale={{ $key }}">{{ $locale }}</a>
+                                @endforeach
+                            </ul>
+                        </div>
+                    </div>
+                @endif
+                {{-- load the view from the application if it exists, otherwise load the one in the package --}}
+                @if(view()->exists('vendor.backpack.crud.form_content'))
+                    @include('vendor.backpack.crud.form_content', ['fields' => $crud->fields(), 'action' => 'edit'])
+                @else
+                    @include('crud::form_content', ['fields' => $crud->fields(), 'action' => 'edit'])
+                @endif
+                {{-- This makes sure that all field assets are loaded. --}}
+                <div class="d-none" id="parentLoadedAssets">{{ json_encode(Assets::loaded()) }}</div>
+                @include('crud::inc.form_save_buttons')
+            </form>
+            @include('vendor.backpack.crud.list-fluidbook')
+        </div>
+        @include('cubist_back::form.shortcuts')
+    </div>
+
+    @stack('after_form')
+@endsection
+@php
+
+    stop_measure('Render edit form');
+@endphp
index 1375623edf865faed61508e27e96e978af1c21ea..f797f6aada9155d499f6a87bba40c320e88675bf 100644 (file)
@@ -8,7 +8,9 @@
 @endphp
 @if(isset($saveAction['active']) && !is_null($saveAction['active']['value']))
     <div id="saveActions" class="form-group">
-
+        @if($crud->entry->getTable() === "fluidbook_external_install_server")
+            <a id='verifyconnection' class='btn btn-primary mr-3' href='verifyconnection'>Tester la connexion</a>
+        @endif
         <input type="hidden" name="_save_action" value="{{ $saveAction['active']['value'] }}">
         @if(!empty($saveAction['options']))
             <div class="btn-group" role="group">
diff --git a/resources/views/vendor/backpack/crud/list-fluidbook.blade.php b/resources/views/vendor/backpack/crud/list-fluidbook.blade.php
new file mode 100644 (file)
index 0000000..2b7fd8c
--- /dev/null
@@ -0,0 +1,29 @@
+@php
+    $tableClasses='stats-details sortable bg-white table table-striped table-hover nowrap rounded shadow-xs border-xs mt-2 dataTable dtr-inline';
+
+    $id = $crud->entry->id;
+
+    $fluidbooks= \App\Models\FluidbookExternalInstallServer::getListFluidbook($id);
+@endphp
+
+@if($fluidbooks)
+    <div class="mt-5">
+        <h3>Liste des fluidbooks installés sur ce serveur</h3>
+        <table class="{!! $tableClasses !!}" data-table="resume">
+            <thead>
+            <th>#</th>
+            <th>Titre</th>
+            <th>Chemin d'installation</th>
+            <th>URL finale du fluidbook</th>
+            </thead>
+            <tr>
+                @foreach($fluidbooks as $fluidbook)
+                    <td>{{$fluidbook->id}}</td>
+                    <td>{{$fluidbook->c_title}}</td>
+                    <td>{{json_decode($fluidbook->settings, true)['install_online']['path']}}</td>
+                    <td>{{$crud->entry->base_url.json_decode($fluidbook->settings, true)['install_online']['path']}}</td>
+                @endforeach
+            </tr>
+        </table>
+    </div>
+@endif