wulf-pulse/app/addigy-devices/page.tsx
lorentz 9bfb57553d feat(design): nav/visual overhaul — brand layer, /status route, KPI dashboard, TanStack DataTable
Major UI refresh on the nav-design-improvements branch.  Drops 2013-era
inline styles and consolidates patterns behind shared primitives.

Foundation
- New Wulf brand layer in app/styles/brand.css repointing --primary to
  the standards-guide blue (#0075AD) with utility classes for numerics
  (.num / .num-lg / .num-xl), metric labels, surface tints, and the
  wolf-mark watermark
- Switch primary face to IBM Plex Sans + IBM Plex Mono via next/font;
  Helvetica/Arial stays in the fallback chain for brand fidelity
- Wordmark subtitle changed from "PSA Management System" to
  "Operations console" everywhere it appeared
- Tagline footer ("Don't be afraid to cry") on every non-mobile page

Status moved out of /dashboard
- New /status route with integration tiles grouped by category, sync
  health table, worker pulse cards (analyzer / RMM / sync scheduler),
  token-expiry section, conditional alert banner
- Top-bar StatusIndicator polls integration health every 60s and links
  to /status
- INTEGRATIONS_DISABLED env var suppresses operator-disabled
  integrations (e.g. SentinelOne) — no failure noise from broken-on-
  purpose entries.  Aliases supported (sentinelone → s1, etc.)

Dashboard rebuilt around KPIs
- /api/dashboard/overview adds today snapshot (opened, resolved, open
  total, SLA breaches) with delta math
- /api/dashboard/trends backs queue × priority heatmap, 30-day volume
  area chart, 30-day mean resolution time line chart, today's active
  engineers leaderboard

Components
- StatusBadge driven by lib/status-registry.ts (priority, ticket
  status, classification, source, company type, publish, active /
  yes-no / billable / approved registries)
- StatusLight (8px geometric square, five states, three sizes)
- EmptyState (shared dashed panel with icon + headline + optional CTA)
- KpiCard with delta indicator and tonal left border
- WulfMark (mark / wordmark variants from /public/branding)
- Skeleton helpers (SkeletonRow / Rows / Card / Chart / Header / Table)

Navigation
- Admin flat link → dropdown with seven shortcuts
- New UserMenu (initials avatar, role badge, settings + sign-out)
- Active-route highlight is now a 2px Wulf-blue underline echoing the
  PageHeader rule (consistent across flat links and submenu triggers);
  active children inside dropdowns use bg-primary/10
- Submenu width is content-driven (min-w 320 / max-w 440, single col)
- Mobile hamburger via Sheet, reuses the same nav config

Pages migrated
- 16 admin sub-pages adopt PageHeader (with accent prop)
- /addigy-devices: shadcn Table + Checkbox; PageHeader; status badges
- 10 raw <table> blocks across admin/sync/* migrated to shadcn Table
- /veeam-analysis migrated to shadcn Table (kept its expansion logic)
- Detail routes (analyzer ticket, analyzer analysis) get breadcrumbs

DataTable
- Rewritten on @tanstack/react-table v8 in manual mode; external API
  unchanged so all 10+ data-browser pages keep working
- New optional props for drill-down rows: getRowCanExpand + renderSubRow

Mobile
- Multi-select Popover gets max-w-[calc(100vw-1rem)] and
  collisionPadding so dropdowns can't overflow narrow viewports
- CI filter bar wraps and shrinks; stat pill flows below

Docs
- New ARCHITECTURE.md (load-bearing reference for runtime, data flow,
  workers, analyzer pipeline, auth, deployment, gotchas)
- New DESIGN.md (tokens, layout, navigation IA, component vocabulary,
  rolling backlog of remaining cleanup)
- CLAUDE.md refreshed with pointers to the two new docs and the
  INTEGRATIONS_DISABLED operator config note
- shadcn registry registered as project-level MCP server (.mcp.json)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 09:33:13 -04:00

186 lines
6.9 KiB
TypeScript

'use client';
import { useState, useEffect } from 'react';
import { AddigyDevice } from '@/lib/types/addigy';
import { PageHeader } from '@/components/navigation/page-header';
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/components/ui/table';
import { Card, CardContent } from '@/components/ui/card';
import { Checkbox } from '@/components/ui/checkbox';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { EmptyState } from '@/components/ui/empty-state';
import { StatusBadge } from '@/components/ui/status-badge';
import { Check, X, Laptop, RefreshCw } from 'lucide-react';
export default function AddigyDevicesPage() {
const [devices, setDevices] = useState<AddigyDevice[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [filterOnline, setFilterOnline] = useState(false);
useEffect(() => {
void fetchDevices();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [filterOnline]);
async function fetchDevices() {
setLoading(true);
setError(null);
try {
const url = filterOnline
? '/api/addigy-devices?online=true'
: '/api/addigy-devices';
const res = await fetch(url, { cache: 'no-store' });
const result = await res.json();
if (result.success) {
setDevices(result.data);
} else {
setError(result.error || 'Failed to fetch devices');
}
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error');
} finally {
setLoading(false);
}
}
return (
<>
<PageHeader
title="Addigy devices"
description={
loading
? 'Loading…'
: `${devices.length} device${devices.length === 1 ? '' : 's'}${filterOnline ? ' · online only' : ''}`
}
breadcrumbs={[{ label: 'Addigy devices' }]}
actions={
<>
<label className="flex items-center gap-2 text-sm cursor-pointer">
<Checkbox
checked={filterOnline}
onCheckedChange={(v) => setFilterOnline(v === true)}
aria-label="Filter to online devices only"
/>
<span>Online only</span>
</label>
<Button onClick={fetchDevices} variant="outline" size="sm" disabled={loading}>
<RefreshCw className={`h-4 w-4 mr-2 ${loading ? 'animate-spin' : ''}`} />
Refresh
</Button>
</>
}
/>
<div className="container mx-auto px-6 py-6 space-y-6">
{error && (
<Alert variant="destructive">
<AlertTitle>Failed to load</AlertTitle>
<AlertDescription>{error}</AlertDescription>
</Alert>
)}
<Card>
<CardContent className="p-0">
{loading ? (
<div className="p-6 space-y-2">
<Skeleton className="h-8 w-full" />
<Skeleton className="h-8 w-full" />
<Skeleton className="h-8 w-3/4" />
</div>
) : devices.length === 0 ? (
<div className="p-6">
<EmptyState
icon={Laptop}
title="No devices found"
description={
filterOnline
? 'No devices are currently online.'
: 'Addigy has not synced any devices yet.'
}
size="sm"
/>
</div>
) : (
<Table>
<TableHeader>
<TableRow>
<TableHead>Device</TableHead>
<TableHead>Model</TableHead>
<TableHead>OS</TableHead>
<TableHead>Current user</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-right">Free disk</TableHead>
<TableHead>Security</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{devices.map((device) => {
const freePct = device['Free Disk Percentage'];
const freeTone =
freePct === undefined
? 'text-muted-foreground'
: freePct < 20
? 'text-destructive'
: freePct < 40
? 'text-amber-600 dark:text-amber-400'
: 'text-emerald-600 dark:text-emerald-400';
return (
<TableRow key={device.agentid}>
<TableCell>
<div className="font-medium">{device['Device Name']}</div>
<div className="text-xs text-muted-foreground num">
{device['Serial Number'] || '—'}
</div>
</TableCell>
<TableCell>{device['Device Model Name'] || 'Unknown'}</TableCell>
<TableCell className="num">
{device['MAC OS X Version'] || device['iOS Version'] || '—'}
</TableCell>
<TableCell>{device['Current User'] || '—'}</TableCell>
<TableCell>
<StatusBadge tone={device.online ? 'ok' : 'inactive'}>
{device.online ? 'Online' : 'Offline'}
</StatusBadge>
</TableCell>
<TableCell className={`text-right num ${freeTone}`}>
{freePct !== undefined ? `${freePct}%` : '—'}
</TableCell>
<TableCell>
<div className="flex items-center gap-3 text-xs">
<SecurityFlag label="FW" enabled={Boolean(device['Firewall Enabled'])} />
<SecurityFlag label="FV" enabled={Boolean(device['FileVault Enabled'])} />
</div>
</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
)}
</CardContent>
</Card>
</div>
</>
);
}
function SecurityFlag({ label, enabled }: { label: string; enabled: boolean }) {
return (
<span
className={`inline-flex items-center gap-0.5 ${enabled ? 'text-emerald-600 dark:text-emerald-400' : 'text-destructive'}`}
title={enabled ? `${label} enabled` : `${label} disabled`}
>
{enabled ? <Check className="h-3 w-3" /> : <X className="h-3 w-3" />}
<span className="num font-medium">{label}</span>
</span>
);
}