Compare commits
8
Commits
v0.7.0
..
fc7fd74d17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -225,7 +225,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}
|
||||||
@@ -241,7 +241,7 @@ export function ButtplugConsole() {
|
|||||||
|
|
||||||
{Object.keys(devices).length === 0 ? (
|
{Object.keys(devices).length === 0 ? (
|
||||||
<Card className="bp-glass">
|
<Card className="bp-glass">
|
||||||
<CardContent className="py-6 text-sm text-muted-foreground">
|
<CardContent className="text-sm text-muted-foreground">
|
||||||
No devices connected yet. Scan to discover nearby toys, then select one from your browser's
|
No devices connected yet. Scan to discover nearby toys, then select one from your browser's
|
||||||
pairing prompt.
|
pairing prompt.
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -137,18 +137,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 +152,28 @@ 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 && (
|
||||||
|
<Card className="bp-glass">
|
||||||
|
<CardContent className="text-sm text-muted-foreground">
|
||||||
|
No devices connected yet. Scan to discover nearby toys, then match them to this session's
|
||||||
|
original device slots.
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<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 +191,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 +243,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>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sexy",
|
"name": "sexy",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user