From a46af1a236aaa26932ed9e1742c3de7607bc303f Mon Sep 17 00:00:00 2001 From: Sanju Sivalingam Date: Tue, 17 Feb 2026 21:04:18 +0530 Subject: [PATCH] feat: rewrite devices page as phone-card grid Co-Authored-By: Claude Opus 4.6 --- web/src/routes/dashboard/devices/+page.svelte | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/web/src/routes/dashboard/devices/+page.svelte b/web/src/routes/dashboard/devices/+page.svelte index ce58f55..6f45859 100644 --- a/web/src/routes/dashboard/devices/+page.svelte +++ b/web/src/routes/dashboard/devices/+page.svelte @@ -2,15 +2,24 @@ import { listDevices } from '$lib/api/devices.remote'; import { dashboardWs } from '$lib/stores/dashboard-ws.svelte'; import { onMount } from 'svelte'; + import DeviceCard from '$lib/components/DeviceCard.svelte'; const initialDevices = await listDevices(); let devices = $state( - initialDevices.map((d: Record) => ({ + initialDevices.map((d) => ({ deviceId: d.deviceId, name: d.name, status: d.status as 'online' | 'offline', - lastSeen: d.lastSeen + model: d.model, + manufacturer: d.manufacturer, + androidVersion: d.androidVersion, + screenWidth: d.screenWidth, + screenHeight: d.screenHeight, + batteryLevel: d.batteryLevel, + isCharging: d.isCharging, + lastSeen: d.lastSeen, + lastGoal: d.lastGoal })) ); @@ -26,7 +35,20 @@ devices = [...devices]; } else { devices = [ - { deviceId: id, name, status: 'online', lastSeen: new Date().toISOString() }, + { + deviceId: id, + name, + status: 'online', + model: null, + manufacturer: null, + androidVersion: null, + screenWidth: null, + screenHeight: null, + batteryLevel: null, + isCharging: false, + lastSeen: new Date().toISOString(), + lastGoal: null + }, ...devices ]; } @@ -37,6 +59,14 @@ existing.status = 'offline'; devices = [...devices]; } + } else if (msg.type === 'device_status') { + const id = msg.deviceId as string; + const existing = devices.find((d) => d.deviceId === id); + if (existing) { + existing.batteryLevel = msg.batteryLevel as number; + existing.isCharging = msg.isCharging as boolean; + devices = [...devices]; + } } }); return unsub; @@ -56,24 +86,9 @@ {:else} -