512 lines
15 KiB
HTML
512 lines
15 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</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; }
|
|
.camera-select {
|
|
background: var(--surface-2);
|
|
color: var(--text);
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
padding: 6px 10px;
|
|
font-size: .85rem;
|
|
min-width: 170px;
|
|
}
|
|
|
|
/* -------- Layout -------- */
|
|
.container {
|
|
display: grid;
|
|
grid-template-columns: 1fr 320px;
|
|
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;
|
|
}
|
|
.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;
|
|
animation: bannerIn .4s ease-out;
|
|
}
|
|
.alert-banner.show { display: flex; align-items: center; gap: 10px; }
|
|
@keyframes bannerIn { from { opacity:0; transform:translateX(-50%) translateY(-12px); } }
|
|
|
|
/* -------- 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; }
|
|
|
|
/* Groups panel */
|
|
.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: .9rem; }
|
|
.group-meta span:last-child { font-size: .75rem; color: var(--text-dim); }
|
|
.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.warning { color: var(--orange); background: rgba(245,158,11,.1); }
|
|
.group-timer.danger { color: var(--red); background: rgba(239,68,68,.1); }
|
|
.no-groups { color: var(--text-dim); font-size: .85rem; padding: 8px 0; }
|
|
|
|
/* Alert history */
|
|
.alert-log {
|
|
max-height: 380px;
|
|
overflow-y: auto;
|
|
scrollbar-width: thin;
|
|
scrollbar-color: var(--border) transparent;
|
|
}
|
|
.alert-entry {
|
|
display: flex;
|
|
gap: 12px;
|
|
padding: 10px 0;
|
|
border-bottom: 1px solid var(--border);
|
|
cursor: pointer;
|
|
transition: background .2s;
|
|
border-radius: 6px;
|
|
padding: 10px 8px;
|
|
}
|
|
.alert-entry:hover { background: var(--surface-2); }
|
|
.alert-entry:last-child { border-bottom: none; }
|
|
.alert-thumb {
|
|
width: 64px;
|
|
height: 44px;
|
|
border-radius: 6px;
|
|
object-fit: cover;
|
|
border: 1px solid var(--border);
|
|
flex-shrink: 0;
|
|
}
|
|
.alert-info { display: flex; flex-direction: column; gap: 2px; }
|
|
.alert-info .time { font-size: .75rem; color: var(--text-dim); }
|
|
.alert-info .desc { font-size: .82rem; font-weight: 600; }
|
|
.alert-info .duration { font-size: .72rem; color: var(--orange); }
|
|
|
|
/* -------- Lightbox -------- */
|
|
.lightbox {
|
|
display: none;
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(0,0,0,.85);
|
|
z-index: 300;
|
|
justify-content: center;
|
|
align-items: center;
|
|
cursor: pointer;
|
|
}
|
|
.lightbox.open { display: flex; }
|
|
.lightbox img {
|
|
max-width: 90vw;
|
|
max-height: 85vh;
|
|
border-radius: 8px;
|
|
box-shadow: 0 12px 60px rgba(0,0,0,.6);
|
|
}
|
|
|
|
/* -------- Responsive -------- */
|
|
@media (max-width: 960px) {
|
|
.container {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
.kpi-strip {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- Alert banner -->
|
|
<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 ALERT — People grouped for over 20 seconds
|
|
</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 Dashboard
|
|
</div>
|
|
<div class="header-right">
|
|
<select id="cameraSelect" class="camera-select"></select>
|
|
<div class="status-badge connecting" id="statusBadge">
|
|
<span class="dot"></span>
|
|
<span id="statusText">Connecting</span>
|
|
</div>
|
|
<div class="clock" id="clock"></div>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="container">
|
|
<!-- KPI strip -->
|
|
<div class="kpi-strip">
|
|
<div class="kpi" id="kpiPeople">
|
|
<span class="kpi-label">People Detected</span>
|
|
<span class="kpi-value accent" id="valPeople">0</span>
|
|
</div>
|
|
<div class="kpi" id="kpiGroups">
|
|
<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">Total Alerts</span>
|
|
<span class="kpi-value red" id="valAlerts">0</span>
|
|
</div>
|
|
<div class="kpi">
|
|
<span class="kpi-label">FPS</span>
|
|
<span class="kpi-value green" id="valFps">0</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Video feed -->
|
|
<div class="video-panel">
|
|
<img id="videoFeed" src="/video_feed" alt="Live Feed">
|
|
<div class="video-overlay">
|
|
<span class="overlay-tag">LIVE</span>
|
|
<span class="overlay-tag" id="overlayPeople">0 People</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Sidebar -->
|
|
<div class="sidebar">
|
|
<!-- Active groups -->
|
|
<div class="panel">
|
|
<div class="panel-header">Active Groups</div>
|
|
<div class="panel-body" id="groupList">
|
|
<div class="no-groups">No groups detected</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alert history -->
|
|
<div class="panel" style="flex:1;">
|
|
<div class="panel-header">Alert History</div>
|
|
<div class="panel-body alert-log" id="alertLog">
|
|
<div class="no-groups">No alerts yet</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Lightbox for alert images -->
|
|
<div class="lightbox" id="lightbox" onclick="this.classList.remove('open')">
|
|
<img id="lightboxImg" src="" alt="Alert snapshot">
|
|
</div>
|
|
|
|
<script>
|
|
function updateClock() {
|
|
const now = new Date();
|
|
document.getElementById('clock').textContent = now.toLocaleString('en-US', {
|
|
hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false,
|
|
year: 'numeric', month: 'short', day: 'numeric'
|
|
});
|
|
}
|
|
setInterval(updateClock, 1000);
|
|
updateClock();
|
|
|
|
let prevAlertActive = false;
|
|
let bannerTimeout = null;
|
|
let camerasLoaded = false;
|
|
|
|
async function loadCameras() {
|
|
try {
|
|
const res = await fetch('/api/cameras');
|
|
const data = await res.json();
|
|
const select = document.getElementById('cameraSelect');
|
|
select.innerHTML = data.cameras
|
|
.map(c => `<option value="${c.id}">${c.name} (${c.ip})</option>`)
|
|
.join('');
|
|
camerasLoaded = true;
|
|
} catch (e) {
|
|
console.error('Failed to load cameras', e);
|
|
}
|
|
}
|
|
|
|
async function selectCamera(cameraId) {
|
|
try {
|
|
await fetch('/api/camera/select', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ camera_id: cameraId })
|
|
});
|
|
} catch (e) {
|
|
console.error('Failed to switch camera', e);
|
|
}
|
|
}
|
|
|
|
async function poll() {
|
|
try {
|
|
const res = await fetch('/api/status');
|
|
const d = await res.json();
|
|
|
|
// Aggregated KPIs
|
|
const totalPeople = d.total_people_count;
|
|
let totalGroups = 0;
|
|
let allGroups = [];
|
|
|
|
Object.keys(d.cameras).forEach(cid => {
|
|
const camData = d.cameras[cid];
|
|
totalGroups += camData.groups.length;
|
|
camData.groups.forEach(g => {
|
|
allGroups.push({...g, camName: camData.name});
|
|
});
|
|
});
|
|
|
|
document.getElementById('valPeople').textContent = totalPeople;
|
|
document.getElementById('valGroups').textContent = totalGroups;
|
|
document.getElementById('valAlerts').textContent = d.alerts.length;
|
|
document.getElementById('valFps').textContent = "GRID";
|
|
document.getElementById('overlayPeople').textContent = totalPeople + ' People Total';
|
|
|
|
// Stream status badge (Aggregated)
|
|
const badge = document.getElementById('statusBadge');
|
|
const stext = document.getElementById('statusText');
|
|
const statuses = Object.values(d.cameras).map(c => c.status);
|
|
|
|
if (statuses.includes('error')) {
|
|
badge.className = 'status-badge error';
|
|
stext.textContent = 'SYSTEM ERROR';
|
|
} else if (statuses.includes('connecting') || statuses.includes('reconnecting')) {
|
|
badge.className = 'status-badge connecting';
|
|
stext.textContent = 'CONNECTING...';
|
|
} else {
|
|
badge.className = 'status-badge live';
|
|
stext.textContent = 'ALL SYSTEMS LIVE';
|
|
}
|
|
|
|
// Alert KPI glow
|
|
const kpiAlerts = document.getElementById('kpiAlerts');
|
|
kpiAlerts.classList.toggle('alert-glow', d.alert_active);
|
|
|
|
// Alert banner
|
|
const banner = document.getElementById('alertBanner');
|
|
if (d.alert_active && !prevAlertActive) {
|
|
banner.classList.add('show');
|
|
clearTimeout(bannerTimeout);
|
|
bannerTimeout = setTimeout(() => banner.classList.remove('show'), 8000);
|
|
}
|
|
prevAlertActive = d.alert_active;
|
|
|
|
// Groups list (Aggregated)
|
|
const gl = document.getElementById('groupList');
|
|
if (allGroups.length === 0) {
|
|
gl.innerHTML = '<div class="no-groups">No groups detected</div>';
|
|
} else {
|
|
gl.innerHTML = allGroups.map(g => {
|
|
const cls = g.duration >= 20 ? 'danger' : g.duration >= 10 ? 'warning' : '';
|
|
return `<div class="group-item">
|
|
<div class="group-meta">
|
|
<span>${g.count} People - ${g.camName}</span>
|
|
<span>Group #${g.id}</span>
|
|
</div>
|
|
<span class="group-timer ${cls}">${g.duration}s</span>
|
|
</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
// Alert log
|
|
const al = document.getElementById('alertLog');
|
|
if (d.alerts.length === 0) {
|
|
al.innerHTML = '<div class="no-groups">No alerts yet</div>';
|
|
} else {
|
|
al.innerHTML = d.alerts.map(a => `
|
|
<div class="alert-entry" onclick="openLightbox('/${a.image}')">
|
|
<img class="alert-thumb" src="/${a.image}" alt="Alert">
|
|
<div class="alert-info">
|
|
<span class="time">${a.time} - ${a.camera || 'Unknown'}</span>
|
|
<span class="desc">${a.people} people gathered</span>
|
|
<span class="duration">Duration: ${a.duration}s</span>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
} catch (e) {
|
|
console.error('Poll error', e);
|
|
}
|
|
}
|
|
|
|
function openLightbox(src) {
|
|
document.getElementById('lightboxImg').src = src;
|
|
document.getElementById('lightbox').classList.add('open');
|
|
}
|
|
|
|
setInterval(poll, 1000);
|
|
loadCameras().then(poll);
|
|
poll();
|
|
</script>
|
|
</body>
|
|
</html>
|