utopia-surveillance-tool/templates/dashboard.html

363 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Surveillance Dashboard - Multi-Cam Grid</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0b0e14;
--surface: #131720;
--surface-2: #1a1f2e;
--border: #252b3b;
--text: #e0e4ec;
--text-dim: #6b7280;
--accent: #3b82f6;
--green: #22c55e;
--red: #ef4444;
--orange: #f59e0b;
--radius: 10px;
}
body {
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
overflow-x: hidden;
}
/* -------- Header -------- */
header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 28px;
background: var(--surface);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 100;
}
.logo {
display: flex;
align-items: center;
gap: 10px;
font-size: 1.2rem;
font-weight: 700;
letter-spacing: .5px;
}
.logo svg { width: 28px; height: 28px; }
.header-right {
display: flex;
align-items: center;
gap: 20px;
}
.status-badge {
display: flex;
align-items: center;
gap: 7px;
padding: 5px 14px;
border-radius: 20px;
font-size: .8rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: .6px;
}
.status-badge.live { background: rgba(34,197,94,.12); color: var(--green); }
.status-badge.error { background: rgba(239,68,68,.12); color: var(--red); }
.status-badge.connecting { background: rgba(245,158,11,.12); color: var(--orange); }
.dot {
width: 8px; height: 8px;
border-radius: 50%;
background: currentColor;
animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.35 } }
.clock { font-size: .85rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
/* -------- Layout -------- */
.container {
display: grid;
grid-template-columns: 1fr 340px;
grid-template-rows: auto 1fr;
gap: 20px;
padding: 20px 28px 28px;
max-width: 1600px;
margin: 0 auto;
}
/* -------- KPI strip -------- */
.kpi-strip {
grid-column: 1 / -1;
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
}
.kpi {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 18px 20px;
display: flex;
flex-direction: column;
gap: 4px;
transition: border-color .3s;
}
.kpi.alert-glow { border-color: var(--red); box-shadow: 0 0 18px rgba(239,68,68,.2); }
.kpi-label { font-size: .75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.accent { color: var(--accent); }
/* -------- Video panel -------- */
.video-panel {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
position: relative;
min-height: 480px;
aspect-ratio: 16/9;
}
.video-panel img {
width: 100%;
height: 100%;
object-fit: contain;
display: block;
background: #000;
}
.video-overlay {
position: absolute;
top: 12px; left: 14px;
display: flex;
gap: 8px;
}
.overlay-tag {
background: rgba(0,0,0,.6);
backdrop-filter: blur(6px);
padding: 4px 10px;
border-radius: 6px;
font-size: .72rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: .5px;
}
/* -------- Alert banner -------- */
.alert-banner {
display: none;
position: fixed;
top: 64px;
left: 50%;
transform: translateX(-50%);
background: linear-gradient(135deg, #dc2626, #b91c1c);
color: #fff;
padding: 12px 32px;
border-radius: 8px;
font-weight: 700;
font-size: .95rem;
letter-spacing: .5px;
box-shadow: 0 8px 30px rgba(239,68,68,.35);
z-index: 200;
}
.alert-banner.show { display: flex; align-items: center; gap: 10px; }
/* -------- Sidebar -------- */
.sidebar {
display: flex;
flex-direction: column;
gap: 16px;
}
.panel {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
}
.panel-header {
padding: 14px 16px;
font-size: .8rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .8px;
color: var(--text-dim);
border-bottom: 1px solid var(--border);
}
.panel-body { padding: 12px 16px; }
.group-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid var(--border);
}
.group-item:last-child { border-bottom: none; }
.group-meta { display: flex; flex-direction: column; gap: 2px; }
.group-meta span:first-child { font-weight: 600; font-size: .95rem; }
.group-meta .cam-name { font-size: .75rem; color: var(--accent); }
.group-timer {
font-variant-numeric: tabular-nums;
font-weight: 700;
font-size: .9rem;
padding: 3px 10px;
border-radius: 6px;
background: var(--surface-2);
}
.group-timer.danger { color: var(--red); background: rgba(239,68,68,.1); }
.alert-log { max-height: 480px; overflow-y: auto; }
.alert-entry {
display: flex;
gap: 12px;
padding: 12px 8px;
border-bottom: 1px solid var(--border);
cursor: pointer;
}
.alert-entry:hover { background: var(--surface-2); }
.alert-thumb { width: 80px; height: 50px; border-radius: 4px; object-fit: cover; }
.alert-info .time { font-size: .75rem; color: var(--text-dim); }
.alert-info .desc { font-size: .85rem; font-weight: 600; display: block; }
</style>
</head>
<body>
<div class="alert-banner" id="alertBanner">
<svg width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
GATHERING DETECTED — Multiple groups active
</div>
<header>
<div class="logo">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"/><circle cx="12" cy="13" r="4"/></svg>
Surveillance Dash: Multi-Grid
</div>
<div class="header-right">
<div class="status-badge live" id="statusBadge">
<span class="dot"></span>
<span id="statusText">System Live</span>
</div>
<div class="clock" id="clock"></div>
</div>
</header>
<div class="container">
<div class="kpi-strip">
<div class="kpi">
<span class="kpi-label">People (Total)</span>
<span class="kpi-value accent" id="valPeople">0</span>
</div>
<div class="kpi">
<span class="kpi-label">Active Groups</span>
<span class="kpi-value orange" id="valGroups">0</span>
</div>
<div class="kpi" id="kpiAlerts">
<span class="kpi-label">Global Alerts</span>
<span class="kpi-value red" id="valAlerts">0</span>
</div>
<div class="kpi">
<span class="kpi-label">Node Status</span>
<span class="kpi-value green" id="valNodes">Online</span>
</div>
</div>
<div class="video-panel">
<img id="videoFeed" src="/video_feed" alt="Simultaneous Feed">
<div class="video-overlay">
<span class="overlay-tag">GRID VIEW</span>
<span class="overlay-tag" id="overlayPeople">0 People Total</span>
</div>
</div>
<div class="sidebar">
<div class="panel">
<div class="panel-header">Active Groups (All Cams)</div>
<div class="panel-body" id="groupList">
<div style="color:var(--text-dim); font-size:.8rem;">Monitoring...</div>
</div>
</div>
<div class="panel" style="flex:1;">
<div class="panel-header">Global Alert History</div>
<div class="panel-body alert-log" id="alertLog">
<div style="color:var(--text-dim); font-size:.8rem;">Scanning for events...</div>
</div>
</div>
</div>
</div>
<script>
function updateClock() {
const now = new Date();
document.getElementById('clock').textContent = now.toLocaleTimeString();
}
setInterval(updateClock, 1000);
updateClock();
let prevAlertActive = false;
async function poll() {
try {
const res = await fetch('/api/status');
const d = await res.json();
document.getElementById('valPeople').textContent = d.total_people_count;
document.getElementById('valAlerts').textContent = d.alerts.length;
document.getElementById('overlayPeople').textContent = d.total_people_count + ' People Total';
let allGroups = [];
Object.keys(d.cameras).forEach(id => {
d.cameras[id].groups.forEach(g => allGroups.push({...g, camName: d.cameras[id].name}));
});
document.getElementById('valGroups').textContent = allGroups.length;
document.getElementById('kpiAlerts').classList.toggle('alert-glow', d.alert_active);
const banner = document.getElementById('alertBanner');
if (d.alert_active && !prevAlertActive) banner.classList.add('show');
else if (!d.alert_active) banner.classList.remove('show');
prevAlertActive = d.alert_active;
const gl = document.getElementById('groupList');
if (allGroups.length === 0) gl.innerHTML = '<div style="color:var(--text-dim); font-size:.8rem;">No groups detected</div>';
else {
gl.innerHTML = allGroups.map(g => `
<div class="group-item">
<div class="group-meta">
<span>${g.count} People</span>
<span class="cam-name">${g.camName}</span>
</div>
<span class="group-timer ${g.duration > 20 ? 'danger' : ''}">${g.duration}s</span>
</div>
`).join('');
}
const al = document.getElementById('alertLog');
if (d.alerts.length === 0) al.innerHTML = '<div style="color:var(--text-dim); font-size:.8rem;">No alerts recorded</div>';
else {
al.innerHTML = d.alerts.map(a => `
<div class="alert-entry">
<img class="alert-thumb" src="/${a.image}" alt="Alert">
<div class="alert-info">
<span class="time">${a.time} - ${a.camera}</span>
<span class="desc">${a.people} people gathered</span>
</div>
</div>
`).join('');
}
} catch (e) { console.error('Poll error', e); }
}
setInterval(poll, 1500);
poll();
</script>
</body>
</html>