Compare commits
16
Commits
v0.7.0
..
44755c6e85
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44755c6e85 | ||
|
|
494e963fa3 | ||
|
|
f8f687af4e | ||
|
|
69e4fb286c | ||
|
|
ea320548b6 | ||
|
|
27d0db0f72 | ||
|
|
e436ced95b | ||
|
|
fe017497a2 | ||
|
|
fc7fd74d17 | ||
|
|
8c3d4e4e33 | ||
|
|
581c3c0e6c | ||
|
|
afa6e8d473 | ||
|
|
1bad1f4e33 | ||
|
|
c06f119dcf | ||
|
|
20433a6749 | ||
|
|
1d88ab96c8 |
@@ -7,7 +7,8 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|||||||
import { SessionTimelineChart } from "@/components/sessions/SessionTimelineChart";
|
import { SessionTimelineChart } from "@/components/sessions/SessionTimelineChart";
|
||||||
import { SessionTitleEditor } from "@/components/sessions/SessionTitleEditor";
|
import { SessionTitleEditor } from "@/components/sessions/SessionTitleEditor";
|
||||||
import { SessionDescriptionEditor } from "@/components/sessions/SessionDescriptionEditor";
|
import { SessionDescriptionEditor } from "@/components/sessions/SessionDescriptionEditor";
|
||||||
import { STATUS_VARIANT } from "@/components/sessions/SessionsTable";
|
import { SessionDeleteButton } from "@/components/sessions/SessionDeleteButton";
|
||||||
|
import { STATUS_VARIANT } from "@/components/sessions/session-status";
|
||||||
import { getSessionDetail, getSessionName } from "@/lib/db/queries/sessions";
|
import { getSessionDetail, getSessionName } from "@/lib/db/queries/sessions";
|
||||||
import { getSessionTimeline } from "@/lib/db/queries/stats";
|
import { getSessionTimeline } from "@/lib/db/queries/stats";
|
||||||
import { Play } from "lucide-react";
|
import { Play } from "lucide-react";
|
||||||
@@ -65,6 +66,7 @@ export default async function SessionDetailPage({ params }: { params: Promise<{
|
|||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
<SessionDeleteButton sessionId={detail.session.id} sessionName={detail.session.name} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,21 @@ import { getSessionName } from "@/lib/db/queries/sessions";
|
|||||||
export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise<Metadata> {
|
export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise<Metadata> {
|
||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
const name = await getSessionName(Number(id));
|
const name = await getSessionName(Number(id));
|
||||||
return { title: name ? `Replay ${name}` : "Replay" };
|
return { title: name ? `${name} - Replay` : "Replay" };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ReplayPage({ params }: { params: Promise<{ id: string }> }) {
|
export default async function ReplayPage({ params }: { params: Promise<{ id: string }> }) {
|
||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
|
const name = await getSessionName(Number(id));
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
<h1 className="font-heading text-2xl font-semibold">Replay</h1>
|
<div>
|
||||||
|
<h1 className="font-heading text-2xl font-semibold">{name ?? `Session #${id}`} - Replay</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
Connect the devices you want to replay onto, then match them to this session's original device
|
||||||
|
slots and play its recorded intensity back live over Web Bluetooth.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<ReplayPlayerLoader sessionId={Number(id)} />
|
<ReplayPlayerLoader sessionId={Number(id)} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import { DeviceCard } from "./DeviceCard";
|
|||||||
import { RecordControls } from "./RecordControls";
|
import { RecordControls } from "./RecordControls";
|
||||||
import { NameSessionDialog } from "./NameSessionDialog";
|
import { NameSessionDialog } from "./NameSessionDialog";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
|
import { Info } from "lucide-react";
|
||||||
|
|
||||||
interface ActiveSession {
|
interface ActiveSession {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -225,7 +227,7 @@ export function ButtplugConsole() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
<div className="flex flex-wrap items-center justify-between gap-4">
|
<div className="flex flex-wrap items-center gap-4">
|
||||||
<DeviceScanPanel scanning={scanning} onScan={handleScan} onStopScan={() => void stopScanning()} />
|
<DeviceScanPanel scanning={scanning} onScan={handleScan} onStopScan={() => void stopScanning()} />
|
||||||
<RecordControls
|
<RecordControls
|
||||||
active={activeSession !== null}
|
active={activeSession !== null}
|
||||||
@@ -240,12 +242,13 @@ export function ButtplugConsole() {
|
|||||||
{storeError && <p className="text-sm text-destructive">{storeError}</p>}
|
{storeError && <p className="text-sm text-destructive">{storeError}</p>}
|
||||||
|
|
||||||
{Object.keys(devices).length === 0 ? (
|
{Object.keys(devices).length === 0 ? (
|
||||||
<Card className="bp-glass">
|
<Alert className="bp-glass">
|
||||||
<CardContent className="py-6 text-sm text-muted-foreground">
|
<Info />
|
||||||
No devices connected yet. Scan to discover nearby toys, then select one from your browser's
|
<AlertTitle>No devices connected yet</AlertTitle>
|
||||||
pairing prompt.
|
<AlertDescription>
|
||||||
</CardContent>
|
Scan to discover nearby toys, then select one from your browser's pairing prompt.
|
||||||
</Card>
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid gap-4 sm:grid-cols-2">
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
{Object.values(devices).map((device) => (
|
{Object.values(devices).map((device) => (
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ export function DeviceCard({
|
|||||||
}: DeviceCardProps) {
|
}: DeviceCardProps) {
|
||||||
return (
|
return (
|
||||||
<Card className="bp-glass">
|
<Card className="bp-glass">
|
||||||
<CardHeader className="flex flex-row items-center justify-between pb-3">
|
<CardHeader className="flex flex-row flex-wrap items-center justify-between gap-2 pb-3">
|
||||||
<span className="text-sm font-medium text-foreground">{device.displayName ?? device.name}</span>
|
<span className="min-w-0 truncate text-sm font-medium text-foreground">{device.displayName ?? device.name}</span>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex shrink-0 items-center gap-3">
|
||||||
{device.hasBattery &&
|
{device.hasBattery &&
|
||||||
(batteryLevel !== null ? (
|
(batteryLevel !== null ? (
|
||||||
<BatteryIndicator level={batteryLevel} />
|
<BatteryIndicator level={batteryLevel} />
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ interface RecordControlsProps {
|
|||||||
export function RecordControls({ active, elapsedLabel, disabled, busy, onStart, onEnd }: RecordControlsProps) {
|
export function RecordControls({ active, elapsedLabel, disabled, busy, onStart, onEnd }: RecordControlsProps) {
|
||||||
if (active) {
|
if (active) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
<span className="flex items-center gap-2 text-sm font-medium">
|
<span className="flex items-center gap-2 text-sm font-medium">
|
||||||
<Circle className="bp-pulse size-2.5 fill-destructive text-destructive" />
|
<Circle className="bp-pulse size-2.5 fill-destructive text-destructive" />
|
||||||
Session live · {elapsedLabel}
|
Session live · {elapsedLabel}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Check, Loader2 } from "lucide-react";
|
import { Check, Loader2 } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
@@ -55,23 +54,23 @@ function DeviceNameCell({ device }: { device: DeviceRow }) {
|
|||||||
}, [status]);
|
}, [status]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-48">
|
<div className="flex items-center gap-2">
|
||||||
<Input
|
<input
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => setValue(e.target.value)}
|
onChange={(e) => setValue(e.target.value)}
|
||||||
className="h-8 pr-8"
|
|
||||||
aria-label="Device display name"
|
aria-label="Device display name"
|
||||||
|
className="max-w-48 min-w-0 border-b-2 border-transparent bg-transparent text-sm font-medium text-foreground caret-primary outline-none transition-colors placeholder:text-muted-foreground/70 hover:border-b-primary focus:border-b-primary [field-sizing:content]"
|
||||||
/>
|
/>
|
||||||
<div className="pointer-events-none absolute inset-y-0 right-2 flex w-3.5 items-center justify-center">
|
<div className="relative flex size-4 shrink-0 items-center justify-center">
|
||||||
<Loader2
|
<Loader2
|
||||||
className={cn(
|
className={cn(
|
||||||
"absolute size-3.5 animate-spin text-muted-foreground transition-opacity",
|
"absolute size-4 animate-spin text-muted-foreground transition-opacity",
|
||||||
status === "saving" ? "opacity-100" : "opacity-0",
|
status === "saving" ? "opacity-100" : "opacity-0",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Check
|
<Check
|
||||||
className={cn(
|
className={cn(
|
||||||
"absolute size-3.5 text-primary transition-opacity",
|
"absolute size-4 text-primary transition-opacity",
|
||||||
status === "saved" ? "opacity-100" : "opacity-0",
|
status === "saved" ? "opacity-100" : "opacity-0",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
+118
-23
@@ -4,48 +4,106 @@ import { useState } from "react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname, useRouter } from "next/navigation";
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import { Menu, Moon, Sun, LogOut } from "lucide-react";
|
import { Moon, Sun, LogOut, Gauge, SlidersHorizontal, ListMusic, Bluetooth, BarChart3 } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Sheet, SheetContent, SheetTitle, SheetTrigger } from "@/components/ui/sheet";
|
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
|
||||||
import { ConnectionStatus } from "./ConnectionStatus";
|
import { ConnectionStatus } from "./ConnectionStatus";
|
||||||
import { BrandMark } from "./BrandMark";
|
import { BrandMark } from "./BrandMark";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
const LINKS = [
|
const LINKS = [
|
||||||
{ href: "/", label: "Dashboard" },
|
{ href: "/", label: "Dashboard", icon: Gauge },
|
||||||
{ href: "/control", label: "Control" },
|
{ href: "/control", label: "Control", icon: SlidersHorizontal },
|
||||||
{ href: "/sessions", label: "Sessions" },
|
{ href: "/sessions", label: "Sessions", icon: ListMusic },
|
||||||
{ href: "/stats", label: "Stats" },
|
{ href: "/devices", label: "Devices", icon: Bluetooth },
|
||||||
{ href: "/devices", label: "Devices" },
|
{ href: "/stats", label: "Stats", icon: BarChart3 },
|
||||||
];
|
];
|
||||||
|
|
||||||
function isActive(pathname: string, href: string): boolean {
|
function isActive(pathname: string, href: string): boolean {
|
||||||
return href === "/" ? pathname === "/" : pathname === href || pathname.startsWith(`${href}/`);
|
return href === "/" ? pathname === "/" : pathname === href || pathname.startsWith(`${href}/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Desktop tab strip - borderless chips; the active tab lights up with a
|
||||||
|
* primary-tinted fill, matching the drawer rows' active treatment. */
|
||||||
function NavLinks({ onNavigate }: { onNavigate?: () => void }) {
|
function NavLinks({ onNavigate }: { onNavigate?: () => void }) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{LINKS.map((link) => (
|
{LINKS.map((link) => {
|
||||||
|
const active = isActive(pathname, link.href);
|
||||||
|
return (
|
||||||
<Link
|
<Link
|
||||||
key={link.href}
|
key={link.href}
|
||||||
href={link.href}
|
href={link.href}
|
||||||
onClick={onNavigate}
|
onClick={onNavigate}
|
||||||
className={cn(
|
className={cn(
|
||||||
"border-b-2 px-2.5 py-1.5 text-xs font-medium tracking-wide uppercase transition-colors",
|
"flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors",
|
||||||
isActive(pathname, link.href)
|
active ? "bg-primary/10 text-foreground" : "text-muted-foreground hover:text-foreground",
|
||||||
? "border-primary text-foreground"
|
|
||||||
: "border-transparent text-muted-foreground hover:text-foreground",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
<link.icon className={cn("size-3.5", active && "text-primary")} />
|
||||||
{link.label}
|
{link.label}
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Drawer rows for the mobile menu - icon + label, styled as tappable
|
||||||
|
* console rows rather than the desktop tab strip's underline treatment. */
|
||||||
|
function MobileNavLinks({ onNavigate }: { onNavigate: () => void }) {
|
||||||
|
const pathname = usePathname();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{LINKS.map((link) => {
|
||||||
|
const active = isActive(pathname, link.href);
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
key={link.href}
|
||||||
|
href={link.href}
|
||||||
|
onClick={onNavigate}
|
||||||
|
className={cn(
|
||||||
|
"flex items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium transition-colors",
|
||||||
|
active ? "bg-primary/10 text-foreground" : "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<link.icon className={cn("size-4 shrink-0", active && "text-primary")} />
|
||||||
|
{link.label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hamburger that morphs into an X - the top/bottom bars rotate into place
|
||||||
|
* and the middle bar collapses, rather than a straight icon swap. */
|
||||||
|
function MenuToggleIcon({ open }: { open: boolean }) {
|
||||||
|
return (
|
||||||
|
<span className="relative flex size-4 shrink-0 flex-col items-center justify-center" aria-hidden>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"absolute h-0.5 w-4 rounded-full bg-current transition-transform duration-300 ease-out motion-reduce:transition-none",
|
||||||
|
open ? "translate-y-0 rotate-45" : "-translate-y-[5px] rotate-0",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"absolute h-0.5 w-4 rounded-full bg-current transition-all duration-200 ease-out motion-reduce:transition-none",
|
||||||
|
open ? "scale-x-0 opacity-0" : "scale-x-100 opacity-100",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"absolute h-0.5 w-4 rounded-full bg-current transition-transform duration-300 ease-out motion-reduce:transition-none",
|
||||||
|
open ? "translate-y-0 -rotate-45" : "translate-y-[5px] rotate-0",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function NavBar() {
|
export function NavBar() {
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -65,12 +123,14 @@ export function NavBar() {
|
|||||||
<span className="font-heading text-lg font-semibold">Sexy</span>
|
<span className="font-heading text-lg font-semibold">Sexy</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<nav className="hidden items-center gap-1 md:flex">
|
<nav className="hidden items-center gap-1.5 md:flex">
|
||||||
<NavLinks />
|
<NavLinks />
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div className="ml-auto flex items-center gap-2">
|
<div className="ml-auto flex items-center gap-2">
|
||||||
<ConnectionStatus />
|
<ConnectionStatus />
|
||||||
|
|
||||||
|
<div className="hidden items-center gap-2 md:flex">
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
@@ -83,18 +143,53 @@ export function NavBar() {
|
|||||||
<Button variant="ghost" size="icon" aria-label="Log out" onClick={handleLogout}>
|
<Button variant="ghost" size="icon" aria-label="Log out" onClick={handleLogout}>
|
||||||
<LogOut className="size-4" />
|
<LogOut className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon-sm"
|
||||||
|
className="md:hidden"
|
||||||
|
aria-label={menuOpen ? "Close menu" : "Open menu"}
|
||||||
|
onClick={() => setMenuOpen((open) => !open)}
|
||||||
|
>
|
||||||
|
<MenuToggleIcon open={menuOpen} />
|
||||||
|
</Button>
|
||||||
|
|
||||||
<Sheet open={menuOpen} onOpenChange={setMenuOpen}>
|
<Sheet open={menuOpen} onOpenChange={setMenuOpen}>
|
||||||
<SheetTrigger asChild>
|
<SheetContent side="right" className="w-72 gap-0 p-0">
|
||||||
<Button variant="ghost" size="icon" className="md:hidden" aria-label="Open menu">
|
<div className="flex items-center gap-2 px-4 pt-4 pb-3">
|
||||||
<Menu className="size-4" />
|
<BrandMark size={24} animated />
|
||||||
</Button>
|
<SheetTitle className="font-heading text-lg font-semibold">Sexy</SheetTitle>
|
||||||
</SheetTrigger>
|
</div>
|
||||||
<SheetContent side="right" className="w-64">
|
<SheetDescription className="px-4 pb-3 text-xs">
|
||||||
<SheetTitle className="px-4 pt-4">Menu</SheetTitle>
|
Jump to another page or manage your session.
|
||||||
<nav className="flex flex-col gap-1 p-4">
|
</SheetDescription>
|
||||||
<NavLinks onNavigate={() => setMenuOpen(false)} />
|
<div className="bp-hairline" />
|
||||||
|
|
||||||
|
<nav className="flex flex-1 flex-col gap-1 p-3">
|
||||||
|
<MobileNavLinks onNavigate={() => setMenuOpen(false)} />
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<div className="bp-hairline" />
|
||||||
|
<div className="flex flex-col gap-1 p-3">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
|
||||||
|
className="flex items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"
|
||||||
|
>
|
||||||
|
<Sun className="hidden size-4 dark:block" />
|
||||||
|
<Moon className="block size-4 dark:hidden" />
|
||||||
|
{theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => void handleLogout()}
|
||||||
|
className="flex items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive"
|
||||||
|
>
|
||||||
|
<LogOut className="size-4" />
|
||||||
|
Log out
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</SheetContent>
|
</SheetContent>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Slider } from "@/components/ui/slider";
|
import { Slider } from "@/components/ui/slider";
|
||||||
import { DeviceScanPanel } from "@/components/control/DeviceScanPanel";
|
import { DeviceScanPanel } from "@/components/control/DeviceScanPanel";
|
||||||
@@ -11,7 +11,8 @@ import { disconnectAll, getButtplugClientHandle, getDevice, startScanning, stopS
|
|||||||
import { SessionPlayer, type SessionEventRow } from "@/lib/buttplug/player";
|
import { SessionPlayer, type SessionEventRow } from "@/lib/buttplug/player";
|
||||||
import { useButtplugStore } from "@/lib/buttplug/store";
|
import { useButtplugStore } from "@/lib/buttplug/store";
|
||||||
import type { ActuatorInfo, ReplayDeviceSlot } from "@/lib/buttplug/types";
|
import type { ActuatorInfo, ReplayDeviceSlot } from "@/lib/buttplug/types";
|
||||||
import { Pause, Play } from "lucide-react";
|
import { Info, Pause, Play } from "lucide-react";
|
||||||
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
|
|
||||||
interface ReplayDataResponse {
|
interface ReplayDataResponse {
|
||||||
session: {
|
session: {
|
||||||
@@ -137,18 +138,9 @@ export function ReplayPlayer({ sessionId }: { sessionId: number }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
<Card className="bp-glass">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>{data.session.name ?? `Session #${data.session.id}`}</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="flex flex-col gap-4">
|
|
||||||
{!player ? (
|
{!player ? (
|
||||||
<>
|
<>
|
||||||
<p className="text-sm text-muted-foreground">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
Connect the devices you want to replay onto, then match them to the session's
|
|
||||||
original device slots.
|
|
||||||
</p>
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<DeviceScanPanel scanning={scanning} onScan={() => void startScanning()} onStopScan={() => void stopScanning()} />
|
<DeviceScanPanel scanning={scanning} onScan={() => void startScanning()} onStopScan={() => void stopScanning()} />
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -161,12 +153,29 @@ export function ReplayPlayer({ sessionId }: { sessionId: number }) {
|
|||||||
}}
|
}}
|
||||||
disabled={connectedDevices.length === 0 || starting}
|
disabled={connectedDevices.length === 0 || starting}
|
||||||
>
|
>
|
||||||
{starting ? "Starting..." : "Match devices & replay"}
|
{starting ? (
|
||||||
|
"Starting..."
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Play className="size-3.5" /> Match & replay
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{connectedDevices.length === 0 && (
|
||||||
|
<Alert className="bp-glass">
|
||||||
|
<Info />
|
||||||
|
<AlertTitle>No devices connected yet</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
Scan to discover nearby toys, then match them to this session's original device slots.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-3">
|
<Card className="bp-glass">
|
||||||
|
<CardContent className="flex flex-col gap-3">
|
||||||
{replayTargets.length > 0 && (
|
{replayTargets.length > 0 && (
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
{replayTargets.map((t) => (
|
{replayTargets.map((t) => (
|
||||||
@@ -184,7 +193,7 @@ export function ReplayPlayer({ sessionId }: { sessionId: number }) {
|
|||||||
max={data.session.durationMs}
|
max={data.session.durationMs}
|
||||||
onValueChange={([v]) => player.seek(v)}
|
onValueChange={([v]) => player.seek(v)}
|
||||||
/>
|
/>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||||
<span className="bp-readout text-xs text-muted-foreground">
|
<span className="bp-readout text-xs text-muted-foreground">
|
||||||
{formatTime(elapsedMs)} / {formatTime(data.session.durationMs)}
|
{formatTime(elapsedMs)} / {formatTime(data.session.durationMs)}
|
||||||
</span>
|
</span>
|
||||||
@@ -236,10 +245,9 @@ export function ReplayPlayer({ sessionId }: { sessionId: number }) {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
<DeviceRemapDialog
|
<DeviceRemapDialog
|
||||||
open={showRemap}
|
open={showRemap}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { Trash2 } from "lucide-react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
export function SessionDeleteButton({ sessionId, sessionName }: { sessionId: number; sessionName: string | null }) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [deleting, setDeleting] = useState(false);
|
||||||
|
|
||||||
|
async function handleDelete() {
|
||||||
|
setDeleting(true);
|
||||||
|
const res = await fetch(`/api/sessions/${sessionId}`, { method: "DELETE" });
|
||||||
|
setDeleting(false);
|
||||||
|
if (res.ok) {
|
||||||
|
toast.success("Session deleted");
|
||||||
|
router.push("/sessions");
|
||||||
|
router.refresh();
|
||||||
|
} else {
|
||||||
|
toast.error("Could not delete session");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button variant="ghost" size="icon-sm" onClick={() => setOpen(true)} aria-label="Delete session">
|
||||||
|
<Trash2 className="size-4" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Delete session?</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
This permanently deletes{" "}
|
||||||
|
<span className="font-medium text-foreground">{sessionName ?? `Session #${sessionId}`}</span> and all
|
||||||
|
of its recorded events. This can't be undone.
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="ghost" onClick={() => setOpen(false)}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button variant="destructive" onClick={() => void handleDelete()} disabled={deleting}>
|
||||||
|
{deleting ? "Deleting..." : "Delete"}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -60,7 +60,7 @@ export function SessionDescriptionEditor({
|
|||||||
placeholder="Add a description..."
|
placeholder="Add a description..."
|
||||||
aria-label="Session description"
|
aria-label="Session description"
|
||||||
rows={1}
|
rows={1}
|
||||||
className="max-w-full min-w-0 resize-none border-b-2 border-transparent bg-transparent text-sm text-muted-foreground outline-none transition-colors placeholder:text-muted-foreground/60 hover:border-b-border focus:border-b-foreground/40 focus:text-foreground sm:max-w-xl [field-sizing:content]"
|
className="max-w-full min-w-0 resize-none border-b-2 border-transparent bg-transparent text-sm text-muted-foreground caret-primary outline-none transition-colors placeholder:text-muted-foreground/60 hover:border-b-primary focus:border-b-primary sm:max-w-xl [field-sizing:content]"
|
||||||
/>
|
/>
|
||||||
<div className="relative mt-0.5 flex size-4 shrink-0 items-center justify-center">
|
<div className="relative mt-0.5 flex size-4 shrink-0 items-center justify-center">
|
||||||
<Loader2
|
<Loader2
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export function SessionTitleEditor({ sessionId, initialName }: { sessionId: numb
|
|||||||
onChange={(e) => setValue(e.target.value)}
|
onChange={(e) => setValue(e.target.value)}
|
||||||
placeholder={`Session #${sessionId}`}
|
placeholder={`Session #${sessionId}`}
|
||||||
aria-label="Session name"
|
aria-label="Session name"
|
||||||
className="max-w-full min-w-0 border-b-2 border-transparent bg-transparent font-heading text-2xl font-semibold text-foreground outline-none transition-colors placeholder:text-muted-foreground/70 hover:border-b-border focus:border-b-foreground/40 sm:max-w-xl [field-sizing:content]"
|
className="max-w-full min-w-0 border-b-2 border-transparent bg-transparent font-heading text-2xl font-semibold text-foreground caret-primary outline-none transition-colors placeholder:text-muted-foreground/70 hover:border-b-primary focus:border-b-primary sm:max-w-xl [field-sizing:content]"
|
||||||
/>
|
/>
|
||||||
<div className="relative flex size-4 shrink-0 items-center justify-center">
|
<div className="relative flex size-4 shrink-0 items-center justify-center">
|
||||||
<Loader2
|
<Loader2
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { Play, Trash2 } from "lucide-react";
|
import { Play, Trash2 } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { STATUS_VARIANT } from "@/components/sessions/session-status";
|
||||||
|
|
||||||
export interface SessionRow {
|
export interface SessionRow {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -25,12 +26,6 @@ export interface SessionRow {
|
|||||||
durationMs: number | null;
|
durationMs: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const STATUS_VARIANT = {
|
|
||||||
active: "default",
|
|
||||||
completed: "secondary",
|
|
||||||
aborted: "destructive",
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
function formatDuration(ms: number | null): string {
|
function formatDuration(ms: number | null): string {
|
||||||
if (ms === null) return "-";
|
if (ms === null) return "-";
|
||||||
const totalSeconds = Math.round(ms / 1000);
|
const totalSeconds = Math.round(ms / 1000);
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Plain data, deliberately kept out of SessionsTable.tsx (a "use client"
|
||||||
|
// module) so server components (e.g. the session detail page) can import it
|
||||||
|
// without pulling a value across the client/server compilation boundary.
|
||||||
|
export const STATUS_VARIANT = {
|
||||||
|
active: "default",
|
||||||
|
completed: "secondary",
|
||||||
|
aborted: "destructive",
|
||||||
|
} as const;
|
||||||
@@ -18,7 +18,7 @@ export function DeviceUsageTable({ devices }: { devices: DeviceUsageRow[] }) {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">Device usage</CardTitle>
|
<CardTitle className="text-base">Device usage</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="py-6 text-sm text-muted-foreground">No device activity yet.</CardContent>
|
<CardContent className="text-sm text-muted-foreground">No device activity yet.</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const alertVariants = cva(
|
||||||
|
"group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default: "bg-card text-card-foreground",
|
||||||
|
destructive:
|
||||||
|
"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "default",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function Alert({
|
||||||
|
className,
|
||||||
|
variant,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="alert"
|
||||||
|
role="alert"
|
||||||
|
className={cn(alertVariants({ variant }), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="alert-title"
|
||||||
|
className={cn(
|
||||||
|
"font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDescription({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="alert-description"
|
||||||
|
className={cn(
|
||||||
|
"text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="alert-action"
|
||||||
|
className={cn("absolute top-2 right-2", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Alert, AlertTitle, AlertDescription, AlertAction }
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sexy",
|
"name": "sexy",
|
||||||
"version": "0.7.0",
|
"version": "0.9.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user