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} -
+ {/if}