added scheduling

This commit is contained in:
Joren de Graaf
2026-10-10 16:03:14 +02:00
parent 51da498c0b
commit f68fb9e048
50 changed files with 768 additions and 67 deletions
@@ -1,9 +1,13 @@
{% load i18n %}
{% if event.source_type == "manual" %}
<h2>{% trans "Manual fireworks report" %}</h2>
<h2>{% if event.is_burst %}{% trans "Burst Event" %}{% else %}{% trans "Manual fireworks report" %}{% endif %}</h2>
<p class="meta">{% blocktrans with date=event.approved_at|date:"j M Y, H:i" %}Approved {{ date }} · Reported manually{% endblocktrans %}</p>
<h3>{% trans "Report details" %}</h3>
<div class="prediction prediction--firework"><strong>{% trans "Occurrences" %}</strong><span>{{ event.occurrences }}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Occurred" %}</strong><span>{% if event.occurrence_time_approximate %}{% trans "Approximately" %} {% endif %}{{ event.captured_at|date:"j M Y, H:i"|default:"Unknown" }}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Submitted" %}</strong><span>{% if event.submitted_at %}{{ event.submitted_at|date:"j M Y, H:i" }}{% else %}{% trans "Unknown" %}{% endif %}</span></div>
{% if event.is_burst %}<div class="prediction prediction--firework"><strong>{% trans "Duration" %}</strong><span>{% if event.observation_duration_minutes %}{{ event.observation_duration_minutes }} {% if event.observation_duration_kind == "estimated" %}{% trans "minutes (estimated)" %}{% else %}{% trans "minutes (measured)" %}{% endif %}{% else %}{% trans "Unknown" %}{% endif %}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Intensity" %}</strong><span>{% if event.burst_intensity %}{{ event.burst_intensity_display }} · {{ event.bangs_per_15_minutes|floatformat:1 }} {% trans "bangs per 15 minutes" %}{% else %}{% trans "Not rated" %}{% endif %}</span></div>{% endif %}
<div class="prediction prediction--firework"><strong>{% trans "Location" %}</strong><span>{{ event.location|default:"Not recorded" }}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Captured location" %}</strong><span>{{ event_h3_cell|default:"Not recorded" }}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Direction" %}</strong><span>{{ event.direction_display }}</span></div>
@@ -5,7 +5,7 @@
<span class="event__content">
{% if event.source_type == "manual" %}
<span class="event__source">{% trans "Manual report" %}</span>
<strong>{% trans "Manual fireworks report" %}</strong><br>
<strong>{% if event.is_burst %}{% trans "Burst Event" %}{% else %}{% trans "Manual fireworks report" %}{% endif %}</strong><br>
<small>{% blocktrans count count=event.occurrences %}{{ count }} occurrence{% plural %}{{ count }} occurrences{% endblocktrans %}{% if event.location %} · {{ event.location }}{% endif %}</small>
{% else %}
<span class="event__source">{% trans "Sensor classification" %}</span>
@@ -20,6 +20,12 @@
<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">
<div class="manual-report__occurrence">
<label class="manual-report__label" for="manual-occurred-at">{% trans "When did it happen?" %}</label>
<div class="manual-report__time-row"><input id="manual-occurred-at" name="occurred_at" type="datetime-local" aria-describedby="manual-time-help"><button id="manual-use-now" type="button">{% trans "Use now" %}</button></div>
<label class="manual-report__check"><input id="manual-time-approximate" name="time_approximate" type="checkbox"> {% trans "Time is approximate" %}</label>
<small id="manual-time-help">{% trans "Leave the time empty to use the submission time." %}</small>
</div>
<div class="manual-report__primary">
<div class="manual-report__quantity">
<label class="manual-report__label" for="manual-occurrences">{% trans "How many times did you hear it?" %}</label>
@@ -28,6 +34,13 @@
<input id="manual-occurrences" name="occurrences" type="number" min="1" max="1000" value="1" required inputmode="numeric">
<button id="manual-increase" type="button" aria-label="{% trans 'Increase occurrences' %}">+</button>
</div>
<p id="manual-burst-status" class="manual-report__burst-status" role="status">{% trans "Ordinary report" %}</p>
</div>
<div id="manual-burst-duration" class="manual-report__duration">
<label class="manual-report__label" for="manual-duration-minutes">{% trans "Estimated observation window (minutes, for 3+ bangs)" %}</label>
<input id="manual-duration-minutes" name="duration_minutes" type="number" min="1" max="1440" value="15" inputmode="numeric">
<label class="manual-report__check"><input id="manual-duration-confirmed" name="duration_confirmed" type="checkbox"> {% trans "Use this estimated window for burst intensity" %}</label>
<small>{% trans "Optional. Without an accepted window, BoomCast reports the count without an intensity rating." %}</small>
</div>
{% include "fireworks_detect/includes/manual_direction_panel.html" %}
</div>
@@ -55,7 +68,7 @@
<p id="burst-error" role="alert" hidden></p>
</div>
</section>
<button id="manual-submit" class="manual-report__submit" type="button"><span aria-hidden="true">🔥</span> <span id="manual-submit-label">{% trans "I heard fireworks" %}</span></button>
<button id="manual-submit" class="manual-report__submit" type="submit"><span aria-hidden="true">🔥</span> <span id="manual-submit-label">{% trans "I heard fireworks" %}</span></button>
</form>
<div id="manual-submission" class="manual-report__submission" aria-live="polite"></div>
<div id="manual-compass-home">
@@ -1,8 +1,8 @@
{% load i18n %}
<section class="map-panel" aria-label="{% trans "Manual fireworks report map" %}">
<div class="map-header"><strong>{% trans "Manual reports · privacy-preserving H3 cells" %}</strong><span class="live"><i></i> {% blocktrans with resolution=h3_resolution %}H3 resolution {{ resolution }} · sensor layer disabled{% endblocktrans %}</span></div>
<div class="map-wrap"><div id="event-map" class="map" data-h3-resolution="{{ h3_resolution }}" aria-label="{% trans "Interactive map of manual fireworks reports" %}"></div>
<aside class="legend" aria-label="{% trans "Map legend" %}"><h2>{% trans "Manual reports" %}</h2><div><span class="legend-dot"></span> {% trans "Report marker at H3-cell centre" %}</div><div><span class="legend-ring"></span> {% blocktrans with resolution=h3_resolution %}H3 cell (resolution {{ resolution }}){% endblocktrans %}</div><div><span class="legend-line"></span> {% trans "Saved compass direction" %}</div></aside>
<section class="map-panel" aria-label="{% trans "Reviewed fireworks report map" %}">
<div class="map-header"><strong>{% trans "Reviewed reports · privacy-preserving H3 cells" %}</strong><span class="live"><i></i> {% blocktrans with resolution=h3_resolution %}H3 resolution {{ resolution }}{% endblocktrans %}</span></div>
<div class="map-wrap"><div id="event-map" class="map" data-h3-resolution="{{ h3_resolution }}" aria-label="{% trans "Interactive map of reviewed fireworks reports" %}"></div>
<aside class="legend" aria-label="{% trans "Map legend" %}"><h2>{% trans "Map legend" %}</h2>{% if map_source != "sensor" %}<div><span class="legend-dot"></span> {% trans "Manual report" %}</div>{% endif %}{% if map_source == "sensor" or map_source == "all" %}<div><span class="legend-sensor"></span> {% trans "Sensor event" %}</div>{% endif %}<div><span class="legend-ring"></span> {% blocktrans with resolution=h3_resolution %}H3 cell (resolution {{ resolution }}){% endblocktrans %}</div>{% if map_source != "sensor" %}<div><span class="legend-line"></span> {% trans "Saved compass direction" %}</div>{% endif %}</aside>
</div>
</section>
{{ h3_cells|json_script:"h3-cells-data" }}
@@ -6,12 +6,24 @@
<p>{{ error }}</p>
{% else %}
<span class="manual-submission__icon" aria-hidden="true">✓</span>
<strong>{% trans "Report received!" %}</strong>
<strong>{% if updated %}{% trans "Report updated!" %}{% else %}{% trans "Report received!" %}{% endif %}</strong>
<p>{% trans "Thank you. Your report helps map fireworks nearby." %}</p>
<p class="manual-submission__summary">
{{ pending.created_at|date:"H:i" }} ·
{% if pending.occurrence_time_approximate %}{% trans "Approximately" %} {% endif %}{{ pending.captured_at|date:"j M Y, H:i" }} ·
{% blocktrans count count=pending.occurrences %}{{ count }} occurrence{% plural %}{{ count }} occurrences{% endblocktrans %}
{% if direction_label %} · {{ direction_label }} {{ pending.direction_degrees|floatformat:0 }}°{% endif %}
{% if pending.direction_degrees is not None %} · {{ direction_label|default:pending.direction_cardinal }} {{ pending.direction_degrees|floatformat:0 }}°{% endif %}
</p>
<p>{% if pending.is_burst %}{% trans "Burst Event" %}{% else %}{% trans "Ordinary report" %}{% endif %} · {% trans "Submitted" %} {{ pending.created_at|date:"j M Y, H:i" }}</p>
{% if pending.is_burst %}<p>{% trans "Duration" %}: {% if pending.observation_duration_minutes %}{{ pending.observation_duration_minutes }} {% trans "minutes (estimated)" %}{% else %}{% trans "Unknown" %}{% endif %}</p>
<p>{% trans "Intensity" %}: {% if pending.burst_intensity %}{{ pending.burst_intensity_display }} ({{ pending.bangs_per_15_minutes|floatformat:1 }} {% trans "bangs per 15 minutes" %}){% else %}{% trans "Not rated" %}{% endif %}</p>{% endif %}
{% if editable %}<form class="manual-submission__edit" method="post" action="{% url 'fireworks_detect:update_manual_pending' pending.pk %}" hx-post="{% url 'fireworks_detect:update_manual_pending' pending.pk %}" hx-target="#manual-submission" hx-swap="outerHTML">
{% csrf_token %}
<label for="manual-edit-count">{% trans "Correct bang count" %}</label>
<input id="manual-edit-count" name="occurrences" type="number" min="1" max="1000" value="{{ pending.occurrences }}" required>
<label for="manual-edit-duration">{% trans "Estimated minutes for a burst" %}</label>
<input id="manual-edit-duration" name="duration_minutes" type="number" min="1" max="1440" value="{{ pending.observation_duration_minutes|default:15 }}">
<label><input name="duration_confirmed" type="checkbox" {% if pending.observation_duration_kind %}checked{% endif %}> {% trans "Use this estimated window" %}</label>
<button type="submit">{% trans "Update report" %}</button>
</form>{% endif %}
{% endif %}
</div>
@@ -14,12 +14,12 @@
{% include "fireworks_detect/includes/navigation.html" with active_page="map" %}
<section class="headline" aria-labelledby="map-title">
<div><p class="kicker">{% trans "Manual report intelligence" %}</p><h1 id="map-title">{% trans "Sound activity map." %}</h1></div>
<p>{% trans "Reviewed manual reports with a captured location appear as their H3 cell, not their precise coordinates. Saved phone compass readings show the reported direction of the sound." %}</p>
<div><p class="kicker">{% trans "Reviewed sound reports" %}</p><h1 id="map-title">{% trans "Sound activity map." %}</h1></div>
<p>{% trans "Reviewed reports with a stored location appear at their H3 cell centre, not their precise coordinates. Sensor events use only saved event locations; device-reported coordinates are not trusted for this map." %}</p>
</section>
<form class="filters" method="get" action="{% url 'fireworks_detect:map' %}" aria-label="{% trans "Map filters" %}">
<div class="filter"><label for="event-source">{% trans "Source" %}</label><select id="event-source" disabled><option selected>{% trans "Manual reports" %}</option><option>{% trans "Sensor events — coming soon" %}</option></select></div>
<div class="filter"><label for="event-source">{% trans "Source" %}</label><select id="event-source" name="source"><option value="manual" {% if map_filters.source == "manual" %}selected{% endif %}>{% trans "Manual reports" %}</option><option value="sensor" {% if map_filters.source == "sensor" %}selected{% endif %}>{% trans "Sensor events" %}</option><option value="all" {% if map_filters.source == "all" %}selected{% endif %}>{% trans "Both sources" %}</option></select></div>
<div class="filter"><label for="range">{% trans "Period" %}</label><select id="range" name="range"><option value="7" {% if map_filters.range == "7" %}selected{% endif %}>{% trans "Last 7 days" %}</option><option value="14" {% if map_filters.range == "14" %}selected{% endif %}>{% trans "Last 2 weeks" %}</option><option value="30" {% if map_filters.range == "30" %}selected{% endif %}>{% trans "Last 30 days" %}</option><option value="all" {% if map_filters.range == "all" %}selected{% endif %}>{% trans "All time" %}</option><option value="custom" {% if map_filters.range == "custom" %}selected{% endif %}>{% trans "Custom range" %}</option></select></div>
<div class="filter"><label for="from-date">{% trans "From" %}</label><input id="from-date" name="from" type="date" value="{{ map_filters.date_from }}"></div>
<div class="filter"><label for="to-date">{% trans "To" %}</label><input id="to-date" name="to" type="date" value="{{ map_filters.date_to }}"></div>