Files
termanager2/resources/views/livewire/audit-log.blade.php
Francesco Picone 426a95211d Revisione blocchi 2 e 3: file protetti, ripristino atomico, import sicuri
Blocco 2
- Esiti delle azioni Livewire come avvisi (trait Avvisa) invece di flash
  che comparivano alla pagina dopo.
- PDF, miniature e versioni dei territori non più serviti da nginx su
  /storage: TerritorioFileController con login, permessi e cache privata.
- Ripristino tutto o niente: verifica dell'archivio, una transazione con
  import, piantine, blocco account e scambio dei file annullabile.
- Backup formato 2 con piantine, storico PDF e area KML.
- Posto unico preso in un passo (Cache::lock) e rispettato anche da
  import XML e PDF.
- Import PDF da cartella: abbinamento corretto (1-A, 12 B, ambigui),
  caricamento a lotti, file non PDF ignorati, PDF sostituito nello storico.
- L'import XML elimina i file dei territori che non usa più; comando
  territori:file-orfani per quelli accumulati prima.

Blocco 3
- Password attuale richiesta al cambio volontario; AuthenticateSession
  chiude le sessioni aperte altrove.
- Niente nomi dei proclamatori in chiaro nel registro attività.
- Export XML senza remember_token; chi riceve l'hash dal file deve
  cambiare password.
- Campagne: ultimo giorno incluso, percentuale sui territori distinti.
- Coda: retry_after 960 s, stop_grace_period 16m, Redis volatile-lru,
  impostazioni rilette a ogni job.
- Azzeramento che cancella anche piantine, area KML e anteprime.
- Pulsanti profilo e menu che non si nascondevano; icona del sito.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:01:41 +02:00

113 lines
6.8 KiB
PHP

<div>
<div class="mb-6">
<h1 class="text-2xl font-bold text-gray-900">Audit Log</h1>
<p class="text-sm text-gray-500">Registro di tutte le azioni eseguite nel sistema.</p>
</div>
{{-- Filters --}}
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-4 mb-4">
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<input wire:model.live.debounce.300ms="search" type="text" placeholder="Cerca..." class="rounded-lg border-gray-300 text-sm focus:ring-indigo-500 focus:border-indigo-500">
<select wire:model.live="filterEvent" class="rounded-lg border-gray-300 text-sm focus:ring-indigo-500 focus:border-indigo-500">
<option value="">Tutti gli eventi</option>
@foreach($events as $event)
<option value="{{ $event }}">{{ $event }}</option>
@endforeach
</select>
<select wire:model.live="filterCauser" class="rounded-lg border-gray-300 text-sm focus:ring-indigo-500 focus:border-indigo-500">
<option value="">Tutti gli utenti</option>
@foreach($users as $user)
<option value="{{ $user->id }}">{{ $user->name }}</option>
@endforeach
</select>
</div>
</div>
{{-- Table --}}
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200 text-sm table-striped table-cards">
<thead style="background:linear-gradient(180deg,#f9fafb,#f3f4f6)">
<tr>
<th class="px-3 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Data/Ora</th>
<th class="px-3 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Utente</th>
<th class="px-3 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Evento</th>
<th class="px-3 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Soggetto</th>
<th class="px-3 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Dettagli</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($activities as $activity)
<tr class="hover:bg-indigo-50/30 transition-colors">
<td data-label="Data/Ora" class="px-3 py-2 text-xs text-gray-500 whitespace-nowrap">{{ $activity->created_at->format('d/m/Y H:i:s') }}</td>
<td data-label="Utente" class="px-3 py-2 text-xs">{{ $activity->causer?->name ?? data_get($activity->properties, 'causer_name') ?? 'Sistema' }}</td>
<td data-label="Evento" class="px-3 py-2">
<span class="inline-flex px-2 py-0.5 text-xs font-medium rounded-full
{{ match($activity->description) {
'created' => 'bg-green-100 text-green-800',
'updated' => 'bg-blue-100 text-blue-800',
'deleted' => 'bg-red-100 text-red-800',
'assigned' => 'bg-indigo-100 text-indigo-800',
'returned' => 'bg-amber-100 text-amber-800',
'restored' => 'bg-purple-100 text-purple-800',
'login' => 'bg-cyan-100 text-cyan-800',
default => 'bg-gray-100 text-gray-700',
} }}">
{{ $activity->description }}
</span>
</td>
<td data-label="Soggetto" class="px-3 py-2 text-xs text-gray-600">
@if($activity->subject_type)
{{ class_basename($activity->subject_type) }} #{{ $activity->subject_id }}
@else
-
@endif
</td>
<td data-label="Dettagli" class="px-3 py-2 text-xs text-gray-500">
@if($activity->properties->isNotEmpty())
<details>
<summary class="cursor-pointer text-indigo-600 hover:text-indigo-800">Mostra</summary>
<div class="mt-1 p-2 bg-gray-50 rounded text-xs font-mono max-w-xs overflow-auto">
@if($activity->properties->has('old'))
<div class="mb-1">
<span class="font-semibold text-red-600">Vecchio:</span>
@foreach($activity->properties['old'] as $k => $v)
<div>{{ $k }}: {{ is_string($v) ? $v : json_encode($v) }}</div>
@endforeach
</div>
<div>
<span class="font-semibold text-green-600">Nuovo:</span>
@foreach($activity->properties['attributes'] ?? [] as $k => $v)
<div>{{ $k }}: {{ is_string($v) ? $v : json_encode($v) }}</div>
@endforeach
</div>
@else
@foreach($activity->properties->toArray() as $k => $v)
@if($k === 'proclamatore_id')
<div>proclamatore: {{ $nomiProclamatori[$v] ?? '#' . $v }}</div>
@else
<div>{{ $k }}: {{ is_string($v) ? $v : json_encode($v) }}</div>
@endif
@endforeach
@endif
</div>
</details>
@else
-
@endif
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-4 py-8 text-center text-gray-500">Nessuna attività registrata.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="px-4 py-3 border-t border-gray-200">
{{ $activities->links() }}
</div>
</div>
</div>