added light/dark mode toggle v1, unified menu

This commit is contained in:
Joren de Graaf
2026-10-01 17:14:19 +02:00
parent 884e2e8a11
commit 66db97b6f7
102 changed files with 1870 additions and 1365 deletions
Binary file not shown.
@@ -1 +1,2 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Events · Sound Signal</title><script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script><style>:root{--i:#edf3ff;--m:#aab9d8;--l:#2b3d68}*{box-sizing:border-box}body{margin:0;min-height:100vh;padding:2rem;color:var(--i);font-family:system-ui;background:radial-gradient(circle at 8% 0,#263a76,transparent 31rem),#090e1d}.shell{width:min(100%,70rem);margin:auto}.top{display:flex;justify-content:space-between;gap:1rem;align-items:center;margin-bottom:3rem}.brand,a{color:inherit}.brand{text-decoration:none;font-weight:900;letter-spacing:.1em;text-transform:uppercase}.top a:not(.brand){padding:.6rem .8rem;border:1px solid var(--l);border-radius:.6rem;text-decoration:none}.eyebrow{color:#bcd4ff;font-size:.76rem;letter-spacing:.15em;text-transform:uppercase;font-weight:800}h1{font-size:clamp(2.5rem,6vw,4.5rem);letter-spacing:-.06em;margin:.4rem 0}.lede{color:var(--m);max-width:38rem;line-height:1.6}.grid{display:grid;grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr);gap:1rem;margin-top:2rem}.panel{border:1px solid var(--l);border-radius:1rem;padding:1rem;background:#111a31d9}.event{width:100%;display:flex;justify-content:space-between;gap:.6rem;text-align:left;margin:.6rem 0;padding:.85rem;border:1px solid #374e7e;border-radius:.7rem;color:var(--i);background:#15223f;cursor:pointer}.event:hover{background:#20345f}.event small,.empty{color:var(--m)}.badge{color:#ffd08a}.detail h2{margin-top:0}.prediction{display:flex;justify-content:space-between;gap:1rem;padding:.65rem;margin:.45rem 0;border-left:3px solid #78a4f0;background:#111c34}.prediction--firework{border-color:#f5aa44}.prediction--speech{border-color:#fb7185}.meta{color:var(--m);font-size:.9rem}@media(max-width:42rem){body{padding:1rem}.grid{grid-template-columns:1fr}}</style></head><body><main class="shell"><header class="top"><a class="brand" href="{% url 'fireworks_detect:fireworks' %}">✦ Sound Signal</a><a href="{% url 'fireworks_detect:map' %}">Map</a></header><p class="eyebrow">Reviewed signal archive</p><h1>Approved events.</h1><p class="lede">This feed refreshes automatically every three seconds after a pending sample is approved in admin.</p><div class="grid"><section class="panel"><h2>Latest events</h2><div id="events-feed" hx-get="{% url 'fireworks_detect:events_list' %}" hx-trigger="load, every 3s" hx-swap="innerHTML"><p class="empty">Loading events…</p></div></section><section class="panel detail" id="event-detail"><h2>Select an event</h2><p class="empty">Choose an approved event to inspect its classification details.</p></section></div></main></body></html>
{% load vite %}
<!doctype html><html lang="en" data-theme="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Events · Sound Signal</title><script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>{% vite_asset "frontend/src/entries/events.js" %}</head><body><main class="shell">{% include "fireworks_detect/includes/navigation.html" with active_page="events" %}<p class="eyebrow">Reviewed signal archive</p><h1>Approved events.</h1><p class="lede">This feed refreshes automatically every three seconds after a pending sample is approved in admin.</p><div class="grid"><section class="panel"><h2>Latest events</h2><div id="events-feed" hx-get="{% url 'fireworks_detect:events_list' %}" hx-trigger="load, every 3s" hx-swap="innerHTML"><p class="empty">Loading events…</p></div></section><section class="panel detail" id="event-detail"><h2>Select an event</h2><p class="empty">Choose an approved event to inspect its classification details.</p></section></div></main></body></html>
@@ -1,11 +1,13 @@
{% if events %}
{% for event in events %}
<button class="event{% if event.source_type == 'manual' %} event--manual{% endif %}" {% if event.source_type == 'manual' %}style="border-color:#e2934a;background:linear-gradient(90deg,#70401e,#15223f);"{% endif %} hx-get="{% url 'fireworks_detect:event_detail' event.id %}" hx-target="#event-detail" hx-swap="innerHTML">
<span>
<button class="event {% if event.source_type == "manual" %}event--manual{% else %}event--sensor{% endif %}" hx-get="{% url 'fireworks_detect:event_detail' event.id %}" hx-target="#event-detail" hx-swap="innerHTML">
<span class="event__content">
{% if event.source_type == "manual" %}
<span class="event__source">Manual report</span>
<strong>Manual fireworks report</strong><br>
<small>{{ event.occurrences }} occurrence{{ event.occurrences|pluralize }}{% if event.location %} · {{ event.location }}{% endif %}</small>
{% else %}
<span class="event__source">Sensor classification</span>
<strong>{{ event.primary_label }}</strong><br>
<small>{{ event.original_filename }} · {{ event.duration }}s</small>
{% endif %}
@@ -1,503 +1,18 @@
{% load vite %}
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sound Signal · Fireworks detection</title>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
<style>
:root {
--ink: #eaf0ff;
--muted: #9caed1;
--surface: #111a31;
--surface-2: #17223e;
--line: #2a3a61;
--blue: #6aa8ff;
--violet: #a78bfa;
--fire: #ffb454;
--danger: #ff727c;
--success: #6ee7b7;
}
* {
box-sizing: border-box;
}
body {
min-width: 320px;
min-height: 100vh;
margin: 0;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: radial-gradient(circle at 10% 0%, #263a76 0, transparent 30rem), radial-gradient(circle at 90% 20%, #4d236c 0, transparent 28rem), #090e1d;
}
.shell {
width: min(100% - 2.5rem, 70rem);
margin: 0 auto;
padding: clamp(2rem, 6vw, 5rem) 0;
}
.brand {
display: flex;
align-items: center;
gap: .75rem;
/* margin-bottom: clamp(2.5rem, 6vw, 5rem); */
font-size: .9rem;
font-weight: 800;
letter-spacing: .11em;
text-transform: uppercase;
}
.brand-mark {
display: grid;
width: 2.25rem;
aspect-ratio: 1;
place-items: center;
border-radius: .75rem;
color: #141022;
background: linear-gradient(135deg, #fcd34d, #fb7185);
box-shadow: 0 .5rem 1.5rem #fb718550;
}
.intro {
max-width: 45rem;
}
.kicker {
margin: 0 0 .8rem;
color: #bfdbfe;
font-size: .78rem;
font-weight: 800;
letter-spacing: .15em;
text-transform: uppercase;
}
h1 {
max-width: 12ch;
margin: 0;
font-size: clamp(2.6rem, 7vw, 5.75rem);
line-height: .96;
letter-spacing: -.065em;
}
.lede {
max-width: 38rem;
margin: 1.5rem 0 2.5rem;
color: var(--muted);
font-size: clamp(1rem, 2vw, 1.18rem);
line-height: 1.65;
}
.upload-card,
.results-card {
border: 1px solid var(--line);
border-radius: 1.5rem;
background: linear-gradient(145deg, #162240d9, #0e162bdd);
box-shadow: 0 1.5rem 4rem #02061680;
backdrop-filter: blur(16px);
}
.upload-card {
padding: clamp(1rem, 3vw, 1.5rem);
}
.drop-zone {
display: grid;
min-height: 16rem;
place-items: center;
padding: 2rem;
border: 1.5px dashed #5d75aa;
border-radius: 1rem;
cursor: pointer;
text-align: center;
background: linear-gradient(135deg, #1b2a4e80, #291c4b66);
transition: .2s ease;
}
.drop-zone:hover,
.drop-zone.dragging {
border-color: var(--blue);
transform: translateY(-2px);
background: #203360a8;
}
.drop-zone:focus-within {
outline: 3px solid #6aa8ff66;
outline-offset: 3px;
}
.file-input {
width: .1px;
height: .1px;
position: absolute;
opacity: 0;
overflow: hidden;
}
.upload-icon {
display: grid;
width: 4rem;
aspect-ratio: 1;
place-items: center;
margin: 0 auto 1rem;
border-radius: 50%;
color: #dbeafe;
font-size: 1.8rem;
background: #4777c94d;
}
.drop-zone strong {
display: block;
font-size: 1.15rem;
}
.drop-zone span {
display: block;
margin-top: .4rem;
color: var(--muted);
font-size: .92rem;
}
.file-name {
min-height: 1.3rem;
margin: 1rem 0 0;
color: #c7d2fe;
font-size: .9rem;
overflow-wrap: anywhere;
}
.form-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: .9rem .25rem 0;
}
.file-note {
margin: 0;
color: var(--muted);
font-size: .8rem;
}
button,
.button {
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
gap: .6rem;
border: 0;
border-radius: .8rem;
padding: .85rem 1.15rem;
cursor: pointer;
color: #10172c;
font: inherit;
font-weight: 800;
background: linear-gradient(135deg, #93c5fd, #c4b5fd);
box-shadow: 0 .5rem 1.25rem #8b5cf640;
transition: transform .2s ease, filter .2s ease;
}
button:hover,
.button:hover {
transform: translateY(-1px);
filter: brightness(1.08);
}
button:disabled {
cursor: wait;
filter: saturate(.4);
transform: none;
}
.spinner {
width: 1rem;
height: 1rem;
border: 2px solid #263253;
border-top-color: currentColor;
border-radius: 50%;
animation: spin .75s linear infinite;
}
.htmx-indicator {
display: none;
}
.htmx-request.htmx-indicator {
display: inline-block;
}
.upload-form.htmx-request button {
pointer-events: none;
}
#upload-status {
min-height: 1.4rem;
margin: 1rem .25rem 0;
color: #c7d2fe;
font-size: .9rem;
}
.upload-form.htmx-request+#upload-status {
color: #fcd34d;
}
#classification-results {
margin-top: 1.5rem;
}
.results-card {
padding: clamp(1.25rem, 3vw, 2rem);
animation: reveal .35s ease-out;
}
.result-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.result-heading h2 {
margin: 0;
font-size: clamp(1.4rem, 3vw, 2rem);
letter-spacing: -.04em;
}
.result-heading p {
margin: .3rem 0 0;
color: var(--muted);
}
.result-status {
padding: .4rem .65rem;
border-radius: 999px;
color: #a7f3d0;
font-size: .75rem;
font-weight: 800;
white-space: nowrap;
background: #065f464d;
}
.meta {
display: flex;
flex-wrap: wrap;
gap: .6rem;
margin: 1.5rem 0;
}
.meta span,
.legend span {
padding: .4rem .65rem;
border: 1px solid var(--line);
border-radius: 999px;
color: #bdc9e5;
font-size: .8rem;
background: #101a31;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: .5rem;
margin: 0 0 1.25rem;
}
.legend .firework {
color: #ffd18c;
border-color: #c7721e80;
}
.legend .speech {
color: #ffadb4;
border-color: #d5485880;
}
.topbar { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:3.5rem; }.brand { display:flex; align-items:center; gap:.7rem; color:var(--ink); font-size:.9rem; font-weight:800; letter-spacing:.1em; text-decoration:none; text-transform:uppercase; }.brand-mark { display:grid; width:2.25rem; aspect-ratio:1; place-items:center; border-radius:.75rem; color:#141022; background:linear-gradient(135deg,#fcd34d,#fb7185); box-shadow:0 .5rem 1.5rem #fb718550; }.nav { display:flex; gap:.35rem; padding:.25rem; border:1px solid var(--line); border-radius:.75rem; background:#111a31a6; }.nav a { padding:.5rem .75rem; border-radius:.5rem; color:var(--muted); font-size:.86rem; font-weight:700; text-decoration:none; }.nav a[aria-current="page"] { color:var(--ink); background:#2a3b67; }
.result-grid {
display: grid;
grid-template-columns: minmax(0, 1.25fr) minmax(18rem, .75fr);
gap: 1.25rem;
}
.result-group {
padding: 1.1rem;
border: 1px solid var(--line);
border-radius: 1rem;
background: #0b1225a8;
}
.result-group h3 {
margin: 0 0 1rem;
font-size: 1rem;
}
.prediction-list {
display: grid;
gap: .75rem;
margin: 0;
padding: 0;
list-style: none;
}
.prediction {
--accent-color: #7799dd;
position: relative;
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: .45rem .75rem;
align-items: center;
padding: .7rem .75rem;
overflow: hidden;
border: 1px solid #26365b;
border-left: 3px solid var(--accent-color);
border-radius: .7rem;
background: #121c34;
}
.prediction--firework {
--accent-color: var(--fire);
background: linear-gradient(90deg, #7a421d55, #121c34);
}
.prediction--speech {
--accent-color: var(--danger);
background: linear-gradient(90deg, #6c213055, #121c34);
}
.prediction-label {
min-width: 0;
font-weight: 700;
overflow-wrap: anywhere;
}
.prediction-score {
color: #c4d1ed;
font-size: .85rem;
font-variant-numeric: tabular-nums;
}
.score-bar {
grid-column: 1/-1;
height: .3rem;
overflow: hidden;
border-radius: 999px;
background: #263657;
}
.score-bar i {
display: block;
width: calc(var(--score) * 1%);
height: 100%;
border-radius: inherit;
background: var(--accent-color);
}
.peak-list {
display: grid;
gap: .7rem;
}
.peak-item {
padding-bottom: .7rem;
border-bottom: 1px solid #253453;
}
.peak-item:last-child {
padding-bottom: 0;
border-bottom: 0;
}
.peak-time {
color: #a9bce0;
font-size: .78rem;
}
.peak-item .prediction {
margin-top: .35rem;
}
.empty {
margin: 0;
color: var(--muted);
}
.error-card {
border-color: #a43d4d;
background: linear-gradient(135deg, #4b1724dd, #1a1427dd);
}
.error-card h2 {
color: #fecdd3;
}
.error-card p {
color: #fecdd3;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@keyframes reveal {
from {
opacity: 0;
transform: translateY(.75rem);
}
}
@media (max-width:42rem) {
.shell {
width: min(100% - 1.25rem, 70rem);
}
.form-footer,
.result-heading {
align-items: stretch;
flex-direction: column;
}
.form-footer button {
width: 100%;
}
.result-grid {
grid-template-columns: 1fr;
}
.result-status {
align-self: flex-start;
}
}
@media (prefers-reduced-motion:reduce) {
*,
::before,
::after {
scroll-behavior: auto !important;
animation-duration: .01ms !important;
transition-duration: .01ms !important;
}
}
</style>
{% vite_asset "frontend/src/entries/fireworks-home.js" %}
</head>
<body>
<main class="shell">
<header class="topbar" style="display: flex">
<a class="brand" href="{% url 'fireworks_detect:fireworks' %}"><span class="brand-mark">✦</span> Sound
Signal</a>
<nav class="nav" aria-label="Fireworks navigation">
<a href="{% url 'fireworks_detect:fireworks' %}" aria-current="page">Analyse</a>
<a href="{% url 'fireworks_detect:map' %}" >Map</a>
</nav>
</header>
{% include "fireworks_detect/includes/navigation.html" with active_page="analyse" %}
<section class="intro" aria-labelledby="page-title">
@@ -536,36 +51,6 @@
<p id="upload-status" role="status" aria-live="polite"></p>
</section>
</main>
<script>
const form = document.querySelector('.upload-form');
const dropZone = document.querySelector('#drop-zone');
const fileInput = document.querySelector('#audio-file');
const fileName = document.querySelector('#file-name');
const status = document.querySelector('#upload-status');
const showFile = (file) => { fileName.textContent = file ? file.name : 'No file selected'; };
fileInput.addEventListener('change', () => showFile(fileInput.files[0]));
['dragenter', 'dragover'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.add('dragging'); }));
['dragleave', 'drop'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.remove('dragging'); }));
dropZone.addEventListener('drop', (event) => { const [file] = event.dataTransfer.files; if (!file) return; fileInput.files = event.dataTransfer.files; showFile(file); });
form.addEventListener('htmx:beforeRequest', () => { status.textContent = 'Analysing your recording…'; form.setAttribute('aria-busy', 'true'); });
form.addEventListener('htmx:afterRequest', () => { status.textContent = ''; form.removeAttribute('aria-busy'); });
form.addEventListener('htmx:responseError', () => { status.textContent = 'Analysis could not be completed.'; });
document.body.addEventListener('htmx:beforeSwap', (event) => {
if (event.detail.xhr.status >= 400) {
event.detail.shouldSwap = true;
event.detail.isError = false;
}
});
window.addEventListener('pageshow', (event) => {
if (event.persisted) {
fileInput.value = '';
showFile();
status.textContent = '';
document.querySelector('#classification-results').replaceChildren();
}
});
</script>
</body>
</html>
@@ -0,0 +1,11 @@
<header class="fireworks-header">
<a class="fireworks-brand" href="{% url "fireworks_detect:fireworks" %}"><span class="brand-mark">✦</span> Sound Signal</a>
<div class="fireworks-header__controls">
<nav class="fireworks-nav" aria-label="Fireworks navigation">
<a href="{% url "fireworks_detect:fireworks" %}"{% if active_page == "analyse" %} aria-current="page"{% endif %}>Analyse</a>
<a href="{% url "fireworks_detect:map" %}"{% if active_page == "map" %} aria-current="page"{% endif %}>Map</a>
<a href="{% url "fireworks_detect:events" %}"{% if active_page == "events" %} aria-current="page"{% endif %}>Events</a>
</nav>
<button class="theme-toggle theme-toggle--inline" type="button" aria-label="Switch theme"></button>
</div>
</header>
@@ -1,37 +1,16 @@
{% load vite %}
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signal map · Sound Signal</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<style>
:root { --ink:#eef3ff; --muted:#a9b9d8; --surface:#111a31; --line:#2a3a61; --blue:#83b7ff; --violet:#b69cff; --amber:#ffbc61; --green:#6ee7b7; }
* { box-sizing:border-box; }
body { min-width:320px; min-height:100vh; margin:0; color:var(--ink); font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:radial-gradient(circle at 8% 0%,#263a76 0,transparent 32rem),radial-gradient(circle at 95% 0%,#492064 0,transparent 27rem),#090e1d; }
.shell {
width: min(100% - 2.5rem, 70rem);
margin: 0 auto;
padding: clamp(2rem, 6vw, 5rem) 0;
}
.topbar { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:3.5rem; }.brand { display:flex; align-items:center; gap:.7rem; color:var(--ink); font-size:.9rem; font-weight:800; letter-spacing:.1em; text-decoration:none; text-transform:uppercase; }.brand-mark { display:grid; width:2.25rem; aspect-ratio:1; place-items:center; border-radius:.75rem; color:#141022; background:linear-gradient(135deg,#fcd34d,#fb7185); box-shadow:0 .5rem 1.5rem #fb718550; }.nav { display:flex; gap:.35rem; padding:.25rem; border:1px solid var(--line); border-radius:.75rem; background:#111a31a6; }.nav a { padding:.5rem .75rem; border-radius:.5rem; color:var(--muted); font-size:.86rem; font-weight:700; text-decoration:none; }.nav a[aria-current="page"] { color:var(--ink); background:#2a3b67; }
.kicker { margin:0 0 .65rem; color:#bfdbfe; font-size:.76rem; font-weight:800; letter-spacing:.14em; text-transform:uppercase; }.headline { display:flex; align-items:end; justify-content:space-between; gap:2rem; margin-bottom:2rem; }.headline h1 { margin:0; font-size:clamp(2.3rem,5vw,4.5rem); line-height:.98; letter-spacing:-.06em; }.headline p { max-width:30rem; margin:0; color:var(--muted); line-height:1.6; }
.filters { display:grid; grid-template-columns:repeat(5,minmax(8rem,1fr)) auto auto; gap:.75rem; align-items:end; margin-bottom:1rem; padding:1rem; border:1px solid var(--line); border-radius:1.1rem; background:#121d37d9; box-shadow:0 1rem 3rem #03071466; }.filter { display:grid; gap:.35rem; }.filter label { color:#9fb1d5; font-size:.7rem; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }.filter select,.filter input { width:100%; min-height:2.65rem; border:1px solid #354a77; border-radius:.65rem; padding:0 .75rem; color:var(--ink); font:inherit; background:#0c1428; }.filter select:focus,.filter input:focus { outline:2px solid #82b5ff; outline-offset:2px; }.filter-submit { min-height:2.65rem; border:1px solid #8ab7ff; border-radius:.65rem; padding:0 1rem; color:#101a31; font:inherit; font-weight:800; background:#b9d6ff; cursor:pointer; }.map-tag { align-self:center; padding:.46rem .65rem; border:1px solid #4a5f8e; border-radius:999px; color:#c9d8f6; font-size:.75rem; font-weight:700; white-space:nowrap; background:#1d2b4e; }
.map-panel { overflow:hidden; border:1px solid var(--line); border-radius:1.25rem; background:var(--surface); box-shadow:0 1.5rem 4rem #0206168a; }.map-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1rem 1.2rem; border-bottom:1px solid var(--line); }.map-header strong { font-size:.95rem; }.live { display:flex; align-items:center; gap:.45rem; color:#a7f3d0; font-size:.8rem; }.live i { width:.5rem; height:.5rem; border-radius:50%; background:var(--green); box-shadow:0 0 0 .25rem #34d3992e; }.map-wrap { position:relative; }.map { height:clamp(30rem,65vh,45rem); background:#dce4cf; }.legend { position:absolute; z-index:600; right:1rem; bottom:1rem; width:min(15rem,calc(100% - 2rem)); padding:.85rem; border:1px solid #344973; border-radius:.8rem; color:#dce7fe; font-size:.78rem; background:#101a31e8; box-shadow:0 .75rem 2rem #05091480; backdrop-filter:blur(10px); }.legend h2 { margin:0 0 .6rem; font-size:.82rem; }.legend div { display:flex; align-items:center; gap:.5rem; margin-top:.4rem; }.legend-dot { width:.7rem; height:.7rem; border:2px solid #f2c56b; border-radius:50%; background:#ed8e2e88; }.legend-ring { width:.85rem; height:.85rem; border:2px solid #a98af7; border-radius:50%; background:#8b5cf633; }.legend-line { width:1.1rem; border-top:2px dashed #644b9c; }.report-icon { display:grid; width:2.3rem; height:2.3rem; place-items:center; border:2px solid #fff3d5; border-radius:50%; color:#452000; font-size:1rem; font-weight:900; background:#f7a52f; box-shadow:0 .3rem 1rem #a84f2670; }.source-icon { display:grid; width:2.45rem; height:2.45rem; place-items:center; border:2px solid #fff3d5; border-radius:50% 50% 50% 0; color:#452000; font-size:1.15rem; background:#f7a52f; box-shadow:0 .3rem 1rem #a84f2670; transform:rotate(-45deg); }.source-icon span { transform:rotate(45deg); }.direction-marker { display:grid; width:3.5rem; height:3.5rem; place-items:center; border:3px solid #fff7e6; border-radius:50%; color:#fff; background:#6d45a0; box-shadow:0 .3rem 1rem #281642b3; }.direction-marker span { display:block; font-size:2.45rem; font-weight:950; line-height:1; text-shadow:0 .1rem .25rem #1e1136; transform-origin:center; }
.map-compass { position:relative; width:5rem; height:5rem; border:2px solid #eaf1ff; border-radius:50%; color:#f7fbff; font-size:.72rem; font-weight:900; background:#111a31e8; box-shadow:0 .5rem 1.5rem #05091480; backdrop-filter:blur(8px); }.map-compass span { position:absolute; display:grid; place-items:center; }.map-compass .compass-n { top:.35rem; left:50%; transform:translateX(-50%); color:#ffd18c; }.map-compass .compass-e { top:50%; right:.45rem; transform:translateY(-50%); }.map-compass .compass-s { bottom:.35rem; left:50%; transform:translateX(-50%); }.map-compass .compass-w { top:50%; left:.45rem; transform:translateY(-50%); }.map-compass .compass-needle { top:1.3rem; left:50%; color:#ffd18c; font-size:2rem; line-height:1; transform:translateX(-50%); text-shadow:0 .1rem .35rem #3b1b48; }.leaflet-control-zoom a { color:#243456!important; }.leaflet-popup-content-wrapper,.leaflet-popup-tip { color:#e9f1ff; background:#14203a; }.leaflet-popup-content { margin:.75rem .9rem; font-family:inherit; }.popup-title { display:block; margin-bottom:.2rem; font-weight:800; }.popup-meta { color:#a9b9d8; font-size:.78rem; }
@media (max-width:52rem) { .shell { width:min(100% - 1.25rem,80rem); }.topbar { margin-bottom:2.5rem; }.headline { align-items:start; flex-direction:column; gap:1rem; }.filters { grid-template-columns:1fr 1fr; }.filters .filter:first-child { grid-column:1/-1; }.map { height:32rem; } }
@media (max-width:30rem) { .nav a { padding:.5rem; }.filters { grid-template-columns:1fr; }.filters .filter:first-child { grid-column:auto; } }
</style>
{% vite_asset "frontend/src/entries/map.js" %}
</head>
<body>
<main class="shell">
<header class="topbar">
<a class="brand" href="{% url 'fireworks_detect:fireworks' %}"><span class="brand-mark">✦</span> Sound Signal</a>
<nav class="nav" aria-label="Fireworks navigation">
<a href="{% url 'fireworks_detect:fireworks' %}">Analyse</a>
<a href="{% url 'fireworks_detect:map' %}" aria-current="page">Map</a>
</nav>
</header>
{% include "fireworks_detect/includes/navigation.html" with active_page="map" %}
<section class="headline" aria-labelledby="map-title">
<div><p class="kicker">Manual report intelligence</p><h1 id="map-title">Sound activity map.</h1></div>
@@ -50,7 +29,7 @@
<section class="map-panel" aria-label="Manual fireworks report map">
<div class="map-header"><strong>Manual reports · privacy-preserving H3 cells</strong><span class="live"><i></i> H3 resolution {{ h3_resolution }} · sensor layer disabled</span></div>
<div class="map-wrap"><div id="event-map" class="map" aria-label="Interactive map of manual fireworks reports"></div>
<div class="map-wrap"><div id="event-map" class="map" data-h3-resolution="{{ h3_resolution }}" aria-label="Interactive map of manual fireworks reports"></div>
<aside class="legend" aria-label="Map legend"><h2>Manual reports</h2><div><span class="legend-dot"></span> Report marker at H3-cell centre</div><div><span class="legend-ring"></span> H3 cell (resolution {{ h3_resolution }})</div><div><span class="legend-line"></span> Saved compass direction</div></aside>
</div>
</section>
@@ -59,101 +38,5 @@
{{ h3_cells|json_script:"h3-cells-data" }}
{{ map_events|json_script:"map-events-data" }}
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
const map = L.map("event-map", { zoomControl: false, scrollWheelZoom: false }).setView([52.1326, 5.2913], 7);
L.control.zoom({ position: "bottomleft" }).addTo(map);
const compassControl = L.control({ position: "topright" });
compassControl.onAdd = () => {
const compass = L.DomUtil.create("div", "map-compass");
compass.setAttribute("role", "img");
compass.setAttribute("aria-label", "Map compass: north is up");
compass.innerHTML = "<span class=\"compass-n\">N</span><span class=\"compass-e\">E</span><span class=\"compass-s\">S</span><span class=\"compass-w\">W</span><span class=\"compass-needle\">↑</span>";
L.DomEvent.disableClickPropagation(compass);
return compass;
};
compassControl.addTo(map);
L.tileLayer("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png", {
maxZoom: 18,
attribution: "&copy; OpenStreetMap contributors",
}).addTo(map);
const h3Cells = JSON.parse(document.getElementById("h3-cells-data").textContent);
const reports = JSON.parse(document.getElementById("map-events-data").textContent);
const bounds = L.latLngBounds([]);
h3Cells.forEach((cell) => {
const polygon = L.polygon(cell.boundary, {
color: "#f59e0b", weight: 2, fillColor: "#f59e0b", fillOpacity: 0.25,
}).addTo(map);
polygon.bindPopup(
"<span class=\"popup-title\">H3 " + cell.cell + "</span>" +
"<span class=\"popup-meta\">" + cell.reports + " reports · " + cell.occurrences +
" occurrences · resolution {{ h3_resolution }}</span>"
);
bounds.extend(L.latLngBounds(cell.boundary));
});
function cardinalDirection(degrees) {
const directions = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
return directions[Math.floor(((degrees + 22.5) % 360) / 45)];
}
function destinationPoint(origin, bearingDegrees, distanceMetres) {
const earthRadius = 6378137;
const bearing = bearingDegrees * Math.PI / 180;
const latitude = origin[0] * Math.PI / 180;
const longitude = origin[1] * Math.PI / 180;
const angularDistance = distanceMetres / earthRadius;
const targetLatitude = Math.asin(
Math.sin(latitude) * Math.cos(angularDistance) +
Math.cos(latitude) * Math.sin(angularDistance) * Math.cos(bearing)
);
const targetLongitude = longitude + Math.atan2(
Math.sin(bearing) * Math.sin(angularDistance) * Math.cos(latitude),
Math.cos(angularDistance) - Math.sin(latitude) * Math.sin(targetLatitude)
);
return [targetLatitude * 180 / Math.PI, targetLongitude * 180 / Math.PI];
}
const reportIcon = L.divIcon({
className: "", html: "<div class=\"report-icon\">✦</div>", iconSize: [37, 37], iconAnchor: [19, 19],
});
reports.forEach((report) => {
const visualStatus = report.visually_confirmed ? "Visually confirmed" : "Not visually confirmed";
let detail = report.occurrences + " occurrence" + (report.occurrences === 1 ? "" : "s") +
" · " + visualStatus + "<br>Reported " + report.reported_on;
if (report.direction_degrees !== null) {
detail += "<br>Compass direction " + Math.round(report.direction_degrees) + "° (" + cardinalDirection(report.direction_degrees) + ")";
if (report.direction_accuracy_degrees !== null) {
detail += " (±" + Math.round(report.direction_accuracy_degrees) + "°)";
}
}
L.marker(report.center, { icon: reportIcon }).addTo(map).bindPopup(
"<span class=\"popup-title\">Manual report · H3 " + report.cell + "</span>" +
"<span class=\"popup-meta\">" + detail + "</span>"
);
if (report.direction_degrees !== null) {
const arrowEnd = destinationPoint(report.center, report.direction_degrees, 900);
L.polyline([report.center, arrowEnd], { color: "#fff7e6", weight: 9, opacity: 0.8 }).addTo(map);
L.polyline([report.center, arrowEnd], { color: "#6d45a0", weight: 5, opacity: 1 }).addTo(map);
const arrowIcon = L.divIcon({
className: "",
html: "<div class=\"direction-marker\"><span style=\"transform:rotate(" + report.direction_degrees + "deg)\">↑</span></div>",
iconSize: [56, 56], iconAnchor: [28, 28],
});
L.marker(arrowEnd, { icon: arrowIcon, interactive: false }).addTo(map);
}
});
if (bounds.isValid()) {
map.fitBounds(bounds.pad(0.18));
}
const range = document.getElementById("range");
document.querySelectorAll("#from-date, #to-date").forEach((input) => {
input.addEventListener("change", () => { range.value = "custom"; });
});
</script>
</body>
</html>
+3 -55
View File
@@ -1,48 +1,12 @@
{% load vite %}
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sound Signal · Fireworks detection</title>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
<style>
:root { --ink:#eaf0ff; --muted:#9caed1; --surface:#111a31; --surface-2:#17223e; --line:#2a3a61; --blue:#6aa8ff; --violet:#a78bfa; --fire:#ffb454; --danger:#ff727c; --success:#6ee7b7; }
* { box-sizing:border-box; }
body { min-width:320px; min-height:100vh; margin:0; color:var(--ink); font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:radial-gradient(circle at 10% 0%,#263a76 0,transparent 30rem),radial-gradient(circle at 90% 20%,#4d236c 0,transparent 28rem),#090e1d; }
.shell { width:min(100% - 2.5rem,70rem); margin:0 auto; padding:clamp(2rem,6vw,5rem) 0; }
.brand { display:flex; align-items:center; gap:.75rem; margin-bottom:clamp(2.5rem,6vw,5rem); font-size:.9rem; font-weight:800; letter-spacing:.11em; text-transform:uppercase; }
.brand-mark { display:grid; width:2.25rem; aspect-ratio:1; place-items:center; border-radius:.75rem; color:#141022; background:linear-gradient(135deg,#fcd34d,#fb7185); box-shadow:0 .5rem 1.5rem #fb718550; }
.intro { max-width:45rem; }
.kicker { margin:0 0 .8rem; color:#bfdbfe; font-size:.78rem; font-weight:800; letter-spacing:.15em; text-transform:uppercase; }
h1 { max-width:12ch; margin:0; font-size:clamp(2.6rem,7vw,5.75rem); line-height:.96; letter-spacing:-.065em; }
.lede { max-width:38rem; margin:1.5rem 0 2.5rem; color:var(--muted); font-size:clamp(1rem,2vw,1.18rem); line-height:1.65; }
.upload-card,.results-card { border:1px solid var(--line); border-radius:1.5rem; background:linear-gradient(145deg,#162240d9,#0e162bdd); box-shadow:0 1.5rem 4rem #02061680; backdrop-filter:blur(16px); }
.upload-card { padding:clamp(1rem,3vw,1.5rem); }
.drop-zone { display:grid; min-height:16rem; place-items:center; padding:2rem; border:1.5px dashed #5d75aa; border-radius:1rem; cursor:pointer; text-align:center; background:linear-gradient(135deg,#1b2a4e80,#291c4b66); transition:.2s ease; }
.drop-zone:hover,.drop-zone.dragging { border-color:var(--blue); transform:translateY(-2px); background:#203360a8; }
.drop-zone:focus-within { outline:3px solid #6aa8ff66; outline-offset:3px; }
.file-input { width:.1px; height:.1px; position:absolute; opacity:0; overflow:hidden; }
.upload-icon { display:grid; width:4rem; aspect-ratio:1; place-items:center; margin:0 auto 1rem; border-radius:50%; color:#dbeafe; font-size:1.8rem; background:#4777c94d; }
.drop-zone strong { display:block; font-size:1.15rem; }
.drop-zone span { display:block; margin-top:.4rem; color:var(--muted); font-size:.92rem; }
.file-name { min-height:1.3rem; margin:1rem 0 0; color:#c7d2fe; font-size:.9rem; overflow-wrap:anywhere; }
.form-footer { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.9rem .25rem 0; }
.file-note { margin:0; color:var(--muted); font-size:.8rem; }
button { display:inline-flex; align-items:center; justify-content:center; gap:.6rem; border:0; border-radius:.8rem; padding:.85rem 1.15rem; cursor:pointer; color:#10172c; font:inherit; font-weight:800; background:linear-gradient(135deg,#93c5fd,#c4b5fd); box-shadow:0 .5rem 1.25rem #8b5cf640; transition:transform .2s ease,filter .2s ease; }
button:hover { transform:translateY(-1px); filter:brightness(1.08); } button:disabled { cursor:wait; filter:saturate(.4); transform:none; }
.spinner { width:1rem; height:1rem; border:2px solid #263253; border-top-color:currentColor; border-radius:50%; animation:spin .75s linear infinite; }
.htmx-indicator { display:none; }.htmx-request.htmx-indicator { display:inline-block; }.upload-form.htmx-request button { pointer-events:none; }
#upload-status { min-height:1.4rem; margin:1rem .25rem 0; color:#c7d2fe; font-size:.9rem; } .upload-form.htmx-request + #upload-status { color:#fcd34d; }
#classification-results { margin-top:1.5rem; }
.results-card { padding:clamp(1.25rem,3vw,2rem); animation:reveal .35s ease-out; }
.result-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; } .result-heading h2 { margin:0; font-size:clamp(1.4rem,3vw,2rem); letter-spacing:-.04em; }.result-heading p { margin:.3rem 0 0; color:var(--muted); }
.result-status { padding:.4rem .65rem; border-radius:999px; color:#a7f3d0; font-size:.75rem; font-weight:800; white-space:nowrap; background:#065f464d; }
.meta { display:flex; flex-wrap:wrap; gap:.6rem; margin:1.5rem 0; }.meta span,.legend span { padding:.4rem .65rem; border:1px solid var(--line); border-radius:999px; color:#bdc9e5; font-size:.8rem; background:#101a31; }.legend { display:flex; flex-wrap:wrap; gap:.5rem; margin:0 0 1.25rem; }.legend .firework { color:#ffd18c; border-color:#c7721e80; }.legend .speech { color:#ffadb4; border-color:#d5485880; }
.result-grid { display:grid; grid-template-columns:minmax(0,1.25fr) minmax(18rem,.75fr); gap:1.25rem; }.result-group { padding:1.1rem; border:1px solid var(--line); border-radius:1rem; background:#0b1225a8; }.result-group h3 { margin:0 0 1rem; font-size:1rem; }.prediction-list { display:grid; gap:.75rem; margin:0; padding:0; list-style:none; }.prediction { --accent-color:#7799dd; position:relative; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.45rem .75rem; align-items:center; padding:.7rem .75rem; overflow:hidden; border:1px solid #26365b; border-left:3px solid var(--accent-color); border-radius:.7rem; background:#121c34; }.prediction--firework { --accent-color:var(--fire); background:linear-gradient(90deg,#7a421d55,#121c34); }.prediction--speech { --accent-color:var(--danger); background:linear-gradient(90deg,#6c213055,#121c34); }.prediction-label { min-width:0; font-weight:700; overflow-wrap:anywhere; }.prediction-score { color:#c4d1ed; font-size:.85rem; font-variant-numeric:tabular-nums; }.score-bar { grid-column:1/-1; height:.3rem; overflow:hidden; border-radius:999px; background:#263657; }.score-bar i { display:block; width:calc(var(--score) * 1%); height:100%; border-radius:inherit; background:var(--accent-color); }.peak-list { display:grid; gap:.7rem; }.peak-item { padding-bottom:.7rem; border-bottom:1px solid #253453; }.peak-item:last-child { padding-bottom:0; border-bottom:0; }.peak-time { color:#a9bce0; font-size:.78rem; }.peak-item .prediction { margin-top:.35rem; }.empty { margin:0; color:var(--muted); }.error-card { border-color:#a43d4d; background:linear-gradient(135deg,#4b1724dd,#1a1427dd); }.error-card h2 { color:#fecdd3; }.error-card p { color:#fecdd3; }
@keyframes spin { to { transform:rotate(360deg); } } @keyframes reveal { from { opacity:0; transform:translateY(.75rem); } }
@media (max-width:42rem) { .shell { width:min(100% - 1.25rem,70rem); }.form-footer,.result-heading { align-items:stretch; flex-direction:column; }.form-footer button { width:100%; }.result-grid { grid-template-columns:1fr; }.result-status { align-self:flex-start; } }
@media (prefers-reduced-motion:reduce) { *,::before,::after { scroll-behavior:auto!important; animation-duration:.01ms!important; transition-duration:.01ms!important; } }
</style>
{% vite_asset "frontend/src/entries/legacy-fireworks-home.js" %}
</head>
<body>
<main class="shell">
@@ -75,21 +39,5 @@
<section id="classification-results" aria-live="polite" aria-label="Classification results"></section>
</main>
<script>
const form = document.querySelector('.upload-form');
const dropZone = document.querySelector('#drop-zone');
const fileInput = document.querySelector('#audio-file');
const fileName = document.querySelector('#file-name');
const status = document.querySelector('#upload-status');
const showFile = (file) => { fileName.textContent = file ? file.name : 'No file selected'; };
fileInput.addEventListener('change', () => showFile(fileInput.files[0]));
['dragenter', 'dragover'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.add('dragging'); }));
['dragleave', 'drop'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.remove('dragging'); }));
dropZone.addEventListener('drop', (event) => { const [file] = event.dataTransfer.files; if (!file) return; fileInput.files = event.dataTransfer.files; showFile(file); });
form.addEventListener('htmx:beforeRequest', () => { status.textContent = 'Analysing your recording…'; form.setAttribute('aria-busy', 'true'); });
form.addEventListener('htmx:afterRequest', () => { status.textContent = ''; form.removeAttribute('aria-busy'); });
form.addEventListener('htmx:responseError', () => { status.textContent = 'Analysis could not be completed.'; });
</script>
</body>
</html>
+5 -10
View File
@@ -115,16 +115,11 @@ class ManualPendingEventTests(TestCase):
self.assertContains(response, "Report fireworks now")
self.assertContains(response, "I heard fireworks — send to Pending")
self.assertContains(response, "navigator.geolocation")
self.assertContains(response, "Capture direction")
self.assertContains(response, "DeviceOrientationEvent.requestPermission")
self.assertContains(response, 'manual-direction-panel" hidden')
self.assertContains(response, "DeviceOrientationEvent.requestPermission(true)")
self.assertContains(response, 'webkitCompassHeading" in event')
self.assertContains(response, "direction will update live")
self.assertContains(response, "Stop direction capture")
self.assertContains(response, "htmx.ajax")
self.assertContains(response, "htmx.min.js")
self.assertContains(response, "/static/vite/")
self.assertContains(response, 'type="module"')
def test_manual_event_appears_in_the_normal_event_list_with_its_details(self):
event = Event.objects.create(
original_filename="Manual fireworks report",
@@ -189,9 +184,9 @@ class ManualPendingEventTests(TestCase):
self.assertContains(response, "map-events-data")
self.assertContains(response, manual_cell)
self.assertContains(response, '"direction_degrees": 237.0')
self.assertContains(response, "cardinalDirection(report.direction_degrees)")
self.assertContains(response, "data-h3-resolution")
self.assertContains(response, 'type="module"')
self.assertContains(response, "sensor layer disabled")
self.assertContains(response, "Map compass: north is up")
self.assertContains(response, "Sensor events — coming soon")
self.assertNotContains(response, sensor_cell)
self.assertNotContains(response, "52.123456")