feat(web): refresh simulator dashboard UI
This commit is contained in:
@@ -9,6 +9,20 @@
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card/index.js';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '$lib/components/ui/dropdown-menu/index.js';
|
||||
import { ScrollArea } from '$lib/components/ui/scroll-area/index.js';
|
||||
import {
|
||||
Plus,
|
||||
RefreshCw,
|
||||
Monitor,
|
||||
Eye,
|
||||
Video,
|
||||
VideoOff,
|
||||
MoreVertical,
|
||||
X,
|
||||
History,
|
||||
Activity,
|
||||
ShieldCheck,
|
||||
Clock
|
||||
} from '@lucide/svelte';
|
||||
|
||||
let clientVideoElement: HTMLVideoElement | null = null;
|
||||
|
||||
@@ -56,62 +70,55 @@
|
||||
</script>
|
||||
|
||||
<AppChrome pageKey="client">
|
||||
<section id="screen-home-client" class="mx-auto flex h-full max-w-7xl min-h-0 flex-col gap-8">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<section id="screen-home-client" class="mx-auto flex h-full max-w-7xl min-h-0 flex-col gap-6">
|
||||
<div class="flex justify-between items-center px-1">
|
||||
<h2 class="text-2xl font-bold text-white tracking-tight">Client Dashboard</h2>
|
||||
<div class="flex gap-3">
|
||||
<div class="flex gap-2">
|
||||
<Button
|
||||
id="linkCameraBtn"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
class="rounded-xl border-white/10 text-gray-300 shadow-none hover:bg-white/5 hover:text-white"
|
||||
onclick={() => appController.linkCamera()}
|
||||
>
|
||||
<svg data-icon="inline-start" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
<Plus class="h-4 w-4 mr-1.5" />
|
||||
Link Camera
|
||||
</Button>
|
||||
<Button
|
||||
id="refreshClientBtn"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
size="icon-sm"
|
||||
class="rounded-xl border border-white/5 bg-white/5 hover:bg-white/10"
|
||||
aria-label="Refresh linked cameras"
|
||||
title="Refresh linked cameras"
|
||||
onclick={() => appController.refreshClientData()}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
||||
/>
|
||||
</svg>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card class="glass-card mb-4 shrink-0 rounded-3xl border-white/10 bg-[#16161d]/80">
|
||||
<CardHeader>
|
||||
<CardTitle class="text-xs font-bold uppercase tracking-wider text-gray-400">Your Cameras</CardTitle>
|
||||
<Card variant="glass" class="mb-2 shrink-0 rounded-3xl">
|
||||
<CardHeader class="pb-3 flex flex-row items-center gap-2">
|
||||
<Monitor class="size-3.5 text-gray-500" />
|
||||
<CardTitle class="text-[10px] font-bold uppercase tracking-widest text-gray-500">Your Cameras</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{#if $appState.linkedCameras.length === 0}
|
||||
<Alert class="border-dashed border-white/10 bg-black/20 text-center">
|
||||
<AlertTitle class="justify-self-center text-sm text-gray-200">No cameras linked</AlertTitle>
|
||||
<AlertDescription class="justify-self-center text-sm text-gray-500">
|
||||
<Alert variant="default" class="border-dashed border-white/10 bg-black/20 text-center py-8">
|
||||
<AlertTitle class="text-sm text-gray-200">No cameras linked</AlertTitle>
|
||||
<AlertDescription class="text-xs text-gray-500">
|
||||
Link a camera to start viewing live feeds and recordings.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
{:else}
|
||||
<ScrollArea class="w-full whitespace-nowrap" orientation="horizontal">
|
||||
<div id="linkedCamerasList" class="flex gap-4 pb-2">
|
||||
<div id="linkedCamerasList" class="flex gap-4 pb-3">
|
||||
{#each $appState.linkedCameras as link (link.id)}
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class="min-w-[240px] max-w-[240px] flex-shrink-0 cursor-pointer text-left"
|
||||
class="min-w-[240px] max-w-[240px] flex-shrink-0 cursor-pointer text-left group"
|
||||
onclick={(event) => {
|
||||
if ((event.target as HTMLElement).closest('[data-menu-trigger]')) return;
|
||||
appController.selectCamera(link.cameraDeviceId);
|
||||
@@ -122,25 +129,20 @@
|
||||
>
|
||||
<Card
|
||||
size="sm"
|
||||
class="overflow-hidden rounded-xl border transition-colors { $appState.activeCameraDeviceId === link.cameraDeviceId ? 'border-blue-500/50 bg-blue-950/20' : 'border-white/5 bg-gray-900/60 hover:border-blue-500/30' }"
|
||||
class="overflow-hidden rounded-xl border transition-all duration-300 { $appState.activeCameraDeviceId === link.cameraDeviceId ? 'border-blue-500/50 bg-blue-950/20' : 'border-white/5 bg-gray-900/60 hover:border-blue-500/30' }"
|
||||
>
|
||||
<div class="relative aspect-video overflow-hidden border-b border-white/5 bg-black/40">
|
||||
{#if $appState.activeCameraDeviceId === link.cameraDeviceId}
|
||||
<div class="absolute inset-0 flex flex-col items-center justify-center gap-2 bg-blue-500/10 text-blue-400">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
||||
</svg>
|
||||
<Eye class="h-6 w-6" />
|
||||
<Badge variant="secondary" class="rounded-full px-2 text-[10px] uppercase tracking-wider">
|
||||
Viewing
|
||||
</Badge>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="absolute inset-0 flex flex-col items-center justify-center gap-2 text-gray-500 transition-colors hover:text-gray-300">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" />
|
||||
</svg>
|
||||
<p class="text-[10px]">{isCameraLive(link.cameraDeviceId) ? 'Live Stream Active' : 'Click to view'}</p>
|
||||
<div class="absolute inset-0 flex flex-col items-center justify-center gap-2 text-gray-600 transition-colors group-hover:text-gray-400">
|
||||
<Video class="h-6 w-6" />
|
||||
<p class="text-[10px] font-medium tracking-wide">{isCameraLive(link.cameraDeviceId) ? 'LIVE' : 'CLICK TO VIEW'}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -152,9 +154,9 @@
|
||||
</p>
|
||||
<Badge
|
||||
variant={link.cameraStatus?.toLowerCase() === 'online' ? 'secondary' : 'outline'}
|
||||
class="gap-1.5 rounded-full px-2 capitalize"
|
||||
class="gap-1.5 rounded-full px-2 capitalize text-[10px]"
|
||||
>
|
||||
<span class="h-2 w-2 rounded-full shrink-0 {statusDotClass(link.cameraStatus)}"></span>
|
||||
<span class="h-1.5 w-1.5 rounded-full shrink-0 {statusDotClass(link.cameraStatus)} shadow-[0_0_4px_rgba(16,185,129,0.4)]"></span>
|
||||
{link.cameraStatus || 'offline'}
|
||||
</Badge>
|
||||
</div>
|
||||
@@ -168,11 +170,7 @@
|
||||
class="text-gray-400 hover:text-white"
|
||||
{...props}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||
<circle cx="10" cy="4" r="1.6" />
|
||||
<circle cx="10" cy="10" r="1.6" />
|
||||
<circle cx="10" cy="16" r="1.6" />
|
||||
</svg>
|
||||
<MoreVertical class="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
{/snippet}
|
||||
</DropdownMenuTrigger>
|
||||
@@ -207,31 +205,32 @@
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<div class="flex flex-1 min-h-0 flex-col gap-8 xl:flex-row">
|
||||
<div class="flex flex-1 min-h-0 flex-col gap-6 xl:flex-row">
|
||||
<Card
|
||||
id="clientStreamViewerWrapper"
|
||||
class="glass-card min-w-0 flex-1 overflow-hidden rounded-3xl border-white/10 bg-[#16161d]/80 shadow-xl {$appState.activeCameraDeviceId ? 'flex min-h-[400px] flex-col xl:min-h-0' : 'hidden'}"
|
||||
variant="glass"
|
||||
class="min-w-0 flex-1 overflow-hidden shadow-xl {$appState.activeCameraDeviceId ? 'flex min-h-[400px] flex-col xl:min-h-0' : 'hidden'}"
|
||||
>
|
||||
<CardHeader class="border-b border-white/5 bg-black/20 px-5 py-4">
|
||||
<CardHeader class="border-b border-white/5 bg-black/20 px-5 py-3">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="w-2 h-2 rounded-full bg-red-500 animate-[pulse_2s_ease-in-out_infinite] {isCameraLive($appState.activeCameraDeviceId) ? '' : 'hidden'}" id="clientLiveDot"></span>
|
||||
<CardTitle class="font-medium tracking-wide text-white" id="clientStreamViewerTitle">
|
||||
Live Feed: {activeCameraLabel()}
|
||||
{#if isCameraLive($appState.activeCameraDeviceId)}
|
||||
<span class="w-2 h-2 rounded-full bg-red-500 animate-[pulse_2s_ease-in-out_infinite]" id="clientLiveDot"></span>
|
||||
{/if}
|
||||
<CardTitle class="text-sm font-semibold tracking-wide text-white" id="clientStreamViewerTitle">
|
||||
{activeCameraLabel()}
|
||||
</CardTitle>
|
||||
</div>
|
||||
<Button
|
||||
id="closeStreamViewerBtn"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
size="icon-xs"
|
||||
class="text-gray-400 hover:text-white"
|
||||
aria-label="Close stream viewer"
|
||||
title="Close stream viewer"
|
||||
onclick={() => appController.closeStreamViewer()}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
<X class="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
@@ -246,44 +245,40 @@
|
||||
bind:this={clientVideoElement}
|
||||
></video>
|
||||
|
||||
<Alert
|
||||
<div
|
||||
id="clientStreamPlaceholder"
|
||||
class="relative z-10 m-6 flex max-w-md flex-col items-center gap-4 border-white/10 bg-black/40 text-center {$appState.clientStreamMode === 'none' || $appState.clientStreamMode === 'connecting' || $appState.clientStreamMode === 'unavailable' ? '' : 'hidden'}"
|
||||
class="relative z-10 m-6 flex max-w-sm flex-col items-center gap-4 text-center {$appState.clientStreamMode === 'none' || $appState.clientStreamMode === 'connecting' || $appState.clientStreamMode === 'unavailable' ? '' : 'hidden'}"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"
|
||||
></path>
|
||||
</svg>
|
||||
<AlertTitle class="justify-self-center text-sm text-gray-200">Stream unavailable</AlertTitle>
|
||||
<AlertDescription class="justify-self-center text-sm font-medium uppercase tracking-wide text-gray-500">
|
||||
<div class="p-5 rounded-full bg-white/5 mb-2">
|
||||
<VideoOff class="h-10 w-10 text-gray-600" />
|
||||
</div>
|
||||
<p class="text-base font-semibold text-white">Stream unavailable</p>
|
||||
<p class="text-xs font-bold uppercase tracking-widest text-gray-500">
|
||||
{$appState.clientPlaceholderText}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
{#if activeStreamDiagnostics()}
|
||||
<div class="border-t border-white/5 bg-black/20 px-5 py-4">
|
||||
<div class="flex flex-wrap items-center gap-2 text-[11px] uppercase tracking-[0.2em] text-gray-500">
|
||||
<span>Live Diagnostics</span>
|
||||
<Badge variant="outline" class="border-white/10 text-[10px] text-gray-400">
|
||||
<div class="flex flex-wrap items-center gap-2 text-[10px] font-bold uppercase tracking-widest text-gray-500">
|
||||
<Activity class="size-3 text-blue-500" />
|
||||
<span>Diagnostics</span>
|
||||
<Badge variant="outline" class="border-white/5 text-[9px] text-gray-500 px-1.5 font-mono">
|
||||
{activeStreamSessionId()?.slice(0, 8)}
|
||||
</Badge>
|
||||
{#if isCameraLive($appState.activeCameraDeviceId)}
|
||||
<Badge variant="secondary" class="rounded-full px-2 text-[10px] uppercase tracking-wide">Peer connected</Badge>
|
||||
<Badge variant="secondary" class="rounded-full px-2 text-[9px] font-bold uppercase tracking-widest">Peer connected</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="mt-3 grid gap-2">
|
||||
{#each activeStreamDiagnostics().entries.slice(0, 6) as entry (entry.id)}
|
||||
<div class="rounded-xl border px-3 py-2 {diagnosticLevelClass(entry.level)}">
|
||||
<div class="mt-4 grid gap-2">
|
||||
{#each activeStreamDiagnostics().entries.slice(0, 4) as entry (entry.id)}
|
||||
<div class="rounded-xl border px-3 py-2 {diagnosticLevelClass(entry.level)} transition-colors">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="text-[11px] font-semibold uppercase tracking-[0.18em]">{entry.stage}</span>
|
||||
<span class="text-[10px] text-gray-500">{new Date(entry.createdAt).toLocaleTimeString()}</span>
|
||||
<span class="text-[10px] font-bold uppercase tracking-wider">{entry.stage}</span>
|
||||
<span class="text-[9px] font-medium opacity-50">{new Date(entry.createdAt).toLocaleTimeString()}</span>
|
||||
</div>
|
||||
<p class="mt-1 text-sm text-current">{entry.message}</p>
|
||||
<p class="mt-1 text-xs text-current opacity-90">{entry.message}</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -292,34 +287,38 @@
|
||||
</Card>
|
||||
|
||||
<div class="flex shrink-0 flex-col gap-6 pr-2 xl:max-h-full xl:w-96 xl:overflow-y-auto">
|
||||
<Card class="glass-card flex-1 rounded-3xl border-white/10 bg-[#16161d]/80">
|
||||
<CardHeader>
|
||||
<CardTitle class="text-xs font-bold uppercase tracking-wider text-gray-400">Recent Recordings</CardTitle>
|
||||
<Card variant="glass" class="flex-1 rounded-3xl">
|
||||
<CardHeader class="pb-3 flex flex-row items-center gap-2">
|
||||
<History class="size-3.5 text-gray-500" />
|
||||
<CardTitle class="text-[10px] font-bold uppercase tracking-widest text-gray-400">Recent Clips</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ScrollArea class="max-h-[26rem] pr-3">
|
||||
<ScrollArea class="max-h-[30rem] pr-3">
|
||||
<div id="recordingsList" class="space-y-3">
|
||||
{#if $appState.recordings.length === 0}
|
||||
<Alert class="border-white/10 bg-gray-900/30 text-center">
|
||||
<AlertTitle class="justify-self-center text-xs text-gray-200">No recordings found</AlertTitle>
|
||||
<AlertDescription class="justify-self-center text-xs text-gray-500">
|
||||
Captured clips will appear here when they are ready.
|
||||
<Alert variant="default" class="border-dashed border-white/10 bg-gray-900/30 text-center py-6">
|
||||
<AlertTitle class="text-xs text-gray-200">No recordings found</AlertTitle>
|
||||
<AlertDescription class="text-[10px] text-gray-500">
|
||||
Captured clips will appear here.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
{:else}
|
||||
{#each $appState.recordings.slice(0, 5) as recording (recording.id)}
|
||||
<Card size="sm" class="border-white/5 bg-gray-900/40">
|
||||
{#each $appState.recordings.slice(0, 8) as recording (recording.id)}
|
||||
<Card size="sm" class="border-white/5 bg-white/5 hover:bg-white/10 transition-colors">
|
||||
<CardContent class="flex items-center justify-between gap-4 px-3 py-3">
|
||||
<div class="flex flex-col">
|
||||
<span class="text-xs font-medium text-gray-300">{new Date(recording.createdAt).toLocaleString()}</span>
|
||||
<span class="text-[10px] text-gray-500">
|
||||
{recording.durationSeconds != null ? `${recording.durationSeconds}s duration` : 'Duration pending'} · {recording.status ?? 'unknown'}
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<Clock class="size-3 text-gray-500" />
|
||||
<span class="text-xs font-semibold text-gray-300">{new Date(recording.createdAt).toLocaleTimeString()}</span>
|
||||
</div>
|
||||
<span class="text-[9px] font-bold uppercase tracking-widest text-gray-500">
|
||||
{recording.status ?? 'unknown'} · {recording.durationSeconds != null ? `${recording.durationSeconds}s` : '--'}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
class="border-white/10 text-gray-400"
|
||||
class="h-7 rounded-lg border-white/10 text-xs font-bold text-gray-400 hover:text-white"
|
||||
disabled={recording.status !== 'ready'}
|
||||
onclick={() => appController.openRecording(recording.id)}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user