Files
2026-11-11 17:35:18 +00:00

142 lines
9.1 KiB
PHP

<x-layouts::app title="Directory sync">
<div class="mx-auto flex w-full max-w-6xl min-w-0 flex-col gap-6">
<header class="flex flex-wrap items-start justify-between gap-4">
<div>
<h1 class="text-2xl font-semibold tracking-tight text-indigo-950 sm:text-3xl dark:text-indigo-100">Directory sync</h1>
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">Active Directory accounts and sync activity</p>
</div>
@if (! $scheduled)
<flux:badge color="zinc" size="sm">Schedule disabled</flux:badge>
@elseif ($stale)
<flux:badge color="amber" size="sm">Stale</flux:badge>
@else
<flux:badge color="green" size="sm">Scheduled every 10 minutes</flux:badge>
@endif
</header>
@if (session('sync_error'))
<p role="alert" class="rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200">{{ session('sync_error') }}</p>
@endif
@if (session('sync_status'))
<p role="status" class="rounded-lg border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800 dark:border-green-900 dark:bg-green-950 dark:text-green-200">{{ session('sync_status') }}</p>
@endif
<section class="overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900" aria-labelledby="sync-summary">
<div class="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 bg-indigo-50 px-5 py-4 sm:px-6 dark:bg-indigo-950">
<h2 id="sync-summary" class="text-base font-semibold">Latest successful sync</h2>
<p class="text-sm tabular-nums text-zinc-500 dark:text-zinc-400">
{{ $success?->finished_at ?? 'No successful sync recorded yet' }}
</p>
</div>
@if ($success)
<dl class="grid grid-cols-2 gap-px border-t border-zinc-200 bg-zinc-200 sm:grid-cols-5 dark:border-zinc-700 dark:bg-zinc-700">
@foreach ([
'created' => ['Created', 'border-t-emerald-500 text-emerald-700 dark:text-emerald-300'],
'updated' => ['Updated', 'border-t-sky-500 text-sky-700 dark:text-sky-300'],
'unchanged' => ['Unchanged', 'border-t-zinc-400 text-zinc-700 dark:text-zinc-300'],
'deactivated' => ['Disabled', 'border-t-amber-500 text-amber-800 dark:text-amber-300'],
'reactivated' => ['Re-enabled', 'border-t-violet-500 text-violet-700 dark:text-violet-300'],
] as $key => [$label, $accent])
<div class="border-t-2 bg-zinc-50 px-5 py-4 sm:px-6 dark:bg-zinc-900 {{ $accent }}">
<dt class="text-sm font-medium">{{ $label }}</dt>
<dd class="mt-1 text-2xl font-semibold tabular-nums">{{ $counts[$key] }}</dd>
</div>
@endforeach
</dl>
@endif
@if ($failure || ($scheduled && $stale))
<div class="space-y-2 border-t border-zinc-200 px-5 py-3 text-sm sm:px-6 dark:border-zinc-700">
@if ($scheduled && $stale)
<p class="text-amber-700 dark:text-amber-300">No successful sync in the last 30 minutes.</p>
@endif
@if ($failure)
<p><strong class="text-red-700 dark:text-red-300">Latest failure</strong> <span class="text-zinc-600 dark:text-zinc-400">· {{ $failure->finished_at }} · {{ $failure->failure }}</span></p>
@endif
</div>
@endif
</section>
<section class="overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900" aria-labelledby="missing-users">
<div class="flex flex-wrap items-center justify-between gap-4 px-5 py-4 sm:px-6">
<div class="space-y-1">
<h2 id="missing-users" class="text-base font-semibold">Review missing users</h2>
<p class="text-sm text-zinc-500 dark:text-zinc-400">Check which active directory accounts are missing. Previews expire after 10 minutes.</p>
</div>
<form method="POST" action="{{ route('admin.directory-sync.preview') }}">
@csrf
<flux:button type="submit" size="sm">Preview missing users</flux:button>
</form>
</div>
@if ($review)
<div class="space-y-4 border-t border-zinc-200 bg-zinc-50 px-5 py-4 sm:px-6 dark:border-zinc-700 dark:bg-zinc-800">
@if ($review['users'])
<ul class="divide-y divide-zinc-200 dark:divide-zinc-700">
@foreach ($review['users'] as $user)
<li class="flex flex-wrap items-baseline gap-x-3 py-2 text-sm">
<span class="font-medium">{{ $user['name'] }}</span>
<span class="break-all text-zinc-500 dark:text-zinc-400">{{ $user['email'] }}</span>
</li>
@endforeach
</ul>
<form method="POST" action="{{ route('admin.directory-sync.apply') }}">
@csrf
<input type="hidden" name="review_token" value="{{ $review['token'] }}">
<flux:button type="submit" variant="danger" size="sm">Deactivate reviewed users</flux:button>
</form>
@else
<p class="text-sm text-zinc-600 dark:text-zinc-400">No missing users found.</p>
@endif
</div>
@endif
</section>
<section class="overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900" aria-labelledby="disabled-users">
<div class="flex items-center justify-between gap-3 px-5 py-4 sm:px-6">
<h2 id="disabled-users" class="text-base font-semibold">Disabled directory users</h2>
<flux:badge :color="$disabledUsers->total() ? 'amber' : 'zinc'" size="sm">{{ $disabledUsers->total() }}</flux:badge>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left text-sm" aria-labelledby="disabled-users">
<thead class="border-y border-zinc-200 bg-zinc-50 text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300">
<tr>
<th scope="col" class="px-5 py-3 font-medium sm:px-6">User</th>
<th scope="col" class="px-5 py-3 font-medium sm:px-6">Reason</th>
<th scope="col" class="whitespace-nowrap px-5 py-3 font-medium sm:px-6">Disabled at</th>
</tr>
</thead>
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
@forelse ($disabledUsers as $user)
<tr>
<td class="px-5 py-3 sm:px-6">
<div class="font-medium">{{ $user->name }}</div>
<div class="break-all text-zinc-500 dark:text-zinc-400">{{ $user->email }}</div>
</td>
<td class="px-5 py-3 text-zinc-600 sm:px-6 dark:text-zinc-300">
@switch($user->ad_disabled_reason)
@case('directory_disabled')
<flux:badge color="amber" size="sm">Disabled in Active Directory</flux:badge>
@break
@case('missing_from_snapshot')
<flux:badge color="violet" size="sm">Missing from the directory</flux:badge>
@break
@default
<flux:badge color="zinc" size="sm">Reason unavailable</flux:badge>
@endswitch
</td>
<td class="whitespace-nowrap px-5 py-3 tabular-nums text-zinc-600 sm:px-6 dark:text-zinc-300">{{ $user->ad_disabled_at }}</td>
</tr>
@empty
<tr><td colspan="3" class="px-5 py-6 text-center text-zinc-500 dark:text-zinc-400">No disabled directory users.</td></tr>
@endforelse
</tbody>
</table>
</div>
@if ($disabledUsers->hasPages())
<div class="border-t border-zinc-200 px-5 py-4 sm:px-6 dark:border-zinc-700">
{{ $disabledUsers->links() }}
</div>
@endif
</section>
</div>
</x-layouts::app>