wulf-pulse/app/admin/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

323 lines
9.8 KiB
TypeScript

'use client';
import { useEffect, useState } from 'react';
import Link from 'next/link';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { PageHeader } from '@/components/navigation/page-header';
import {
RefreshCw,
Network,
Globe,
Smartphone,
Radio,
AlertTriangle,
Workflow,
GitBranch,
Sparkles,
Zap,
Bell,
Sun,
BarChart3,
ScrollText,
Database,
SlidersHorizontal,
Activity,
Tv,
Users,
ShieldCheck,
Settings as SettingsIcon,
Shield,
DollarSign,
CalendarClock,
} from 'lucide-react';
interface AdminCounts {
linkConflicts: number;
schedules: { enabled: number; total: number };
unmappedAuvik: number;
unmappedRmm: number;
unmappedAddigy: number;
}
interface NavTile {
title: string;
href: string;
icon: React.ElementType;
description?: string;
badge?: { label: string; tone: 'warn' | 'info' | 'muted' };
}
interface Section {
title: string;
tiles: NavTile[];
}
function tone(badge?: NavTile['badge']) {
if (!badge) return null;
const variant: 'destructive' | 'secondary' | 'outline' =
badge.tone === 'warn' ? 'destructive' : badge.tone === 'info' ? 'secondary' : 'outline';
return (
<Badge variant={variant} className="text-[10px] font-mono ml-2 shrink-0">
{badge.label}
</Badge>
);
}
export default function AdminIndexPage() {
const [counts, setCounts] = useState<AdminCounts | null>(null);
useEffect(() => {
void (async () => {
try {
const [overviewRes, mappingsRes] = await Promise.all([
fetch('/api/dashboard/overview'),
fetch('/api/dashboard/stats'),
]);
const overview = overviewRes.ok ? await overviewRes.json() : null;
const mappings = mappingsRes.ok ? await mappingsRes.json() : null;
setCounts({
linkConflicts: overview?.attention?.linkConflicts ?? 0,
schedules: overview?.attention?.schedules ?? { enabled: 0, total: 0 },
unmappedAuvik: mappings?.mappings?.auvik?.unmapped ?? 0,
unmappedRmm: mappings?.mappings?.rmm?.unmapped ?? 0,
unmappedAddigy: 0,
});
} catch {
// Counts are decorative — fail quiet.
}
})();
}, []);
const sections: Section[] = [
{
title: 'Sync',
tiles: [
{
title: 'Integrations & Sync',
href: '/admin/sync',
icon: RefreshCw,
description: 'Overview of sync status across all integrations',
badge: counts
? {
label: `${counts.schedules.enabled}/${counts.schedules.total} schedules on`,
tone: 'muted',
}
: undefined,
},
{ title: 'Autotask', href: '/admin/sync/autotask', icon: RefreshCw },
{ title: 'Datto RMM', href: '/admin/sync/datto-rmm', icon: Globe },
{ title: 'IT Glue', href: '/admin/sync/itglue', icon: Shield },
{ title: 'SentinelOne', href: '/admin/sync/sentinelone', icon: Shield },
{ title: 'Veeam', href: '/admin/sync/veeam', icon: Activity },
{ title: 'Auvik', href: '/admin/sync/auvik', icon: Network },
{ title: 'Addigy', href: '/admin/sync/addigy', icon: Smartphone },
{ title: 'Mimecast', href: '/admin/sync/mimecast', icon: Shield },
{ title: 'Duo', href: '/admin/sync/duo', icon: Shield },
{ title: 'QuickBooks Online', href: '/admin/qbo', icon: DollarSign },
],
},
{
title: 'Mappings',
tiles: [
{
title: 'Device-Link Conflicts',
href: '/admin/device-link-conflicts',
icon: AlertTriangle,
description: 'Resolve cases where one external device matches multiple Autotask CIs',
badge:
counts && counts.linkConflicts > 0
? { label: counts.linkConflicts.toLocaleString(), tone: 'warn' }
: undefined,
},
{
title: 'NMS Mapping (Auvik)',
href: '/auvik-mappings',
icon: Network,
description: 'Map Auvik tenants to companies',
badge:
counts && counts.unmappedAuvik > 0
? { label: `${counts.unmappedAuvik} unmapped`, tone: 'info' }
: undefined,
},
{
title: 'RMM Mapping (Datto)',
href: '/rmm-mappings',
icon: Globe,
description: 'Map RMM sites to companies',
badge:
counts && counts.unmappedRmm > 0
? { label: `${counts.unmappedRmm} unmapped`, tone: 'info' }
: undefined,
},
{
title: 'Apple RMM (Addigy)',
href: '/addigy-mappings',
icon: Smartphone,
description: 'Map Addigy devices to companies',
},
{
title: 'SentinelOne Mappings',
href: '/sentinelone/mappings',
icon: Shield,
description: 'Map S1 sites to companies (gap blocks reconciler)',
},
{
title: 'Zabbix WAN Monitor',
href: '/admin/zabbix-wan',
icon: Radio,
description: 'Sync RMM site WAN IPs to Zabbix with Autotask routing',
},
],
},
{
title: 'Workflow',
tiles: [
{
title: 'Ticket Workflows',
href: '/admin/workflow',
icon: Workflow,
description: 'Automated ticket triage and classification',
},
{
title: 'Classification Rules',
href: '/admin/workflow/classification-rules',
icon: GitBranch,
description: 'Keyword-based classification rules',
},
{
title: 'AI Templates',
href: '/admin/workflow/ai-templates',
icon: Sparkles,
description: 'AI prompt templates for enhancement',
},
{
title: 'Webhook Pipelines',
href: '/admin/workflow/pipelines',
icon: Zap,
description: 'Automated webhook processing workflows',
},
{
title: 'Notification Channels',
href: '/admin/workflow/channels',
icon: Bell,
description: 'Teams, Telegram, and webhook notifications',
},
],
},
{
title: 'Reports',
tiles: [
{
title: 'Morning NOC Summary',
href: '/admin/morning-summary',
icon: Sun,
description: 'Daily Zabbix overnight summary posted to Teams',
},
{
title: 'Ticket Digest Reports',
href: '/admin/ticket-digest',
icon: BarChart3,
description: 'LLM-analyzed ticket reports — daily/weekly/monthly',
},
{
title: 'IT Glue Writes',
href: '/admin/itglue-writes',
icon: ScrollText,
description: 'History of audit-driven IT Glue field writes',
},
{
title: 'Audit Log',
href: '/admin/audit-log',
icon: ScrollText,
description: 'System audit trail',
},
],
},
{
title: 'Tools & Data',
tiles: [
{
title: 'RMM Overshell',
href: '/admin/rmm-overshell',
icon: Database,
description: 'Datto RMM PowerShell discovery — settings, executions, evidence pipeline',
},
{
title: 'Data Browser',
href: '/admin/data-browser',
icon: Database,
description: 'Browse and query system data',
},
{
title: 'Display Settings',
href: '/admin/display-settings',
icon: SlidersHorizontal,
description: 'Configure company filters for Kiosk and Mobile dashboards',
},
{
title: 'Kiosk Settings',
href: '/kiosk/settings',
icon: Tv,
description: 'Configure executive dashboard for TV display',
},
],
},
{
title: 'Access',
tiles: [
{ title: 'Users', href: '/admin/users', icon: Users },
{ title: 'Roles', href: '/admin/roles', icon: ShieldCheck },
{ title: 'Settings', href: '/admin/settings', icon: SettingsIcon },
],
},
];
return (
<>
<PageHeader
title="Admin"
description="Sync, mappings, workflows, reporting, and tooling."
breadcrumbs={[{ label: 'Admin' }]}
accent
/>
<div className="container mx-auto px-6 py-6 space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
{sections.map((section) => (
<Card key={section.title}>
<CardHeader className="pb-3">
<CardTitle className="text-sm font-semibold uppercase tracking-wide text-muted-foreground">
{section.title}
</CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-1 gap-1">
{section.tiles.map((tile) => (
<Link
key={tile.href}
href={tile.href}
className="flex items-start gap-3 rounded-md p-2 -mx-2 hover:bg-muted/60 transition-colors"
>
<tile.icon className="size-4 mt-0.5 text-muted-foreground shrink-0" />
<div className="min-w-0 flex-1">
<div className="flex items-baseline gap-2">
<span className="text-sm font-medium truncate">{tile.title}</span>
{tone(tile.badge)}
</div>
{tile.description && (
<p className="text-xs text-muted-foreground line-clamp-2">
{tile.description}
</p>
)}
</div>
</Link>
))}
</div>
</CardContent>
</Card>
))}
</div>
</div>
</>
);
}