// Sidebar navigation component
const NAV_ITEMS = [
{ id: 'dashboard', label: 'Dashboard', icon: '▦' },
{ id: 'calendar', label: 'Calendar', icon: '◫' },
{ id: 'search', label: 'Search', icon: '⌕' },
{ id: 'highlights', label: 'Highlights', icon: '◈' },
];
function Sidebar({ view, setView, data }) {
const totalGB = (data.recordings.reduce((a, r) => a + r.fileSizeMB, 0) / 1024).toFixed(1);
const totalCount = data.recordings.length;
return (
{/* Logo */}
RecordingsViewer
{totalCount} files
{totalGB} GB
{/* Nav */}
{/* Device status */}
);
}
function DeviceStatus({ devices }) {
const now = new Date();
function hoursSince(date) {
return (now - date) / (1000 * 60 * 60);
}
function fmtSince(date) {
const h = hoursSince(date);
if (h < 1) return `${Math.round(h * 60)}m ago`;
if (h < 24) return `${Math.round(h)}h ago`;
return `${Math.round(h / 24)}d ago`;
}
return (
Devices
{Object.entries(devices).map(([key, dev]) => {
const hours = hoursSince(dev.lastSeen);
const bad = hours > 24;
const color = bad ? 'var(--red)' : 'var(--green)';
const dotColor = bad ? 'var(--red)' : 'var(--green)';
return (
{key}
{fmtSince(dev.lastSeen)}
{dev.model}
);
})}
);
}
Object.assign(window, { Sidebar, DeviceStatus });