Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions src/ui/src/lib/DeviceCalibrationManager.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
import type { Device } from '$lib/types';
import ago from 's-ago';

$: filteredDevices = $devices?.filter(device => {
// Check if device is active based on lastSeen and timeout
if (device.lastSeen == null) return false;
const timeout = device.timeout !== null && device.timeout !== undefined ? device.timeout : 30000;
return new Date().getTime() - new Date(device.lastSeen).getTime() < timeout;
}) || [];
$: filteredDevices =
$devices?.filter((device) => {
// Check if device is active based on lastSeen and timeout
if (device.lastSeen == null) return false;
const timeout = device.timeout !== null && device.timeout !== undefined ? device.timeout : 30000;
return new Date().getTime() - new Date(device.lastSeen).getTime() < timeout;
}) || [];

$: calibrationStats = {
total: filteredDevices.length,
calibrated: filteredDevices.filter(d => d['rssi@1m'] != null).length,
needsCalibration: filteredDevices.filter(d => d['rssi@1m'] == null).length
calibrated: filteredDevices.filter((d) => d['rssi@1m'] != null).length,
needsCalibration: filteredDevices.filter((d) => d['rssi@1m'] == null).length
};

function isDeviceActive(device: Device): boolean {
Expand All @@ -38,7 +39,7 @@

function displayRoomFloor(d: Device): string {
const base = baseRoomFloor(d);
return d.isAnchored ? `${base} 📍` : base;
return (d.isAnchored ?? false) ? `${base} 📍` : base;
}

const columns = [
Expand Down Expand Up @@ -136,16 +137,9 @@
<div class="card">
<header class="text-lg font-semibold mb-4">Device Calibration</header>
{#if filteredDevices.length > 0}
<DataTable
{columns}
rows={filteredDevices}
classNameTable="table table-compact"
onclickRow={onRowClick}
/>
<DataTable {columns} rows={filteredDevices} classNameTable="table table-compact" onclickRow={onRowClick} />
{:else}
<div class="text-center py-8 text-surface-600-400">
No active devices found
</div>
<div class="text-center py-8 text-surface-600-400">No active devices found</div>
{/if}
</div>
</div>
Expand Down
27 changes: 6 additions & 21 deletions src/ui/src/lib/DeviceMarker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,12 @@

{#if visible && d.confidence > 1 && d.location}
<g in:fade={{ duration: 1000 }} out:fade={{ duration: 1000 }}>
<circle
role="none"
cx={$xScale($x)}
cy={$yScale($y)}
fill={$c}
stroke={d.id == hovered ? 'black' : 'white'}
stroke-width={$s}
r={$r}
onmouseover={() => {
hover(d);
}}
onfocus={() => {
select(d);
}}
onmouseout={() => {
hover(null);
}}
onblur={() => {
unselect();
}}
/>
{#if d.isAnchored ?? false}
<path role="none" d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z" transform="translate({$xScale($x) - 12}, {$yScale($y) - 24})" fill={$c} stroke={d.id == hovered ? 'black' : 'white'} stroke-width={$s} onmouseover={() => hover(d)} onfocus={() => select(d)} onmouseout={() => hover(null)} onblur={() => unselect()} />
<circle cx={$xScale($x)} cy={$yScale($y) - 15} r={3} fill="white" pointer-events="none" />
{:else}
<circle role="none" cx={$xScale($x)} cy={$yScale($y)} fill={$c} stroke={d.id == hovered ? 'black' : 'white'} stroke-width={$s} r={$r} onmouseover={() => hover(d)} onfocus={() => select(d)} onmouseout={() => hover(null)} onblur={() => unselect()} />
{/if}
<text x={$xScale($x) + 7} y={$yScale($y) + 3} fill="white" font-size="10px">{d.name ?? d.id}</text>
</g>
{/if}
Loading