% const page = it.page; const monitors = it.monitors; const groups = it.groups; const incidents = it.incidents; const themeClass = page.theme === 'dark' ? 'dark' : page.theme === 'light' ? 'light' : ''; // Group monitors. group_id null = "ungrouped". const grouped = {}; for (const m of monitors) { const key = m.group_id || ''; if (!grouped[key]) grouped[key] = []; grouped[key].push(m); } const groupOrder = [...groups.map(g => g.id), '']; function fmtPct(p) { if (p == null) return '-'; // Only show "100%" when the value is *exactly* 100. Anything below - even // 99.9999% - must show 2 decimals so visitors can see there was downtime. // Truncate (floor) rather than round, otherwise 99.9999 would render as // "100.00" and silently swallow the downtime. if (p >= 100) return '100%'; return (Math.floor(p * 100) / 100).toFixed(2) + '%'; } function statusLabel(s) { if (s === 'up') return 'Operational'; if (s === 'down') return 'Down'; if (s === 'paused') return 'Under maintenance'; return 'Unknown'; } function statusColor(s) { if (s === 'up') return 'var(--bar-up)'; if (s === 'down') return 'var(--bar-down)'; if (s === 'paused') return 'var(--bar-paused)'; return 'var(--muted)'; } function bucketColor(b) { if (!b || b.total === 0) return 'var(--bar-empty)'; if (b.up === b.total) return 'var(--bar-up)'; if (b.up === 0) return 'var(--bar-down)'; return 'var(--bar-partial)'; } function uptimeBand(p) { if (p == null) return 'empty'; if (p >= 97) return 'good'; if (p >= 87) return 'warn'; return 'bad'; } function fmtUptime(p) { if (p == null) return '-'; // Only "100%" if the monitor was up for every single check in the window. // Truncate (not round) below that so 99.9999% never displays as "100.00". if (p >= 100) return '100%'; return (Math.floor(p * 100) / 100).toFixed(2) + '%'; } // Overall status: down if any monitor is down, degraded if any partial, else up. // Paused monitors are operator-declared maintenance - they don't count // toward "down" or "degraded", but we surface a small note in the banner // when at least one is in maintenance so visitors aren't confused. let paused_count = 0; let down_count = 0; let active_count = 0; let has_degraded = false; for (const m of monitors) { if (m.current_state === 'paused') { paused_count++; continue; } active_count++; const partial = m.region_states.some(r => r.state === 'down') && m.region_states.some(r => r.state === 'up'); if (m.current_state === 'down') down_count++; else if (partial) has_degraded = true; } const overall = down_count === 0 && !has_degraded ? 'up' : active_count > 0 && down_count === active_count ? 'down' : 'degraded'; let overallText = overall === 'up' ? 'All systems operational' : overall === 'down' ? 'Major outage in progress' : 'Partial outage'; if (paused_count > 0) { overallText += ' - ' + paused_count + (paused_count === 1 ? ' service' : ' services') + ' under maintenance'; } const overallBg = overall === 'up' ? 'rgba(16,185,129,0.1)' : overall === 'degraded' ? 'rgba(245,158,11,0.1)' : 'rgba(239,68,68,0.1)'; const overallBorder = overall === 'up' ? 'rgba(16,185,129,0.25)' : overall === 'degraded' ? 'rgba(245,158,11,0.25)' : 'rgba(239,68,68,0.25)'; const overallFg = overall === 'up' ? 'var(--bar-up)' : overall === 'degraded' ? 'var(--bar-partial)' : 'var(--bar-down)'; const dotColor = overall === 'up' ? '#10b981' : overall === 'degraded' ? '#f59e0b' : '#ef4444'; const dotGlow = overall === 'up' ? 'rgba(16,185,129,0.4)' : overall === 'degraded' ? 'rgba(245,158,11,0.4)' : 'rgba(239,68,68,0.4)'; %>