Ver Fonte

Fix upload

Luca Parisio há 1 mês atrás
pai
commit
773229f3ad

+ 3 - 2
app/Http/Livewire/Traits/HasAllegato.php

@@ -54,7 +54,7 @@ trait HasAllegato
                 if (!in_array(strtolower($extension), $this->imageExtensions)) {
                     session()->flash('error', 'I File devono essere immagini per Tipologia: Foto sinistro');
                     return;
-                }
+                }                
             }
         }
 
@@ -151,10 +151,11 @@ trait HasAllegato
                 $name = $allegato->getClientOriginalName();
                 $allegato->storeAs('', $name, 'public');
                 $this->allegatiFiles[] = $name;
+                $this->emit('fileSize', '');
             }
             else
             {
-                $this->emit('fileSize', 'Superato il limite di ' . number_format($size / 1000 / 1000, 0) . "MB");
+                $this->emit('fileSize', 'Superato il limite di ' . number_format(env('FILE_SIZE', 10000000) / 1000 / 1000, 0) . " MB (" . number_format($size / 1000 / 1000, 0) . "MB)");
             }
         }
         $this->emit('attachments', implode("|", $this->allegatiFiles));

+ 159 - 0
config/livewire.php

@@ -0,0 +1,159 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Class Namespace
+    |--------------------------------------------------------------------------
+    |
+    | This value sets the root namespace for Livewire component classes in
+    | your application. This value affects component auto-discovery and
+    | any Livewire file helper commands, like `artisan make:livewire`.
+    |
+    | After changing this item, run: `php artisan livewire:discover`.
+    |
+    */
+
+    'class_namespace' => 'App\\Http\\Livewire',
+
+    /*
+    |--------------------------------------------------------------------------
+    | View Path
+    |--------------------------------------------------------------------------
+    |
+    | This value sets the path for Livewire component views. This affects
+    | file manipulation helper commands like `artisan make:livewire`.
+    |
+    */
+
+    'view_path' => resource_path('views/livewire'),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Layout
+    |--------------------------------------------------------------------------
+    | The default layout view that will be used when rendering a component via
+    | Route::get('/some-endpoint', SomeComponent::class);. In this case the
+    | the view returned by SomeComponent will be wrapped in "layouts.app"
+    |
+    */
+
+    'layout' => 'layouts.app',
+
+    /*
+    |--------------------------------------------------------------------------
+    | Livewire Assets URL
+    |--------------------------------------------------------------------------
+    |
+    | This value sets the path to Livewire JavaScript assets, for cases where
+    | your app's domain root is not the correct path. By default, Livewire
+    | will load its JavaScript assets from the app's "relative root".
+    |
+    | Examples: "/assets", "myurl.com/app".
+    |
+    */
+
+    'asset_url' => null,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Livewire App URL
+    |--------------------------------------------------------------------------
+    |
+    | This value should be used if livewire assets are served from CDN.
+    | Livewire will communicate with an app through this url.
+    |
+    | Examples: "https://my-app.com", "myurl.com/app".
+    |
+    */
+
+    'app_url' => null,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Livewire Endpoint Middleware Group
+    |--------------------------------------------------------------------------
+    |
+    | This value sets the middleware group that will be applied to the main
+    | Livewire "message" endpoint (the endpoint that gets hit everytime
+    | a Livewire component updates). It is set to "web" by default.
+    |
+    */
+
+    'middleware_group' => 'web',
+
+    /*
+    |--------------------------------------------------------------------------
+    | Livewire Temporary File Uploads Endpoint Configuration
+    |--------------------------------------------------------------------------
+    |
+    | Livewire handles file uploads by storing uploads in a temporary directory
+    | before the file is validated and stored permanently. All file uploads
+    | are directed to a global endpoint for temporary storage. The config
+    | items below are used for customizing the way the endpoint works.
+    |
+    */
+
+    'temporary_file_upload' => [
+        'disk' => null,        // Example: 'local', 's3'              Default: 'default'
+        //'rules' => null,       // Example: ['file', 'mimes:png,jpg']  Default: ['required', 'file', 'max:12288'] (12MB)
+        'rules' => 'file|mimes:png,jpg,pdf|max:102400', // (100MB max, and only pngs, jpegs, and pdfs.)
+        'directory' => null,   // Example: 'tmp'                      Default  'livewire-tmp'
+        'middleware' => null,  // Example: 'throttle:5,1'             Default: 'throttle:60,1'
+        'preview_mimes' => [   // Supported file types for temporary pre-signed file URLs.
+            'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
+            'mov', 'avi', 'wmv', 'mp3', 'm4a',
+            'jpg', 'jpeg', 'mpga', 'webp', 'wma',
+        ],
+        'max_upload_time' => 5, // Max duration (in minutes) before an upload gets invalidated.
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Manifest File Path
+    |--------------------------------------------------------------------------
+    |
+    | This value sets the path to the Livewire manifest file.
+    | The default should work for most cases (which is
+    | "<app_root>/bootstrap/cache/livewire-components.php"), but for specific
+    | cases like when hosting on Laravel Vapor, it could be set to a different value.
+    |
+    | Example: for Laravel Vapor, it would be "/tmp/storage/bootstrap/cache/livewire-components.php".
+    |
+    */
+
+    'manifest_path' => null,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Back Button Cache
+    |--------------------------------------------------------------------------
+    |
+    | This value determines whether the back button cache will be used on pages
+    | that contain Livewire. By disabling back button cache, it ensures that
+    | the back button shows the correct state of components, instead of
+    | potentially stale, cached data.
+    |
+    | Setting it to "false" (default) will disable back button cache.
+    |
+    */
+
+    'back_button_cache' => false,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Render On Redirect
+    |--------------------------------------------------------------------------
+    |
+    | This value determines whether Livewire will render before it's redirected
+    | or not. Setting it to "false" (default) will mean the render method is
+    | skipped when redirecting. And "true" will mean the render method is
+    | run before redirecting. Browsers bfcache can store a potentially
+    | stale view if render is skipped on redirect.
+    |
+    */
+
+    'render_on_redirect' => false,
+
+];

+ 10 - 3
resources/views/components/report/allegati/allegati-modal.blade.php

@@ -118,7 +118,7 @@
             <div class="modal-footer">
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
                 @if (!$this->validated)
-                    <button type="button" class="btn btn-primary" wire:click.prevent="saveAllegato()">Salva</button>
+                    <button type="button" class="btn btn-primary" wire:click.prevent="saveAllegato()" id="btSaveAllegato">Salva</button>
                 @endif
             </div>
         </div>
@@ -146,9 +146,16 @@
         });
 
         window.livewire.on('fileSize', function (txt) {
-            console.log("QUA" + txt);
             setTimeout(function() {
-                $("#fileSize").html(txt);
+                if (txt == "")
+                {
+                    $("#btSaveAllegato").show();
+                }
+                else
+                {
+                    $("#btSaveAllegato").hide();
+                    $("#fileSize").html(txt);
+                }
             }, 200);
         });
     });

+ 13 - 11
resources/views/components/report/segnaletica/segnaletica.blade.php

@@ -10,7 +10,7 @@
                         <div class="col-sm-6">
                             <div class="form-group">
                                 <label>Stato segnaletica</label>
-                                <select class="form-control" wire:model="segnaletica" style="width:100%">
+                                <select class="form-control" wire:model="segnaletica" id="cbSegnaletica" style="width:100%">
                                     <option value="">
                                         @foreach ($segnaletiche as $s)
                                             <option value="{{ $s['id'] }}">{{ $s['name'] }}
@@ -18,17 +18,19 @@
                                 </select>
                             </div>
                         </div>
-                        <div class="col-sm-6" style="display:none">
-                            <div class="form-group">
-                                <label>Organi</label>
-                                <select class="form-control" wire:model="organo" style="width:100%">
-                                    <option value="">
-                                        @foreach ($organi as $organo)
-                                            <option value="{{ $organo }}">{{ $organo }}
-                                        @endforeach
-                                </select>
+                        @if($segnaletica == 8)
+                            <div class="col-sm-6" id="organi">
+                                <div class="form-group">
+                                    <label>Organi</label>
+                                    <select class="form-control" wire:model="organo" style="width:100%">
+                                        <option value="">
+                                            @foreach ($organi as $organo)
+                                                <option value="{{ $organo }}">{{ $organo }}
+                                            @endforeach
+                                    </select>
+                                </div>
                             </div>
-                        </div>
+                        @endif
                     </div>
                 </div>
             </div>

+ 1 - 1
resources/views/components/report/veicoli/accordion/accertamenti-passeggeri-accordion.blade.php

@@ -59,7 +59,7 @@
         </div>
         <div class="row mt-3">
             <div class="col-md-4">
-                <label for="data_casco_passeggero" class="form-label">Uso del cascoxxx</label>
+                <label for="data_casco_passeggero" class="form-label">Uso del casco</label>
                 <select class="form-control" style="width:100%" wire:model="data_casco_passeggero"
                     id="data_casco_passeggero">
                     <option value="0"></option>

+ 24 - 2
resources/views/livewire/report.blade.php

@@ -291,6 +291,21 @@
                     @this.set(value, data);
                 });
             }
+/*
+            $('#cbSegnaletica').on('change', function (e) {
+                var data = $(this).val();
+
+                var last = '';
+                $('select#cbSegnaletica').find('option').each(function() {
+                    last = $(this).val();
+                });
+
+                if (data == last)
+                    $("#organi").show();
+                else
+                    $("#organi").hide();
+            });
+*/
         });
         Livewire.on('load-anagrafica-modal', () => {
     const modalsAnag = [
@@ -827,9 +842,16 @@
         });
 
         Livewire.on('fileSize', function (txt) {
-            console.log("QUA" + txt);
             setTimeout(function() {
-                $("#fileSize").html(txt);
+                if (txt == "")
+                {
+                    $("#btSaveAllegato").show();
+                }
+                else
+                {
+                    $("#btSaveAllegato").hide();
+                    $("#fileSize").html(txt);
+                }
             }, 200);
         });