add dashboard to home

This commit is contained in:
Joren de Graaf
2026-10-01 17:29:29 +02:00
parent 66db97b6f7
commit b676f35f0a
24 changed files with 214 additions and 82 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,48 @@
{% 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>Report fireworks · Sound Signal</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
{% vite_asset "frontend/src/entries/dashboard.js" %}
</head>
<body class="dashboard-page">
{% if user.is_authenticated %}<a class="profile-circle" href="{% url "user_settings" %}" aria-label="Open settings for {{ user.get_username }}" title="Settings">{{ user.get_username|first|upper }}</a>{% endif %}
<main class="dashboard-shell">
{% include "fireworks_detect/includes/navigation.html" %}
<section class="dashboard-intro" aria-labelledby="dashboard-title">
<p class="dashboard-kicker">Community reporting</p>
<h1 id="dashboard-title">Report what you heard.</h1>
<p>Quickly log fireworks when they happen. Your optional location is represented as an H3 cell on the map, rather than as precise coordinates.</p>
</section>
<section class="dashboard-section" aria-label="Quick fireworks report">
<div class="dashboard-report">
{% include "fireworks_detect/includes/manual_report_form.html" %}
</div>
</section>
<section class="dashboard-section dashboard-map" aria-labelledby="dashboard-map-title">
<header class="dashboard-section__header">
<div><p class="dashboard-kicker">Recent reports</p><h2 id="dashboard-map-title">Activity map</h2></div>
<a class="dashboard-link" href="{% url "fireworks_detect:map" %}">Open map controls <span aria-hidden="true">→</span></a>
</header>
{% include "fireworks_detect/includes/map_panel.html" %}
</section>
<section class="dashboard-section" aria-labelledby="dashboard-audio-title">
<header class="dashboard-section__header">
<div><p class="dashboard-kicker">Audio analysis</p><h2 id="dashboard-audio-title">Classify a recording</h2></div>
</header>
<div class="upload-card dashboard-upload">
{% include "fireworks_detect/includes/audio_upload_form.html" %}
</div>
</section>
</main>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
</body>
</html>
@@ -26,30 +26,8 @@
</section>
<section class="upload-card" aria-label="Upload audio for classification">
<form class="upload-form" action="{% url 'fireworks_detect:classify_upload' %}" method="post"
enctype="multipart/form-data" hx-post="{% url 'fireworks_detect:classify_upload' %}"
hx-target="#classification-results" hx-swap="innerHTML" hx-encoding="multipart/form-data"
hx-indicator="#upload-indicator">
{% csrf_token %}
<label class="drop-zone" id="drop-zone">
<input class="file-input" id="audio-file" type="file" name="audio"
accept="audio/*,.wav,.mp3,.m4a,.ogg,.flac,.aac,.opus" required>
<span>
<span class="upload-icon">↑</span>
<strong>Drop an audio file here</strong>
<span>or click to browse your device</span>
</span>
<span class="file-name" id="file-name">No file selected</span>
</label>
<div class="form-footer">
<p class="file-note">WAV, MP3, M4A, OGG and more · 25 MiB maximum</p>
<button type="submit"><span class="spinner htmx-indicator" id="upload-indicator"
aria-hidden="true"></span>Analyse audio</button>
</div>
<section id="classification-results" aria-live="polite" aria-label="Classification results"></section>
</form>
<p id="upload-status" role="status" aria-live="polite"></p>
</section>
{% include "fireworks_detect/includes/audio_upload_form.html" %}
</section>
</main>
</body>
@@ -0,0 +1,18 @@
<form class="upload-form" action="{% url "fireworks_detect:classify_upload" %}" method="post" enctype="multipart/form-data" hx-post="{% url "fireworks_detect:classify_upload" %}" hx-target="#classification-results" hx-swap="innerHTML" hx-encoding="multipart/form-data" hx-indicator="#upload-indicator">
{% csrf_token %}
<label class="drop-zone" id="drop-zone">
<input class="file-input" id="audio-file" type="file" name="audio" accept="audio/*,.wav,.mp3,.m4a,.ogg,.flac,.aac,.opus" required>
<span>
<span class="upload-icon">↑</span>
<strong>Drop an audio file here</strong>
<span>or click to browse your device</span>
</span>
<span class="file-name" id="file-name">No file selected</span>
</label>
<div class="form-footer">
<p class="file-note">WAV, MP3, M4A, OGG and more · 25 MiB maximum</p>
<button type="submit"><span class="spinner htmx-indicator" id="upload-indicator" aria-hidden="true"></span>Analyse audio</button>
</div>
<section id="classification-results" aria-live="polite" aria-label="Classification results"></section>
</form>
<p id="upload-status" role="status" aria-live="polite"></p>
@@ -0,0 +1,22 @@
<section class="manual-report" aria-labelledby="manual-report-title">
<p class="eyebrow">No recording needed</p>
<h2 class="manual-report__title" id="manual-report-title">Report fireworks now</h2>
<p class="manual-report__intro">Choose how many times you heard fireworks, then send it straight to Pending. The report is timestamped now.</p>
<form id="manual-report-form" action="{% url "fireworks_detect:submit_manual_pending" %}" method="post" hx-post="{% url "fireworks_detect:submit_manual_pending" %}" hx-target="#manual-submission" hx-swap="outerHTML">
{% csrf_token %}
<label class="manual-report__label" for="manual-occurrences">Number of occurrences</label>
<input id="manual-latitude" name="latitude" type="hidden">
<input id="manual-longitude" name="longitude" type="hidden">
<input id="manual-direction-degrees" name="direction_degrees" type="hidden">
<input id="manual-direction-accuracy" name="direction_accuracy_degrees" type="hidden">
<input id="manual-occurrences" name="occurrences" type="number" min="1" max="1000" value="1" required inputmode="numeric">
<div class="manual-direction-panel" id="manual-direction-panel" hidden>
<strong class="manual-direction-panel__heading">Direction <span>(optional)</span></strong>
<p class="manual-direction-panel__copy">Point the top of your phone toward the fireworks, then capture a single compass reading.</p>
<button id="manual-capture-direction" class="manual-direction-panel__button" type="button">Capture direction</button>
<div id="manual-direction-status" class="manual-direction-panel__status" aria-live="polite"></div>
</div>
<button id="manual-submit" class="manual-report__submit" type="button">I heard fireworks — send to Pending</button>
</form>
<div id="manual-submission" class="manual-report__submission" aria-live="polite"></div>
</section>
@@ -0,0 +1,8 @@
<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" 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>
{{ h3_cells|json_script:"h3-cells-data" }}
{{ map_events|json_script:"map-events-data" }}
@@ -27,16 +27,8 @@
<span class="map-tag">{{ mapped_event_count }} report{{ mapped_event_count|pluralize }}</span>
</form>
<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" 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>
{% include "fireworks_detect/includes/map_panel.html" %}
</main>
{{ 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>
</body>
</html>
+11
View File
@@ -120,6 +120,17 @@ class ManualPendingEventTests(TestCase):
self.assertContains(response, "htmx.min.js")
self.assertContains(response, "/static/vite/")
self.assertContains(response, 'type="module"')
self.assertContains(response, "Activity map")
self.assertContains(response, "Open map controls")
self.assertContains(response, "Classify a recording")
def test_old_route_preserves_the_previous_landing_page(self):
response = self.client.get(reverse("old_home"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Welkom Joren")
self.assertContains(response, "Open vuurwerk detector")
def test_manual_event_appears_in_the_normal_event_list_with_its_details(self):
event = Event.objects.create(
original_filename="Manual fireworks report",
+16
View File
@@ -145,6 +145,22 @@ def fireworks_map_view(request):
@never_cache
def dashboard_view(request):
map_events, h3_cells = _events_for_map({
"date_from": None,
"date_to": None,
"range": "all",
"visual": "all",
})
return render(request, "fireworks_detect/dashboard.html", {
"h3_resolution": h3_resolution(),
"h3_cells": h3_cells,
"map_events": map_events,
})
def events_view(request):
return render(request, "fireworks_detect/events.html")