diff --git a/web/src/lib/api/devices.remote.ts b/web/src/lib/api/devices.remote.ts index 49b5ea8..832e6d1 100644 --- a/web/src/lib/api/devices.remote.ts +++ b/web/src/lib/api/devices.remote.ts @@ -108,7 +108,7 @@ export const listDeviceSessions = query(async (deviceId: string) => { return sessions; }); -export const listSessionSteps = query(async (deviceId: string, sessionId: string) => { +export const listSessionSteps = query(async ({ deviceId, sessionId }: { deviceId: string; sessionId: string }) => { const { locals } = getRequestEvent(); if (!locals.user) return []; diff --git a/web/src/routes/dashboard/devices/+page.svelte b/web/src/routes/dashboard/devices/+page.svelte index 6f45859..eea9380 100644 --- a/web/src/routes/dashboard/devices/+page.svelte +++ b/web/src/routes/dashboard/devices/+page.svelte @@ -4,22 +4,37 @@ import { onMount } from 'svelte'; import DeviceCard from '$lib/components/DeviceCard.svelte'; + interface DeviceEntry { + deviceId: string; + name: string; + status: 'online' | 'offline'; + model: string | null; + manufacturer: string | null; + androidVersion: string | null; + screenWidth: number | null; + screenHeight: number | null; + batteryLevel: number | null; + isCharging: boolean; + lastSeen: string; + lastGoal: { goal: string; status: string; startedAt: string } | null; + } + const initialDevices = await listDevices(); - let devices = $state( + let devices = $state( initialDevices.map((d) => ({ deviceId: d.deviceId, name: d.name, status: d.status as 'online' | 'offline', - model: d.model, - manufacturer: d.manufacturer, - androidVersion: d.androidVersion, - screenWidth: d.screenWidth, - screenHeight: d.screenHeight, - batteryLevel: d.batteryLevel, - isCharging: d.isCharging, + model: d.model as string | null, + manufacturer: d.manufacturer as string | null, + androidVersion: d.androidVersion as string | null, + screenWidth: d.screenWidth as number | null, + screenHeight: d.screenHeight as number | null, + batteryLevel: d.batteryLevel as number | null, + isCharging: d.isCharging as boolean, lastSeen: d.lastSeen, - lastGoal: d.lastGoal + lastGoal: d.lastGoal as DeviceEntry['lastGoal'] })) ); diff --git a/web/src/routes/dashboard/devices/[deviceId]/+page.svelte b/web/src/routes/dashboard/devices/[deviceId]/+page.svelte index a76b134..c94b1c3 100644 --- a/web/src/routes/dashboard/devices/[deviceId]/+page.svelte +++ b/web/src/routes/dashboard/devices/[deviceId]/+page.svelte @@ -19,7 +19,12 @@ const deviceData = allDevices.find((d) => d.deviceId === deviceId); // Device stats - const stats = await getDeviceStats(deviceId); + const stats = (await getDeviceStats(deviceId)) as { + totalSessions: number; + successRate: number; + avgSteps: number; + lastGoal: { goal: string; status: string; startedAt: Date } | null; + } | null; // Session history interface Session { @@ -59,7 +64,7 @@ } expandedSession = sessionId; if (!sessionSteps.has(sessionId)) { - const loadedSteps = await listSessionSteps(deviceId, sessionId); + const loadedSteps = await listSessionSteps({ deviceId, sessionId }); sessionSteps.set(sessionId, loadedSteps as Step[]); sessionSteps = new Map(sessionSteps); }