// CompliancePage.jsx — full-page assembly of the AEO Compliance view. // Rebuilt from frontend/src/components/pages/CompliancePage.js with // inline-rendered chart placeholders that match Recharts visually. const { COLORS: PC, statusColor: pStatusColor, pctDisplay: pPct, cAlpha: pAlpha, CompPageHeader, CompButton, TeamTabs, MetricHealthCard, DeviceTable, DeviceTableToolbar, DeviceTableHeader, DeviceRow, CompEmpty, ChartCard, ChartLegend, RollbackDialog, RollbackToast, CompIcon: PIcon, } = window.COMP; const { useState: useCompPageState } = React; /* ── Sample data — what summary + items endpoints look like ── */ const SAMPLE_FAMILIES = [ { metricId: 'VM-CRITICAL', category: 'Vulnerability Management', target: 0.95, worstStatus: 'Below 15% of Target', entries: [ { metric_id: 'VM-CRITICAL', priority: 'P1', compliance_pct: 0.74, status: 'Below 15% of Target' }, { metric_id: 'VM-CRITICAL', priority: 'P2', compliance_pct: 0.91, status: 'Within 15% of Target' }, ], }, { metricId: 'AUTH-MFA', category: 'Access & MFA', target: 0.98, worstStatus: 'Within 15% of Target', entries: [{ metric_id: 'AUTH-MFA', compliance_pct: 0.94, status: 'Within 15% of Target' }], }, { metricId: 'LOG-COVERAGE', category: 'Logging & Monitoring', target: 0.90, worstStatus: 'Meets/Exceeds Target', entries: [{ metric_id: 'LOG-COVERAGE', compliance_pct: 0.97, status: 'Meets/Exceeds Target' }], }, { metricId: 'EOL-OS', category: 'End-of-Life OS', target: 1.00, worstStatus: 'Below 15% of Target', entries: [{ metric_id: 'EOL-OS', compliance_pct: 0.62, status: 'Below 15% of Target' }], }, { metricId: 'EDR-DEPLOY', category: 'Endpoint Protection', target: 0.95, worstStatus: 'Meets/Exceeds Target', entries: [{ metric_id: 'EDR-DEPLOY', compliance_pct: 0.96, status: 'Meets/Exceeds Target' }], }, ]; const SAMPLE_DEVICES = [ { hostname: 'app-prod-04.steam.internal', ip: '10.42.18.4', type: 'Linux server', failingMetrics: [{ metric_id: 'VM-CRITICAL', category: 'Vulnerability Management' }, { metric_id: 'EOL-OS', category: 'End-of-Life OS' }], seenCount: 5, hasNotes: true }, { hostname: 'db-staging-01.steam.internal', ip: '10.42.20.11', type: 'Linux server', failingMetrics: [{ metric_id: 'VM-CRITICAL', category: 'Vulnerability Management' }], seenCount: 2, hasNotes: false }, { hostname: 'fileshare-02.steam.internal', ip: '10.42.16.32', type: 'Windows server', failingMetrics: [{ metric_id: 'AUTH-MFA', category: 'Access & MFA' }], seenCount: 1, hasNotes: false }, { hostname: 'jumpbox-east.steam.internal', ip: '10.42.4.7', type: 'Linux server', failingMetrics: [{ metric_id: 'AUTH-MFA', category: 'Access & MFA' }, { metric_id: 'VM-CRITICAL', category: 'Vulnerability Management' }], seenCount: 4, hasNotes: true }, { hostname: 'legacy-billing.steam.internal', ip: '10.42.8.18', type: 'Windows server', failingMetrics: [{ metric_id: 'EOL-OS', category: 'End-of-Life OS' }], seenCount: 7, hasNotes: false }, ]; /* ── Inline chart visuals — semantic stand-ins for Recharts. ── */ function NetworkScoreChart() { const points = [82, 84, 81, 86, 85, 87, 88]; return ( ); } function StatusDistributionChart() { const data = [ { meets: 62, within: 22, below: 16 }, { meets: 65, within: 20, below: 15 }, { meets: 67, within: 21, below: 12 }, { meets: 72, within: 18, below: 10 }, ]; return ; } function TeamHealthChart() { return ( ); } function NewRecurringResolvedChart() { const data = [ { new_count: 12, recurring_count: 7, resolved_count: -10 }, { new_count: 8, recurring_count: 9, resolved_count: -14 }, { new_count: 14, recurring_count: 5, resolved_count: -8 }, { new_count: 9, recurring_count: 6, resolved_count: -12 }, ]; return ( ); } function AvgDaysToResolveChart() { const rows = [ { label: 'AUTH-MFA', v: 4 }, { label: 'VM-CRITICAL', v: 12 }, { label: 'EOL-OS', v: 28 }, { label: 'EDR-DEPLOY', v: 6 }, ]; return ; } function PersistentFindingsChart() { const rows = [ { label: 'legacy-billing', v: 7 }, { label: 'app-prod-04', v: 5 }, { label: 'jumpbox-east', v: 4 }, { label: 'db-staging-01', v: 2 }, ]; return ; } /* Tiny SVG primitives — flat, deterministic, no library. */ function ChartSvg({ children, height = 180 }) { return (
{children}
); } function Line({ points, color, fill }) { const max = Math.max(...points); const min = Math.min(...points) * 0.85; const range = max - min || 1; const w = 100, h = 100; const step = w / (points.length - 1); const path = points.map((v, i) => `${i === 0 ? 'M' : 'L'} ${i * step} ${h - ((v - min) / range) * h}`).join(' '); const fillPath = path + ` L ${w} ${h} L 0 ${h} Z`; return ( {fill && } {points.map((v, i) => ( ))} ); } function YAxisLabels({ labels }) { return (
{labels.map(l => {l})}
); } function StackedBars({ data, keys, colors, centered = false }) { const total = (d) => keys.reduce((s, k) => s + Math.abs(d[k]), 0); const maxTotal = Math.max(...data.map(total)); return (
{data.map((d, i) => { const segs = keys.map((k, ki) => ({ v: d[k], color: colors[ki], k })); return (
{segs.map((s, si) => (
))}
); })}
); } function HorizontalBars({ rows, max, color, unit }) { return (
{rows.map(r => (
{r.label}
{r.v} {unit}
))}
); } /* ── Page assembly ── */ function CompliancePage() { const [team, setTeam] = useCompPageState('STEAM'); const [tab, setTab] = useCompPageState('active'); const [filter, setFilter] = useCompPageState(null); const [search, setSearch] = useCompPageState(''); const [selected, setSelected] = useCompPageState(null); const [rollback, setRollback] = useCompPageState(null); const filteredDevices = SAMPLE_DEVICES .filter(d => !filter || d.failingMetrics.some(m => filter.includes(m.metric_id))) .filter(d => !search || d.hostname.toLowerCase().includes(search.toLowerCase())); return (
setRollback('confirm')} /> {/* Metric Health */}
Metric Health — click to filter {filter && ( )}
{SAMPLE_FAMILIES.map(family => { const ids = family.entries.map(e => e.metric_id); const isActive = filter !== null && filter.length === ids.length && ids.every(id => filter.includes(id)); return (
setFilter(isActive ? null : ids)} onInfoClick={() => {}} />
); })}
{/* Charts */}
{/* Device table */} setSearch(e.target.value)} /> {filteredDevices.length === 0 ? ( No non-compliant devices match the current filter ) : ( filteredDevices.map(d => ( setSelected(selected === d.hostname ? null : d.hostname)} /> )) )} {rollback === 'confirm' && ( setRollback(null)} onConfirm={() => setRollback('toast')} /> )} {rollback === 'toast' && ( setRollback(null)} /> )}
); } window.COMP_PAGE = { CompliancePage };