Files
coolify/resources/views/livewire/traffic/_live-toggle.blade.php
T
Aditya Tripathi 7c01f63f53 fix(traffic-analytics): stop leaking geoip key and gate sentinel restart
- Only send GEOIP_MAXMIND_LICENSE_KEY to Sentinel when GeoIP is enabled
- Skip restarting Sentinel when disabling analytics unless it was already running
- Validate Sentinel API responses are JSON objects before reading them
- Restore "live" toggle state from localStorage instead of only disabling it
- Use content-based wire:key for breakdown/path rows instead of loop index
- Add missing Kosovo country code and require update permission for geoip listbox
2026-08-21 11:22:36 +00:00

33 lines
1.9 KiB
PHP

{{--
"Live Refresh" toggle for realtime analytics. Sits next to the time-range selector.
Realtime is only meaningful at the 24h range (minute-level rollups), so the control
is hidden entirely for 7d/30d. The label is constant; the active state is shown by the
button color + a pulsing emerald dot. The choice is persisted per-browser in
localStorage. Expects `$range` in scope and a `live` bool on the host Livewire component.
The pulse respects prefers-reduced-motion.
--}}
@if ($range === '24h')
<div x-data="{ live: $wire.entangle('live').live }"
x-init="
const stored = localStorage.getItem('traffic-live');
if (stored === '0') { live = false; }
if (stored === '1') { live = true; }
$watch('live', value => localStorage.setItem('traffic-live', value ? '1' : '0'));
">
<button type="button"
@click="live = !live"
:aria-pressed="live ? 'true' : 'false'"
title="Toggle realtime refresh (updates every 60s)"
class="inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-[12px] font-medium ring-1 transition-colors"
:class="live
? 'bg-white text-black shadow-sm ring-neutral-200 dark:bg-white/[0.09] dark:text-fg dark:ring-white/[0.08]'
: 'text-neutral-500 ring-neutral-200 hover:text-black dark:text-fg-faint dark:ring-white/[0.08] dark:hover:text-fg'">
<span class="relative flex h-1.5 w-1.5 shrink-0" aria-hidden="true">
<span x-show="live" class="absolute inline-flex h-full w-full rounded-full bg-emerald-500 opacity-75 motion-safe:animate-ping"></span>
<span class="relative inline-flex h-1.5 w-1.5 rounded-full" :class="live ? 'bg-emerald-500' : 'bg-neutral-400 dark:bg-white/40'"></span>
</span>
<span>Live Refresh</span>
</button>
</div>
@endif