diff --git a/frontend/src/components/fleet/FleetDashboard.tsx b/frontend/src/components/fleet/FleetDashboard.tsx index 30f56fa..c072d55 100644 --- a/frontend/src/components/fleet/FleetDashboard.tsx +++ b/frontend/src/components/fleet/FleetDashboard.tsx @@ -1,11 +1,12 @@ import { useState, useMemo } from 'react' import { useQuery } from '@tanstack/react-query' +import { Link } from '@tanstack/react-router' import { useAuth } from '@/lib/auth' import { metricsApi, tenantsApi, type FleetDevice } from '@/lib/api' import { useUIStore } from '@/lib/store' import { alertsApi } from '@/lib/alertsApi' import { useEventStreamContext } from '@/contexts/EventStreamContext' -import { LayoutDashboard } from 'lucide-react' +import { LayoutDashboard, MapPin } from 'lucide-react' import { cn } from '@/lib/utils' import { LoadingText } from '@/components/ui/skeleton' import { EmptyState } from '@/components/ui/empty-state' @@ -43,10 +44,13 @@ function DashboardLoading() { interface AttentionItem { id: string + deviceId: string + tenantId: string hostname: string model: string | null severity: 'error' | 'warning' reason: string + hasCoords: boolean } function NeedsAttention({ devices }: { devices: FleetDevice[] }) { @@ -54,36 +58,25 @@ function NeedsAttention({ devices }: { devices: FleetDevice[] }) { const result: AttentionItem[] = [] for (const d of devices) { + const base = { + deviceId: d.id, + tenantId: d.tenant_id, + hostname: d.hostname, + model: d.model, + hasCoords: d.latitude != null && d.longitude != null, + } + if (d.status === 'offline') { - result.push({ - id: `${d.id}-offline`, - hostname: d.hostname, - model: d.model, - severity: 'error', - reason: 'Offline', - }) + result.push({ ...base, id: `${d.id}-offline`, severity: 'error', reason: 'Offline' }) } else if (d.status === 'degraded') { - result.push({ - id: `${d.id}-degraded`, - hostname: d.hostname, - model: d.model, - severity: 'warning', - reason: 'Degraded', - }) + result.push({ ...base, id: `${d.id}-degraded`, severity: 'warning', reason: 'Degraded' }) } if (d.last_cpu_load != null && d.last_cpu_load > 80) { - result.push({ - id: `${d.id}-cpu`, - hostname: d.hostname, - model: d.model, - severity: 'warning', - reason: `CPU ${d.last_cpu_load}%`, - }) + result.push({ ...base, id: `${d.id}-cpu`, severity: 'warning', reason: `CPU ${d.last_cpu_load}%` }) } } - // Sort: errors first, then warnings result.sort((a, b) => { if (a.severity === b.severity) return 0 return a.severity === 'error' ? -1 : 1 @@ -96,7 +89,6 @@ function NeedsAttention({ devices }: { devices: FleetDevice[] }) { return (