Download src/components/views/queue-view.tsx from Zero124/VR-MEDIA: direct link, hf CLI and curl.
- Browser
- Download file 9.21 kB
-
https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/components/views/queue-view.tsx
- Command line
-
hf download hf://spaces/Zero124/VR-MEDIA/src/components/views/queue-view.tsx
-
curl -L -o queue-view.tsx https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/components/views/queue-view.tsx
9.21 kB
| // Processing Queue view — live scan progress per step. | |
| "use client"; | |
| import { useQuery } from "@tanstack/react-query"; | |
| import { Card } from "@/components/ui/card"; | |
| import { Progress } from "@/components/ui/progress"; | |
| import { Badge } from "@/components/ui/badge"; | |
| import { | |
| Radio, Clock, CheckCircle2, AlertTriangle, ListChecks, History, | |
| } from "lucide-react"; | |
| import { useAppStore } from "@/lib/store"; | |
| import { SourceBadge } from "@/components/shared/badges"; | |
| import type { QueueItemView } from "@/lib/types"; | |
| const STEP_LABELS: Record<string, string> = { | |
| metadata: "Container Metadata", | |
| filename: "Filename Intelligence", | |
| stream: "Stream Analysis", | |
| alpha: "Alpha Channel", | |
| mask: "Mask Track", | |
| frame: "Frame Analysis", | |
| depth: "Depth Detection", | |
| classify: "Classification", | |
| }; | |
| export function QueueView() { | |
| const setView = useAppStore((s) => s.setView); | |
| const queueQ = useQuery({ | |
| queryKey: ["queue"], | |
| queryFn: async () => { | |
| const res = await fetch("/api/queue"); | |
| if (!res.ok) throw new Error("queue fetch failed"); | |
| return res.json() as Promise<{ | |
| active: QueueItemView[]; | |
| recentlyDone: { id: string; videoId: string; videoName: string; finishedAt: string | null }[]; | |
| recentErrors: { id: string; videoId: string; videoName: string; errorMessage: string | null; finishedAt: string | null }[]; | |
| totals: { queued: number; running: number }; | |
| }>; | |
| }, | |
| refetchInterval: 1500, | |
| }); | |
| const q = queueQ.data; | |
| return ( | |
| <div className="space-y-4"> | |
| {/* Summary cards */} | |
| <div className="grid grid-cols-2 md:grid-cols-4 gap-3"> | |
| <Card className="glass-card p-4"> | |
| <div className="flex items-center justify-between"> | |
| <div> | |
| <div className="text-xs uppercase tracking-wider text-muted-foreground">Running</div> | |
| <div className="text-2xl font-bold text-cyan-300 mt-1">{q?.totals?.running ?? 0}</div> | |
| </div> | |
| <Radio className="h-5 w-5 text-cyan-300 vr-pulse" /> | |
| </div> | |
| </Card> | |
| <Card className="glass-card p-4"> | |
| <div className="flex items-center justify-between"> | |
| <div> | |
| <div className="text-xs uppercase tracking-wider text-muted-foreground">Queued</div> | |
| <div className="text-2xl font-bold text-amber-300 mt-1">{q?.totals?.queued ?? 0}</div> | |
| </div> | |
| <Clock className="h-5 w-5 text-amber-300" /> | |
| </div> | |
| </Card> | |
| <Card className="glass-card p-4"> | |
| <div className="flex items-center justify-between"> | |
| <div> | |
| <div className="text-xs uppercase tracking-wider text-muted-foreground">Recently Done</div> | |
| <div className="text-2xl font-bold text-emerald-300 mt-1">{q?.recentlyDone?.length ?? 0}</div> | |
| </div> | |
| <CheckCircle2 className="h-5 w-5 text-emerald-300" /> | |
| </div> | |
| </Card> | |
| <Card className="glass-card p-4"> | |
| <div className="flex items-center justify-between"> | |
| <div> | |
| <div className="text-xs uppercase tracking-wider text-muted-foreground">Errors</div> | |
| <div className="text-2xl font-bold text-red-300 mt-1">{q?.recentErrors?.length ?? 0}</div> | |
| </div> | |
| <AlertTriangle className="h-5 w-5 text-red-300" /> | |
| </div> | |
| </Card> | |
| </div> | |
| {/* Active queue */} | |
| <Card className="glass-card p-5"> | |
| <h3 className="text-sm font-semibold mb-4 flex items-center gap-2"> | |
| <ListChecks className="h-4 w-4 text-cyan-300" /> Active Queue | |
| </h3> | |
| {q?.active?.length === 0 ? ( | |
| <div className="text-sm text-muted-foreground text-center py-6"> | |
| Queue is empty. Trigger a scan from the top bar. | |
| </div> | |
| ) : ( | |
| <div className="space-y-3"> | |
| {q?.active?.map((item) => ( | |
| <div key={item.id} className="p-3 rounded-lg bg-background/40 border border-border/60"> | |
| <div className="flex items-center justify-between gap-3 mb-2"> | |
| <div className="min-w-0 flex-1"> | |
| <button | |
| onClick={() => setView("inspector", { videoId: item.videoId })} | |
| className="text-sm font-medium hover:text-cyan-300 truncate block text-left" | |
| > | |
| {item.videoName} | |
| </button> | |
| <div className="text-xs text-muted-foreground"> | |
| Started: {item.startedAt ? new Date(item.startedAt).toLocaleTimeString() : "—"} | |
| </div> | |
| <div className="mt-1"> | |
| <SourceBadge value={item.source} /> | |
| </div> | |
| </div> | |
| <Badge | |
| variant="outline" | |
| className={`text-xs ${ | |
| item.status === "running" | |
| ? "bg-cyan-500/15 text-cyan-200 border-cyan-500/40" | |
| : "bg-amber-500/15 text-amber-200 border-amber-500/40" | |
| }`} | |
| > | |
| {item.status} | |
| </Badge> | |
| </div> | |
| <Progress value={item.stepProgress} className="h-1.5 mb-3" /> | |
| <div className="grid grid-cols-4 sm:grid-cols-8 gap-1"> | |
| {item.steps.map((step) => ( | |
| <div | |
| key={step.step} | |
| className={`flex flex-col items-center gap-1 p-1.5 rounded text-[10px] ${ | |
| step.status === "done" | |
| ? "bg-emerald-500/10 text-emerald-300" | |
| : step.status === "running" | |
| ? "bg-cyan-500/15 text-cyan-200 vr-pulse" | |
| : step.status === "error" | |
| ? "bg-red-500/15 text-red-300" | |
| : "bg-muted/30 text-muted-foreground" | |
| }`} | |
| title={step.label} | |
| > | |
| <div className="font-medium">{step.label.split(" ")[0]}</div> | |
| <div className="capitalize opacity-70">{step.status}</div> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| ))} | |
| </div> | |
| )} | |
| </Card> | |
| {/* Recent activity */} | |
| <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <Card className="glass-card p-5"> | |
| <h3 className="text-sm font-semibold mb-3 flex items-center gap-2"> | |
| <History className="h-4 w-4 text-emerald-300" /> Recently Completed | |
| </h3> | |
| {q?.recentlyDone?.length === 0 ? ( | |
| <div className="text-xs text-muted-foreground py-4 text-center">No completed scans yet.</div> | |
| ) : ( | |
| <div className="space-y-2 max-h-64 overflow-y-auto scrollbar-vr"> | |
| {q?.recentlyDone?.map((item) => ( | |
| <div key={item.id} className="flex items-center gap-2 text-xs"> | |
| <CheckCircle2 className="h-3.5 w-3.5 text-emerald-300 shrink-0" /> | |
| <button | |
| onClick={() => setView("inspector", { videoId: item.videoId })} | |
| className="flex-1 truncate text-left hover:text-cyan-300" | |
| > | |
| {item.videoName} | |
| </button> | |
| <span className="text-muted-foreground shrink-0"> | |
| {item.finishedAt ? new Date(item.finishedAt).toLocaleTimeString() : "—"} | |
| </span> | |
| </div> | |
| ))} | |
| </div> | |
| )} | |
| </Card> | |
| <Card className="glass-card p-5"> | |
| <h3 className="text-sm font-semibold mb-3 flex items-center gap-2"> | |
| <AlertTriangle className="h-4 w-4 text-red-300" /> Recent Errors | |
| </h3> | |
| {q?.recentErrors?.length === 0 ? ( | |
| <div className="text-xs text-muted-foreground py-4 text-center">No errors. All good.</div> | |
| ) : ( | |
| <div className="space-y-2 max-h-64 overflow-y-auto scrollbar-vr"> | |
| {q?.recentErrors?.map((item) => ( | |
| <div key={item.id} className="flex items-start gap-2 text-xs"> | |
| <AlertTriangle className="h-3.5 w-3.5 text-red-300 shrink-0 mt-0.5" /> | |
| <div className="min-w-0 flex-1"> | |
| <button | |
| onClick={() => setView("inspector", { videoId: item.videoId })} | |
| className="font-medium truncate block text-left hover:text-cyan-300" | |
| > | |
| {item.videoName} | |
| </button> | |
| <div className="text-red-300/80 truncate">{item.errorMessage}</div> | |
| </div> | |
| </div> | |
| ))} | |
| </div> | |
| )} | |
| </Card> | |
| </div> | |
| </div> | |
| ); | |
| } | |