@php $phone = trim((string) $device->country_code . ' ' . (string) $device->phone_number); $pill = match ($device->status) { 'connected' => ['bg-wa-mint text-wa-deep', 'bg-wa-green', __('Connected')], 'needs_pair' => ['bg-accent-amber/15 text-accent-amber', 'bg-accent-amber', __('Needs re-pair')], 'failed' => ['bg-accent-coral/10 text-accent-coral', 'bg-accent-coral', __('Failed')], default => ['bg-paper-100 text-ink-700', 'bg-paper-300', __('Disconnected')], }; $sent = (int) $device->sent_24h; $fail = (int) $device->failed_24h; $ok = max(0, $sent - $fail); $delivPct = $sent > 0 ? round($ok / $sent * 100, 1) : 0; // Lifetime, per-device (conversations.device_id) — independent of the // range picker so these cards always read all-time. $lifeRead = (int) ($analytics['lifetime']['read'] ?? 0); $lifeFailed = (int) ($analytics['lifetime']['failed'] ?? 0); $lifeTotal = (int) ($analytics['lifetime']['total'] ?? 0); $readRate = $lifeTotal > 0 ? round($lifeRead / $lifeTotal * 100, 1) : 0; $failedPct = $lifeTotal > 0 ? round($lifeFailed / $lifeTotal * 100, 1) : 0; @endphp
{{ __('Admin') }} {{ __('Devices') }} {{ $device->device_name ?: __('Device #:id', ['id' => $device->id]) }}{{ optional($device->workspace)->name ? ' · ' . optional($device->workspace)->name : '' }}
{{ $pill[2] }} {{-- Drives the volume chart + status donut window. Plain reload — keeps the URL shareable and needs no JS. --}} {{-- Re-sync pulls this device's live status from the bridge, like the user-side reconnect. --}}
@csrf
@if ($device->status === 'connected')
@csrf
@endif {{ __('Export CSV') }}
{{ __('Device') }} #{{ $device->id }}

{{ $device->device_name ?: __('Device #:id', ['id' => $device->id]) }}

{{ $phone !== '' ? mask_phone($phone) : '—' }}
{{ optional($device->workspace)->name ?: '—' }} {{ optional($device->workspace)->plan ?: '—' }} {{ $device->region ?: '—' }} {{ __('Status') }}: {{ $device->status }} {{ __('Owner') }}: {{ optional($device->user)->name ?: '—' }} {{ __('Paired') }} {{ optional($device->created_at)->diffForHumans() ?: '—' }}
@csrf @method('DELETE')
{{ __('Sent (24h)') }}
{{ number_format($sent) }}{{ __('outgoing') }}
{{ __('Delivered') }}{{ __('healthy') }}
{{ $delivPct }}%{{ number_format($ok) }} ok
{{ __('Read rate') }}
{{ $readRate }}%{{ number_format($lifeRead) }} {{ __('read') }}
{{ __('Failed') }}{{ $failedPct }}%
{{ number_format($lifeFailed) }}{{ __('all time') }}
{{ __('Total sent') }}
{{ number_format($lifeTotal) }}{{ __('all time') }}
@php $rangeLabel = ['24h' => __('last 24h'), '7d' => __('last 7 days'), '30d' => __('last 30 days')][$range] ?? __('last 7 days'); @endphp
{{ __('Activity') }}

{{ __('Sent vs failed') }} · {{ $rangeLabel }}

{{ __('Status mix') }}

{{ __('Delivery breakdown') }}

{{ __('Read') }}{{ number_format($analytics['status']['read']) }}
{{ __('Delivered') }}{{ number_format($analytics['status']['delivered']) }}
{{ __('Pending') }}{{ number_format($analytics['status']['pending']) }}
{{ __('Failed') }}{{ number_format($analytics['status']['failed']) }}
{{ __('When it fires') }}

{{ __('Hour-of-day heatmap') }}

{{ __('last 7 days · IST') }}
{{ __('Recent events') }}

{{ __('Session log') }}

@forelse ($events as $ev) @php $act = (string) $ev->action; $short = \Illuminate\Support\Str::afterLast($act, '.'); $tone = str_contains($act, 'destroy') || str_contains($act, 'remove') ? 'bg-accent-coral/10 text-accent-coral' : (str_contains($act, 'disconnect') ? 'bg-accent-amber/15 text-accent-amber' : 'bg-wa-mint text-wa-deep'); $meta = is_array($ev->meta ?? null) ? $ev->meta : []; @endphp @empty @endforelse
{{ __('When') }} {{ __('Event') }} {{ __('Detail') }} By
{{ optional($ev->created_at)->diffForHumans() ?: '—' }} {{ $short }} {{ $meta ? json_encode($meta) : $act }} {{ optional($ev->actor)->name ?: __('system') }}
{{ __('No recorded events for this device yet.') }}
@if ($events->hasPages())
{{ $events->links() }}
@endif
{{ __('Admin audit') }}

{{ __('Action log') }}

    @forelse ($events as $ev) @php $dot = str_contains((string) $ev->action, 'destroy') ? 'bg-accent-coral' : (str_contains((string) $ev->action, 'disconnect') ? 'bg-accent-amber' : 'bg-wa-green'); @endphp
  1. {{ optional($ev->actor)->name ?: __('system') }} {{ \Illuminate\Support\Str::afterLast((string) $ev->action, '.') }} · {{ optional($ev->created_at)->format('Y-m-d H:i') }}
  2. @empty
  3. {{ __('No admin actions recorded for this device yet.') }}
  4. @endforelse