spaxel/dashboard/index.html
jedarden fb691904c6 feat(dashboard): per-link motion presence indicator with amplitude time series
- Dashboard hub broadcasts motion state changes immediately on transition
  (idle↔motion) via BroadcastMotionState; periodic state snapshots include
  motion_states for new client init
- Per-link presence badge (green CLEAR / red MOTION) rendered in link list
  alongside global presence indicator in status bar
- Amplitude mean time-series chart (60 s rolling window) for selected link,
  line segments colored by motion state at each sample
- Fix: links created from JSON link_active/state events now initialize
  ampHistory and lastAmpSample so time-series accumulates from first frame

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 22:55:33 -04:00

303 lines
7.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spaxel Dashboard</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background: #1a1a2e;
color: #eee;
overflow: hidden;
}
#scene-container {
width: 100vw;
height: 100vh;
}
/* Status bar at top */
#status-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 40px;
background: rgba(0, 0, 0, 0.7);
display: flex;
align-items: center;
padding: 0 16px;
gap: 24px;
z-index: 100;
font-size: 14px;
}
.status-item {
display: flex;
align-items: center;
gap: 8px;
}
.status-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: #666;
}
.status-dot.connected {
background: #4caf50;
box-shadow: 0 0 8px #4caf50;
}
.status-dot.disconnected {
background: #f44336;
}
/* Amplitude chart overlay */
#chart-panel {
position: fixed;
bottom: 20px;
right: 20px;
width: 400px;
height: 260px;
background: rgba(0, 0, 0, 0.8);
border-radius: 8px;
padding: 12px;
z-index: 100;
}
#chart-title {
font-size: 12px;
color: #888;
margin-bottom: 6px;
}
#chart-title .link-id {
color: #4fc3f7;
font-family: monospace;
}
#amplitude-chart {
width: 100%;
height: 130px;
display: block;
}
#chart-divider {
border: none;
border-top: 1px solid rgba(255,255,255,0.08);
margin: 6px 0;
}
#timeseries-label {
font-size: 10px;
color: #555;
margin-bottom: 4px;
}
#timeseries-chart {
width: 100%;
height: 64px;
display: block;
}
/* Node list panel */
#node-panel {
position: fixed;
top: 60px;
left: 20px;
width: 280px;
max-height: calc(100vh - 80px);
background: rgba(0, 0, 0, 0.8);
border-radius: 8px;
padding: 12px;
z-index: 100;
overflow-y: auto;
}
#node-panel h3 {
font-size: 14px;
color: #888;
margin-bottom: 12px;
text-transform: uppercase;
letter-spacing: 1px;
}
.node-item {
padding: 8px;
margin-bottom: 4px;
background: rgba(255, 255, 255, 0.05);
border-radius: 4px;
font-size: 13px;
cursor: pointer;
transition: background 0.2s;
}
.node-item:hover {
background: rgba(255, 255, 255, 0.1);
}
.node-item.selected {
background: rgba(79, 195, 247, 0.2);
border: 1px solid rgba(79, 195, 247, 0.5);
}
.node-mac {
font-family: monospace;
color: #4fc3f7;
}
.node-status {
float: right;
font-size: 11px;
padding: 2px 6px;
border-radius: 3px;
}
.node-status.online {
background: rgba(76, 175, 80, 0.3);
color: #81c784;
}
.node-status.offline {
background: rgba(244, 67, 54, 0.3);
color: #e57373;
}
/* Empty state */
.empty-state {
text-align: center;
color: #666;
padding: 20px;
font-size: 13px;
}
/* Link list */
.link-section {
margin-top: 16px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
padding-top: 12px;
}
.link-item {
padding: 6px 8px;
margin-bottom: 4px;
background: rgba(255, 255, 255, 0.03);
border-radius: 4px;
font-size: 12px;
cursor: pointer;
display: flex;
justify-content: space-between;
}
.link-item:hover {
background: rgba(255, 255, 255, 0.08);
}
.link-item.selected {
background: rgba(79, 195, 247, 0.2);
}
/* Presence badge */
.presence-badge {
font-size: 10px;
font-weight: 600;
padding: 2px 6px;
border-radius: 3px;
letter-spacing: 0.5px;
}
.presence-badge.motion {
background: rgba(244, 67, 54, 0.25);
color: #ef5350;
}
.presence-badge.clear {
background: rgba(76, 175, 80, 0.2);
color: #66bb6a;
}
/* Overall presence indicator in status bar */
#presence-indicator {
font-size: 12px;
font-weight: 600;
padding: 3px 8px;
border-radius: 4px;
transition: background 0.3s, color 0.3s;
}
#presence-indicator.motion {
background: rgba(244, 67, 54, 0.3);
color: #ef5350;
}
#presence-indicator.clear {
background: rgba(76, 175, 80, 0.15);
color: #66bb6a;
}
</style>
</head>
<body>
<!-- Status bar -->
<div id="status-bar">
<div class="status-item">
<div id="ws-status" class="status-dot disconnected"></div>
<span id="ws-status-text">Disconnected</span>
</div>
<div class="status-item">
<span>Nodes: <strong id="node-count">0</strong></span>
</div>
<div class="status-item">
<span>Links: <strong id="link-count">0</strong></span>
</div>
<div class="status-item">
<span id="presence-indicator" class="clear">CLEAR</span>
</div>
<div class="status-item" style="margin-left:auto;">
<span>FPS: <strong id="fps-counter">0</strong></span>
</div>
</div>
<!-- 3D Scene container -->
<div id="scene-container"></div>
<!-- Node panel -->
<div id="node-panel">
<h3>Nodes</h3>
<div id="node-list">
<div class="empty-state">No nodes connected</div>
</div>
<div class="link-section">
<h3>Links</h3>
<div id="link-list">
<div class="empty-state">No links active</div>
</div>
</div>
</div>
<!-- Amplitude chart -->
<div id="chart-panel">
<div id="chart-title">Amplitude — <span class="link-id">no link selected</span></div>
<canvas id="amplitude-chart"></canvas>
<hr id="chart-divider">
<div id="timeseries-label">Mean amplitude (60 s)</div>
<canvas id="timeseries-chart"></canvas>
</div>
<!-- Three.js from CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- OrbitControls from CDN -->
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script>
<!-- Main application -->
<script src="js/app.js"></script>
</body>
</html>