@extends('layouts.app') @section('title', 'Permissions') @section('header', 'Permissions des dossiers') @section('content') @php $statutLabels = ['pending' => ['En attente…', 'text-yellow-600'], 'running' => ['Scan en cours…', 'text-blue-600'], 'stopped' => ['Arrêté (partiel)', 'text-orange-600'], 'failed' => ['Échec', 'text-red-600'], 'completed' => ['Terminé', 'text-green-600'], 'remplace' => ['Remplacé', 'text-gray-400']]; $displayName = fn($s) => $s->site_name ?? ($s->serveur ?? '') . '\\' . ($s->chemin ?? ''); $estStuck = fn($s) => $s->statut === 'pending' && $s->updated_at->diffInSeconds(now()) > 30; $estFrozen = fn($s) => $s->statut === 'running' && $s->updated_at->diffInMinutes(now()) > 3; $fmtDuree = function($s) { $debut = $s->created_at; if ($s->statut === 'running' || $s->statut === 'pending') { $fin = now(); } elseif ($s->statut === 'completed') { $fin = $s->scanne_le ?? $s->updated_at; } elseif ($s->statut === 'stopped') { $fin = $s->stopped_le ?? $s->scanne_le ?? $s->updated_at; } else { return null; } $secs = $debut->diffInSeconds($fin); if ($secs < 0) $secs = 0; if ($secs === 0) return null; $h = intdiv($secs, 3600); $m = intdiv($secs % 3600, 60); $sec = $secs % 60; return ($h ? $h . 'h ' : '') . ($m ? $m . 'm ' : '') . $sec . 's'; }; @endphp
@foreach([ ['scans' => $partageScans, 'type' => 'partage', 'name' => 'Serveur de fichiers', 'empty' => 'Aucun scan. Lancez-le depuis les connecteurs.'], ['scans' => $spScans, 'type' => 'sharepoint', 'name' => 'SharePoint SRVPG', 'empty' => 'Aucun scan. Cliquez sur "Scan SP" dans le connecteur M365.'], ] as $section)

{{ $section['name'] }}

@if($section['scans']->isEmpty())

{{ $section['empty'] }}

@else
@foreach($section['scans'] as $s) @php $label = $statutLabels[$s->statut] ?? ['?', 'text-gray-400']; @endphp
@if($s->statut === 'remplace') {{ $displayName($s) }} @else {{ $displayName($s) }} @endif
{{ $label[0] }} {{ $s->total_dossiers }} dossiers — {{ $s->total_entrees_acl }} entrées @if($s->scanne_le) {{ $s->scanne_le->format('d/m/Y H:i') }} @endif @if($duree = $fmtDuree($s)) ⏱ {{ $duree }} @endif @if($s->declenche_par) ({{ $s->declenche_par }}) @endif
@if(in_array($s->statut, ['pending', 'running']))
@csrf
@else @php $nomScan = str_replace('\\', '/', (string) $displayName($s)); @endphp
@csrf
@endif
@if($s->statut === 'failed' && $s->erreurs)
{{ is_array($s->erreurs) ? implode('; ', $s->erreurs) : $s->erreurs }}
@endif @if($estStuck($s))
⚠ Bloqué — le scan n'a pas démarré.
@endif @if($estFrozen($s))
⏳ Gelé — plus d'activité depuis {{ $s->updated_at->diffForHumans() }}.
@endif
@endforeach
@endif
@endforeach
@if($spScans->contains(fn($s) => in_array($s->statut, ['pending', 'running'])) || $partageScans->contains(fn($s) => in_array($s->statut, ['pending', 'running']))) @endif @endsection