add dashboard to home
This commit is contained in:
BIN
Binary file not shown.
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>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import "../styles/components/fireworks-navigation.css";
|
||||
import "../styles/pages/fireworks-home.css";
|
||||
import "../styles/pages/map.css";
|
||||
import "../styles/pages/dashboard.css";
|
||||
import "../styles/theme.css";
|
||||
import "../scripts/theme.js";
|
||||
import "../scripts/manual-report.js";
|
||||
import "../scripts/audio-upload.js";
|
||||
import "../scripts/event-map.js";
|
||||
@@ -92,7 +92,9 @@
|
||||
}
|
||||
|
||||
const range = document.getElementById("range");
|
||||
document.querySelectorAll("#from-date, #to-date").forEach((input) => {
|
||||
input.addEventListener("change", () => { range.value = "custom"; });
|
||||
});
|
||||
if (range) {
|
||||
document.querySelectorAll("#from-date, #to-date").forEach((input) => {
|
||||
input.addEventListener("change", () => { range.value = "custom"; });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
:root {
|
||||
--dashboard-ink: #edf3ff;
|
||||
--dashboard-muted: #aab9d8;
|
||||
--dashboard-line: #2b3d68;
|
||||
--dashboard-surface: #111a31;
|
||||
--dashboard-surface-raised: #172443;
|
||||
}
|
||||
body.dashboard-page {
|
||||
display: block;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
color: var(--dashboard-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 31rem), radial-gradient(circle at 96% 100%, #512363 0, transparent 29rem), #090e1d;
|
||||
}
|
||||
.dashboard-shell { width: min(100% - 2.5rem, 70rem); margin: 0 auto; padding: clamp(2rem, 6vw, 5rem) 0; }
|
||||
.dashboard-intro { max-width: 44rem; margin-bottom: 2rem; }
|
||||
.dashboard-kicker { margin: 0 0 .8rem; color: #bfdbfe; font-size: .76rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
|
||||
.dashboard-intro h1 { max-width: 11ch; margin: 0; color: var(--dashboard-ink); font-size: clamp(2.8rem, 7vw, 5.5rem); line-height: .94; letter-spacing: -.065em; }
|
||||
.dashboard-intro p:last-child { max-width: 42rem; margin: 1.25rem 0 0; color: var(--dashboard-muted); font-size: clamp(1rem, 2vw, 1.16rem); line-height: 1.65; }
|
||||
.dashboard-section { margin-top: 2.25rem; }
|
||||
.dashboard-section__header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
|
||||
.dashboard-section__header h2 { margin: .25rem 0 0; color: var(--dashboard-ink); font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: -.045em; }
|
||||
.dashboard-section__header .dashboard-kicker { margin-bottom: .3rem; }
|
||||
.dashboard-link { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .7rem 1rem; border: 1px solid #789ed7; border-radius: .7rem; color: #dceaff; font-size: .9rem; font-weight: 800; text-decoration: none; background: #1b2e52; transition: transform .2s ease, background .2s ease; }
|
||||
.dashboard-link:hover { transform: translateY(-1px); background: #274574; }
|
||||
.dashboard-report { position: relative; overflow: hidden; padding: clamp(1.35rem, 4vw, 2.4rem); border: 1px solid #b86c2a; border-radius: 1.35rem; background: linear-gradient(135deg, #4a2b16e8, #171225dd); box-shadow: 0 1.5rem 4rem #02061680; }
|
||||
.dashboard-report::after { content: ""; position: absolute; width: 17rem; height: 17rem; right: -9rem; top: -10rem; border-radius: 50%; background: #ffb4541f; pointer-events: none; }
|
||||
.dashboard-report > * { position: relative; }
|
||||
.dashboard-report .eyebrow { margin: 0 0 .7rem; color: #ffd08a; font-size: .76rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
|
||||
.dashboard-report .eyebrow::before { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-right: .45rem; border-radius: 50%; background: #ffbd62; box-shadow: 0 0 0 .25rem #fbbf2430; }
|
||||
.dashboard-report .manual-report__title { max-width: 14ch; margin: 0 0 .6rem; color: #fff6e7; font-size: clamp(2rem, 5vw, 3.4rem); line-height: .98; letter-spacing: -.06em; }
|
||||
.dashboard-report .manual-report__intro { max-width: 42rem; margin: 0 0 1.35rem; color: #f3c8a3; line-height: 1.55; }
|
||||
.dashboard-report .manual-report__label { display: block; margin-bottom: .5rem; color: #fff2df; font-weight: 800; }
|
||||
.dashboard-report #manual-occurrences { width: min(100%, 36rem); min-height: 3.25rem; display: block; margin-bottom: 1rem; padding: .75rem .9rem; border: 1px solid #e2934a; border-radius: .75rem; color: #edf3ff; font: inherit; font-weight: 800; background: #151b31; }
|
||||
.dashboard-report .manual-direction-panel { width: min(100%, 36rem); margin: 0 0 1rem; padding: 1rem; border: 1px solid #8d5bb5; border-radius: .75rem; background: #241b38; }
|
||||
.dashboard-report .manual-direction-panel__heading { display: block; margin-bottom: .35rem; }.dashboard-report .manual-direction-panel__heading span { color: #c7b5eb; font-weight: 600; }.dashboard-report .manual-direction-panel__copy { margin: 0 0 .75rem; color: #d4c6ef; font-size: .88rem; line-height: 1.45; }.dashboard-report .manual-direction-panel__button { min-height: 2.75rem; padding: .65rem .9rem; border: 1px solid #c3a5eb; border-radius: .65rem; color: #211234; font: inherit; font-weight: 850; background: #d8c1fb; cursor: pointer; }.dashboard-report .manual-direction-panel__status { min-height: 1.4rem; margin-top: .7rem; color: #e5dcf7; font-size: .9rem; }
|
||||
.dashboard-report .manual-report__submit { width: min(100%, 36rem); min-height: 4.5rem; border: 0; border-radius: 1rem; color: #281306; font: inherit; font-size: clamp(1.05rem, 2vw, 1.3rem); font-weight: 900; background: linear-gradient(135deg, #ffd18c, #ff8f5b); box-shadow: 0 .75rem 1.8rem #d664344d; cursor: pointer; }.dashboard-report .manual-report__submission { min-height: 1.5rem; margin-top: 1rem; color: #ffd18c; }
|
||||
.dashboard-map .map { height: clamp(22rem, 48vh, 34rem); }.dashboard-map .map-header { background: #121d37; }.dashboard-map .legend { display: none; }
|
||||
.dashboard-upload { padding: clamp(1rem, 3vw, 1.5rem); }
|
||||
.dashboard-upload .drop-zone { min-height: 12rem; }
|
||||
@media (max-width: 42rem) { .dashboard-shell { width: min(100% - 1.25rem, 70rem); }.dashboard-section__header { align-items: flex-start; flex-direction: column; }.dashboard-link { width: 100%; }.dashboard-map .map { height: 23rem; } }
|
||||
:root[data-theme="light"] body.dashboard-page { --dashboard-ink: #172b50; --dashboard-muted: #596d88; --dashboard-line: #cbd9ed; --dashboard-surface: #fff; --dashboard-surface-raised: #f4f8ff; background: radial-gradient(circle at 8% 0%, #dbeaff 0, transparent 31rem), radial-gradient(circle at 96% 100%, #eee2ff 0, transparent 29rem), #f4f7fc; }
|
||||
:root[data-theme="light"] .dashboard-intro h1, :root[data-theme="light"] .dashboard-section__header h2 { color: #172b50 !important; }
|
||||
:root[data-theme="light"] .dashboard-kicker { color: #3f6fa9 !important; }
|
||||
:root[data-theme="light"] .dashboard-link { border-color: #9fc0e9; color: #234a7b; background: #e6f0ff; }.dashboard-link:hover { background: #d8e8ff; }
|
||||
:root[data-theme="light"] .dashboard-report { border-color: #eca851; background: linear-gradient(145deg, #fff8ef, #ffe0bb); box-shadow: 0 1.4rem 3.4rem rgba(116, 69, 25, .18); }
|
||||
:root[data-theme="light"] .dashboard-report .eyebrow { color: #9f4d16 !important; }:root[data-theme="light"] .dashboard-report .manual-report__title { color: #4a2510 !important; }:root[data-theme="light"] .dashboard-report .manual-report__intro { color: #70411d !important; }:root[data-theme="light"] .dashboard-report .manual-report__label { color: #54311b; }:root[data-theme="light"] .dashboard-report #manual-occurrences { border-color: #dfaa68; color: #322014; background: #fffdfa; }:root[data-theme="light"] .dashboard-report .manual-direction-panel { border-color: #d9b4d8; background: #fff5fc; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__heading { color: #492846; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__heading span { color: #70466d; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__copy { color: #694b68; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__button { border-color: #b68bb5; color: #321a34; background: #ead2eb; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__status { color: #6b4267; }:root[data-theme="light"] .dashboard-report .manual-report__submission { color: #87421b; }
|
||||
:root[data-theme="light"] .dashboard-map .map-header { background: #f2f6fc !important; }
|
||||
|
||||
.dashboard-page .profile-circle { display: grid; width: 3rem; height: 3rem; position: fixed; top: 1.25rem; right: 1.25rem; place-items: center; border: 1px solid #d0c0ff; border-radius: 50%; z-index: 1201; color: #17132b; font-weight: 900; text-decoration: none; background: linear-gradient(135deg, #fcd34d, #c4a5fd); box-shadow: 0 .5rem 1.5rem #01030c66; }.dashboard-page .profile-circle:focus-visible { outline: 3px solid #a5c9ff80; outline-offset: 3px; }
|
||||
@@ -24,28 +24,7 @@
|
||||
<span class="hint">Audio analysis · Sensor map</span>
|
||||
</div>
|
||||
</main>
|
||||
<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>
|
||||
{% include "fireworks_detect/includes/manual_report_form.html" %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Binary file not shown.
+14
-24
@@ -1,33 +1,23 @@
|
||||
"""
|
||||
URL configuration for myproject project.
|
||||
"""URL configuration for the project."""
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/6.1/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.conf import settings
|
||||
from django.urls import path, include, re_path
|
||||
from django.urls import include, path, re_path
|
||||
from django.views.static import serve
|
||||
|
||||
from fireworks_detect.views import dashboard_view
|
||||
from hello.views import hello_view
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('login/', auth_views.LoginView.as_view(template_name='members/login.html'), name='login'),
|
||||
path('classifications/', include('fireworks_detect.classification_urls')),
|
||||
path('settings/', include('members.settings_urls')),
|
||||
path('', include('hello.urls')),
|
||||
path('fireworks/', include('fireworks_detect.urls')),
|
||||
path('members/', include('members.urls'))
|
||||
path("admin/", admin.site.urls),
|
||||
path("login/", auth_views.LoginView.as_view(template_name="members/login.html"), name="login"),
|
||||
path("classifications/", include("fireworks_detect.classification_urls")),
|
||||
path("settings/", include("members.settings_urls")),
|
||||
path("fireworks/", include("fireworks_detect.urls")),
|
||||
path("members/", include("members.urls")),
|
||||
path("old/", hello_view, name="old_home"),
|
||||
path("", dashboard_view, name="hello"),
|
||||
]
|
||||
|
||||
urlpatterns += [re_path(r"^static/(?P<path>.*)$", serve, {"document_root": settings.STATIC_ROOT})]
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
/* empty css */import"./fireworks-home.js-BAmW5fGZ.js";import"./map.js-DCafyyWY.js";import"../../../theme-BwRovl8e.js";import"../../../manual-report-BMn4sn8O.js";
|
||||
@@ -0,0 +1 @@
|
||||
/* empty css */import"./fireworks-home.js-BAmW5fGZ.js";import"./map.js-DCafyyWY.js";import"../../../theme-BwRovl8e.js";import"../../../manual-report-BMn4sn8O.js";
|
||||
@@ -0,0 +1 @@
|
||||
import"../../../theme-BwRovl8e.js";import"../../../manual-report-BMn4sn8O.js";
|
||||
@@ -0,0 +1 @@
|
||||
/* empty css */import"../../../theme-BwRovl8e.js";const p=document.getElementById("event-map"),g=p.dataset.h3Resolution,o=L.map(p,{zoomControl:!1,scrollWheelZoom:!1}).setView([52.1326,5.2913],7);L.control.zoom({position:"bottomleft"}).addTo(o);const u=L.control({position:"topright"});u.onAdd=()=>{const t=L.DomUtil.create("div","map-compass");return t.setAttribute("role","img"),t.setAttribute("aria-label","Map compass: north is up"),t.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(t),t};u.addTo(o);L.tileLayer("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png",{maxZoom:18,attribution:"© OpenStreetMap contributors"}).addTo(o);const f=JSON.parse(document.getElementById("h3-cells-data").textContent),M=JSON.parse(document.getElementById("map-events-data").textContent),r=L.latLngBounds([]);f.forEach(t=>{L.polygon(t.boundary,{color:"#f59e0b",weight:2,fillColor:"#f59e0b",fillOpacity:.25}).addTo(o).bindPopup('<span class="popup-title">H3 '+t.cell+'</span><span class="popup-meta">'+t.reports+" reports · "+t.occurrences+" occurrences · resolution "+g+"</span>"),r.extend(L.latLngBounds(t.boundary))});function y(t){return["N","NE","E","SE","S","SW","W","NW"][Math.floor((t+22.5)%360/45)]}function b(t,e,n){const s=e*Math.PI/180,c=t[0]*Math.PI/180,m=t[1]*Math.PI/180,i=n/6378137,d=Math.asin(Math.sin(c)*Math.cos(i)+Math.cos(c)*Math.sin(i)*Math.cos(s)),h=m+Math.atan2(Math.sin(s)*Math.sin(i)*Math.cos(c),Math.cos(i)-Math.sin(c)*Math.sin(d));return[d*180/Math.PI,h*180/Math.PI]}const v=L.divIcon({className:"",html:'<div class="report-icon">✦</div>',iconSize:[37,37],iconAnchor:[19,19]});M.forEach(t=>{const e=t.visually_confirmed?"Visually confirmed":"Not visually confirmed";let n=t.occurrences+" occurrence"+(t.occurrences===1?"":"s")+" · "+e+"<br>Reported "+t.reported_on;if(t.direction_degrees!==null&&(n+="<br>Compass direction "+Math.round(t.direction_degrees)+"° ("+y(t.direction_degrees)+")",t.direction_accuracy_degrees!==null&&(n+=" (±"+Math.round(t.direction_accuracy_degrees)+"°)")),L.marker(t.center,{icon:v}).addTo(o).bindPopup('<span class="popup-title">Manual report · H3 '+t.cell+'</span><span class="popup-meta">'+n+"</span>"),t.direction_degrees!==null){const a=b(t.center,t.direction_degrees,900);L.polyline([t.center,a],{color:"#fff7e6",weight:9,opacity:.8}).addTo(o),L.polyline([t.center,a],{color:"#6d45a0",weight:5,opacity:1}).addTo(o);const s=L.divIcon({className:"",html:'<div class="direction-marker"><span style="transform:rotate('+t.direction_degrees+'deg)">↑</span></div>',iconSize:[56,56],iconAnchor:[28,28]});L.marker(a,{icon:s,interactive:!1}).addTo(o)}});r.isValid()&&o.fitBounds(r.pad(.18));const l=document.getElementById("range");l&&document.querySelectorAll("#from-date, #to-date").forEach(t=>{t.addEventListener("change",()=>{l.value="custom"})});
|
||||
@@ -0,0 +1 @@
|
||||
const a=document.querySelector("#manual-report-form"),m=document.querySelector("#manual-submit"),g=document.querySelector("#manual-submission"),C=document.querySelector("#manual-latitude"),b=document.querySelector("#manual-longitude"),w=document.querySelector("#manual-direction-degrees"),y=document.querySelector("#manual-direction-accuracy"),c=document.querySelector("#manual-capture-direction"),t=document.querySelector("#manual-direction-status"),v=document.querySelector("#manual-direction-panel"),f=/Android|iPhone|iPad|iPod|IEMobile|Opera Mini/.test(navigator.userAgent)||navigator.userAgent.includes("Macintosh")&&navigator.maxTouchPoints>1;f&&(v.hidden=!1);let o,r;const l=e=>Number.isFinite(e),S=e=>["N","NE","E","SE","S","SW","W","NW"][Math.floor((e+22.5)%360/45)],p=e=>Number(e.toFixed(1)).toString(),s=()=>{o&&window.removeEventListener("deviceorientation",o),window.clearTimeout(r),o=null,r=null},x=(e,i)=>{const n=i===null?"Accuracy unavailable":"Accuracy: ±"+p(i)+"°";t.innerHTML="<strong>"+p(e)+"° · "+S(e)+"</strong><br>"+n,c.textContent="Stop direction capture"},h=()=>{s(),t.textContent="Point the top of your phone toward the sound — direction will update live.",o=e=>{const i="webkitCompassHeading"in e,n=l(e.webkitCompassHeading)?e.webkitCompassHeading:!i&&e.absolute&&l(e.alpha)?(360-e.alpha)%360:null;if(n===null||n<0||n>=360)return;const u=l(e.webkitCompassAccuracy)&&e.webkitCompassAccuracy>=0?e.webkitCompassAccuracy:null;w.value=n,y.value=u===null?"":u,x(n,u),window.clearTimeout(r)},window.addEventListener("deviceorientation",o),r=window.setTimeout(()=>{s(),c.textContent="Capture direction",t.textContent="Compass unavailable on this device."},15e3)},q=async()=>{if(o){s(),c.textContent="Capture again";return}if(!window.isSecureContext){t.textContent="Compass capture requires a secure HTTPS connection.";return}if(typeof window.DeviceOrientationEvent>"u"){t.textContent="Compass unavailable on this device.";return}if(typeof DeviceOrientationEvent.requestPermission=="function"){t.textContent="Requesting compass permission…";try{if(await DeviceOrientationEvent.requestPermission(!0)!=="granted"){t.textContent="Compass permission denied.";return}}catch{t.textContent="Compass permission denied.";return}}h()},d=()=>{s(),m.disabled=!0,window.htmx?htmx.ajax("POST",a.action,{source:a,target:"#manual-submission",swap:"outerHTML"}):a.submit()};c.addEventListener("click",q);m.addEventListener("click",()=>{if(!navigator.geolocation){d();return}g.textContent="Requesting your optional location…",navigator.geolocation.getCurrentPosition(e=>{C.value=e.coords.latitude,b.value=e.coords.longitude,d()},()=>d(),{enableHighAccuracy:!1,maximumAge:3e5,timeout:1e4})});document.body.addEventListener("htmx:afterRequest",e=>{e.detail.elt===a&&(m.disabled=!1)});
|
||||
Reference in New Issue
Block a user