diff --git a/FIELD_NOTES.md b/FIELD_NOTES.md new file mode 100644 index 0000000..af014ce --- /dev/null +++ b/FIELD_NOTES.md @@ -0,0 +1,105 @@ +# Field notes: specification review and implementation + +## Review decisions + +The requested separation between recorded evidence and human context fits the +application. Inspection found these differences from the illustrative spec: + +1. **Bursts are Event/PendingEvent records with occurrences >= 3**, not separate + incidents. The live browser listener has no server-side event until submission. + `FieldNoteContext` is a small, author-owned association record, with no incident + timestamps, count, audio or classification of its own. It holds a draft UUID and + later references the existing PendingEvent or Event. Multiple notes attach once + to that report rather than being copied across individual bangs. +2. **Pending manual ownership was session-based.** Note contexts preserve author + attribution across sessions without inventing ownership for old reports. New + draft tokens are signed, author-bound and expire after seven days. A submitted + token cannot be reused for another report; the UI rotates it on success. Late + note saves still follow the original report through moderation. +3. **The frontend uses custom SCSS, HTMX and existing theme tokens**, not Bootstrap. + These conventions are reused; no second CSS framework is introduced. +4. **There was no incident export pipeline or event merge UI.** Added CSV/JSON + note exports through one permission-filtered service. PDF export and event + regrouping interfaces remain outside this pass. A tested regrouping service + preserves note provenance for future merge operations. +5. **Corrections are new notes.** No edit/delete route or editable admin form is + provided. This keeps original text and entry timestamps unchanged. Verification + labels describe the author's stated assessment, not automated validation. +6. **Timezone follows Django's active timezone**, currently Europe/Amsterdam; + there is no per-user timezone setting. Datetimes are stored timezone-aware, + with the timezone shown beside entry/observation times. Adding a user timezone + preference later can use the same fields. + +## Privacy and permissions + +- Notes default to private, unknown source and unverified. Only content is required. +- An authenticated author can read/create their own notes. Reportable notes are + still not public and do not become verified. +- Approved events are already public; authenticated users may add their own notes + to them. Pending targets require existing session ownership, sensor ownership, + a note context owned by that user, or staff `view_pendingevent` permission. +- `view_all_fieldnotes` explicitly allows reading other authors' private notes. + Staff status alone does not. Django superusers have this permission. +- `export_reportable_fieldnotes` explicitly allows exporting other authors' + reportable notes. Without it, exports contain only the caller's reportable notes. + **Private notes are excluded even for superusers.** Read-all permission does not + imply export-all permission. +- Every export starts with `field_notes.reportable_notes(user)`. Future PDF/API + reporting must use this service, rather than `visible_to()` or raw relations. +- CSV escapes formula-like user values; HTML renders escaped plain text and keeps + line breaks. Public event/map responses do not serialize note data. +- Link operations are author-only, POST/CSRF-protected, and only accept an existing + approved event. Existing linked notes cannot be silently reparented through the + user endpoint. Each standalone observation context can hold several live notes; + linking it moves that observation's notes together. +- Admin is read-only and uses the same visibility boundary. Association history + is similarly scoped. ORM `save()` rejects note/history edits; direct SQL or + `QuerySet.update()` is not an application editing interface and must not be used + to bypass this policy. + +## Lifecycle and interfaces + +- The dashboard's Add field note form is adjacent to quick reporting and updates + only its own HTMX region, leaving listener/audio controls mounted and running. +- Submission binds the draft context to Pending Review. Approval atomically moves + contexts to the approved Event and records the moderator (or system/null actor + for non-request approvals). Notes retain their original entry timestamps. +- Denial/deletion clears the foreign key but preserves the note and its historical + target ID. The observation remains available in My field notes. +- `regroup_event_notes(actor, source, target)` requires staff, `change_event` and + `view_all_fieldnotes`. Existing or future merge code must call it inside its + transaction before deleting the source. It moves associations without copying + notes and records previous/current event IDs. No automatic grouping is added. +- Historical event details show only visible notes and counts. Direct event pages + and the archive now have normal links for no-JavaScript access. +- `/fireworks/notes/` creates standalone observations and lists accessible notes; + event/pending filters provide contextual forms. `/fireworks/notes/export/json/` + and `/fireworks/notes/export/csv/` export authorised reportable notes, optionally + filtered by approved event ID. +- Standard POST forms redirect after saving. HTMX forms return their own updated + region; validation responses intentionally use HTTP 200 so HTMX renders errors. +- Occurrence and entry dates are displayed separately. New information is appended + chronologically; author-supplied observed time does not reorder entry history. + +## Validation and deployment + +Migration `0014` adds three tables, constraints and an author/time index. It does +not rewrite existing event data. Apply with `python manage.py migrate` after +updating the application; build assets with the existing `npm run build` command. +No firmware changes or version bump are needed for this Django-only feature. + +Automated tests cover defaults, escaping, anonymous/cross-user access, explicit +staff permissions, private export exclusion (including superuser), source and +uncertainty preservation, observed/entry timestamps, append-only saves, invalid +forms, active draft binding, approval, late saves, stale-token rejection, +standalone linking, regrouping and denied-report retention. + +Browser verification uses the actual Django application with an isolated SQLite +DB under `/tmp`. It covers HTMX note saves during a **synthetic browser audio +stream**, listener continuity, report binding/token rotation, historical notes, +mobile/desktop layouts, dark/light appearance, accessibility labels, exports and +standard form submission in a JavaScript-disabled browser context. This is not a +microphone/hardware validation and does not claim classification accuracy. + +Out of scope: attachments, CCTV files, witness identity management, PDF generation, +new incident/merge interfaces, full timeline redesign, or changing detection logic. diff --git a/fireworks_detect/__pycache__/admin.cpython-312.pyc b/fireworks_detect/__pycache__/admin.cpython-312.pyc index 7a9ba43..862dd98 100644 Binary files a/fireworks_detect/__pycache__/admin.cpython-312.pyc and b/fireworks_detect/__pycache__/admin.cpython-312.pyc differ diff --git a/fireworks_detect/__pycache__/admin.cpython-313.pyc b/fireworks_detect/__pycache__/admin.cpython-313.pyc index 9a95c3f..571cc12 100644 Binary files a/fireworks_detect/__pycache__/admin.cpython-313.pyc and b/fireworks_detect/__pycache__/admin.cpython-313.pyc differ diff --git a/fireworks_detect/__pycache__/field_notes.cpython-312.pyc b/fireworks_detect/__pycache__/field_notes.cpython-312.pyc new file mode 100644 index 0000000..ca74b3e Binary files /dev/null and b/fireworks_detect/__pycache__/field_notes.cpython-312.pyc differ diff --git a/fireworks_detect/__pycache__/field_notes.cpython-313.pyc b/fireworks_detect/__pycache__/field_notes.cpython-313.pyc new file mode 100644 index 0000000..1fe1450 Binary files /dev/null and b/fireworks_detect/__pycache__/field_notes.cpython-313.pyc differ diff --git a/fireworks_detect/__pycache__/forms.cpython-312.pyc b/fireworks_detect/__pycache__/forms.cpython-312.pyc new file mode 100644 index 0000000..ce62538 Binary files /dev/null and b/fireworks_detect/__pycache__/forms.cpython-312.pyc differ diff --git a/fireworks_detect/__pycache__/forms.cpython-313.pyc b/fireworks_detect/__pycache__/forms.cpython-313.pyc new file mode 100644 index 0000000..a79d3da Binary files /dev/null and b/fireworks_detect/__pycache__/forms.cpython-313.pyc differ diff --git a/fireworks_detect/__pycache__/models.cpython-312.pyc b/fireworks_detect/__pycache__/models.cpython-312.pyc index d53d28a..f6e0f57 100644 Binary files a/fireworks_detect/__pycache__/models.cpython-312.pyc and b/fireworks_detect/__pycache__/models.cpython-312.pyc differ diff --git a/fireworks_detect/__pycache__/models.cpython-313.pyc b/fireworks_detect/__pycache__/models.cpython-313.pyc index c446bb7..7e9c35c 100644 Binary files a/fireworks_detect/__pycache__/models.cpython-313.pyc and b/fireworks_detect/__pycache__/models.cpython-313.pyc differ diff --git a/fireworks_detect/__pycache__/note_views.cpython-312.pyc b/fireworks_detect/__pycache__/note_views.cpython-312.pyc new file mode 100644 index 0000000..9cff4e2 Binary files /dev/null and b/fireworks_detect/__pycache__/note_views.cpython-312.pyc differ diff --git a/fireworks_detect/__pycache__/note_views.cpython-313.pyc b/fireworks_detect/__pycache__/note_views.cpython-313.pyc new file mode 100644 index 0000000..0cf937c Binary files /dev/null and b/fireworks_detect/__pycache__/note_views.cpython-313.pyc differ diff --git a/fireworks_detect/__pycache__/test_field_notes.cpython-313.pyc b/fireworks_detect/__pycache__/test_field_notes.cpython-313.pyc new file mode 100644 index 0000000..909491d Binary files /dev/null and b/fireworks_detect/__pycache__/test_field_notes.cpython-313.pyc differ diff --git a/fireworks_detect/__pycache__/urls.cpython-312.pyc b/fireworks_detect/__pycache__/urls.cpython-312.pyc index 5a2f055..f7d2c50 100644 Binary files a/fireworks_detect/__pycache__/urls.cpython-312.pyc and b/fireworks_detect/__pycache__/urls.cpython-312.pyc differ diff --git a/fireworks_detect/__pycache__/urls.cpython-313.pyc b/fireworks_detect/__pycache__/urls.cpython-313.pyc index 798a095..27cb2a7 100644 Binary files a/fireworks_detect/__pycache__/urls.cpython-313.pyc and b/fireworks_detect/__pycache__/urls.cpython-313.pyc differ diff --git a/fireworks_detect/__pycache__/views.cpython-312.pyc b/fireworks_detect/__pycache__/views.cpython-312.pyc index fec4f31..b6bc7e0 100644 Binary files a/fireworks_detect/__pycache__/views.cpython-312.pyc and b/fireworks_detect/__pycache__/views.cpython-312.pyc differ diff --git a/fireworks_detect/__pycache__/views.cpython-313.pyc b/fireworks_detect/__pycache__/views.cpython-313.pyc index 1debce5..3352251 100644 Binary files a/fireworks_detect/__pycache__/views.cpython-313.pyc and b/fireworks_detect/__pycache__/views.cpython-313.pyc differ diff --git a/fireworks_detect/admin.py b/fireworks_detect/admin.py index 8057b62..5fe0bf8 100644 --- a/fireworks_detect/admin.py +++ b/fireworks_detect/admin.py @@ -134,7 +134,7 @@ class PendingEventAdmin(ClassificationAdmin): def approve_selected(self, request, queryset): approved = 0 for pending in queryset: - pending.approve() + pending.approve(actor=request.user) approved += 1 self.message_user(request, ngettext("%(count)d sample approved and moved to Events.", "%(count)d samples approved and moved to Events.", approved) % {"count": approved}, messages.SUCCESS) @@ -198,3 +198,47 @@ class SensorAdmin(admin.ModelAdmin): sensor = queryset.get() token = sensor.issue_token() self.message_user(request, format_html(_("Copy this token now; it is not stored and will not be shown again: {}"), token), messages.WARNING) + + +from .models import FieldNote, FieldNoteAssociation + + +@admin.register(FieldNote) +class FieldNoteAdmin(admin.ModelAdmin): + list_display = ("id", "author", "category", "source_type", "verification_status", "visibility", "created_at") + list_filter = ("visibility", "category", "source_type", "verification_status") + readonly_fields = tuple(f.name for f in FieldNote._meta.fields) + search_fields = ("content",) + + def get_queryset(self, request): + return super().get_queryset(request).visible_to(request.user).select_related("author", "context") + + def has_add_permission(self, request): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + +@admin.register(FieldNoteAssociation) +class FieldNoteAssociationAdmin(admin.ModelAdmin): + list_display = ("context", "actor", "reason", "created_at") + readonly_fields = tuple(f.name for f in FieldNoteAssociation._meta.fields) + + def get_queryset(self, request): + qs = super().get_queryset(request) + if request.user.has_perm("fireworks_detect.view_all_fieldnotes"): + return qs + return qs.filter(context__author=request.user) + + def has_add_permission(self, request): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False diff --git a/fireworks_detect/field_notes.py b/fireworks_detect/field_notes.py new file mode 100644 index 0000000..8af38d8 --- /dev/null +++ b/fireworks_detect/field_notes.py @@ -0,0 +1,100 @@ +"""Central access checks and association/reporting services for field notes.""" +import uuid + +from django.contrib.auth import get_user_model +from django.core import signing +from django.core.exceptions import PermissionDenied +from django.db import transaction +from django.db.models import Q +from django.http import Http404 + +from .models import Event, PendingEvent, FieldNote, FieldNoteContext, FieldNoteAssociation + + +def draft_token(user): + if not user.is_authenticated: + return "" + return signing.dumps({"author": user.pk, "id": str(uuid.uuid4())}, salt="field-notes") + + +def token_id(user, token): + try: + data = signing.loads(token, salt="field-notes", max_age=7 * 86400) + if data["author"] != user.pk: + raise ValueError + return uuid.UUID(data["id"]) + except (signing.BadSignature, ValueError, KeyError, TypeError): + raise PermissionDenied("Invalid or expired note context. Reload the reporting page.") + + +def accessible_pending(user, session_ids=()): + if not user.is_authenticated: + return PendingEvent.objects.none() + if user.is_staff and user.has_perm("fireworks_detect.view_pendingevent"): + return PendingEvent.objects.all() + return PendingEvent.objects.filter(Q(note_contexts__author=user) | Q(sensor__owner=user) | Q(pk__in=session_ids)).distinct() + + +def target_snapshot(context): + if context.event_id: + return {"kind": "event", "id": context.event_id} + if context.pending_event_id: + return {"kind": "pending", "id": context.pending_event_id} + return {} + + +def associate(context, *, event=None, pending=None, actor=None, reason): + previous = target_snapshot(context) + context.event = event + context.pending_event = pending + context.full_clean() + context.save(update_fields=["event", "pending_event"]) + FieldNoteAssociation.objects.create(context=context, actor=actor, previous=previous, + target=target_snapshot(context), reason=reason) + + +@transaction.atomic +def context_for_token(user, token): + # Serialize draft-note creation and report binding for the same author. + get_user_model().objects.select_for_update().get(pk=user.pk) + context, _ = FieldNoteContext.objects.get_or_create(id=token_id(user, token), defaults={"author": user}) + if context.author_id != user.pk: + raise PermissionDenied + return context + + +@transaction.atomic +def bind_report(user, token, pending): + if not user.is_authenticated or not token: + return + context = context_for_token(user, token) + if context.event_id or context.pending_event_id: + raise PermissionDenied("This note context already belongs to a report. Reload before reporting again.") + associate(context, pending=pending, actor=user, reason="submission") + + +@transaction.atomic +def link_standalone(user, context_id, event): + # Approved events are publicly accessible in the existing application. + context = FieldNoteContext.objects.select_for_update().filter(pk=context_id, author=user).first() + if not context or context.event_id or context.pending_event_id: + raise Http404 + associate(context, event=event, actor=user, reason="linked") + return context + + +@transaction.atomic +def regroup_event_notes(user, source, target): + """Hook for future event-merging code; does not modify detection records.""" + if not (user.is_staff and user.has_perm("fireworks_detect.change_event") and + user.has_perm("fireworks_detect.view_all_fieldnotes")): + raise PermissionDenied + if source.pk == target.pk: + return + for context in FieldNoteContext.objects.select_for_update().filter(event=source): + associate(context, event=target, actor=user, reason="regrouped") + + +def reportable_notes(user): + """All exports, including future PDF reports, must start with this queryset.""" + return FieldNote.objects.reportable_to(user).select_related("author", "context") diff --git a/fireworks_detect/forms.py b/fireworks_detect/forms.py new file mode 100644 index 0000000..65f3025 --- /dev/null +++ b/fireworks_detect/forms.py @@ -0,0 +1,33 @@ +from django import forms +from django.utils.translation import gettext_lazy as _ +from .models import FieldNote + + +class FieldNoteForm(forms.ModelForm): + class Meta: + model = FieldNote + fields = ["content", "category", "source_type", "verification_status", "visibility", "observed_at"] + widgets = { + "content": forms.Textarea(attrs={"rows": 3, "placeholder": _("What did you observe or learn?")}), + "observed_at": forms.DateTimeInput(format="%Y-%m-%dT%H:%M", attrs={"type": "datetime-local"}), + } + labels = {"content": _("Note"), "observed_at": _("Observed at (optional)"), + "category": _("Category"), "source_type": _("Source"), + "verification_status": _("Verification status"), "visibility": _("Visibility")} + help_texts = { + "visibility": _("Private by default. Reportable permits authorised export; it does not mean verified or public."), + "observed_at": _("Local time (Europe/Amsterdam). The entry time is recorded separately."), + } + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + for name in self.fields: + if name != "content": + self.fields[name].required = False + + def clean(self): + data = super().clean() + for name in ("category", "source_type", "verification_status", "visibility"): + if not data.get(name): + data[name] = FieldNote._meta.get_field(name).get_default() + return data diff --git a/fireworks_detect/migrations/0014_fieldnotecontext_fieldnoteassociation_fieldnote_and_more.py b/fireworks_detect/migrations/0014_fieldnotecontext_fieldnoteassociation_fieldnote_and_more.py new file mode 100644 index 0000000..c22d071 --- /dev/null +++ b/fireworks_detect/migrations/0014_fieldnotecontext_fieldnoteassociation_fieldnote_and_more.py @@ -0,0 +1,86 @@ +# Generated by Django 6.1.1 on 2026-10-13 07:57 + +import django.db.models.deletion +import uuid +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fireworks_detect', '0013_event_submitted_at'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='FieldNoteContext', + fields=[ + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), + ('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='note_contexts', to='fireworks_detect.event')), + ('pending_event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='note_contexts', to='fireworks_detect.pendingevent')), + ], + ), + migrations.CreateModel( + name='FieldNoteAssociation', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('previous', models.JSONField(default=dict)), + ('target', models.JSONField(default=dict)), + ('reason', models.CharField(max_length=32)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('actor', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), + ('context', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='associations', to='fireworks_detect.fieldnotecontext')), + ], + options={ + 'ordering': ['created_at', 'pk'], + }, + ), + migrations.CreateModel( + name='FieldNote', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('content', models.TextField(max_length=10000)), + ('category', models.CharField(choices=[('general', 'General'), ('witness', 'Witness'), ('people_vehicles', 'People / vehicles'), ('cctv', 'CCTV'), ('location_direction', 'Location / direction'), ('follow_up', 'Follow-up'), ('other', 'Other')], default='general', max_length=32)), + ('source_type', models.CharField(choices=[('first_hand', 'First-hand'), ('second_hand', 'Second-hand'), ('unknown', 'Other / unknown')], default='unknown', max_length=24)), + ('verification_status', models.CharField(choices=[('unverified', 'Unverified'), ('corroborated', 'Corroborated'), ('disputed', 'Disputed')], default='unverified', max_length=24)), + ('visibility', models.CharField(choices=[('private', 'Private'), ('reportable', 'Reportable')], default='private', max_length=16)), + ('observed_at', models.DateTimeField(blank=True, null=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='field_notes', to=settings.AUTH_USER_MODEL)), + ('context', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='notes', to='fireworks_detect.fieldnotecontext')), + ], + options={ + 'ordering': ['created_at', 'pk'], + 'permissions': [('view_all_fieldnotes', 'Read all private field notes'), ('export_reportable_fieldnotes', 'Export reportable field notes from all authors')], + }, + ), + migrations.AddConstraint( + model_name='fieldnotecontext', + constraint=models.CheckConstraint(condition=models.Q(('event__isnull', False), ('pending_event__isnull', False), _negated=True), name='note_context_one_target'), + ), + migrations.AddIndex( + model_name='fieldnote', + index=models.Index(fields=['author', 'created_at'], name='fieldnote_author_time'), + ), + migrations.AddConstraint( + model_name='fieldnote', + constraint=models.CheckConstraint(condition=models.Q(('content', ''), _negated=True), name='fieldnote_nonempty'), + ), + migrations.AddConstraint( + model_name='fieldnote', + constraint=models.CheckConstraint(condition=models.Q(('visibility__in', ['private', 'reportable'])), name='fieldnote_visibility'), + ), + migrations.AddConstraint( + model_name='fieldnote', + constraint=models.CheckConstraint(condition=models.Q(('source_type__in', ['first_hand', 'second_hand', 'unknown'])), name='fieldnote_source'), + ), + migrations.AddConstraint( + model_name='fieldnote', + constraint=models.CheckConstraint(condition=models.Q(('verification_status__in', ['unverified', 'corroborated', 'disputed'])), name='fieldnote_verification'), + ), + ] diff --git a/fireworks_detect/migrations/__pycache__/0014_fieldnotecontext_fieldnoteassociation_fieldnote_and_more.cpython-313.pyc b/fireworks_detect/migrations/__pycache__/0014_fieldnotecontext_fieldnoteassociation_fieldnote_and_more.cpython-313.pyc new file mode 100644 index 0000000..5e0cac6 Binary files /dev/null and b/fireworks_detect/migrations/__pycache__/0014_fieldnotecontext_fieldnoteassociation_fieldnote_and_more.cpython-313.pyc differ diff --git a/fireworks_detect/models.py b/fireworks_detect/models.py index 9ae03dd..983db32 100644 --- a/fireworks_detect/models.py +++ b/fireworks_detect/models.py @@ -265,7 +265,7 @@ class PendingEvent(ClassifiedAudio): verbose_name_plural = _("Pending") @transaction.atomic - def approve(self): + def approve(self, actor=None): event = Event.objects.create( submitted_at=self.created_at, audio_file=self.audio_file.name, @@ -289,6 +289,9 @@ class PendingEvent(ClassifiedAudio): direction_accuracy_degrees=self.direction_accuracy_degrees, direction_source=self.direction_source, ) + from .field_notes import associate + for context in self.note_contexts.select_for_update(): + associate(context, event=event, actor=actor, reason="approved") self.delete() return event @@ -334,3 +337,117 @@ class SensorSubmission(models.Model): class Meta: constraints = [models.UniqueConstraint(fields=["sensor", "event_id"], name="unique_sensor_event_id")] + + +class FieldNoteContext(models.Model): + """An author's note association, including drafts before a report exists. + + This stores no detection/incident data; Event/PendingEvent remain canonical. + """ + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT) + event = models.ForeignKey(Event, null=True, blank=True, on_delete=models.SET_NULL, related_name="note_contexts") + pending_event = models.ForeignKey(PendingEvent, null=True, blank=True, on_delete=models.SET_NULL, related_name="note_contexts") + created_at = models.DateTimeField(auto_now_add=True) + + class Meta: + constraints = [models.CheckConstraint(condition=~(models.Q(event__isnull=False) & models.Q(pending_event__isnull=False)), name="note_context_one_target")] + + +class FieldNoteQuerySet(models.QuerySet): + def visible_to(self, user): + if not user.is_authenticated or not user.is_active: + return self.none() + if user.is_active and user.has_perm("fireworks_detect.view_all_fieldnotes"): + return self + return self.filter(author=user) + + def reportable_to(self, user): + if not user.is_authenticated or not user.is_active: + return self.none() + notes = self.filter(visibility="reportable") + if user.is_active and user.has_perm("fireworks_detect.export_reportable_fieldnotes"): + return notes + return notes.filter(author=user) + + +class FieldNote(models.Model): + class Category(models.TextChoices): + GENERAL = "general", _("General") + WITNESS = "witness", _("Witness") + PEOPLE = "people_vehicles", _("People / vehicles") + CCTV = "cctv", _("CCTV") + LOCATION = "location_direction", _("Location / direction") + FOLLOW_UP = "follow_up", _("Follow-up") + OTHER = "other", _("Other") + + class Source(models.TextChoices): + FIRST_HAND = "first_hand", _("First-hand") + SECOND_HAND = "second_hand", _("Second-hand") + UNKNOWN = "unknown", _("Other / unknown") + + class Verification(models.TextChoices): + UNVERIFIED = "unverified", _("Unverified") + CORROBORATED = "corroborated", _("Corroborated") + DISPUTED = "disputed", _("Disputed") + + class Visibility(models.TextChoices): + PRIVATE = "private", _("Private") + REPORTABLE = "reportable", _("Reportable") + + author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, related_name="field_notes") + context = models.ForeignKey(FieldNoteContext, on_delete=models.PROTECT, related_name="notes") + content = models.TextField(max_length=10000) + category = models.CharField(max_length=32, choices=Category.choices, default=Category.GENERAL) + source_type = models.CharField(max_length=24, choices=Source.choices, default=Source.UNKNOWN) + verification_status = models.CharField(max_length=24, choices=Verification.choices, default=Verification.UNVERIFIED) + visibility = models.CharField(max_length=16, choices=Visibility.choices, default=Visibility.PRIVATE) + observed_at = models.DateTimeField(null=True, blank=True) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + objects = FieldNoteQuerySet.as_manager() + + class Meta: + ordering = ["created_at", "pk"] + indexes = [models.Index(fields=["author", "created_at"], name="fieldnote_author_time")] + permissions = [ + ("view_all_fieldnotes", "Read all private field notes"), + ("export_reportable_fieldnotes", "Export reportable field notes from all authors"), + ] + constraints = [ + models.CheckConstraint(condition=~models.Q(content=""), name="fieldnote_nonempty"), + models.CheckConstraint(condition=models.Q(visibility__in=["private", "reportable"]), name="fieldnote_visibility"), + models.CheckConstraint(condition=models.Q(source_type__in=["first_hand", "second_hand", "unknown"]), name="fieldnote_source"), + models.CheckConstraint(condition=models.Q(verification_status__in=["unverified", "corroborated", "disputed"]), name="fieldnote_verification"), + ] + + def clean(self): + super().clean() + if not self.content.strip(): + raise ValidationError({"content": _("Enter a note.")}) + if self.context_id and self.author_id != self.context.author_id: + raise ValidationError(_("The note and its context must have the same author.")) + + def save(self, *args, **kwargs): + if not self._state.adding: + raise ValidationError(_("Field notes are append-only. Add a follow-up to correct an earlier note.")) + self.full_clean() + return super().save(*args, **kwargs) + + +class FieldNoteAssociation(models.Model): + """Immutable provenance retained even when the original event is deleted.""" + context = models.ForeignKey(FieldNoteContext, on_delete=models.PROTECT, related_name="associations") + actor = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) + previous = models.JSONField(default=dict) + target = models.JSONField(default=dict) + reason = models.CharField(max_length=32) + created_at = models.DateTimeField(auto_now_add=True) + + class Meta: + ordering = ["created_at", "pk"] + + def save(self, *args, **kwargs): + if not self._state.adding: + raise ValidationError("Association history is append-only.") + return super().save(*args, **kwargs) diff --git a/fireworks_detect/note_views.py b/fireworks_detect/note_views.py new file mode 100644 index 0000000..edaea15 --- /dev/null +++ b/fireworks_detect/note_views.py @@ -0,0 +1,126 @@ +import csv +import json +from urllib.parse import urlencode + +from django.contrib.auth.decorators import login_required +from django.db import transaction +from django.http import Http404, HttpResponse, JsonResponse +from django.shortcuts import get_object_or_404, redirect, render +from django.urls import reverse +from django.views.decorators.cache import never_cache +from django.views.decorators.http import require_http_methods + +from .field_notes import accessible_pending, associate, context_for_token, link_standalone, reportable_notes, token_id +from .forms import FieldNoteForm +from .models import Event, FieldNote, FieldNoteContext + + +def panel_context(request, params=None): + params = params if params is not None else request.GET + selected = [(k, params.get(k)) for k in ("event", "pending", "token") if params.get(k)] + if len(selected) > 1: + raise Http404 + notes = FieldNote.objects.visible_to(request.user).select_related("author", "context__event", "context__pending_event").prefetch_related("context__associations") + target = None + kind, value = selected[0] if selected else ("", "") + try: + if kind == "event": + target = get_object_or_404(Event, pk=int(value)) + notes = notes.filter(context__event=target) + elif kind == "pending": + target = get_object_or_404(accessible_pending(request.user, request.session.get("manual_pending_ids", [])), pk=int(value)) + notes = notes.filter(context__pending_event=target) + elif kind == "token": + key = token_id(request.user, value) + notes = notes.filter(context_id=key) + except (ValueError, TypeError): + raise Http404 + return {"field_notes": notes, "note_count": notes.count(), "note_form": FieldNoteForm(), + "note_kind": kind, "note_value": value, "note_target": target, + "note_panel_id": "live-field-notes" if kind == "token" else "field-notes", + "note_query": urlencode({kind: value}) if kind else "", + "note_events": Event.objects.all() if not kind else (), + "note_token": value if kind == "token" else ""} + + +@login_required +@never_cache +@require_http_methods(["GET", "POST"]) +def notes(request): + params = request.POST if request.method == "POST" else request.GET + context = panel_context(request, params) + if request.method == "POST": + form = FieldNoteForm(request.POST) + if form.is_valid(): + with transaction.atomic(): + kind = context["note_kind"] + if kind == "token": + owner_context = context_for_token(request.user, context["note_value"]) + else: + owner_context = FieldNoteContext.objects.create(author=request.user) + if kind: + associate(owner_context, event=context["note_target"] if kind == "event" else None, + pending=context["note_target"] if kind == "pending" else None, + actor=request.user, reason="created") + note = form.save(commit=False) + note.author = request.user + note.context = owner_context + note.save() + if request.headers.get("HX-Request") != "true": + return redirect(reverse("fireworks_detect:field_notes") + ("?" + context["note_query"] if context["note_query"] else "")) + context = panel_context(request, params) + context["note_saved"] = True + else: + context["note_form"] = form + # Invalid HTMX forms deliberately return 200 so HTMX renders field errors. + template = "fireworks_detect/notes/panel.html" if request.headers.get("HX-Request") == "true" else "fireworks_detect/notes/page.html" + return render(request, template, context) + + +@login_required +@never_cache +@require_http_methods(["POST"]) +def link_note(request, context_id): + try: + event = get_object_or_404(Event, pk=int(request.POST.get("event", ""))) + except (ValueError, TypeError): + raise Http404 + link_standalone(request.user, context_id, event) + return redirect("fireworks_detect:field_notes") + + +@login_required +@never_cache +@require_http_methods(["GET"]) +def export_notes(request, format): + notes = reportable_notes(request.user).prefetch_related("context__associations") + if request.GET.get("event"): + try: + event = get_object_or_404(Event, pk=int(request.GET["event"])) + except (ValueError, TypeError): + raise Http404 + notes = notes.filter(context__event=event) + rows = [{"id": n.pk, "author": n.author.get_username(), "event_id": n.context.event_id, + "pending_event_id": n.context.pending_event_id, "content": n.content, + "category": n.category, "source_type": n.source_type, + "verification_status": n.verification_status, "visibility": n.visibility, + "observed_at": n.observed_at.isoformat() if n.observed_at else None, + "created_at": n.created_at.isoformat(), "updated_at": n.updated_at.isoformat(), + "association_history": [{"previous": a.previous, "target": a.target, "reason": a.reason, + "created_at": a.created_at.isoformat()} for a in n.context.associations.all()]} + for n in notes] + if format == "json": + response = JsonResponse({"notes": rows}) + elif format == "csv": + response = HttpResponse(content_type="text/csv; charset=utf-8") + fields = ["id", "author", "event_id", "pending_event_id", "content", "category", "source_type", "verification_status", "visibility", "observed_at", "created_at", "updated_at", "association_history"] + writer = csv.DictWriter(response, fieldnames=fields) + writer.writeheader() + for row in rows: + row["association_history"] = json.dumps(row["association_history"]) + # Prevent spreadsheet formula execution from user-authored text. + writer.writerow({k: "'" + v if isinstance(v, str) and v.lstrip().startswith(("=", "+", "-", "@")) else v for k, v in row.items()}) + else: + raise Http404 + response["Content-Disposition"] = f'attachment; filename="boomcast-field-notes.{format}"' + return response diff --git a/fireworks_detect/templates/fireworks_detect/dashboard.html b/fireworks_detect/templates/fireworks_detect/dashboard.html index d17542c..3c9f915 100644 --- a/fireworks_detect/templates/fireworks_detect/dashboard.html +++ b/fireworks_detect/templates/fireworks_detect/dashboard.html @@ -25,6 +25,7 @@
{% include "fireworks_detect/includes/manual_report_form.html" %} + {% if user.is_authenticated %}{% include "fireworks_detect/notes/panel.html" %}{% else %}

{% trans "Sign in to add private field notes" %}

{% endif %}
diff --git a/fireworks_detect/templates/fireworks_detect/event_detail.html b/fireworks_detect/templates/fireworks_detect/event_detail.html index 6e34feb..e490108 100644 --- a/fireworks_detect/templates/fireworks_detect/event_detail.html +++ b/fireworks_detect/templates/fireworks_detect/event_detail.html @@ -30,3 +30,5 @@

{% trans "No peak events returned." %}

{% endfor %} {% endif %} + +{% if request.user.is_authenticated %}{% include "fireworks_detect/notes/panel.html" %}{% else %}

{% trans "Sign in to add private field notes" %}

{% endif %} diff --git a/fireworks_detect/templates/fireworks_detect/event_page.html b/fireworks_detect/templates/fireworks_detect/event_page.html new file mode 100644 index 0000000..dce77db --- /dev/null +++ b/fireworks_detect/templates/fireworks_detect/event_page.html @@ -0,0 +1,2 @@ +{% load i18n vite %} +{% trans "Event · BoomCast" %}{% vite_asset "frontend/src/entries/events.js" %}
{% include "fireworks_detect/includes/navigation.html" %}
{% include "fireworks_detect/event_detail.html" %}
diff --git a/fireworks_detect/templates/fireworks_detect/events.html b/fireworks_detect/templates/fireworks_detect/events.html index 7afee08..a7ac08a 100644 --- a/fireworks_detect/templates/fireworks_detect/events.html +++ b/fireworks_detect/templates/fireworks_detect/events.html @@ -1,2 +1,2 @@ {% load i18n vite %} -{% trans "Events · Sound Signal" %}{% vite_asset "frontend/src/entries/events.js" %}{% include "js_translations.html" %}
{% include "fireworks_detect/includes/navigation.html" with active_page="events" %}

{% trans "Reviewed signal archive" %}

{% trans "Approved events." %}

{% trans "This feed refreshes automatically every three seconds after a pending sample is approved in admin." %}

{% trans "Latest events" %}

{% trans "Loading events…" %}

{% trans "Select an event" %}

{% trans "Choose an approved event to inspect its classification details." %}

+{% trans "Events · Sound Signal" %}{% vite_asset "frontend/src/entries/events.js" %}{% include "js_translations.html" %}
{% include "fireworks_detect/includes/navigation.html" with active_page="events" %}

{% trans "Reviewed signal archive" %}

{% trans "Approved events." %}

{% trans "This feed refreshes automatically every three seconds after a pending sample is approved in admin." %}

{% trans "Latest events" %}

{% include "fireworks_detect/events_list.html" %}

{% trans "Select an event" %}

{% trans "Choose an approved event to inspect its classification details." %}

diff --git a/fireworks_detect/templates/fireworks_detect/events_list.html b/fireworks_detect/templates/fireworks_detect/events_list.html index 3323d78..624e94a 100644 --- a/fireworks_detect/templates/fireworks_detect/events_list.html +++ b/fireworks_detect/templates/fireworks_detect/events_list.html @@ -1,7 +1,7 @@ {% load i18n %} {% if events %} {% for event in events %} - + {% endfor %} {% else %}

{% trans "No approved events yet. Submit a classification, then approve it from the Pending page in admin." %}

diff --git a/fireworks_detect/templates/fireworks_detect/includes/manual_report_form.html b/fireworks_detect/templates/fireworks_detect/includes/manual_report_form.html index bde7f6c..28caeb1 100644 --- a/fireworks_detect/templates/fireworks_detect/includes/manual_report_form.html +++ b/fireworks_detect/templates/fireworks_detect/includes/manual_report_form.html @@ -10,22 +10,32 @@ - +
+ {% trans "Now" %} + +
+ + + +
{% csrf_token %} + {% if note_token %}{% endif %} -
- -
- - {% trans "Leave the time empty to use the submission time." %} -
+
diff --git a/fireworks_detect/templates/fireworks_detect/includes/navigation.html b/fireworks_detect/templates/fireworks_detect/includes/navigation.html index 689a1f8..c20e85c 100644 --- a/fireworks_detect/templates/fireworks_detect/includes/navigation.html +++ b/fireworks_detect/templates/fireworks_detect/includes/navigation.html @@ -8,6 +8,7 @@ {% trans "Map" %} {% trans "Events" %} {% if request.user.is_authenticated %} + {% trans "Field notes" %} {% csrf_token %} diff --git a/fireworks_detect/templates/fireworks_detect/manual_pending_submission.html b/fireworks_detect/templates/fireworks_detect/manual_pending_submission.html index 9c23088..3453417 100644 --- a/fireworks_detect/templates/fireworks_detect/manual_pending_submission.html +++ b/fireworks_detect/templates/fireworks_detect/manual_pending_submission.html @@ -1,5 +1,5 @@ {% load i18n %} -
+
{% if error %} {% trans "Could not report fireworks" %} @@ -16,6 +16,7 @@

{% if pending.is_burst %}{% trans "Burst Event" %}{% else %}{% trans "Ordinary report" %}{% endif %} · {% trans "Submitted" %} {{ pending.created_at|date:"j M Y, H:i" }}

{% if pending.is_burst %}

{% trans "Duration" %}: {% if pending.observation_duration_minutes %}{{ pending.observation_duration_minutes }} {% trans "minutes (estimated)" %}{% else %}{% trans "Unknown" %}{% endif %}

{% 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 %}

{% endif %} + {% if request.user.is_authenticated %}

{% trans "Add or review field notes for this report" %}

{% endif %} {% if editable %} {% csrf_token %} diff --git a/fireworks_detect/templates/fireworks_detect/notes/page.html b/fireworks_detect/templates/fireworks_detect/notes/page.html new file mode 100644 index 0000000..693345b --- /dev/null +++ b/fireworks_detect/templates/fireworks_detect/notes/page.html @@ -0,0 +1,2 @@ +{% load i18n vite %} +{% trans "Field notes · BoomCast" %}{% vite_asset "frontend/src/entries/events.js" %}
{% include "fireworks_detect/includes/navigation.html" %}
{% include "fireworks_detect/notes/panel.html" %}

{% trans "Exports include only reportable notes you are authorised to export. Private notes are always excluded." %}

JSON · CSV
diff --git a/fireworks_detect/templates/fireworks_detect/notes/panel.html b/fireworks_detect/templates/fireworks_detect/notes/panel.html new file mode 100644 index 0000000..bfaf83b --- /dev/null +++ b/fireworks_detect/templates/fireworks_detect/notes/panel.html @@ -0,0 +1,38 @@ +{% load i18n tz %} +
+

{% trans "Field notes" %} ({{ note_count|default:0 }})

+

{% trans "Human context, separate from detection evidence. Notes are private by default. Add a follow-up to correct an earlier entry." %}

+ {% if note_target %}

{% trans "Report" %} #{{ note_target.pk }} · {{ note_target.occurrences }} {% trans "bangs" %}

{% endif %} + {% if note_saved %}

{% trans "Field note saved." %}

{% endif %} +
+ {% trans "Add field note" %} + + {% csrf_token %} + {% if note_token %}{% elif note_kind %}{% endif %} + {{ note_form.non_field_errors }} +
{{ note_form.content.label_tag }}{{ note_form.content }}{{ note_form.content.errors }}
+
{% trans "Optional details" %} +
+ {% for field in note_form %}{% if field.name != 'content' %}
{{ field.label_tag }}{{ field }}{% if field.help_text %}{{ field.help_text }}{% endif %}{{ field.errors }}
{% endif %}{% endfor %} +
+
+ + +
+
    + {% for note in field_notes %} +
  1. +

    {{ note.get_category_display }} · {{ note.author.get_username }} · {{ note.get_visibility_display }}

    +

    {{ note.get_source_type_display }} · {{ note.get_verification_status_display }}

    +

    {{ note.content }}

    +

    {% trans "Entered" %}: {% if note.observed_at %}
    {% trans "Observed" %}: {% endif %}

    + {% if note.context.event_id %}{% trans "Event" %} #{{ note.context.event_id }}{% elif note.context.pending_event_id %}{% trans "Pending report" %} #{{ note.context.pending_event_id }}{% else %}{% if note_token %}{% trans "Current observation — not yet submitted" %}{% else %}{% trans "Standalone observation" %}{% endif %}{% endif %} + {% if note.context.associations.all %}
    {% trans "Association history" %}
      {% for change in note.context.associations.all %}
    • {{ change.created_at|localtime|date:"j M Y, H:i" }} · {{ change.reason }} · {{ change.previous.kind|default:"standalone" }} {{ change.previous.id|default:"" }} → {{ change.target.kind }} {{ change.target.id }}
    • {% endfor %}
    {% endif %} + {% if not note_kind and not note.context.event_id and not note.context.pending_event_id and note.author_id == request.user.pk %} +
    {% csrf_token %}
    + {% endif %} +
  2. + {% empty %}
  3. {% trans "No field notes visible to you yet." %}
  4. {% endfor %} +
+

{% trans "My field notes" %}

+
diff --git a/fireworks_detect/test_field_notes.py b/fireworks_detect/test_field_notes.py new file mode 100644 index 0000000..32571b0 --- /dev/null +++ b/fireworks_detect/test_field_notes.py @@ -0,0 +1,182 @@ +from datetime import timedelta + +from django.contrib.auth import get_user_model +from django.contrib.auth.models import Permission +from django.core.exceptions import PermissionDenied, ValidationError +from django.test import TestCase +from django.urls import reverse +from django.utils import timezone + +from .field_notes import draft_token, regroup_event_notes, reportable_notes +from .models import Event, FieldNote, FieldNoteContext, FieldNoteAssociation, PendingEvent + + +class FieldNotesTests(TestCase): + def setUp(self): + User = get_user_model() + self.alice = User.objects.create_user('alice', password='test-password') + self.bob = User.objects.create_user('bob', password='test-password') + self.event = Event.objects.create(original_filename='Burst', classifier_response={}, source_type='manual', occurrences=15) + self.url = reverse('fireworks_detect:field_notes') + self.client.force_login(self.alice) + + def note(self, user=None, visibility='private', **kwargs): + user = user or self.alice + context = FieldNoteContext.objects.create(author=user, event=self.event) + return FieldNote.objects.create(author=user, context=context, content='A private observation', visibility=visibility, **kwargs) + + def test_only_content_required_private_defaults_plain_text(self): + response = self.client.post(self.url, {'content': '\nSecond line'}) + self.assertEqual(response.status_code, 302) + note = FieldNote.objects.get() + self.assertEqual(note.visibility, 'private') + self.assertEqual(note.source_type, 'unknown') + self.assertEqual(note.verification_status, 'unverified') + response = self.client.get(self.url) + self.assertContains(response, '<script>') + self.assertNotContains(response, '') + + def test_cross_user_read_create_link_and_export_are_scoped(self): + note = self.note() + self.client.force_login(self.bob) + self.assertNotContains(self.client.get(self.url), note.content) + self.assertNotContains(self.client.get(reverse('fireworks_detect:event_detail', args=[self.event.pk])), note.content) + response = self.client.post(self.url, {'content':'forged', 'token':draft_token(self.alice)}) + self.assertEqual(response.status_code, 403) + self.assertEqual(self.client.post(reverse('fireworks_detect:link_field_note', args=[note.context_id]), {'event': self.event.pk}).status_code, 404) + self.assertEqual(self.client.get(reverse('fireworks_detect:export_field_notes', args=['json'])).json()['notes'], []) + + def test_anonymous_cannot_create_read_or_export_notes(self): + self.note() + self.client.logout() + self.assertEqual(self.client.post(self.url, {'content':'no'}).status_code, 302) + self.assertEqual(self.client.get(self.url).status_code, 302) + self.assertNotContains(self.client.get(reverse('fireworks_detect:event_detail', args=[self.event.pk])), 'A private observation') + self.assertEqual(self.client.get(reverse('fireworks_detect:export_field_notes', args=['json'])).status_code, 302) + + def test_export_always_excludes_private_even_for_superuser(self): + self.note() + public = self.note(visibility='reportable', source_type='second_hand') + self.note(self.bob, visibility='reportable') + self.assertEqual(list(reportable_notes(self.alice)), [public]) + self.alice.is_superuser = self.alice.is_staff = True + self.alice.save() + for format in ['json','csv']: + response = self.client.get(reverse('fireworks_detect:export_field_notes', args=[format])) + self.assertEqual(response.status_code, 200) + self.assertNotIn('"visibility": "private"', response.content.decode()) + rows = self.client.get(reverse('fireworks_detect:export_field_notes', args=['json'])).json()['notes'] + self.assertEqual(len(rows), 2) + self.assertEqual(rows[0]['source_type'], 'second_hand') + self.assertEqual(rows[0]['verification_status'], 'unverified') + + def test_reportable_does_not_grant_other_users_read_access(self): + note = self.note(visibility='reportable') + self.client.force_login(self.bob) + self.assertNotContains(self.client.get(self.url), note.content) + + def test_observed_time_entry_time_and_append_only(self): + self.client.post(self.url, {'content':'Later information', 'observed_at':'2026-10-09T14:00'}) + note = FieldNote.objects.get() + self.assertTrue(timezone.is_aware(note.observed_at)) + self.assertLess(note.observed_at, note.created_at) + entered = note.created_at + note.content = 'rewrite' + with self.assertRaises(ValidationError): note.save() + note.refresh_from_db() + self.assertEqual(note.content, 'Later information') + self.assertEqual(note.created_at, entered) + + def test_invalid_forms_render_with_and_without_htmx(self): + for headers in [{}, {'HTTP_HX_REQUEST':'true'}]: + response = self.client.post(self.url, {'content':' ', 'visibility':'public'}, **headers) + self.assertEqual(response.status_code, 200) + self.assertContains(response, 'errorlist') + self.assertFalse(FieldNote.objects.exists()) + + def test_live_notes_bind_to_report_and_survive_approval(self): + token = draft_token(self.alice) + self.client.post(self.url, {'token':token, 'content':'Heard during listening'}, HTTP_HX_REQUEST='true') + note = FieldNote.objects.get() + original_time = note.created_at + response = self.client.post(reverse('fireworks_detect:submit_manual_pending'), {'occurrences':'15', 'field_note_context':token}) + self.assertEqual(response.status_code, 200) + pending = PendingEvent.objects.get() + note.context.refresh_from_db() + self.assertEqual(note.context.pending_event_id, pending.pk) + event = pending.approve(actor=self.alice) + note.context.refresh_from_db() + self.assertEqual(note.context.event_id, event.pk) + self.assertIsNone(note.context.pending_event_id) + note.refresh_from_db() + self.assertEqual(note.created_at, original_time) + self.assertEqual(note.context.associations.count(), 2) + self.assertEqual(note.context.associations.last().actor_id, self.alice.pk) + # A note submitted from an already-open form follows the approved report. + self.client.post(self.url, {'token':token, 'content':'Late save'}) + self.assertEqual(FieldNote.objects.get(content='Late save').context.event_id, event.pk) + # Reusing a report token cannot reparent existing notes or create a report. + self.assertEqual(self.client.post(reverse('fireworks_detect:submit_manual_pending'), {'occurrences':'1', 'field_note_context':token}).status_code, 403) + self.assertFalse(PendingEvent.objects.exists()) + + def test_pending_access_checked_and_historical_append(self): + pending = PendingEvent.objects.create(original_filename='secret', classifier_response={}) + self.assertEqual(self.client.get(self.url, {'pending':pending.pk}).status_code, 404) + self.assertEqual(self.client.post(self.url, {'pending':pending.pk,'content':'no'}).status_code, 404) + self.assertEqual(self.client.post(self.url, {'event':self.event.pk,'content':'Historical follow-up'}).status_code, 302) + self.assertEqual(FieldNote.objects.get().context.event_id, self.event.pk) + + def test_standalone_link_and_regroup_preserve_provenance(self): + self.client.post(self.url, {'content':'Possible camera lead'}) + note = FieldNote.objects.get() + response = self.client.post(reverse('fireworks_detect:link_field_note', args=[note.context_id]), {'event':self.event.pk}) + self.assertEqual(response.status_code, 302) + target = Event.objects.create(original_filename='Grouped burst', classifier_response={}, occurrences=20) + with self.assertRaises(PermissionDenied): regroup_event_notes(self.alice, self.event, target) + self.alice.is_superuser = self.alice.is_staff = True; self.alice.save() + regroup_event_notes(self.alice, self.event, target) + self.event.delete() + note.context.refresh_from_db() + self.assertEqual(note.context.event_id, target.pk) + self.assertEqual(note.context.associations.count(), 2) + self.assertEqual(note.context.associations.last().previous['id'], self.event.pk or note.context.associations.first().target['id']) + self.assertEqual(FieldNote.objects.count(), 1) + + def test_denied_report_retains_notes_and_original_reference(self): + token = draft_token(self.alice) + self.client.post(self.url, {'token':token,'content':'Retain observation'}) + self.client.post(reverse('fireworks_detect:submit_manual_pending'), {'occurrences':'3','field_note_context':token}) + pending = PendingEvent.objects.get(); old_id = pending.pk; pending.deny() + note = FieldNote.objects.get() + self.assertIsNone(note.context.pending_event_id) + self.assertEqual(note.context.associations.get().target, {'kind':'pending','id':old_id}) + + def test_staff_needs_explicit_permission_for_private_notes(self): + self.note() + self.bob.is_staff = True; self.bob.save() + self.assertFalse(FieldNote.objects.visible_to(self.bob).exists()) + self.bob.user_permissions.add(Permission.objects.get(codename='view_all_fieldnotes')) + bob = get_user_model().objects.get(pk=self.bob.pk) + self.assertEqual(FieldNote.objects.visible_to(bob).count(), 1) + self.assertFalse(reportable_notes(bob).exists()) + + def test_csv_formula_is_escaped(self): + ctx = FieldNoteContext.objects.create(author=self.alice) + FieldNote.objects.create(author=self.alice, context=ctx, content='=1+1', visibility='reportable') + self.assertContains(self.client.get(reverse('fireworks_detect:export_field_notes', args=['csv'])), "'=1+1") + + def test_note_posts_require_csrf(self): + from django.test import Client + browser = Client(enforce_csrf_checks=True) + browser.force_login(self.alice) + self.assertEqual(browser.post(self.url, {"content":"forged"}).status_code, 403) + self.assertFalse(FieldNote.objects.exists()) + + def test_history_orders_by_entry_not_backdated_observation(self): + first = self.note(observed_at=timezone.now()) + second = self.note(observed_at=timezone.now()-timedelta(days=7)) + self.assertEqual(list(FieldNote.objects.values_list("pk", flat=True)), [first.pk, second.pk]) + self.client.force_login(self.bob) + self.bob.user_permissions.add(Permission.objects.get(codename="export_reportable_fieldnotes")) + # Export permission does not grant read access to private history. + self.assertNotContains(self.client.get(self.url), first.content) diff --git a/fireworks_detect/urls.py b/fireworks_detect/urls.py index bd02c69..5f69920 100644 --- a/fireworks_detect/urls.py +++ b/fireworks_detect/urls.py @@ -19,9 +19,14 @@ from .views import ( browser_processing_policy, ) +from . import note_views + app_name = "fireworks_detect" urlpatterns = [ + path("notes/", note_views.notes, name="field_notes"), + path("notes//link/", note_views.link_note, name="link_field_note"), + path("notes/export//", note_views.export_notes, name="export_field_notes"), path("", fireworks_view, name="fireworks"), path("map/", fireworks_map_view, name="map"), path("classify/", classify_audio, name="classify"), diff --git a/fireworks_detect/views.py b/fireworks_detect/views.py index 4c807e3..95b2f3d 100644 --- a/fireworks_detect/views.py +++ b/fireworks_detect/views.py @@ -30,6 +30,7 @@ from django.views.decorators.http import require_http_methods from .h3_utils import cell_boundary, cell_center, cell_from_coordinates, h3_resolution from .browser_policy import advisory_browser_metadata, browser_config, browser_policy from .models import BrowserProcessingSettings, ClassificationRule, Event, ManualReportRevision, PendingEvent, Sensor, SensorSubmission +from .field_notes import draft_token from .bursts import BURST_MIN_BANGS, DEFAULT_ESTIMATED_DURATION_MINUTES, burst_intensity, burst_rate @@ -187,6 +188,8 @@ def fireworks_map_view(request): @never_cache def dashboard_view(request): + from .field_notes import draft_token + from .forms import FieldNoteForm map_events, h3_cells = _events_for_map({ "date_from": None, "date_to": None, @@ -194,6 +197,10 @@ def dashboard_view(request): "visual": "all", }) return render(request, "fireworks_detect/dashboard.html", { + "note_token": draft_token(request.user), + "note_form": FieldNoteForm(), + "note_mode": "draft", + "note_panel_id": "live-field-notes", "h3_resolution": h3_resolution(), "h3_cells": h3_cells, "map_events": map_events, @@ -204,7 +211,7 @@ def dashboard_view(request): def events_view(request): - return render(request, "fireworks_detect/events.html") + return render(request, "fireworks_detect/events.html", {"events": Event.objects.all()[:30]}) def _classification_context(payload): @@ -405,6 +412,7 @@ def manual_direction_panel(request): @require_http_methods(["POST"]) @never_cache +@transaction.atomic def submit_manual_pending_event(request): try: occurrences = int(request.POST.get("occurrences", "")) @@ -437,6 +445,14 @@ def submit_manual_pending_event(request): h3_cell = cell_from_coordinates(latitude, longitude) direction_degrees, direction_accuracy_degrees = _manual_direction(request) + # Reject stale/foreign contexts before FileField writes an audio file. + note_token = request.POST.get("field_note_context") + if request.user.is_authenticated and note_token: + from .field_notes import context_for_token + from django.core.exceptions import PermissionDenied + note_context = context_for_token(request.user, note_token) + if note_context.event_id or note_context.pending_event_id: + raise PermissionDenied("This note context already belongs to a report. Reload before reporting again.") pending = PendingEvent.objects.create( audio_file=uploaded_file, original_filename="Manual fireworks report", @@ -451,6 +467,8 @@ def submit_manual_pending_event(request): direction_accuracy_degrees=direction_accuracy_degrees, direction_source="device_compass" if direction_degrees is not None else "", ) + from .field_notes import bind_report + bind_report(request.user, request.POST.get("field_note_context"), pending) owned = request.session.get("manual_pending_ids", []) request.session["manual_pending_ids"] = (owned + [pending.pk])[-20:] direction_names = { @@ -460,6 +478,7 @@ def submit_manual_pending_event(request): return render(request, "fireworks_detect/manual_pending_submission.html", { "pending": pending, "editable": True, + "next_note_token": draft_token(request.user), "direction_label": direction_names.get(pending.direction_cardinal) if direction_degrees is not None else "", }) @@ -542,7 +561,11 @@ def event_detail(request, event_id): context = _classification_context(event.classifier_response) context["event"] = event context["event_h3_cell"] = event.h3_cell or cell_from_coordinates(event.latitude, event.longitude) - return render(request, "fireworks_detect/event_detail.html", context) + if request.user.is_authenticated: + from .note_views import panel_context + context.update(panel_context(request, {"event": event.pk})) + template = "fireworks_detect/event_detail.html" if request.headers.get("HX-Request") == "true" else "fireworks_detect/event_page.html" + return render(request, template, context) def _audio_response(record): diff --git a/frontend/src/entries/dashboard.js b/frontend/src/entries/dashboard.js index f9a4261..ff7775f 100644 --- a/frontend/src/entries/dashboard.js +++ b/frontend/src/entries/dashboard.js @@ -11,3 +11,5 @@ import "../scripts/theme.js"; import "../scripts/manual-report.js"; import "../scripts/audio-upload.js"; import "../scripts/event-map.js"; + +import "../styles/components/field-notes.scss"; diff --git a/frontend/src/entries/events.js b/frontend/src/entries/events.js index cb71edb..e6984f1 100644 --- a/frontend/src/entries/events.js +++ b/frontend/src/entries/events.js @@ -3,3 +3,5 @@ import "../styles/components/fireworks-navigation.scss"; import "../styles/pages/events.scss"; import "../styles/theme.scss"; import "../scripts/theme.js"; + +import "../styles/components/field-notes.scss"; diff --git a/frontend/src/scripts/manual-report.js b/frontend/src/scripts/manual-report.js index 632d48d..62f7d51 100644 --- a/frontend/src/scripts/manual-report.js +++ b/frontend/src/scripts/manual-report.js @@ -22,7 +22,20 @@ const reportHours = document.querySelector("#report-clock-hours"); const reportMinutes = document.querySelector("#report-clock-minutes"); const occurredAt = document.querySelector("#manual-occurred-at"); - const useNow = document.querySelector("#manual-use-now"); + const clockModeLabel = document.querySelector("#report-clock-mode-label"); + const clockDate = document.querySelector("#report-clock-date"); + const clockEdit = document.querySelector("#report-clock-edit"); + const clockReset = document.querySelector("#report-clock-reset"); + const clockEditor = document.querySelector("#report-clock-editor"); + const clockDraftDate = document.querySelector("#report-clock-draft-date"); + const clockDraftTime = document.querySelector("#report-clock-draft-time"); + const clockApply = document.querySelector("#report-clock-apply"); + const clockCancel = document.querySelector("#report-clock-cancel"); + const clockError = document.querySelector("#report-clock-error"); + const timeApproximate = document.querySelector("#manual-time-approximate"); + let timestampMode = "NOW"; + let overrideTime = null; + let overrideApproximate = false; const burstStatus = document.querySelector("#manual-burst-status"); const burstDuration = document.querySelector("#manual-burst-duration"); let orientationListener; @@ -38,23 +51,93 @@ const displayDegrees = (value) => Number(value.toFixed(1)).toString(); const updateReportTime = () => { if (!reportTime) return; - const now = new Date(); - reportTime.dateTime = now.toISOString(); - const parts = new Intl.DateTimeFormat(document.documentElement.lang || undefined, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).formatToParts(now); + const shown = timestampMode === "OVERRIDE" ? overrideTime : new Date(); + reportTime.dateTime = shown.toISOString(); + const parts = new Intl.DateTimeFormat(document.documentElement.lang || undefined, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).formatToParts(shown); const hours = parts.find((part) => part.type === "hour")?.value; const minutes = parts.find((part) => part.type === "minute")?.value; if (!hours || !minutes || !reportHours || !reportMinutes) return; reportHours.textContent = hours; reportMinutes.textContent = minutes; reportTime.setAttribute("aria-label", `${hours}:${minutes}`); + if (clockDate) { + clockDate.hidden = timestampMode !== "OVERRIDE"; + if (timestampMode === "OVERRIDE") clockDate.textContent = new Intl.DateTimeFormat(document.documentElement.lang || undefined, { day: "numeric", month: "long", year: "numeric" }).format(shown); + } }; updateReportTime(); if (reportTime) window.setInterval(updateReportTime, 60000); const idleSubmitLabel = submitLabel?.textContent || "I heard fireworks"; - useNow?.addEventListener("click", () => { - const now = new Date(); - const local = new Date(now.getTime() - now.getTimezoneOffset() * 60000); - occurredAt.value = local.toISOString().slice(0, 16); + const localInputValue = (date) => { + const pad = (value) => String(value).padStart(2, "0"); + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`; + }; + const clearClockError = () => { + if (!clockError) return; + clockError.hidden = true; + clockError.textContent = ""; + clockDraftDate.removeAttribute("aria-invalid"); + clockDraftTime.removeAttribute("aria-invalid"); + }; + const closeClockEditor = () => { + clockEditor.hidden = true; + clockEdit.setAttribute("aria-expanded", "false"); + clearClockError(); + clockEdit.focus(); + }; + clockEdit?.addEventListener("click", () => { + const [date, time] = localInputValue(timestampMode === "OVERRIDE" ? overrideTime : new Date()).split("T"); + clockDraftDate.value = date; + clockDraftTime.value = time; + timeApproximate.checked = timestampMode === "OVERRIDE" && overrideApproximate; + timeApproximate.disabled = false; + clearClockError(); + clockEditor.hidden = false; + clockEdit.setAttribute("aria-expanded", "true"); + clockDraftDate.focus(); + }); + clockCancel?.addEventListener("click", () => { + timeApproximate.checked = timestampMode === "OVERRIDE" && overrideApproximate; + timeApproximate.disabled = timestampMode === "NOW"; + closeClockEditor(); + }); + clockApply?.addEventListener("click", () => { + const date = clockDraftDate.value; + const time = clockDraftTime.value.trim(); + const value = `${date}T${time}`; + const complete = /^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d$/.test(value); + const chosen = complete ? new Date(value) : null; + if (!chosen || Number.isNaN(chosen.getTime()) || localInputValue(chosen) !== value || chosen.getTime() > Date.now() + 300000) { + clockError.textContent = !chosen || Number.isNaN(chosen.getTime()) || localInputValue(chosen) !== value + ? (t.invalidReportTime || "Enter a valid date and time.") + : (t.futureReportTime || "Report time cannot be in the future."); + clockError.hidden = false; + clockDraftDate.setAttribute("aria-invalid", "true"); + clockDraftTime.setAttribute("aria-invalid", "true"); + (!date ? clockDraftDate : clockDraftTime).focus(); + return; + } + overrideTime = chosen; + overrideApproximate = timeApproximate.checked; + timestampMode = "OVERRIDE"; + occurredAt.value = chosen.toISOString(); + clockModeLabel.textContent = t.adjusted || "Adjusted"; + clockReset.hidden = false; + updateReportTime(); + closeClockEditor(); + }); + clockReset?.addEventListener("click", () => { + timestampMode = "NOW"; + overrideTime = null; + overrideApproximate = false; + occurredAt.value = ""; + timeApproximate.checked = false; + timeApproximate.disabled = true; + clockModeLabel.textContent = t.now || "Now"; + clockReset.hidden = true; + updateReportTime(); + if (!clockEditor.hidden) closeClockEditor(); + clockEdit.focus(); }); const setSubmissionState = (next, message = "") => { @@ -68,6 +151,13 @@ } }; + const rotateNoteContext = (receipt) => { + const token = receipt?.dataset.nextNoteToken; + const input = document.querySelector("#manual-note-context"); + if (!token || !input || input.value === token) return; + input.value = token; + if (window.htmx) htmx.ajax("GET", "/fireworks/notes/?token=" + encodeURIComponent(token), {target: "#live-field-notes", swap: "outerHTML"}); + }; const showResponse = (html, successful) => { const parsed = new DOMParser().parseFromString(html, "text/html").querySelector("#manual-submission"); if (!parsed) { @@ -75,6 +165,7 @@ return false; } document.querySelector("#manual-submission").replaceWith(parsed); + if (successful) rotateNoteContext(parsed); setSubmissionState(successful ? "submitted" : "error"); return successful; }; @@ -213,6 +304,11 @@ }; const submitManualReport = async () => { + if (occurredAt) occurredAt.value = timestampMode === "OVERRIDE" ? overrideTime.toISOString() : ""; + if (timeApproximate) { + timeApproximate.checked = timestampMode === "OVERRIDE" && overrideApproximate; + timeApproximate.disabled = timestampMode === "NOW"; + } setCount(occurrences.value); stopCompassReading(); setSubmissionState("submitting", t.sendingReport || "Sending…"); @@ -300,3 +396,5 @@ if (event.detail.elt === manualForm) setSubmissionState("error", t.reportFailed || "Could not send the report. Please try again."); }); + + document.body.addEventListener("htmx:afterSwap", () => rotateNoteContext(document.querySelector("#manual-submission"))); diff --git a/frontend/src/styles/components/field-notes.scss b/frontend/src/styles/components/field-notes.scss new file mode 100644 index 0000000..ff786ce --- /dev/null +++ b/frontend/src/styles/components/field-notes.scss @@ -0,0 +1,21 @@ +.field-notes { + margin-top: 1.5rem; padding: 1rem; border: 1px solid var(--theme-line); border-radius: 1rem; + color: var(--theme-ink); background: var(--theme-surface); overflow-wrap: anywhere; + h2 { font-size: 1.3rem; } + p, small { line-height: 1.55; } + details { margin: .8rem 0; } + summary { cursor: pointer; padding: .4rem 0; font-weight: 650; } + form { margin-top: .8rem; } + label, small { display: block; margin: .4rem 0; } + input, select, textarea { width: 100%; max-width: 100%; min-width: 0; padding: .65rem; border: 1px solid var(--theme-line); border-radius: .5rem; font: inherit; color: var(--theme-ink); background: var(--theme-input); } + textarea { resize: vertical; } + button { margin-top: .7rem; padding: .65rem 1rem; border: 1px solid var(--theme-line); border-radius: .5rem; background: var(--theme-surface-raised); color: var(--theme-ink); font: inherit; cursor: pointer; } + :focus-visible { outline: 3px solid #789eff; outline-offset: 3px; } + &__fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; } + &__timeline { padding-left: 1.3rem; } + &__timeline > li { padding: .6rem 0 1rem .4rem; border-bottom: 1px solid var(--theme-line); } + &__content { white-space: pre-wrap; } + &__meta, small { color: var(--theme-muted); font-size: .85rem; } + .errorlist { color: #f28c96; } + @media (max-width: 650px) { &__fields { grid-template-columns: 1fr; } } +} diff --git a/frontend/src/styles/components/manual-report-structure.scss b/frontend/src/styles/components/manual-report-structure.scss index 874796c..8eefd21 100644 --- a/frontend/src/styles/components/manual-report-structure.scss +++ b/frontend/src/styles/components/manual-report-structure.scss @@ -6,7 +6,7 @@ --manual-report-section-gap: 1rem; } -.manual-report__occurrence, .manual-report__duration { +.manual-report__duration { display: grid; gap: .55rem; max-width: 36rem; @@ -31,26 +31,6 @@ } .manual-report__duration[hidden] { display: none; } -.manual-report__time-row { - display: flex; - gap: .5rem; - align-items: center; - input { min-width: 0; flex: 1; } - button { flex: none; } -} -@media (max-width: 30rem) { - .manual-report__time-row { flex-direction: column; align-items: stretch; } - .manual-report__time-row button { align-self: flex-start; } -} -.manual-report__occurrence button { - justify-self: start; - padding: .35rem .75rem; - border: 1px solid #725da4; - border-radius: .55rem; - color: #f5f0ff; - background: #302553; - cursor: pointer; -} .manual-report__check { display: flex; align-items: center; @@ -367,6 +347,10 @@ .manual-report__header { padding-right: 2.5rem; } + .manual-report__header .report-clock { + width: calc(100% + 2.5rem); + max-width: none; + } .manual-report form { padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); } @@ -461,6 +445,55 @@ gap: .75rem; } +.report-clock__controls { + display: flex; + align-items: center; + gap: .4rem; +} + +.report-clock__edit, .report-clock__reset, .report-clock__actions button { + min-height: 2.25rem; + padding: .35rem .65rem; + border: 1px solid #936ea8; + border-radius: .55rem; + color: #f5f0ff; + background: #302553; + font: inherit; + cursor: pointer; +} + +.report-clock__edit { min-width: 2.25rem; font-size: 1.2rem; line-height: 1; } +.report-clock__date { display: block; margin-top: .25rem; color: #e9def8; font-size: .85rem; } +.report-clock__reset { margin-top: .6rem; } +.report-clock__editor { display: grid; gap: .5rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid #69539d; color: #f5f0ff; } +.report-clock__fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(7rem, .6fr); gap: .6rem; } +.report-clock__fields > div { min-width: 0; } +@media (max-width: 30rem) { + .report-clock__fields { grid-template-columns: minmax(0, 1fr); } +} +.report-clock__editor label { display: block; margin-bottom: .3rem; font-weight: 650; } +.report-clock__editor input[type="date"], .report-clock__editor input[type="text"] { + box-sizing: border-box; + width: 100%; + min-height: 2.75rem; + padding: .45rem .65rem; + border: 1px solid #936ea8; + border-radius: .55rem; + color: #f5f0ff; + background: #211d3d; + color-scheme: dark; + font: inherit; +} +.report-clock__editor input[type="text"] { font-variant-numeric: tabular-nums; } +.report-clock__actions { display: flex; flex-wrap: wrap; gap: .5rem; } +.report-clock__error { margin: 0; color: #ffb9a9; } +.report-clock [hidden] { display: none !important; } + +@media (max-width: 25rem) { + .report-clock__display { align-items: center; } + .report-clock__now { font-size: .6rem; } +} + .report-clock__time { display: inline-flex; align-items: center; diff --git a/frontend/tests/manual-compass.test.mjs b/frontend/tests/manual-compass.test.mjs index ad6a2cf..31b1680 100644 --- a/frontend/tests/manual-compass.test.mjs +++ b/frontend/tests/manual-compass.test.mjs @@ -5,7 +5,13 @@ import { JSDOM } from "jsdom"; test("compass stays hidden until permission and a heading, then rotates and hides when stopped", async () => { const dom = new JSDOM(` + Now + +
+ @@ -37,6 +43,43 @@ test("compass stays hidden until permission and a heading, then rotates and hide assert.match(reportTime.getAttribute("aria-label"), /^\d{2}:\d{2}$/); assert.equal(reportTime.querySelector(".report-clock__colon").textContent, ":"); assert.match(reportTime.dateTime, /^\d{4}-\d{2}-\d{2}T/); + const editTime = window.document.querySelector("#report-clock-edit"); + const draftDate = window.document.querySelector("#report-clock-draft-date"); + const draftTime = window.document.querySelector("#report-clock-draft-time"); + const submittedTime = window.document.querySelector("#manual-occurred-at"); + editTime.click(); + draftDate.value = "2020-01-02"; + draftTime.value = "12:30"; + window.document.querySelector("#report-clock-cancel").click(); + assert.equal(submittedTime.value, ""); + editTime.click(); + draftTime.value = ""; + window.document.querySelector("#report-clock-apply").click(); + assert.equal(window.document.querySelector("#report-clock-editor").hidden, false); + assert.equal(draftTime.getAttribute("aria-invalid"), "true"); + draftTime.value = "25:00"; + window.document.querySelector("#report-clock-apply").click(); + assert.equal(submittedTime.value, ""); + draftDate.value = "2099-01-02"; + draftTime.value = "12:30"; + window.document.querySelector("#report-clock-apply").click(); + assert.equal(submittedTime.value, ""); + draftDate.value = "2020-01-02"; + draftTime.value = "12:30"; + window.document.querySelector("#manual-time-approximate").checked = true; + window.document.querySelector("#report-clock-apply").click(); + assert.equal(submittedTime.value, new Date("2020-01-02T12:30").toISOString()); + assert.equal(new window.FormData(window.document.querySelector("#manual-report-form")).get("time_approximate"), "on"); + assert.equal(window.document.querySelector("#report-clock-reset").hidden, false); + editTime.click(); + draftDate.value = "2020-01-03"; + draftTime.value = "12:30"; + window.document.querySelector("#report-clock-cancel").click(); + assert.equal(submittedTime.value, new Date("2020-01-02T12:30").toISOString()); + assert.equal(new window.FormData(window.document.querySelector("#manual-report-form")).get("time_approximate"), "on"); + window.document.querySelector("#report-clock-reset").click(); + assert.equal(submittedTime.value, ""); + assert.equal(new window.FormData(window.document.querySelector("#manual-report-form")).get("time_approximate"), null); const compass = window.document.querySelector("#manual-compass"); const rose = window.document.querySelector("#manual-compass-rose"); const button = window.document.querySelector("#manual-capture-direction"); diff --git a/locale/nl/LC_MESSAGES/django.mo b/locale/nl/LC_MESSAGES/django.mo index 4e803a1..808a22e 100644 Binary files a/locale/nl/LC_MESSAGES/django.mo and b/locale/nl/LC_MESSAGES/django.mo differ diff --git a/locale/nl/LC_MESSAGES/django.po b/locale/nl/LC_MESSAGES/django.po index 45fa5cf..333b815 100644 --- a/locale/nl/LC_MESSAGES/django.po +++ b/locale/nl/LC_MESSAGES/django.po @@ -1299,6 +1299,33 @@ msgstr "Nu" msgid "Report time" msgstr "Tijdstip melding" +msgid "Edit report time" +msgstr "Tijdstip aanpassen" + +msgid "Date and time" +msgstr "Datum en tijd" + +msgid "Date" +msgstr "Datum" + +msgid "Time (24-hour)" +msgstr "Tijd (24 uur)" + +msgid "Apply" +msgstr "Toepassen" + +msgid "Cancel" +msgstr "Annuleren" + +msgid "Adjusted" +msgstr "Aangepast" + +msgid "Enter a valid date and time." +msgstr "Voer een geldige datum en tijd in." + +msgid "Report time cannot be in the future." +msgstr "Het tijdstip van de melding kan niet in de toekomst liggen." + msgid "How many times did you hear it?" msgstr "Hoe vaak hoorde je het?" @@ -1483,3 +1510,223 @@ msgstr "Intens" msgid "Report updated!" msgstr "Melding bijgewerkt!" + +#: fireworks_detect/forms.py:11 +msgid "What did you observe or learn?" +msgstr "Wat heb je waargenomen of vernomen?" + +#: fireworks_detect/forms.py:14 +msgid "Note" +msgstr "Notitie" + +#: fireworks_detect/forms.py:14 +msgid "Observed at (optional)" +msgstr "Waargenomen op (optioneel)" + +#: fireworks_detect/forms.py:15 +msgid "Category" +msgstr "Categorie" + +#: fireworks_detect/forms.py:16 +#| msgid "Classification results" +msgid "Verification status" +msgstr "Verificatiestatus" + +#: fireworks_detect/forms.py:16 +msgid "Visibility" +msgstr "Zichtbaarheid" + +#: fireworks_detect/forms.py:18 +msgid "" +"Private by default. Reportable permits authorised export; it does not mean " +"verified or public." +msgstr "Standaard privé. Opneembaar in rapporten staat bevoegde export toe; de notitie is daarmee niet geverifieerd of openbaar." + +#: fireworks_detect/forms.py:19 +msgid "Local time (Europe/Amsterdam). The entry time is recorded separately." +msgstr "Lokale tijd (Europe/Amsterdam). Het tijdstip van invoeren wordt apart vastgelegd." + +#: fireworks_detect/models.py:376 +msgid "General" +msgstr "Algemeen" + +#: fireworks_detect/models.py:377 +msgid "Witness" +msgstr "Getuige" + +#: fireworks_detect/models.py:378 +msgid "People / vehicles" +msgstr "Personen / voertuigen" + +#: fireworks_detect/models.py:379 +msgid "CCTV" +msgstr "Camerabeelden" + +#: fireworks_detect/models.py:380 +#| msgid "Capture direction" +msgid "Location / direction" +msgstr "Locatie / richting" + +#: fireworks_detect/models.py:381 +msgid "Follow-up" +msgstr "Aanvulling" + +#: fireworks_detect/models.py:382 +msgid "Other" +msgstr "Overig" + +#: fireworks_detect/models.py:385 +msgid "First-hand" +msgstr "Zelf waargenomen" + +#: fireworks_detect/models.py:386 +msgid "Second-hand" +msgstr "Van horen zeggen" + +#: fireworks_detect/models.py:387 +msgid "Other / unknown" +msgstr "Overig / onbekend" + +#: fireworks_detect/models.py:390 +msgid "Unverified" +msgstr "Onbevestigd" + +#: fireworks_detect/models.py:391 +msgid "Corroborated" +msgstr "Ondersteund door andere informatie" + +#: fireworks_detect/models.py:392 +msgid "Disputed" +msgstr "Betwist" + +#: fireworks_detect/models.py:395 +msgid "Private" +msgstr "Privé" + +#: fireworks_detect/models.py:396 +#| msgid "Reported" +msgid "Reportable" +msgstr "Opneembaar in rapporten" + +#: fireworks_detect/models.py:427 +msgid "Enter a note." +msgstr "Voer een notitie in." + +#: fireworks_detect/models.py:429 +msgid "The note and its context must have the same author." +msgstr "De notitie en de context moeten dezelfde auteur hebben." + +#: fireworks_detect/models.py:433 +msgid "" +"Field notes are append-only. Add a follow-up to correct an earlier note." +msgstr "Veldnotities kunnen alleen worden aangevuld. Voeg een nieuwe notitie toe om een eerdere notitie te corrigeren." + +#: fireworks_detect/templates/fireworks_detect/dashboard.html:28 +#: fireworks_detect/templates/fireworks_detect/event_detail.html:34 +msgid "Sign in to add private field notes" +msgstr "Log in om privéveldnotities toe te voegen" + +#: fireworks_detect/templates/fireworks_detect/event_page.html:2 +msgid "Event · BoomCast" +msgstr "Gebeurtenis · BoomCast" + +#: fireworks_detect/templates/fireworks_detect/includes/navigation.html:11 +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:2 +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:3 +msgid "Field notes" +msgstr "Veldnotities" + +#: fireworks_detect/templates/fireworks_detect/manual_pending_submission.html:19 +msgid "Add or review field notes for this report" +msgstr "Veldnotities bij deze melding toevoegen of bekijken" + +#: fireworks_detect/templates/fireworks_detect/notes/page.html:2 +msgid "Field notes · BoomCast" +msgstr "Veldnotities · BoomCast" + +#: fireworks_detect/templates/fireworks_detect/notes/page.html:2 +msgid "" +"Exports include only reportable notes you are authorised to export. Private " +"notes are always excluded." +msgstr "Exports bevatten alleen notities die in rapporten mogen worden opgenomen en die je mag exporteren. Privénotities worden altijd uitgesloten." + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:4 +msgid "" +"Human context, separate from detection evidence. Notes are private by " +"default. Add a follow-up to correct an earlier entry." +msgstr "Menselijke context, los van detectiegegevens. Notities zijn standaard privé. Voeg een aanvulling toe om een eerdere notitie te corrigeren." + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:5 +#| msgid "Reported" +msgid "Report" +msgstr "Melding" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:5 +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:32 +msgid "bangs" +msgstr "knallen" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:6 +msgid "Field note saved." +msgstr "Veldnotitie opgeslagen." + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:8 +msgid "Add field note" +msgstr "Veldnotitie toevoegen" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:14 +#| msgid "Report details" +msgid "Optional details" +msgstr "Optionele details" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:19 +msgid "Save field note" +msgstr "Veldnotitie opslaan" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:28 +msgid "Entered" +msgstr "Ingevoerd" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:28 +msgid "Observed" +msgstr "Waargenomen" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:29 +#| msgid "Pending event" +msgid "Pending report" +msgstr "Melding in beoordeling" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:29 +msgid "Current observation — not yet submitted" +msgstr "Huidige waarneming — nog niet ingediend" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:29 +msgid "Standalone observation" +msgstr "Losse waarneming" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:30 +msgid "Association history" +msgstr "Koppelgeschiedenis" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:32 +#| msgid "Approved events." +msgid "Link to an approved event" +msgstr "Koppelen aan een goedgekeurde gebeurtenis" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:32 +#| msgid "Select an event" +msgid "Choose an event" +msgstr "Kies een gebeurtenis" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:32 +#| msgid "Administration" +msgid "Link observation" +msgstr "Waarneming koppelen" + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:35 +msgid "No field notes visible to you yet." +msgstr "Er zijn nog geen veldnotities zichtbaar voor jou." + +#: fireworks_detect/templates/fireworks_detect/notes/panel.html:37 +msgid "My field notes" +msgstr "Mijn veldnotities" diff --git a/staticfiles/vite/.vite/manifest.json b/staticfiles/vite/.vite/manifest.json index 51f0c9d..31e3dc6 100644 --- a/staticfiles/vite/.vite/manifest.json +++ b/staticfiles/vite/.vite/manifest.json @@ -1,198 +1,332 @@ { - "_fireworks-navigation-B0T7du8_.css": { - "file": "assets/fireworks-navigation-B0T7du8_.css", - "src": "_fireworks-navigation-B0T7du8_.css" + "_field-notes-STCCElbj.css": { + "file": "assets/field-notes-STCCElbj.css", + "src": "_field-notes-STCCElbj.css" }, - "_manual-report-BLClvilD.js": { - "file": "assets/manual-report-BLClvilD.js", + "_fireworks-navigation-BViXwBBT.css": { + "file": "assets/fireworks-navigation-BViXwBBT.css", + "src": "_fireworks-navigation-BViXwBBT.css" + }, + "_fonts-4o1Uz5dn.css": { + "file": "assets/fonts-4o1Uz5dn.css", + "src": "_fonts-4o1Uz5dn.css" + }, + "_manual-report-BCwcwvAZ.css": { + "file": "assets/manual-report-BCwcwvAZ.css", + "src": "_manual-report-BCwcwvAZ.css" + }, + "_manual-report-DoPagyx-.js": { + "file": "assets/manual-report-DoPagyx-.js", "name": "manual-report", "css": [ - "assets/manual-report-CLK_w7Fu.css" + "assets/manual-report-BCwcwvAZ.css" ] }, - "_manual-report-CLK_w7Fu.css": { - "file": "assets/manual-report-CLK_w7Fu.css", - "src": "_manual-report-CLK_w7Fu.css" + "_theme-CHgv-U5K.css": { + "file": "assets/theme-CHgv-U5K.css", + "src": "_theme-CHgv-U5K.css" }, - "_theme-CW8WI6CF.css": { - "file": "assets/theme-CW8WI6CF.css", - "src": "_theme-CW8WI6CF.css" - }, - "_theme-DLdboZXJ.js": { - "file": "assets/theme-DLdboZXJ.js", + "_theme-DXAi27ON.js": { + "file": "assets/theme-DXAi27ON.js", "name": "theme", "css": [ - "assets/theme-CW8WI6CF.css" + "assets/theme-CHgv-U5K.css" ] }, "frontend/src/entries/admin-audio-preview.js": { - "file": "assets/frontend/src/entries/admin-audio-preview.js-B71K8d99.js", + "file": "assets/frontend/src/entries/admin-audio-preview.js-vLZXVaMY.js", "name": "frontend/src/entries/admin-audio-preview.js", "src": "frontend/src/entries/admin-audio-preview.js", "isEntry": true, "css": [ - "assets/admin-audio-preview-GrJiPCWO.css" + "assets/admin-audio-preview-GrJiPCWO.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/admin-login.js": { - "file": "assets/frontend/src/entries/admin-login.js-CfSuUv-t.js", + "file": "assets/frontend/src/entries/admin-login.js-Bh9Fp4Fr.js", "name": "frontend/src/entries/admin-login.js", "src": "frontend/src/entries/admin-login.js", "isEntry": true, "css": [ - "assets/admin-login-DfgxK8tz.css" + "assets/admin-login-CJd637Ns.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/dashboard.js": { - "file": "assets/frontend/src/entries/dashboard.js-ERuRY_J9.js", + "file": "assets/frontend/src/entries/dashboard.js-Bp7rX0Fc.js", "name": "frontend/src/entries/dashboard.js", "src": "frontend/src/entries/dashboard.js", "isEntry": true, "imports": [ "frontend/src/entries/fireworks-home.js", "frontend/src/entries/map.js", - "_manual-report-BLClvilD.js", - "_theme-DLdboZXJ.js" + "_manual-report-DoPagyx-.js", + "_theme-DXAi27ON.js" ], "css": [ - "assets/dashboard-BLKe9w6Q.css", - "assets/fireworks-navigation-B0T7du8_.css" + "assets/dashboard-C1NKhBy7.css", + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css", + "assets/field-notes-STCCElbj.css" ] }, "frontend/src/entries/events.js": { - "file": "assets/frontend/src/entries/events.js-BOQifILX.js", + "file": "assets/frontend/src/entries/events.js-CoDvu5q7.js", "name": "frontend/src/entries/events.js", "src": "frontend/src/entries/events.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/events-CTJ_TfvY.css", - "assets/fireworks-navigation-B0T7du8_.css" + "assets/events-eRxioTQd.css", + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css", + "assets/field-notes-STCCElbj.css" ] }, "frontend/src/entries/fireworks-home.js": { - "file": "assets/frontend/src/entries/fireworks-home.js-CHsiS21S.js", + "file": "assets/frontend/src/entries/fireworks-home.js-CZsCTUTv.js", "name": "frontend/src/entries/fireworks-home.js", "src": "frontend/src/entries/fireworks-home.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" + ], + "dynamicImports": [ + "frontend/src/scripts/browser-submission-processor.js" ], "css": [ - "assets/fireworks-home-ofY4zwOZ.css", - "assets/fireworks-navigation-B0T7du8_.css" + "assets/fireworks-home-ojbnZX65.css", + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css" ] }, "frontend/src/entries/home.js": { - "file": "assets/frontend/src/entries/home.js-CZl35ei7.js", + "file": "assets/frontend/src/entries/home.js-Ds8f2Z8A.js", "name": "frontend/src/entries/home.js", "src": "frontend/src/entries/home.js", "isEntry": true, "imports": [ - "_manual-report-BLClvilD.js", - "_theme-DLdboZXJ.js" + "_manual-report-DoPagyx-.js", + "_theme-DXAi27ON.js" ], "css": [ - "assets/home-tgr8z1B7.css" + "assets/home-BZbCv9Mm.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/legacy-fireworks-home.js": { - "file": "assets/frontend/src/entries/legacy-fireworks-home.js-BQuB64h2.js", + "file": "assets/frontend/src/entries/legacy-fireworks-home.js-Cod9E8XY.js", "name": "frontend/src/entries/legacy-fireworks-home.js", "src": "frontend/src/entries/legacy-fireworks-home.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/legacy-fireworks-home-DVDWazp8.css" + "assets/legacy-fireworks-home-C1-s3aRT.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/login.js": { - "file": "assets/frontend/src/entries/login.js-fU9bqtQj.js", + "file": "assets/frontend/src/entries/login.js-PEW1GjqV.js", "name": "frontend/src/entries/login.js", "src": "frontend/src/entries/login.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/login-CMTHjyC6.css" + "assets/login-CxDTcyYu.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/map.js": { - "file": "assets/frontend/src/entries/map.js-BA2PfDOg.js", + "file": "assets/frontend/src/entries/map.js-ZTK3kmoy.js", "name": "frontend/src/entries/map.js", "src": "frontend/src/entries/map.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/map-CUm_1Dqq.css", - "assets/fireworks-navigation-B0T7du8_.css" + "assets/map-CneBwLkV.css", + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css" ] }, "frontend/src/entries/member-form.js": { - "file": "assets/frontend/src/entries/member-form.js-B30CZoK0.js", + "file": "assets/frontend/src/entries/member-form.js-Di4vmLCq.js", "name": "frontend/src/entries/member-form.js", "src": "frontend/src/entries/member-form.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/member-form-BzsMXZtV.css" + "assets/member-form-CvIJ0BOZ.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/member-list.js": { - "file": "assets/frontend/src/entries/member-list.js-CfYXXJhy.js", + "file": "assets/frontend/src/entries/member-list.js-Buj1pYaw.js", "name": "frontend/src/entries/member-list.js", "src": "frontend/src/entries/member-list.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/member-list-D2ApQodm.css" + "assets/member-list-DxFGu1JS.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/member-success.js": { - "file": "assets/frontend/src/entries/member-success.js-BXfLAYYO.js", + "file": "assets/frontend/src/entries/member-success.js-By5Mf6TX.js", "name": "frontend/src/entries/member-success.js", "src": "frontend/src/entries/member-success.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/member-success-BCH60Gre.css" + "assets/member-success-Ck85tFD-.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/not-found.js": { - "file": "assets/frontend/src/entries/not-found.js-CuGnbXiG.js", + "file": "assets/frontend/src/entries/not-found.js-BtTrR72f.js", "name": "frontend/src/entries/not-found.js", "src": "frontend/src/entries/not-found.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/not-found-BeUv81Ot.css" + "assets/not-found-BuNpIK-z.css", + "assets/fonts-4o1Uz5dn.css" ] }, "frontend/src/entries/settings.js": { - "file": "assets/frontend/src/entries/settings.js-SrQbM6Ii.js", + "file": "assets/frontend/src/entries/settings.js-s58FgvNQ.js", "name": "frontend/src/entries/settings.js", "src": "frontend/src/entries/settings.js", "isEntry": true, "imports": [ - "_theme-DLdboZXJ.js" + "_theme-DXAi27ON.js" ], "css": [ - "assets/settings-B_NtXgaK.css" + "assets/settings-D3H5dzmU.css", + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css" ] + }, + "frontend/src/scripts/audio-preprocessor.js": { + "file": "assets/audio-preprocessor-B6FBlKED.js", + "name": "audio-preprocessor", + "src": "frontend/src/scripts/audio-preprocessor.js", + "isDynamicEntry": true + }, + "frontend/src/scripts/browser-submission-gate.js": { + "file": "assets/browser-submission-gate-D8pBYGfs.js", + "name": "browser-submission-gate", + "src": "frontend/src/scripts/browser-submission-gate.js", + "isDynamicEntry": true + }, + "frontend/src/scripts/browser-submission-processor.js": { + "file": "assets/browser-submission-processor-YT5vt2-z.js", + "name": "browser-submission-processor", + "src": "frontend/src/scripts/browser-submission-processor.js", + "isDynamicEntry": true, + "imports": [ + "frontend/src/entries/fireworks-home.js", + "_theme-DXAi27ON.js" + ], + "dynamicImports": [ + "frontend/src/scripts/ffmpeg-video-extractor.js", + "frontend/src/scripts/audio-preprocessor.js", + "frontend/src/scripts/browser-yamnet-classifier.js", + "frontend/src/scripts/browser-submission-gate.js" + ], + "css": [ + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css" + ] + }, + "frontend/src/scripts/browser-yamnet-classifier.js": { + "file": "assets/browser-yamnet-classifier-ldF6zTfh.js", + "name": "browser-yamnet-classifier", + "src": "frontend/src/scripts/browser-yamnet-classifier.js", + "isDynamicEntry": true, + "imports": [ + "frontend/src/entries/fireworks-home.js", + "_theme-DXAi27ON.js" + ], + "dynamicImports": [ + "node_modules/@tensorflow/tfjs/dist/index.js" + ], + "css": [ + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css" + ] + }, + "frontend/src/scripts/ffmpeg-video-extractor.js": { + "file": "assets/ffmpeg-video-extractor-KJPjcx9x.js", + "name": "ffmpeg-video-extractor", + "src": "frontend/src/scripts/ffmpeg-video-extractor.js", + "isDynamicEntry": true, + "imports": [ + "frontend/src/entries/fireworks-home.js", + "_theme-DXAi27ON.js" + ], + "dynamicImports": [ + "node_modules/@ffmpeg/ffmpeg/dist/esm/index.js", + "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js?url", + "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.wasm?url" + ], + "css": [ + "assets/fonts-4o1Uz5dn.css", + "assets/fireworks-navigation-BViXwBBT.css" + ] + }, + "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js": { + "file": "assets/ffmpeg-core-CI9Irx9p.js", + "src": "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js" + }, + "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js?url": { + "file": "assets/ffmpeg-core-CTa1UqMt.js", + "name": "ffmpeg-core", + "src": "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js?url", + "isDynamicEntry": true, + "assets": [ + "assets/ffmpeg-core-CI9Irx9p.js" + ] + }, + "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.wasm": { + "file": "assets/ffmpeg-core-CgUfceKH.wasm", + "src": "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.wasm" + }, + "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.wasm?url": { + "file": "assets/ffmpeg-core-DJ3ydieg.js", + "name": "ffmpeg-core", + "src": "node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.wasm?url", + "isDynamicEntry": true, + "assets": [ + "assets/ffmpeg-core-CgUfceKH.wasm" + ] + }, + "node_modules/@ffmpeg/ffmpeg/dist/esm/index.js": { + "file": "assets/index-Cr8NHl2n.js", + "name": "index", + "src": "node_modules/@ffmpeg/ffmpeg/dist/esm/index.js", + "isDynamicEntry": true + }, + "node_modules/@tensorflow/tfjs/dist/index.js": { + "file": "assets/index-jWGXPN38.js", + "name": "index", + "src": "node_modules/@tensorflow/tfjs/dist/index.js", + "isDynamicEntry": true } } \ No newline at end of file diff --git a/staticfiles/vite/assets/field-notes-STCCElbj.css b/staticfiles/vite/assets/field-notes-STCCElbj.css new file mode 100644 index 0000000..19ddd11 --- /dev/null +++ b/staticfiles/vite/assets/field-notes-STCCElbj.css @@ -0,0 +1 @@ +.field-notes{margin-top:1.5rem;padding:1rem;border:1px solid var(--theme-line);border-radius:1rem;color:var(--theme-ink);background:var(--theme-surface);overflow-wrap:anywhere}.field-notes h2{font-size:1.3rem}.field-notes p,.field-notes small{line-height:1.55}.field-notes details{margin:.8rem 0}.field-notes summary{cursor:pointer;padding:.4rem 0;font-weight:650}.field-notes form{margin-top:.8rem}.field-notes label,.field-notes small{display:block;margin:.4rem 0}.field-notes input,.field-notes select,.field-notes textarea{width:100%;max-width:100%;min-width:0;padding:.65rem;border:1px solid var(--theme-line);border-radius:.5rem;font:inherit;color:var(--theme-ink);background:var(--theme-input)}.field-notes textarea{resize:vertical}.field-notes button{margin-top:.7rem;padding:.65rem 1rem;border:1px solid var(--theme-line);border-radius:.5rem;background:var(--theme-surface-raised);color:var(--theme-ink);font:inherit;cursor:pointer}.field-notes :focus-visible{outline:3px solid #789eff;outline-offset:3px}.field-notes__fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.8rem}.field-notes__timeline{padding-left:1.3rem}.field-notes__timeline>li{padding:.6rem 0 1rem .4rem;border-bottom:1px solid var(--theme-line)}.field-notes__content{white-space:pre-wrap}.field-notes__meta,.field-notes small{color:var(--theme-muted);font-size:.85rem}.field-notes .errorlist{color:#f28c96}@media(max-width:650px){.field-notes__fields{grid-template-columns:1fr}} diff --git a/staticfiles/vite/assets/frontend/src/entries/dashboard.js-3hFnSBs1.js b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-3hFnSBs1.js new file mode 100644 index 0000000..8cb8cc4 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-3hFnSBs1.js @@ -0,0 +1 @@ +/* empty css *//* empty css */import"./fireworks-home.js-CZsCTUTv.js";import"./map.js-ZTK3kmoy.js";import"../../../manual-report-C-E8HQa9.js";import"../../../theme-DXAi27ON.js";/* empty css */ diff --git a/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Bp7rX0Fc.js b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Bp7rX0Fc.js new file mode 100644 index 0000000..452ccce --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Bp7rX0Fc.js @@ -0,0 +1 @@ +/* empty css *//* empty css */import"./fireworks-home.js-CZsCTUTv.js";import"./map.js-ZTK3kmoy.js";import"../../../manual-report-DoPagyx-.js";import"../../../theme-DXAi27ON.js";/* empty css */ diff --git a/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Cd3cJ7c8.js b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Cd3cJ7c8.js new file mode 100644 index 0000000..2b579e5 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Cd3cJ7c8.js @@ -0,0 +1 @@ +/* empty css *//* empty css */import"./fireworks-home.js-CZsCTUTv.js";import"./map.js-ZTK3kmoy.js";import"../../../manual-report-v3jdwBHW.js";import"../../../theme-DXAi27ON.js";/* empty css */ diff --git a/staticfiles/vite/assets/frontend/src/entries/dashboard.js-DjXGzNR2.js b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-DjXGzNR2.js new file mode 100644 index 0000000..c2be428 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-DjXGzNR2.js @@ -0,0 +1 @@ +/* empty css *//* empty css */import"./fireworks-home.js-CZsCTUTv.js";import"./map.js-ZTK3kmoy.js";import"../../../manual-report-CvfBM7VE.js";import"../../../theme-DXAi27ON.js";/* empty css */ diff --git a/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Py-48UFv.js b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Py-48UFv.js new file mode 100644 index 0000000..7b2d808 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/dashboard.js-Py-48UFv.js @@ -0,0 +1 @@ +/* empty css *//* empty css */import"./fireworks-home.js-CZsCTUTv.js";import"./map.js-ZTK3kmoy.js";import"../../../manual-report-DqrR4OFn.js";import"../../../theme-DXAi27ON.js";/* empty css */ diff --git a/staticfiles/vite/assets/frontend/src/entries/events.js-CoDvu5q7.js b/staticfiles/vite/assets/frontend/src/entries/events.js-CoDvu5q7.js new file mode 100644 index 0000000..cd325ca --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/events.js-CoDvu5q7.js @@ -0,0 +1 @@ +/* empty css *//* empty css */import"../../../theme-DXAi27ON.js";/* empty css */ diff --git a/staticfiles/vite/assets/frontend/src/entries/home.js-C50yGk5n.js b/staticfiles/vite/assets/frontend/src/entries/home.js-C50yGk5n.js new file mode 100644 index 0000000..913c1e0 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/home.js-C50yGk5n.js @@ -0,0 +1 @@ +/* empty css */import"../../../manual-report-v3jdwBHW.js";import"../../../theme-DXAi27ON.js"; diff --git a/staticfiles/vite/assets/frontend/src/entries/home.js-CfStiIoi.js b/staticfiles/vite/assets/frontend/src/entries/home.js-CfStiIoi.js new file mode 100644 index 0000000..0948473 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/home.js-CfStiIoi.js @@ -0,0 +1 @@ +/* empty css */import"../../../manual-report-CvfBM7VE.js";import"../../../theme-DXAi27ON.js"; diff --git a/staticfiles/vite/assets/frontend/src/entries/home.js-CwB_w-Jk.js b/staticfiles/vite/assets/frontend/src/entries/home.js-CwB_w-Jk.js new file mode 100644 index 0000000..03cb586 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/home.js-CwB_w-Jk.js @@ -0,0 +1 @@ +/* empty css */import"../../../manual-report-DqrR4OFn.js";import"../../../theme-DXAi27ON.js"; diff --git a/staticfiles/vite/assets/frontend/src/entries/home.js-Ds8f2Z8A.js b/staticfiles/vite/assets/frontend/src/entries/home.js-Ds8f2Z8A.js new file mode 100644 index 0000000..64a41c5 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/home.js-Ds8f2Z8A.js @@ -0,0 +1 @@ +/* empty css */import"../../../manual-report-DoPagyx-.js";import"../../../theme-DXAi27ON.js"; diff --git a/staticfiles/vite/assets/frontend/src/entries/home.js-rs216Ihj.js b/staticfiles/vite/assets/frontend/src/entries/home.js-rs216Ihj.js new file mode 100644 index 0000000..0a32645 --- /dev/null +++ b/staticfiles/vite/assets/frontend/src/entries/home.js-rs216Ihj.js @@ -0,0 +1 @@ +/* empty css */import"../../../manual-report-C-E8HQa9.js";import"../../../theme-DXAi27ON.js"; diff --git a/staticfiles/vite/assets/manual-report-BCwcwvAZ.css b/staticfiles/vite/assets/manual-report-BCwcwvAZ.css new file mode 100644 index 0000000..533a659 --- /dev/null +++ b/staticfiles/vite/assets/manual-report-BCwcwvAZ.css @@ -0,0 +1 @@ +.manual-report__supporting{padding:1rem;border:1px solid #514282;border-radius:1rem;background:#11152c}.manual-report__supporting-header{display:flex;align-items:center;gap:.7rem}.manual-report__microphone{display:grid;width:2.5rem;height:2.5rem;flex:none;place-items:center;border-radius:.7rem;background:#2a2051;font-size:1.3rem}.burst-listener__state{display:block;margin-top:.15rem;color:#b9addb;font-size:.84rem}.manual-report__supporting[data-state=listening] .burst-listener__state{color:#8fe5cc}.manual-report__supporting[data-state=error] .burst-listener__state{color:#ffbd9d}.burst-listener{width:100%;margin-top:.85rem}.burst-listener__button,.burst-listener__actions button{min-height:2.75rem;padding:.65rem 1rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#292148;cursor:pointer}.burst-listener__button{width:100%}.burst-listener__panel{color:#f0eaff}.burst-listener__panel strong{font-size:.92rem}.burst-listener__panel canvas{display:block;width:100%;height:4rem;margin:.7rem 0 .35rem;border-radius:.5rem;background:linear-gradient(90deg,#191738,#241b44)}.burst-listener__panel p{margin:.35rem 0 .75rem;color:#b9addb;font-size:.82rem}.burst-listener__panel audio{width:100%;margin-bottom:.75rem}.burst-listener__actions{display:flex;flex-wrap:wrap;gap:.5rem}.burst-listener__actions button{flex:1 1 10rem}.burst-listener__actions #burst-stop{border-color:#fb9b72;color:#ffd8c4;background:#2e1b31}.burst-listener [hidden]{display:none!important}.burst-listener [role=alert]{margin:.65rem 0 0;color:#ffd1b6}.burst-listener button:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__microphone{background:#ead2eb}:root[data-theme=light] .burst-listener__state,:root[data-theme=light] .burst-listener__panel p{color:#694b68}:root[data-theme=light] .burst-listener__panel{color:#321d42}:root[data-theme=light] .burst-listener__button,:root[data-theme=light] .burst-listener__actions button{border-color:#b68bb5;color:#321d42;background:#ead2eb}:root[data-theme=light] .burst-listener__actions #burst-stop{border-color:#cf7957;color:#71331d;background:#ffe9de}.manual-compass{display:grid;justify-items:center;width:7rem;margin:.6rem 0 0 auto;color:#fff3d7;font-size:.78rem;font-weight:850;font-variant-numeric:tabular-nums}.manual-compass[hidden]{display:none}.manual-compass__dial{position:relative;width:5.75rem;aspect-ratio:1;border:2px solid #f2d7a8;border-radius:50%;background:radial-gradient(circle,#342441 0,#342441 28%,#211a32 75%);box-shadow:0 .35rem 1rem #09061566,inset 0 0 0 .25rem #ffffff12}.manual-compass__rose{position:absolute;top:0;right:0;bottom:0;left:0;transition:transform .12s ease-out}.manual-compass__rose span{position:absolute;line-height:1}.manual-compass__north{top:.38rem;left:50%;color:#ff9e78;transform:translate(-50%)}.manual-compass__east{right:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__south{bottom:.38rem;left:50%;transform:translate(-50%)}.manual-compass__west{left:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__pointer{position:absolute;top:-.55rem;left:50%;width:0;height:0;border-right:.37rem solid transparent;border-bottom:.65rem solid #ffbd62;border-left:.37rem solid transparent;transform:translate(-50%);filter:drop-shadow(0 .1rem .15rem #160d1b)}.manual-compass__center{position:absolute;top:50%;left:50%;width:.5rem;aspect-ratio:1;border-radius:50%;background:#ffbd62;transform:translate(-50%,-50%)}.manual-compass__heading{margin-top:.5rem;white-space:nowrap}:root[data-theme=light] .manual-compass{color:#43243d}:root[data-theme=light] .manual-compass__dial{border-color:#996a9b;background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 28%,#e8d7e9 75%)}:root[data-theme=light] .manual-compass__east,:root[data-theme=light] .manual-compass__south,:root[data-theme=light] .manual-compass__west{color:#43243d}@media(prefers-reduced-motion:reduce){.manual-compass__rose{transition:none}}.manual-report__header{max-width:42rem}.manual-report{--manual-report-section-gap: 1rem}.manual-report__duration{display:grid;gap:.55rem;max-width:36rem;margin-bottom:var(--manual-report-section-gap);padding:.85rem 1rem;border:1px solid #584891;border-radius:1rem;background:#151932;color:#e9def8}.manual-report__duration input[type=datetime-local],.manual-report__duration input[type=number]{width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #725da4;border-radius:.55rem;color:#f5f0ff;background:#211d3d;font:inherit;color-scheme:dark}.manual-report__duration small{color:#cbbce5}.manual-report__duration[hidden]{display:none}.manual-report__check{display:flex;align-items:center;gap:.5rem;color:#e9def8}.manual-report__burst-status{margin:.5rem 0 0;color:#ffbf72;font-weight:750}.manual-submission__edit{display:grid;gap:.4rem;max-width:18rem;margin-top:1rem}.manual-submission__edit input[type=number]{min-height:2.5rem;padding:.4rem;border-radius:.5rem}.manual-submission__edit button{min-height:2.5rem;cursor:pointer}.manual-report__primary{display:grid;gap:var(--manual-report-section-gap);max-width:36rem}.manual-report__quantity{padding:1rem;border:1px solid #584891;border-radius:1rem;background:#151932}.manual-report .manual-report__quantity #manual-occurrences{width:100%;min-width:0;min-height:3.75rem;margin:0;padding:0;border:0;color:#f5f0ff;font-size:clamp(2.25rem,8vw,3.5rem);font-weight:850;text-align:center;background:transparent;-webkit-appearance:textfield;appearance:textfield;-moz-appearance:textfield}.manual-report__quantity #manual-occurrences::-webkit-inner-spin-button,.manual-report__quantity #manual-occurrences::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.manual-report__stepper{display:grid;grid-template-columns:3.5rem minmax(0,1fr) 3.5rem;align-items:center;gap:.5rem}.manual-report__stepper button{display:grid;place-items:center;width:3.5rem;height:3.5rem;min-height:0;padding:0;border:1px solid #6d54ac;border-radius:50%;color:#f5f0ff;font:inherit;font-size:2rem;line-height:1;background:#302553;cursor:pointer}.manual-report__stepper button:disabled{opacity:.4;cursor:default}.manual-report .manual-report__primary .manual-direction-panel{width:100%;margin:0;border-radius:1rem;background:#1a1739}.manual-direction-panel[data-state=measuring]{border-color:#a27cff}.manual-direction-panel[data-state=captured]{border-color:#68dba1}.manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}.manual-direction-panel__topline{display:flex;align-items:center;justify-content:space-between;gap:1rem}.manual-direction-panel__summary{margin:.35rem 0 .8rem;color:#f5f0ff;font-weight:700}.manual-report .manual-direction-panel__status--accuracy{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin:.75rem 0;padding:.55rem .75rem;border:1px solid #5d4d92;border-radius:.7rem;color:#d9cfee;background:#191630;font-size:.85rem}.manual-direction-panel__status--accuracy strong{color:#f5edff;font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.manual-direction-panel__open,.manual-direction-panel__close{min-height:2.75rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#302553;cursor:pointer}.manual-direction-panel__open{padding:.5rem .85rem}.manual-direction-panel__close{min-width:2.75rem;font-size:1.4rem}.manual-report #manual-submit{width:100%;max-width:36rem;min-height:4.5rem;margin-top:var(--manual-report-section-gap)}.manual-report__submit:disabled{cursor:wait;opacity:.72}.manual-submission{display:grid;justify-items:center;gap:.5rem;max-width:36rem;margin-top:1rem;padding:1.3rem;border:1px solid #4caa82;border-radius:1rem;color:#eafff2;text-align:center;background:#10352e}.manual-submission__icon{display:grid;width:3.5rem;height:3.5rem;place-items:center;border:2px solid #6ce4a8;border-radius:50%;color:#eafff2;font-size:2rem;background:#226c51}.manual-submission strong{font-size:1.35rem}.manual-submission p{margin:0;line-height:1.45}.manual-submission__summary{margin-top:.35rem!important;color:#b2e8cf;font-size:.9rem}.manual-submission--error{border-color:#d37c6a;color:#fff0e8;background:#3a1c2b}.manual-submission--error .manual-submission__icon{border-color:#ffac8c;background:#9b493a}.manual-report__submission:empty{display:none}.manual-report button:focus-visible,.manual-report input:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}.manual-report__supporting{max-width:36rem;margin-top:var(--manual-report-section-gap);padding-top:1.25rem;border-top:1px solid #584891}.manual-report__supporting h3{margin:0;color:#d8cffd;font-size:1rem}.manual-report__supporting .burst-listener{width:100%}:root[data-theme=light] .manual-report__quantity{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__quantity #manual-occurrences{border:0!important;color:#321d42!important;background:transparent!important}:root[data-theme=light] .manual-report__stepper button,:root[data-theme=light] .manual-direction-panel__open,:root[data-theme=light] .manual-direction-panel__close{color:#321d42;border-color:#b68bb5;background:#ead2eb}:root[data-theme=light] .manual-direction-panel__summary{color:#321d42}:root[data-theme=light] .manual-report .manual-direction-panel__status--accuracy{border-color:#cfaad1;color:#694b68;background:#fff8fb}:root[data-theme=light] .manual-direction-panel__status--accuracy strong{color:#321d42}:root[data-theme=light] .manual-submission{border-color:#54a67b;color:#164d34;background:#e8fff2}:root[data-theme=light] .manual-submission__icon{color:#fff}:root[data-theme=light] .manual-submission__summary{color:#2b6b48}:root[data-theme=light] .manual-submission--error{border-color:#ca7d65;color:#743520;background:#fff0e8}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8}:root[data-theme=light] .manual-report__supporting h3{color:#492846}@media(max-width:42rem){.home-grid{grid-template-columns:minmax(0,1fr)}body:not(.dashboard-page){padding:max(1rem,env(safe-area-inset-top,0px)) max(.5rem,env(safe-area-inset-right,0px)) max(1rem,env(safe-area-inset-bottom,0px)) max(.5rem,env(safe-area-inset-left,0px))}.home-grid .manual-report,.dashboard-report,.dashboard-report .manual-report{overflow:visible}.manual-report{padding:1.25rem}.dashboard-report .manual-report{padding:0}.manual-report__header{padding-right:2.5rem}.manual-report__header .report-clock{width:calc(100% + 2.5rem);max-width:none}.manual-report form{padding-bottom:calc(5rem + env(safe-area-inset-bottom,0px))}.manual-report #manual-submit{position:sticky;bottom:calc(.5rem + env(safe-area-inset-bottom,0px));z-index:10;box-shadow:0 .7rem 1.6rem #070a18b3}body:has(#manual-occurrences:focus) .manual-report #manual-submit{position:static}.dashboard-intro{margin-bottom:1rem}.dashboard-intro h1{font-size:clamp(2rem,8vw,2.8rem)}.dashboard-intro p:last-child{margin-top:.75rem;font-size:.95rem;line-height:1.4}.dashboard-section{margin-top:1rem}.dashboard-shell{padding-bottom:calc(2rem + env(safe-area-inset-bottom,0px))}.manual-report__stepper{grid-template-columns:3.5rem minmax(0,1fr) 3.5rem}}@media(max-width:23.5rem){.manual-report{padding:1rem}.manual-report__quantity{padding:.75rem}.manual-report__stepper{grid-template-columns:3rem minmax(0,1fr) 3rem;gap:.25rem}.manual-report__stepper button{width:3rem;height:3rem}}.manual-report__heading-row{display:flex;align-items:center;gap:.7rem}.manual-report__fire{flex:none;font-size:clamp(1.8rem,5vw,2.5rem);filter:drop-shadow(0 .2rem .65rem rgba(255,112,59,.5333333333))}.manual-report__intro,.dashboard-report .manual-report__intro{margin-bottom:.85rem}.report-clock{box-sizing:border-box;width:100%;max-width:36rem;margin:0 0 1rem;padding:.65rem .95rem .7rem;border:1px solid #69539d;border-radius:.85rem;background:linear-gradient(115deg,#17162d,#10182c);box-shadow:inset 0 1px #ffffff0a}.report-clock__label{color:#cbbce5;font-size:.66rem;font-weight:750;letter-spacing:.13em;text-transform:uppercase}.report-clock__display{display:flex;align-items:end;justify-content:space-between;gap:.75rem}.report-clock__controls{display:flex;align-items:center;gap:.4rem}.report-clock__edit,.report-clock__reset,.report-clock__actions button{min-height:2.25rem;padding:.35rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#302553;font:inherit;cursor:pointer}.report-clock__edit{min-width:2.25rem;font-size:1.2rem;line-height:1}.report-clock__date{display:block;margin-top:.25rem;color:#e9def8;font-size:.85rem}.report-clock__reset{margin-top:.6rem}.report-clock__editor{display:grid;gap:.5rem;margin-top:.8rem;padding-top:.8rem;border-top:1px solid #69539d;color:#f5f0ff}.report-clock__fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(7rem,.6fr);gap:.6rem}.report-clock__fields>div{min-width:0}@media(max-width:30rem){.report-clock__fields{grid-template-columns:minmax(0,1fr)}}.report-clock__editor label{display:block;margin-bottom:.3rem;font-weight:650}.report-clock__editor input[type=date],.report-clock__editor input[type=text]{box-sizing:border-box;width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#211d3d;color-scheme:dark;font:inherit}.report-clock__editor input[type=text]{font-variant-numeric:tabular-nums}.report-clock__actions{display:flex;flex-wrap:wrap;gap:.5rem}.report-clock__error{margin:0;color:#ffb9a9}.report-clock [hidden]{display:none!important}@media(max-width:25rem){.report-clock__display{align-items:center}.report-clock__now{font-size:.6rem}}.report-clock__time{display:inline-flex;align-items:center;color:#ffbf72;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:clamp(2rem,9vw,2.45rem);font-weight:700;line-height:1.1;letter-spacing:0;font-variant-numeric:tabular-nums;text-shadow:0 0 .7rem rgba(255,150,59,.3333333333);white-space:nowrap}.report-clock__time span{display:inline-block}.report-clock__time #report-clock-hours,.report-clock__time #report-clock-minutes{width:2ch}.report-clock__colon{width:1ch;flex:none;margin-inline:-.08em;line-height:1;text-align:center;transform:translateY(-.06em);animation:report-clock-blink 2s steps(1,end) infinite}.report-clock__now{display:inline-flex;align-items:center;gap:.4rem;flex:none;padding:.2rem .45rem;border:1px solid #93634d;border-radius:999px;color:#ffd2a2;font-size:.7rem;font-weight:750;letter-spacing:.08em;text-transform:uppercase}.report-clock__dot{width:.4rem;height:.4rem;border-radius:50%;background:#ffab5d}@keyframes report-clock-blink{50%{opacity:0}}.manual-direction-panel__open{width:100%;text-align:left}.manual-direction-panel--open .manual-compass{width:100%;margin:.5rem auto 1rem}.manual-direction-panel--open .manual-compass__dial{width:min(100%,12rem);border-color:#8b67d4;background:radial-gradient(circle,#302054 0,#302054 20%,#17132d 70%);box-shadow:0 0 0 .35rem #6640a228,0 0 2rem #ac6aff35}.manual-direction-panel--open .manual-compass__pointer{border-bottom-color:#ff925f}.manual-direction-panel--open .manual-compass__heading{font-size:1.1rem}.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:transform .15s ease,box-shadow .15s ease,filter .15s ease}.manual-report__stepper button:not(:disabled):active,.manual-direction-panel__open:active,.manual-report__submit:not(:disabled):active{transform:scale(.97)}.manual-report__submit:not(:disabled):hover{filter:brightness(1.05)}.manual-submission--success .manual-submission__icon{animation:manual-confirm .35s ease-out both}@keyframes manual-confirm{0%{transform:scale(.75);opacity:.3}to{transform:scale(1);opacity:1}}:root[data-theme=dark] .home-grid .manual-report,:root[data-theme=dark] .dashboard-report{border-color:#7256ab;background:radial-gradient(circle at 88% 5%,rgba(88,37,74,.3333333333),transparent 13rem),linear-gradient(155deg,#151326,#0d1022 72%);box-shadow:0 1rem 3rem #02041399}:root[data-theme=dark] .manual-report__title{color:#fff8f3}:root[data-theme=dark] .manual-report__intro{color:#d6cce4}:root[data-theme=dark] .manual-report__quantity{border-color:#514896;background:linear-gradient(145deg,#19183a,#121834);box-shadow:inset 0 0 0 1px #ffffff08}:root[data-theme=dark] .home-grid .manual-direction-panel,:root[data-theme=dark] .dashboard-report .manual-direction-panel{border-color:#59499b;background:linear-gradient(145deg,#211945,#151835)}:root[data-theme=dark] .manual-report__supporting{border-color:#493d7d;background:linear-gradient(145deg,#15142f,#10162d)}:root[data-theme=dark] .manual-report__stepper button{box-shadow:0 .25rem .7rem #07041655}:root[data-theme=dark] .manual-report__submit{background:linear-gradient(110deg,#ffc276,#ff7654);box-shadow:0 .55rem 1.35rem #e2633a4d}:root[data-theme=dark] .manual-direction-panel[data-state=measuring]{border-color:#a27cff}:root[data-theme=dark] .manual-direction-panel[data-state=captured]{border-color:#68dba1}:root[data-theme=dark] .manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}:root[data-theme=light] .report-clock{border-color:#8b6bab;background:linear-gradient(115deg,#221b37,#182039)}:root[data-theme=light] .manual-direction-panel--open .manual-compass__dial{background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 25%,#e8d7e9 75%)}@media(prefers-reduced-motion:reduce){.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:none}.manual-submission--success .manual-submission__icon{animation:none}.report-clock__colon{animation:none;opacity:1}} diff --git a/staticfiles/vite/assets/manual-report-BFVLi-LY.css b/staticfiles/vite/assets/manual-report-BFVLi-LY.css new file mode 100644 index 0000000..9bc137e --- /dev/null +++ b/staticfiles/vite/assets/manual-report-BFVLi-LY.css @@ -0,0 +1 @@ +.manual-report__supporting{padding:1rem;border:1px solid #514282;border-radius:1rem;background:#11152c}.manual-report__supporting-header{display:flex;align-items:center;gap:.7rem}.manual-report__microphone{display:grid;width:2.5rem;height:2.5rem;flex:none;place-items:center;border-radius:.7rem;background:#2a2051;font-size:1.3rem}.burst-listener__state{display:block;margin-top:.15rem;color:#b9addb;font-size:.84rem}.manual-report__supporting[data-state=listening] .burst-listener__state{color:#8fe5cc}.manual-report__supporting[data-state=error] .burst-listener__state{color:#ffbd9d}.burst-listener{width:100%;margin-top:.85rem}.burst-listener__button,.burst-listener__actions button{min-height:2.75rem;padding:.65rem 1rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#292148;cursor:pointer}.burst-listener__button{width:100%}.burst-listener__panel{color:#f0eaff}.burst-listener__panel strong{font-size:.92rem}.burst-listener__panel canvas{display:block;width:100%;height:4rem;margin:.7rem 0 .35rem;border-radius:.5rem;background:linear-gradient(90deg,#191738,#241b44)}.burst-listener__panel p{margin:.35rem 0 .75rem;color:#b9addb;font-size:.82rem}.burst-listener__panel audio{width:100%;margin-bottom:.75rem}.burst-listener__actions{display:flex;flex-wrap:wrap;gap:.5rem}.burst-listener__actions button{flex:1 1 10rem}.burst-listener__actions #burst-stop{border-color:#fb9b72;color:#ffd8c4;background:#2e1b31}.burst-listener [hidden]{display:none!important}.burst-listener [role=alert]{margin:.65rem 0 0;color:#ffd1b6}.burst-listener button:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__microphone{background:#ead2eb}:root[data-theme=light] .burst-listener__state,:root[data-theme=light] .burst-listener__panel p{color:#694b68}:root[data-theme=light] .burst-listener__panel{color:#321d42}:root[data-theme=light] .burst-listener__button,:root[data-theme=light] .burst-listener__actions button{border-color:#b68bb5;color:#321d42;background:#ead2eb}:root[data-theme=light] .burst-listener__actions #burst-stop{border-color:#cf7957;color:#71331d;background:#ffe9de}.manual-compass{display:grid;justify-items:center;width:7rem;margin:.6rem 0 0 auto;color:#fff3d7;font-size:.78rem;font-weight:850;font-variant-numeric:tabular-nums}.manual-compass[hidden]{display:none}.manual-compass__dial{position:relative;width:5.75rem;aspect-ratio:1;border:2px solid #f2d7a8;border-radius:50%;background:radial-gradient(circle,#342441 0,#342441 28%,#211a32 75%);box-shadow:0 .35rem 1rem #09061566,inset 0 0 0 .25rem #ffffff12}.manual-compass__rose{position:absolute;top:0;right:0;bottom:0;left:0;transition:transform .12s ease-out}.manual-compass__rose span{position:absolute;line-height:1}.manual-compass__north{top:.38rem;left:50%;color:#ff9e78;transform:translate(-50%)}.manual-compass__east{right:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__south{bottom:.38rem;left:50%;transform:translate(-50%)}.manual-compass__west{left:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__pointer{position:absolute;top:-.55rem;left:50%;width:0;height:0;border-right:.37rem solid transparent;border-bottom:.65rem solid #ffbd62;border-left:.37rem solid transparent;transform:translate(-50%);filter:drop-shadow(0 .1rem .15rem #160d1b)}.manual-compass__center{position:absolute;top:50%;left:50%;width:.5rem;aspect-ratio:1;border-radius:50%;background:#ffbd62;transform:translate(-50%,-50%)}.manual-compass__heading{margin-top:.5rem;white-space:nowrap}:root[data-theme=light] .manual-compass{color:#43243d}:root[data-theme=light] .manual-compass__dial{border-color:#996a9b;background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 28%,#e8d7e9 75%)}:root[data-theme=light] .manual-compass__east,:root[data-theme=light] .manual-compass__south,:root[data-theme=light] .manual-compass__west{color:#43243d}@media(prefers-reduced-motion:reduce){.manual-compass__rose{transition:none}}.manual-report__header{max-width:42rem}.manual-report{--manual-report-section-gap: 1rem}.manual-report__duration{display:grid;gap:.55rem;max-width:36rem;margin-bottom:var(--manual-report-section-gap);padding:.85rem 1rem;border:1px solid #584891;border-radius:1rem;background:#151932;color:#e9def8}.manual-report__duration input[type=datetime-local],.manual-report__duration input[type=number]{width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #725da4;border-radius:.55rem;color:#f5f0ff;background:#211d3d;font:inherit;color-scheme:dark}.manual-report__duration small{color:#cbbce5}.manual-report__duration[hidden]{display:none}.manual-report__check{display:flex;align-items:center;gap:.5rem;color:#e9def8}.manual-report__burst-status{margin:.5rem 0 0;color:#ffbf72;font-weight:750}.manual-submission__edit{display:grid;gap:.4rem;max-width:18rem;margin-top:1rem}.manual-submission__edit input[type=number]{min-height:2.5rem;padding:.4rem;border-radius:.5rem}.manual-submission__edit button{min-height:2.5rem;cursor:pointer}.manual-report__primary{display:grid;gap:var(--manual-report-section-gap);max-width:36rem}.manual-report__quantity{padding:1rem;border:1px solid #584891;border-radius:1rem;background:#151932}.manual-report .manual-report__quantity #manual-occurrences{width:100%;min-width:0;min-height:3.75rem;margin:0;padding:0;border:0;color:#f5f0ff;font-size:clamp(2.25rem,8vw,3.5rem);font-weight:850;text-align:center;background:transparent;-webkit-appearance:textfield;appearance:textfield;-moz-appearance:textfield}.manual-report__quantity #manual-occurrences::-webkit-inner-spin-button,.manual-report__quantity #manual-occurrences::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.manual-report__stepper{display:grid;grid-template-columns:3.5rem minmax(0,1fr) 3.5rem;align-items:center;gap:.5rem}.manual-report__stepper button{display:grid;place-items:center;width:3.5rem;height:3.5rem;min-height:0;padding:0;border:1px solid #6d54ac;border-radius:50%;color:#f5f0ff;font:inherit;font-size:2rem;line-height:1;background:#302553;cursor:pointer}.manual-report__stepper button:disabled{opacity:.4;cursor:default}.manual-report .manual-report__primary .manual-direction-panel{width:100%;margin:0;border-radius:1rem;background:#1a1739}.manual-direction-panel[data-state=measuring]{border-color:#a27cff}.manual-direction-panel[data-state=captured]{border-color:#68dba1}.manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}.manual-direction-panel__topline{display:flex;align-items:center;justify-content:space-between;gap:1rem}.manual-direction-panel__summary{margin:.35rem 0 .8rem;color:#f5f0ff;font-weight:700}.manual-report .manual-direction-panel__status--accuracy{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin:.75rem 0;padding:.55rem .75rem;border:1px solid #5d4d92;border-radius:.7rem;color:#d9cfee;background:#191630;font-size:.85rem}.manual-direction-panel__status--accuracy strong{color:#f5edff;font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.manual-direction-panel__open,.manual-direction-panel__close{min-height:2.75rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#302553;cursor:pointer}.manual-direction-panel__open{padding:.5rem .85rem}.manual-direction-panel__close{min-width:2.75rem;font-size:1.4rem}.manual-report #manual-submit{width:100%;max-width:36rem;min-height:4.5rem;margin-top:var(--manual-report-section-gap)}.manual-report__submit:disabled{cursor:wait;opacity:.72}.manual-submission{display:grid;justify-items:center;gap:.5rem;max-width:36rem;margin-top:1rem;padding:1.3rem;border:1px solid #4caa82;border-radius:1rem;color:#eafff2;text-align:center;background:#10352e}.manual-submission__icon{display:grid;width:3.5rem;height:3.5rem;place-items:center;border:2px solid #6ce4a8;border-radius:50%;color:#eafff2;font-size:2rem;background:#226c51}.manual-submission strong{font-size:1.35rem}.manual-submission p{margin:0;line-height:1.45}.manual-submission__summary{margin-top:.35rem!important;color:#b2e8cf;font-size:.9rem}.manual-submission--error{border-color:#d37c6a;color:#fff0e8;background:#3a1c2b}.manual-submission--error .manual-submission__icon{border-color:#ffac8c;background:#9b493a}.manual-report__submission:empty{display:none}.manual-report button:focus-visible,.manual-report input:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}.manual-report__supporting{max-width:36rem;margin-top:var(--manual-report-section-gap);padding-top:1.25rem;border-top:1px solid #584891}.manual-report__supporting h3{margin:0;color:#d8cffd;font-size:1rem}.manual-report__supporting .burst-listener{width:100%}:root[data-theme=light] .manual-report__quantity{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__quantity #manual-occurrences{border:0!important;color:#321d42!important;background:transparent!important}:root[data-theme=light] .manual-report__stepper button,:root[data-theme=light] .manual-direction-panel__open,:root[data-theme=light] .manual-direction-panel__close{color:#321d42;border-color:#b68bb5;background:#ead2eb}:root[data-theme=light] .manual-direction-panel__summary{color:#321d42}:root[data-theme=light] .manual-report .manual-direction-panel__status--accuracy{border-color:#cfaad1;color:#694b68;background:#fff8fb}:root[data-theme=light] .manual-direction-panel__status--accuracy strong{color:#321d42}:root[data-theme=light] .manual-submission{border-color:#54a67b;color:#164d34;background:#e8fff2}:root[data-theme=light] .manual-submission__icon{color:#fff}:root[data-theme=light] .manual-submission__summary{color:#2b6b48}:root[data-theme=light] .manual-submission--error{border-color:#ca7d65;color:#743520;background:#fff0e8}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8}:root[data-theme=light] .manual-report__supporting h3{color:#492846}@media(max-width:42rem){.home-grid{grid-template-columns:minmax(0,1fr)}body:not(.dashboard-page){padding:max(1rem,env(safe-area-inset-top,0px)) max(.5rem,env(safe-area-inset-right,0px)) max(1rem,env(safe-area-inset-bottom,0px)) max(.5rem,env(safe-area-inset-left,0px))}.home-grid .manual-report,.dashboard-report,.dashboard-report .manual-report{overflow:visible}.manual-report{padding:1.25rem}.dashboard-report .manual-report{padding:0}.manual-report__header{padding-right:2.5rem}.manual-report form{padding-bottom:calc(5rem + env(safe-area-inset-bottom,0px))}.manual-report #manual-submit{position:sticky;bottom:calc(.5rem + env(safe-area-inset-bottom,0px));z-index:10;box-shadow:0 .7rem 1.6rem #070a18b3}body:has(#manual-occurrences:focus) .manual-report #manual-submit{position:static}.dashboard-intro{margin-bottom:1rem}.dashboard-intro h1{font-size:clamp(2rem,8vw,2.8rem)}.dashboard-intro p:last-child{margin-top:.75rem;font-size:.95rem;line-height:1.4}.dashboard-section{margin-top:1rem}.dashboard-shell{padding-bottom:calc(2rem + env(safe-area-inset-bottom,0px))}.manual-report__stepper{grid-template-columns:3.5rem minmax(0,1fr) 3.5rem}}@media(max-width:23.5rem){.manual-report{padding:1rem}.manual-report__quantity{padding:.75rem}.manual-report__stepper{grid-template-columns:3rem minmax(0,1fr) 3rem;gap:.25rem}.manual-report__stepper button{width:3rem;height:3rem}}.manual-report__heading-row{display:flex;align-items:center;gap:.7rem}.manual-report__fire{flex:none;font-size:clamp(1.8rem,5vw,2.5rem);filter:drop-shadow(0 .2rem .65rem rgba(255,112,59,.5333333333))}.manual-report__intro,.dashboard-report .manual-report__intro{margin-bottom:.85rem}.report-clock{box-sizing:border-box;width:100%;max-width:36rem;margin:0 0 1rem;padding:.65rem .95rem .7rem;border:1px solid #69539d;border-radius:.85rem;background:linear-gradient(115deg,#17162d,#10182c);box-shadow:inset 0 1px #ffffff0a}.report-clock__label{color:#cbbce5;font-size:.66rem;font-weight:750;letter-spacing:.13em;text-transform:uppercase}.report-clock__display{display:flex;align-items:end;justify-content:space-between;gap:.75rem}.report-clock__controls{display:flex;align-items:center;gap:.4rem}.report-clock__edit,.report-clock__reset,.report-clock__actions button{min-height:2.25rem;padding:.35rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#302553;font:inherit;cursor:pointer}.report-clock__edit{min-width:2.25rem;font-size:1.2rem;line-height:1}.report-clock__date{display:block;margin-top:.25rem;color:#e9def8;font-size:.85rem}.report-clock__reset{margin-top:.6rem}.report-clock__editor{display:grid;gap:.5rem;margin-top:.8rem;padding-top:.8rem;border-top:1px solid #69539d;color:#f5f0ff}.report-clock__fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(7rem,.6fr);gap:.6rem}.report-clock__fields>div{min-width:0}@media(max-width:30rem){.report-clock__fields{grid-template-columns:minmax(0,1fr)}}.report-clock__editor label{display:block;margin-bottom:.3rem;font-weight:650}.report-clock__editor input[type=date],.report-clock__editor input[type=text]{box-sizing:border-box;width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#211d3d;color-scheme:dark;font:inherit}.report-clock__editor input[type=text]{font-variant-numeric:tabular-nums}.report-clock__actions{display:flex;flex-wrap:wrap;gap:.5rem}.report-clock__error{margin:0;color:#ffb9a9}.report-clock [hidden]{display:none!important}@media(max-width:25rem){.report-clock__display{align-items:center}.report-clock__now{font-size:.6rem}}.report-clock__time{display:inline-flex;align-items:center;color:#ffbf72;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:clamp(2rem,9vw,2.45rem);font-weight:700;line-height:1.1;letter-spacing:0;font-variant-numeric:tabular-nums;text-shadow:0 0 .7rem rgba(255,150,59,.3333333333);white-space:nowrap}.report-clock__time span{display:inline-block}.report-clock__time #report-clock-hours,.report-clock__time #report-clock-minutes{width:2ch}.report-clock__colon{width:1ch;flex:none;margin-inline:-.08em;line-height:1;text-align:center;transform:translateY(-.06em);animation:report-clock-blink 2s steps(1,end) infinite}.report-clock__now{display:inline-flex;align-items:center;gap:.4rem;flex:none;padding:.2rem .45rem;border:1px solid #93634d;border-radius:999px;color:#ffd2a2;font-size:.7rem;font-weight:750;letter-spacing:.08em;text-transform:uppercase}.report-clock__dot{width:.4rem;height:.4rem;border-radius:50%;background:#ffab5d}@keyframes report-clock-blink{50%{opacity:0}}.manual-direction-panel__open{width:100%;text-align:left}.manual-direction-panel--open .manual-compass{width:100%;margin:.5rem auto 1rem}.manual-direction-panel--open .manual-compass__dial{width:min(100%,12rem);border-color:#8b67d4;background:radial-gradient(circle,#302054 0,#302054 20%,#17132d 70%);box-shadow:0 0 0 .35rem #6640a228,0 0 2rem #ac6aff35}.manual-direction-panel--open .manual-compass__pointer{border-bottom-color:#ff925f}.manual-direction-panel--open .manual-compass__heading{font-size:1.1rem}.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:transform .15s ease,box-shadow .15s ease,filter .15s ease}.manual-report__stepper button:not(:disabled):active,.manual-direction-panel__open:active,.manual-report__submit:not(:disabled):active{transform:scale(.97)}.manual-report__submit:not(:disabled):hover{filter:brightness(1.05)}.manual-submission--success .manual-submission__icon{animation:manual-confirm .35s ease-out both}@keyframes manual-confirm{0%{transform:scale(.75);opacity:.3}to{transform:scale(1);opacity:1}}:root[data-theme=dark] .home-grid .manual-report,:root[data-theme=dark] .dashboard-report{border-color:#7256ab;background:radial-gradient(circle at 88% 5%,rgba(88,37,74,.3333333333),transparent 13rem),linear-gradient(155deg,#151326,#0d1022 72%);box-shadow:0 1rem 3rem #02041399}:root[data-theme=dark] .manual-report__title{color:#fff8f3}:root[data-theme=dark] .manual-report__intro{color:#d6cce4}:root[data-theme=dark] .manual-report__quantity{border-color:#514896;background:linear-gradient(145deg,#19183a,#121834);box-shadow:inset 0 0 0 1px #ffffff08}:root[data-theme=dark] .home-grid .manual-direction-panel,:root[data-theme=dark] .dashboard-report .manual-direction-panel{border-color:#59499b;background:linear-gradient(145deg,#211945,#151835)}:root[data-theme=dark] .manual-report__supporting{border-color:#493d7d;background:linear-gradient(145deg,#15142f,#10162d)}:root[data-theme=dark] .manual-report__stepper button{box-shadow:0 .25rem .7rem #07041655}:root[data-theme=dark] .manual-report__submit{background:linear-gradient(110deg,#ffc276,#ff7654);box-shadow:0 .55rem 1.35rem #e2633a4d}:root[data-theme=dark] .manual-direction-panel[data-state=measuring]{border-color:#a27cff}:root[data-theme=dark] .manual-direction-panel[data-state=captured]{border-color:#68dba1}:root[data-theme=dark] .manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}:root[data-theme=light] .report-clock{border-color:#8b6bab;background:linear-gradient(115deg,#221b37,#182039)}:root[data-theme=light] .manual-direction-panel--open .manual-compass__dial{background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 25%,#e8d7e9 75%)}@media(prefers-reduced-motion:reduce){.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:none}.manual-submission--success .manual-submission__icon{animation:none}.report-clock__colon{animation:none;opacity:1}} diff --git a/staticfiles/vite/assets/manual-report-C-E8HQa9.js b/staticfiles/vite/assets/manual-report-C-E8HQa9.js new file mode 100644 index 0000000..5c06cc9 --- /dev/null +++ b/staticfiles/vite/assets/manual-report-C-E8HQa9.js @@ -0,0 +1 @@ +const qe=document.querySelector("#manual-report-form"),d=window.BOOMCAST_I18N||{};function Fe(){if(!qe)return null;const e=document.querySelector("#burst-start"),t=e.closest(".burst-listener"),n=e.closest(".manual-report__supporting"),i=document.querySelector("#burst-state"),r=document.querySelector("#burst-panel"),w=document.querySelector("#burst-heading"),H=document.querySelector("#burst-detail"),S=document.querySelector("#burst-waveform"),N=document.querySelector("#burst-preview"),we=document.querySelector("#burst-resume"),Se=document.querySelector("#burst-discard"),Be=document.querySelector("#burst-stop"),le=document.querySelector("#burst-error"),A=new Float32Array(300);let v=0,G="off",W,I,D,l,R,E,j,M;function ue(){const a=S.getContext("2d");a.clearRect(0,0,S.width,S.height),a.fillStyle="#ffbd62";const u=S.width/A.length,h=Math.max(.003,...A);for(let c=0;c{for(let ee=0;ee{if(u.type==="level"&&(G==="listening"||G==="tail"))A[v]=u.value,v=(v+1)%A.length,ue();else if(u.type==="trigger"&&G==="listening")q("tail");else if(u.type==="clip"){const h=new File([ke(u.samples,u.sampleRate)],He(),{type:"audio/wav"});M?(M(h),M=null):G==="tail"&&(de(),j=h,E=URL.createObjectURL(h),N.src=E,N.hidden=!1,q("captured"))}},D.connect(l),l.connect(R).connect(I.destination),await I.resume(),A.fill(0),v=0,ue(),q("listening")}catch(u){await _(),t&&(t.dataset.state="error"),n&&(n.dataset.state="error"),i&&(i.textContent=d.microphoneUnavailable||"Microphone unavailable"),le.textContent=u.name==="NotAllowedError"?d.microphoneDenied||"Microphone permission was denied. Manual reporting is still available.":d.microphoneFailed||"Microphone capture failed.",le.hidden=!1}finally{e.disabled=!1}}async function _(){M&&(M(null),M=null),de(),l==null||l.disconnect(),D==null||D.disconnect(),R==null||R.disconnect(),W==null||W.getTracks().forEach(a=>a.stop()),await(I==null?void 0:I.close()),W=I=D=l=R=null,A.fill(0),v=0,q("off")}function ge(){de(),A.fill(0),v=0,ue(),l==null||l.port.postMessage("reset"),l&&q("listening")}return e.addEventListener("click",Ee),Be.addEventListener("click",_),Se.addEventListener("click",ge),we.addEventListener("click",ge),window.addEventListener("pagehide",_),document.addEventListener("visibilitychange",()=>{document.hidden&&_()}),{get active(){return G!=="off"},async clipForSubmission(){return j||(G==="off"||!l?null:new Promise(a=>{M=a,l.port.postMessage("snapshot")}))},submissionSucceeded:ge}}const o=window.BOOMCAST_I18N||{},p=document.querySelector("#manual-report-form"),T=document.querySelector("#manual-submit"),K=document.querySelector("#manual-submit-label"),m=document.querySelector("#manual-occurrences"),xe=document.querySelector("#manual-decrease"),Ze=document.querySelector("#manual-increase"),Ye=document.querySelector("#manual-latitude"),ze=document.querySelector("#manual-longitude"),ne=document.querySelector("#manual-direction-degrees"),Ve=document.querySelector("#manual-direction-accuracy"),ce=()=>document.querySelector("#manual-capture-direction"),g=()=>document.querySelector("#manual-direction-status"),s=()=>document.querySelector("#manual-direction-panel"),k=document.querySelector("#manual-compass"),oe=document.querySelector("#manual-compass-home"),Y=document.querySelector("#manual-compass-rose"),Ke=document.querySelector("#manual-compass-heading"),te=document.querySelector("#manual-report-time"),ve=document.querySelector("#report-clock-hours"),Ge=document.querySelector("#report-clock-minutes"),ae=document.querySelector("#manual-occurred-at"),Ne=document.querySelector("#report-clock-mode-label"),Ce=document.querySelector("#report-clock-date"),Z=document.querySelector("#report-clock-edit"),V=document.querySelector("#report-clock-reset"),ye=document.querySelector("#report-clock-editor"),L=document.querySelector("#report-clock-draft-date"),O=document.querySelector("#report-clock-draft-time"),Ie=document.querySelector("#report-clock-apply"),me=document.querySelector("#report-clock-cancel"),U=document.querySelector("#report-clock-error"),b=document.querySelector("#manual-time-approximate");let C="NOW",J=null,Q=!1;const Re=document.querySelector("#manual-burst-status"),Me=document.querySelector("#manual-burst-duration");let B,ie,x=null;const z=Fe(),Ae=e=>Number.isFinite(e),be=e=>[o.north||"North",o.northeast||"Northeast",o.east||"East",o.southeast||"Southeast",o.south||"South",o.southwest||"Southwest",o.west||"West",o.northwest||"Northwest"][Math.floor((e+22.5)%360/45)],re=e=>Number(e.toFixed(1)).toString(),se=()=>{var r,w;if(!te)return;const e=C==="OVERRIDE"?J:new Date;te.dateTime=e.toISOString();const t=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e),n=(r=t.find(H=>H.type==="hour"))==null?void 0:r.value,i=(w=t.find(H=>H.type==="minute"))==null?void 0:w.value;!n||!i||!ve||!Ge||(ve.textContent=n,Ge.textContent=i,te.setAttribute("aria-label",`${n}:${i}`),Ce&&(Ce.hidden=C!=="OVERRIDE",C==="OVERRIDE"&&(Ce.textContent=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{day:"numeric",month:"long",year:"numeric"}).format(e))))};se();te&&window.setInterval(se,6e4);const Oe=(K==null?void 0:K.textContent)||"I heard fireworks",he=e=>{const t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`},We=()=>{U&&(U.hidden=!0,U.textContent="",L.removeAttribute("aria-invalid"),O.removeAttribute("aria-invalid"))},fe=()=>{ye.hidden=!0,Z.setAttribute("aria-expanded","false"),We(),Z.focus()};Z==null||Z.addEventListener("click",()=>{const[e,t]=he(C==="OVERRIDE"?J:new Date).split("T");L.value=e,O.value=t,b.checked=C==="OVERRIDE"&&Q,b.disabled=!1,We(),ye.hidden=!1,Z.setAttribute("aria-expanded","true"),L.focus()});me==null||me.addEventListener("click",()=>{b.checked=C==="OVERRIDE"&&Q,b.disabled=C==="NOW",fe()});Ie==null||Ie.addEventListener("click",()=>{const e=L.value,t=O.value.trim(),n=`${e}T${t}`,r=/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d$/.test(n)?new Date(n):null;if(!r||Number.isNaN(r.getTime())||he(r)!==n||r.getTime()>Date.now()+3e5){U.textContent=!r||Number.isNaN(r.getTime())||he(r)!==n?o.invalidReportTime||"Enter a valid date and time.":o.futureReportTime||"Report time cannot be in the future.",U.hidden=!1,L.setAttribute("aria-invalid","true"),O.setAttribute("aria-invalid","true"),(e?O:L).focus();return}J=r,Q=b.checked,C="OVERRIDE",ae.value=r.toISOString(),Ne.textContent=o.adjusted||"Adjusted",V.hidden=!1,se(),fe()});V==null||V.addEventListener("click",()=>{C="NOW",J=null,Q=!1,ae.value="",b.checked=!1,b.disabled=!0,Ne.textContent=o.now||"Now",V.hidden=!0,se(),ye.hidden||fe(),Z.focus()});const f=(e,t="")=>{if(p.dataset.state=e,T.disabled=e==="submitting",K&&(K.textContent=e==="submitting"?o.sendingReport||"Sending…":Oe),t){const n=document.querySelector("#manual-submission");n.className="manual-report__submission",n.textContent=t}},De=e=>{const t=e==null?void 0:e.dataset.nextNoteToken,n=document.querySelector("#manual-note-context");!t||!n||n.value===t||(n.value=t,window.htmx&&htmx.ajax("GET","/fireworks/notes/?token="+encodeURIComponent(t),{target:"#live-field-notes",swap:"outerHTML"}))},Xe=(e,t)=>{const n=new DOMParser().parseFromString(e,"text/html").querySelector("#manual-submission");return n?(document.querySelector("#manual-submission").replaceWith(n),t&&De(n),f(t?"submitted":"error"),t):(f("error",o.reportFailed||"Could not send the report. Please try again."),!1)},Le=()=>{const e=Number(m.value)>=3;Re&&(Re.textContent=e?o.burstEvent||"Burst Event":o.ordinaryReport||"Ordinary report"),Me&&(Me.hidden=!e)},$=e=>{const t=Number.parseInt(e,10);m.value=String(Math.min(1e3,Math.max(1,Number.isFinite(t)?t:1))),xe.disabled=m.value==="1",Ze.disabled=m.value==="1000",Le()};$(m.value);xe.addEventListener("click",()=>$(Number(m.value)-1));Ze.addEventListener("click",()=>$(Number(m.value)+1));m.addEventListener("change",()=>$(m.value));m.addEventListener("input",Le);const P=()=>{B&&window.removeEventListener("deviceorientation",B),window.clearTimeout(ie),B=null,ie=null,k.hidden=!0,x=null},Ue=e=>{const t=-e;if(x===null)x=t,Y.style.transition="none",Y.style.transform=`rotate(${x}deg)`,Y.offsetWidth,Y.style.transition="";else{const n=(t-x+540)%360-180;x+=n,Y.style.transform=`rotate(${x}deg)`}Ke.textContent=`${re(e)}° · ${be(e)}`,k.setAttribute("aria-label",`${o.compassDirection||"Compass direction"} ${re(e)}° ${be(e)}`),k.hidden=!1},Te=(e,t)=>{const n=g();if(n)if(n.classList.toggle("manual-direction-panel__status--accuracy",t!==null),t===null)n.textContent=o.accuracyUnavailable||"Accuracy unavailable";else{const r=document.createElement("span");r.textContent=o.accuracy||"Accuracy";const w=document.createElement("strong");w.textContent=`±${re(t)}°`,n.replaceChildren(r,w)}const i=ce();i&&(i.textContent=o.stopCapture||"Stop measuring direction")},Pe=()=>{g()&&(P(),s()&&(s().dataset.state="measuring"),g().textContent=o.pointPhone||"Point the top of your phone toward the sound — direction will update live.",B=e=>{const t="webkitCompassHeading"in e,n=Ae(e.webkitCompassHeading)?e.webkitCompassHeading:!t&&e.absolute&&Ae(e.alpha)?(360-e.alpha)%360:null;if(n===null||n<0||n>=360)return;const i=Ae(e.webkitCompassAccuracy)&&e.webkitCompassAccuracy>=0?e.webkitCompassAccuracy:null;ne.value=n,Ve.value=i===null?"":i,Te(n,i),Ue(n),window.clearTimeout(ie)},window.addEventListener("deviceorientation",B),ie=window.setTimeout(()=>{P();const e=ce(),t=g();e&&(e.textContent=o.captureDirection||"Start measuring direction"),t&&(t.textContent=o.compassUnavailable||"Compass unavailable on this device."),s()&&(s().dataset.state="unavailable")},15e3))},Je=async()=>{var e;if(B){P(),ce().textContent=o.captureAgain||"Measure again",s()&&(s().dataset.state=ne.value?"captured":"ready");return}if((e=g())==null||e.classList.remove("manual-direction-panel__status--accuracy"),!window.isSecureContext){g().textContent=o.secureCompass||"Compass capture requires a secure HTTPS connection.",s()&&(s().dataset.state="unavailable");return}if(typeof window.DeviceOrientationEvent>"u"){g().textContent=o.compassUnavailable||"Compass unavailable on this device.",s()&&(s().dataset.state="unavailable");return}if(typeof DeviceOrientationEvent.requestPermission=="function"){g().textContent=o.compassPermission||"Requesting compass permission…";try{if(await DeviceOrientationEvent.requestPermission(!0)!=="granted"){g()&&(g().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}catch{g()&&(g().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}Pe()},pe=async()=>{if(ae&&(ae.value=C==="OVERRIDE"?J.toISOString():""),b&&(b.checked=C==="OVERRIDE"&&Q,b.disabled=C==="NOW"),$(m.value),P(),f("submitting",o.sendingReport||"Sending…"),z!=null&&z.active){try{const e=await z.clipForSubmission(),t=new FormData(p);e&&t.append("audio",e);const n=await fetch(p.action,{method:"POST",body:t,credentials:"same-origin"}),i=await n.text();Xe(i,n.ok)&&z.submissionSucceeded()}catch{f("error",o.reportFailed||"Could not send the report. Please try again.")}return}if(window.htmx)try{htmx.ajax("POST",p.action,{source:p,target:"#manual-submission",swap:"outerHTML"})}catch{f("error",o.reportFailed||"Could not send the report. Please try again.")}else p.submit()};p.addEventListener("click",e=>{e.target.closest("#manual-capture-direction")&&Je(),e.target.closest(".manual-direction-panel__close")&&(P(),oe&&oe.append(k))});document.body.addEventListener("htmx:beforeSwap",e=>{var t;((t=e.detail.target)==null?void 0:t.id)==="manual-direction-panel"&&oe&&oe.append(k)});document.body.addEventListener("htmx:afterSwap",e=>{var n,i;if(((n=e.detail.target)==null?void 0:n.id)!=="manual-direction-panel")return;ce()&&((i=s().querySelector(".manual-direction-panel__copy"))==null||i.after(k));const t=document.querySelector("#manual-direction-summary");if(t&&ne.value!==""){const r=Number(ne.value);t.textContent=`${be(r)} · ${re(r)}°`,s().dataset.state="captured"}});T.addEventListener("click",()=>{if(!T.disabled){if(f("submitting",o.requestingLocation||"Requesting your optional location…"),!navigator.geolocation){pe();return}navigator.geolocation.getCurrentPosition(e=>{Ye.value=e.coords.latitude,ze.value=e.coords.longitude,pe()},()=>pe(),{enableHighAccuracy:!1,maximumAge:3e5,timeout:1e4})}});p.addEventListener("submit",e=>{e.preventDefault(),T.disabled||T.click()});document.body.addEventListener("htmx:afterRequest",e=>{if(e.detail.elt!==p)return;const t=e.detail.xhr;t?t.status>=400?Xe(t.responseText,!1):f("submitted"):f("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:sendError",e=>{e.detail.elt===p&&f("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:afterSwap",()=>De(document.querySelector("#manual-submission"))); diff --git a/staticfiles/vite/assets/manual-report-C2Y4rZkz.css b/staticfiles/vite/assets/manual-report-C2Y4rZkz.css new file mode 100644 index 0000000..5801d69 --- /dev/null +++ b/staticfiles/vite/assets/manual-report-C2Y4rZkz.css @@ -0,0 +1 @@ +.manual-report__supporting{padding:1rem;border:1px solid #514282;border-radius:1rem;background:#11152c}.manual-report__supporting-header{display:flex;align-items:center;gap:.7rem}.manual-report__microphone{display:grid;width:2.5rem;height:2.5rem;flex:none;place-items:center;border-radius:.7rem;background:#2a2051;font-size:1.3rem}.burst-listener__state{display:block;margin-top:.15rem;color:#b9addb;font-size:.84rem}.manual-report__supporting[data-state=listening] .burst-listener__state{color:#8fe5cc}.manual-report__supporting[data-state=error] .burst-listener__state{color:#ffbd9d}.burst-listener{width:100%;margin-top:.85rem}.burst-listener__button,.burst-listener__actions button{min-height:2.75rem;padding:.65rem 1rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#292148;cursor:pointer}.burst-listener__button{width:100%}.burst-listener__panel{color:#f0eaff}.burst-listener__panel strong{font-size:.92rem}.burst-listener__panel canvas{display:block;width:100%;height:4rem;margin:.7rem 0 .35rem;border-radius:.5rem;background:linear-gradient(90deg,#191738,#241b44)}.burst-listener__panel p{margin:.35rem 0 .75rem;color:#b9addb;font-size:.82rem}.burst-listener__panel audio{width:100%;margin-bottom:.75rem}.burst-listener__actions{display:flex;flex-wrap:wrap;gap:.5rem}.burst-listener__actions button{flex:1 1 10rem}.burst-listener__actions #burst-stop{border-color:#fb9b72;color:#ffd8c4;background:#2e1b31}.burst-listener [hidden]{display:none!important}.burst-listener [role=alert]{margin:.65rem 0 0;color:#ffd1b6}.burst-listener button:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__microphone{background:#ead2eb}:root[data-theme=light] .burst-listener__state,:root[data-theme=light] .burst-listener__panel p{color:#694b68}:root[data-theme=light] .burst-listener__panel{color:#321d42}:root[data-theme=light] .burst-listener__button,:root[data-theme=light] .burst-listener__actions button{border-color:#b68bb5;color:#321d42;background:#ead2eb}:root[data-theme=light] .burst-listener__actions #burst-stop{border-color:#cf7957;color:#71331d;background:#ffe9de}.manual-compass{display:grid;justify-items:center;width:7rem;margin:.6rem 0 0 auto;color:#fff3d7;font-size:.78rem;font-weight:850;font-variant-numeric:tabular-nums}.manual-compass[hidden]{display:none}.manual-compass__dial{position:relative;width:5.75rem;aspect-ratio:1;border:2px solid #f2d7a8;border-radius:50%;background:radial-gradient(circle,#342441 0,#342441 28%,#211a32 75%);box-shadow:0 .35rem 1rem #09061566,inset 0 0 0 .25rem #ffffff12}.manual-compass__rose{position:absolute;top:0;right:0;bottom:0;left:0;transition:transform .12s ease-out}.manual-compass__rose span{position:absolute;line-height:1}.manual-compass__north{top:.38rem;left:50%;color:#ff9e78;transform:translate(-50%)}.manual-compass__east{right:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__south{bottom:.38rem;left:50%;transform:translate(-50%)}.manual-compass__west{left:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__pointer{position:absolute;top:-.55rem;left:50%;width:0;height:0;border-right:.37rem solid transparent;border-bottom:.65rem solid #ffbd62;border-left:.37rem solid transparent;transform:translate(-50%);filter:drop-shadow(0 .1rem .15rem #160d1b)}.manual-compass__center{position:absolute;top:50%;left:50%;width:.5rem;aspect-ratio:1;border-radius:50%;background:#ffbd62;transform:translate(-50%,-50%)}.manual-compass__heading{margin-top:.5rem;white-space:nowrap}:root[data-theme=light] .manual-compass{color:#43243d}:root[data-theme=light] .manual-compass__dial{border-color:#996a9b;background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 28%,#e8d7e9 75%)}:root[data-theme=light] .manual-compass__east,:root[data-theme=light] .manual-compass__south,:root[data-theme=light] .manual-compass__west{color:#43243d}@media(prefers-reduced-motion:reduce){.manual-compass__rose{transition:none}}.manual-report__header{max-width:42rem}.manual-report{--manual-report-section-gap: 1rem}.manual-report__duration{display:grid;gap:.55rem;max-width:36rem;margin-bottom:var(--manual-report-section-gap);padding:.85rem 1rem;border:1px solid #584891;border-radius:1rem;background:#151932;color:#e9def8}.manual-report__duration input[type=datetime-local],.manual-report__duration input[type=number]{width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #725da4;border-radius:.55rem;color:#f5f0ff;background:#211d3d;font:inherit;color-scheme:dark}.manual-report__duration small{color:#cbbce5}.manual-report__duration[hidden]{display:none}.manual-report__check{display:flex;align-items:center;gap:.5rem;color:#e9def8}.manual-report__burst-status{margin:.5rem 0 0;color:#ffbf72;font-weight:750}.manual-submission__edit{display:grid;gap:.4rem;max-width:18rem;margin-top:1rem}.manual-submission__edit input[type=number]{min-height:2.5rem;padding:.4rem;border-radius:.5rem}.manual-submission__edit button{min-height:2.5rem;cursor:pointer}.manual-report__primary{display:grid;gap:var(--manual-report-section-gap);max-width:36rem}.manual-report__quantity{padding:1rem;border:1px solid #584891;border-radius:1rem;background:#151932}.manual-report .manual-report__quantity #manual-occurrences{width:100%;min-width:0;min-height:3.75rem;margin:0;padding:0;border:0;color:#f5f0ff;font-size:clamp(2.25rem,8vw,3.5rem);font-weight:850;text-align:center;background:transparent;-webkit-appearance:textfield;appearance:textfield;-moz-appearance:textfield}.manual-report__quantity #manual-occurrences::-webkit-inner-spin-button,.manual-report__quantity #manual-occurrences::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.manual-report__stepper{display:grid;grid-template-columns:3.5rem minmax(0,1fr) 3.5rem;align-items:center;gap:.5rem}.manual-report__stepper button{display:grid;place-items:center;width:3.5rem;height:3.5rem;min-height:0;padding:0;border:1px solid #6d54ac;border-radius:50%;color:#f5f0ff;font:inherit;font-size:2rem;line-height:1;background:#302553;cursor:pointer}.manual-report__stepper button:disabled{opacity:.4;cursor:default}.manual-report .manual-report__primary .manual-direction-panel{width:100%;margin:0;border-radius:1rem;background:#1a1739}.manual-direction-panel[data-state=measuring]{border-color:#a27cff}.manual-direction-panel[data-state=captured]{border-color:#68dba1}.manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}.manual-direction-panel__topline{display:flex;align-items:center;justify-content:space-between;gap:1rem}.manual-direction-panel__summary{margin:.35rem 0 .8rem;color:#f5f0ff;font-weight:700}.manual-report .manual-direction-panel__status--accuracy{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin:.75rem 0;padding:.55rem .75rem;border:1px solid #5d4d92;border-radius:.7rem;color:#d9cfee;background:#191630;font-size:.85rem}.manual-direction-panel__status--accuracy strong{color:#f5edff;font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.manual-direction-panel__open,.manual-direction-panel__close{min-height:2.75rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#302553;cursor:pointer}.manual-direction-panel__open{padding:.5rem .85rem}.manual-direction-panel__close{min-width:2.75rem;font-size:1.4rem}.manual-report #manual-submit{width:100%;max-width:36rem;min-height:4.5rem;margin-top:var(--manual-report-section-gap)}.manual-report__submit:disabled{cursor:wait;opacity:.72}.manual-submission{display:grid;justify-items:center;gap:.5rem;max-width:36rem;margin-top:1rem;padding:1.3rem;border:1px solid #4caa82;border-radius:1rem;color:#eafff2;text-align:center;background:#10352e}.manual-submission__icon{display:grid;width:3.5rem;height:3.5rem;place-items:center;border:2px solid #6ce4a8;border-radius:50%;color:#eafff2;font-size:2rem;background:#226c51}.manual-submission strong{font-size:1.35rem}.manual-submission p{margin:0;line-height:1.45}.manual-submission__summary{margin-top:.35rem!important;color:#b2e8cf;font-size:.9rem}.manual-submission--error{border-color:#d37c6a;color:#fff0e8;background:#3a1c2b}.manual-submission--error .manual-submission__icon{border-color:#ffac8c;background:#9b493a}.manual-report__submission:empty{display:none}.manual-report button:focus-visible,.manual-report input:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}.manual-report__supporting{max-width:36rem;margin-top:var(--manual-report-section-gap);padding-top:1.25rem;border-top:1px solid #584891}.manual-report__supporting h3{margin:0;color:#d8cffd;font-size:1rem}.manual-report__supporting .burst-listener{width:100%}:root[data-theme=light] .manual-report__quantity{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__quantity #manual-occurrences{border:0!important;color:#321d42!important;background:transparent!important}:root[data-theme=light] .manual-report__stepper button,:root[data-theme=light] .manual-direction-panel__open,:root[data-theme=light] .manual-direction-panel__close{color:#321d42;border-color:#b68bb5;background:#ead2eb}:root[data-theme=light] .manual-direction-panel__summary{color:#321d42}:root[data-theme=light] .manual-report .manual-direction-panel__status--accuracy{border-color:#cfaad1;color:#694b68;background:#fff8fb}:root[data-theme=light] .manual-direction-panel__status--accuracy strong{color:#321d42}:root[data-theme=light] .manual-submission{border-color:#54a67b;color:#164d34;background:#e8fff2}:root[data-theme=light] .manual-submission__icon{color:#fff}:root[data-theme=light] .manual-submission__summary{color:#2b6b48}:root[data-theme=light] .manual-submission--error{border-color:#ca7d65;color:#743520;background:#fff0e8}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8}:root[data-theme=light] .manual-report__supporting h3{color:#492846}@media(max-width:42rem){.home-grid{grid-template-columns:minmax(0,1fr)}body:not(.dashboard-page){padding:max(1rem,env(safe-area-inset-top,0px)) max(.5rem,env(safe-area-inset-right,0px)) max(1rem,env(safe-area-inset-bottom,0px)) max(.5rem,env(safe-area-inset-left,0px))}.home-grid .manual-report,.dashboard-report,.dashboard-report .manual-report{overflow:visible}.manual-report{padding:1.25rem}.dashboard-report .manual-report{padding:0}.manual-report__header{padding-right:2.5rem}.manual-report form{padding-bottom:calc(5rem + env(safe-area-inset-bottom,0px))}.manual-report #manual-submit{position:sticky;bottom:calc(.5rem + env(safe-area-inset-bottom,0px));z-index:10;box-shadow:0 .7rem 1.6rem #070a18b3}body:has(#manual-occurrences:focus) .manual-report #manual-submit{position:static}.dashboard-intro{margin-bottom:1rem}.dashboard-intro h1{font-size:clamp(2rem,8vw,2.8rem)}.dashboard-intro p:last-child{margin-top:.75rem;font-size:.95rem;line-height:1.4}.dashboard-section{margin-top:1rem}.dashboard-shell{padding-bottom:calc(2rem + env(safe-area-inset-bottom,0px))}.manual-report__stepper{grid-template-columns:3.5rem minmax(0,1fr) 3.5rem}}@media(max-width:23.5rem){.manual-report{padding:1rem}.manual-report__quantity{padding:.75rem}.manual-report__stepper{grid-template-columns:3rem minmax(0,1fr) 3rem;gap:.25rem}.manual-report__stepper button{width:3rem;height:3rem}}.manual-report__heading-row{display:flex;align-items:center;gap:.7rem}.manual-report__fire{flex:none;font-size:clamp(1.8rem,5vw,2.5rem);filter:drop-shadow(0 .2rem .65rem rgba(255,112,59,.5333333333))}.manual-report__intro,.dashboard-report .manual-report__intro{margin-bottom:.85rem}.report-clock{box-sizing:border-box;width:100%;max-width:36rem;margin:0 0 1rem;padding:.65rem .95rem .7rem;border:1px solid #69539d;border-radius:.85rem;background:linear-gradient(115deg,#17162d,#10182c);box-shadow:inset 0 1px #ffffff0a}.report-clock__label{color:#cbbce5;font-size:.66rem;font-weight:750;letter-spacing:.13em;text-transform:uppercase}.report-clock__display{display:flex;align-items:end;justify-content:space-between;gap:.75rem}.report-clock__controls{display:flex;align-items:center;gap:.4rem}.report-clock__edit,.report-clock__reset,.report-clock__actions button{min-height:2.25rem;padding:.35rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#302553;font:inherit;cursor:pointer}.report-clock__edit{min-width:2.25rem;font-size:1.2rem;line-height:1}.report-clock__date{display:block;margin-top:.25rem;color:#e9def8;font-size:.85rem}.report-clock__reset{margin-top:.6rem}.report-clock__editor{display:grid;gap:.5rem;margin-top:.8rem;padding-top:.8rem;border-top:1px solid #69539d;color:#f5f0ff}.report-clock__fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(7rem,.6fr);gap:.6rem}.report-clock__fields>div{min-width:0}.report-clock__editor label{display:block;margin-bottom:.3rem;font-weight:650}.report-clock__editor input[type=date],.report-clock__editor input[type=text]{box-sizing:border-box;width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#211d3d;color-scheme:dark;font:inherit}.report-clock__editor input[type=text]{font-variant-numeric:tabular-nums}.report-clock__actions{display:flex;flex-wrap:wrap;gap:.5rem}.report-clock__error{margin:0;color:#ffb9a9}.report-clock [hidden]{display:none!important}@media(max-width:25rem){.report-clock__display{align-items:center}.report-clock__now{font-size:.6rem}}.report-clock__time{display:inline-flex;align-items:center;color:#ffbf72;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:clamp(2rem,9vw,2.45rem);font-weight:700;line-height:1.1;letter-spacing:0;font-variant-numeric:tabular-nums;text-shadow:0 0 .7rem rgba(255,150,59,.3333333333);white-space:nowrap}.report-clock__time span{display:inline-block}.report-clock__time #report-clock-hours,.report-clock__time #report-clock-minutes{width:2ch}.report-clock__colon{width:1ch;flex:none;margin-inline:-.08em;line-height:1;text-align:center;transform:translateY(-.06em);animation:report-clock-blink 2s steps(1,end) infinite}.report-clock__now{display:inline-flex;align-items:center;gap:.4rem;flex:none;padding:.2rem .45rem;border:1px solid #93634d;border-radius:999px;color:#ffd2a2;font-size:.7rem;font-weight:750;letter-spacing:.08em;text-transform:uppercase}.report-clock__dot{width:.4rem;height:.4rem;border-radius:50%;background:#ffab5d}@keyframes report-clock-blink{50%{opacity:0}}.manual-direction-panel__open{width:100%;text-align:left}.manual-direction-panel--open .manual-compass{width:100%;margin:.5rem auto 1rem}.manual-direction-panel--open .manual-compass__dial{width:min(100%,12rem);border-color:#8b67d4;background:radial-gradient(circle,#302054 0,#302054 20%,#17132d 70%);box-shadow:0 0 0 .35rem #6640a228,0 0 2rem #ac6aff35}.manual-direction-panel--open .manual-compass__pointer{border-bottom-color:#ff925f}.manual-direction-panel--open .manual-compass__heading{font-size:1.1rem}.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:transform .15s ease,box-shadow .15s ease,filter .15s ease}.manual-report__stepper button:not(:disabled):active,.manual-direction-panel__open:active,.manual-report__submit:not(:disabled):active{transform:scale(.97)}.manual-report__submit:not(:disabled):hover{filter:brightness(1.05)}.manual-submission--success .manual-submission__icon{animation:manual-confirm .35s ease-out both}@keyframes manual-confirm{0%{transform:scale(.75);opacity:.3}to{transform:scale(1);opacity:1}}:root[data-theme=dark] .home-grid .manual-report,:root[data-theme=dark] .dashboard-report{border-color:#7256ab;background:radial-gradient(circle at 88% 5%,rgba(88,37,74,.3333333333),transparent 13rem),linear-gradient(155deg,#151326,#0d1022 72%);box-shadow:0 1rem 3rem #02041399}:root[data-theme=dark] .manual-report__title{color:#fff8f3}:root[data-theme=dark] .manual-report__intro{color:#d6cce4}:root[data-theme=dark] .manual-report__quantity{border-color:#514896;background:linear-gradient(145deg,#19183a,#121834);box-shadow:inset 0 0 0 1px #ffffff08}:root[data-theme=dark] .home-grid .manual-direction-panel,:root[data-theme=dark] .dashboard-report .manual-direction-panel{border-color:#59499b;background:linear-gradient(145deg,#211945,#151835)}:root[data-theme=dark] .manual-report__supporting{border-color:#493d7d;background:linear-gradient(145deg,#15142f,#10162d)}:root[data-theme=dark] .manual-report__stepper button{box-shadow:0 .25rem .7rem #07041655}:root[data-theme=dark] .manual-report__submit{background:linear-gradient(110deg,#ffc276,#ff7654);box-shadow:0 .55rem 1.35rem #e2633a4d}:root[data-theme=dark] .manual-direction-panel[data-state=measuring]{border-color:#a27cff}:root[data-theme=dark] .manual-direction-panel[data-state=captured]{border-color:#68dba1}:root[data-theme=dark] .manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}:root[data-theme=light] .report-clock{border-color:#8b6bab;background:linear-gradient(115deg,#221b37,#182039)}:root[data-theme=light] .manual-direction-panel--open .manual-compass__dial{background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 25%,#e8d7e9 75%)}@media(prefers-reduced-motion:reduce){.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:none}.manual-submission--success .manual-submission__icon{animation:none}.report-clock__colon{animation:none;opacity:1}} diff --git a/staticfiles/vite/assets/manual-report-CvfBM7VE.js b/staticfiles/vite/assets/manual-report-CvfBM7VE.js new file mode 100644 index 0000000..f02189a --- /dev/null +++ b/staticfiles/vite/assets/manual-report-CvfBM7VE.js @@ -0,0 +1 @@ +const fe=document.querySelector("#manual-report-form"),u=window.BOOMCAST_I18N||{};function Se(){if(!fe)return null;const e=document.querySelector("#burst-start"),t=e.closest(".burst-listener"),n=e.closest(".manual-report__supporting"),i=document.querySelector("#burst-state"),I=document.querySelector("#burst-panel"),y=document.querySelector("#burst-heading"),L=document.querySelector("#burst-detail"),w=document.querySelector("#burst-waveform"),Z=document.querySelector("#burst-preview"),se=document.querySelector("#burst-resume"),re=document.querySelector("#burst-discard"),be=document.querySelector("#burst-stop"),_=document.querySelector("#burst-error"),A=new Float32Array(300);let f=0,S="off",M,d,X,c,G,H,U,v;function $(){const a=w.getContext("2d");a.clearRect(0,0,w.width,w.height),a.fillStyle="#ffbd62";const l=w.width/A.length,p=Math.max(.003,...A);for(let s=0;s{for(let V=0;V{if(l.type==="level"&&(S==="listening"||S==="tail"))A[f]=l.value,f=(f+1)%A.length,$();else if(l.type==="trigger"&&S==="listening")N("tail");else if(l.type==="clip"){const p=new File([he(l.samples,l.sampleRate)],ye(),{type:"audio/wav"});v?(v(p),v=null):S==="tail"&&(ee(),U=p,H=URL.createObjectURL(p),Z.src=H,Z.hidden=!1,N("captured"))}},X.connect(c),c.connect(G).connect(d.destination),await d.resume(),A.fill(0),f=0,$(),N("listening")}catch(l){await P(),t&&(t.dataset.state="error"),n&&(n.dataset.state="error"),i&&(i.textContent=u.microphoneUnavailable||"Microphone unavailable"),_.textContent=l.name==="NotAllowedError"?u.microphoneDenied||"Microphone permission was denied. Manual reporting is still available.":u.microphoneFailed||"Microphone capture failed.",_.hidden=!1}finally{e.disabled=!1}}async function P(){v&&(v(null),v=null),ee(),c==null||c.disconnect(),X==null||X.disconnect(),G==null||G.disconnect(),M==null||M.getTracks().forEach(a=>a.stop()),await(d==null?void 0:d.close()),M=d=X=c=G=null,A.fill(0),f=0,N("off")}function te(){ee(),A.fill(0),f=0,$(),c==null||c.port.postMessage("reset"),c&&N("listening")}return e.addEventListener("click",we),be.addEventListener("click",P),re.addEventListener("click",te),se.addEventListener("click",te),window.addEventListener("pagehide",P),document.addEventListener("visibilitychange",()=>{document.hidden&&P()}),{get active(){return S!=="off"},async clipForSubmission(){return U||(S==="off"||!c?null:new Promise(a=>{v=a,c.port.postMessage("snapshot")}))},submissionSucceeded:te}}const o=window.BOOMCAST_I18N||{},m=document.querySelector("#manual-report-form"),K=document.querySelector("#manual-submit"),F=document.querySelector("#manual-submit-label"),C=document.querySelector("#manual-occurrences"),de=document.querySelector("#manual-decrease"),Ce=document.querySelector("#manual-increase"),Ge=document.querySelector("#manual-latitude"),ve=document.querySelector("#manual-longitude"),O=document.querySelector("#manual-direction-degrees"),Re=document.querySelector("#manual-direction-accuracy"),j=()=>document.querySelector("#manual-capture-direction"),g=()=>document.querySelector("#manual-direction-status"),r=()=>document.querySelector("#manual-direction-panel"),B=document.querySelector("#manual-compass"),T=document.querySelector("#manual-compass-home"),z=document.querySelector("#manual-compass-rose"),Ze=document.querySelector("#manual-compass-heading"),E=document.querySelector("#manual-report-time"),ce=document.querySelector("#report-clock-hours"),le=document.querySelector("#report-clock-minutes"),Me=document.querySelector("#manual-occurred-at"),ne=document.querySelector("#manual-use-now"),ue=document.querySelector("#manual-burst-status"),ge=document.querySelector("#manual-burst-duration");let x,J,R=null;const Y=Se(),oe=e=>Number.isFinite(e),ie=e=>[o.north||"North",o.northeast||"Northeast",o.east||"East",o.southeast||"Southeast",o.south||"South",o.southwest||"Southwest",o.west||"West",o.northwest||"Northwest"][Math.floor((e+22.5)%360/45)],Q=e=>Number(e.toFixed(1)).toString(),Ie=()=>{var I,y;if(!E)return;const e=new Date;E.dateTime=e.toISOString();const t=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e),n=(I=t.find(L=>L.type==="hour"))==null?void 0:I.value,i=(y=t.find(L=>L.type==="minute"))==null?void 0:y.value;!n||!i||!ce||!le||(ce.textContent=n,le.textContent=i,E.setAttribute("aria-label",`${n}:${i}`))};Ie();E&&window.setInterval(Ie,6e4);const Xe=(F==null?void 0:F.textContent)||"I heard fireworks";ne==null||ne.addEventListener("click",()=>{const e=new Date,t=new Date(e.getTime()-e.getTimezoneOffset()*6e4);Me.value=t.toISOString().slice(0,16)});const h=(e,t="")=>{if(m.dataset.state=e,K.disabled=e==="submitting",F&&(F.textContent=e==="submitting"?o.sendingReport||"Sending…":Xe),t){const n=document.querySelector("#manual-submission");n.className="manual-report__submission",n.textContent=t}},Ae=e=>{const t=e==null?void 0:e.dataset.nextNoteToken,n=document.querySelector("#manual-note-context");!t||!n||n.value===t||(n.value=t,window.htmx&&htmx.ajax("GET","/fireworks/notes/?token="+encodeURIComponent(t),{target:"#live-field-notes",swap:"outerHTML"}))},me=(e,t)=>{const n=new DOMParser().parseFromString(e,"text/html").querySelector("#manual-submission");return n?(document.querySelector("#manual-submission").replaceWith(n),t&&Ae(n),h(t?"submitted":"error"),t):(h("error",o.reportFailed||"Could not send the report. Please try again."),!1)},pe=()=>{const e=Number(C.value)>=3;ue&&(ue.textContent=e?o.burstEvent||"Burst Event":o.ordinaryReport||"Ordinary report"),ge&&(ge.hidden=!e)},k=e=>{const t=Number.parseInt(e,10);C.value=String(Math.min(1e3,Math.max(1,Number.isFinite(t)?t:1))),de.disabled=C.value==="1",Ce.disabled=C.value==="1000",pe()};k(C.value);de.addEventListener("click",()=>k(Number(C.value)-1));Ce.addEventListener("click",()=>k(Number(C.value)+1));C.addEventListener("change",()=>k(C.value));C.addEventListener("input",pe);const q=()=>{x&&window.removeEventListener("deviceorientation",x),window.clearTimeout(J),x=null,J=null,B.hidden=!0,R=null},We=e=>{const t=-e;if(R===null)R=t,z.style.transition="none",z.style.transform=`rotate(${R}deg)`,z.offsetWidth,z.style.transition="";else{const n=(t-R+540)%360-180;R+=n,z.style.transform=`rotate(${R}deg)`}Ze.textContent=`${Q(e)}° · ${ie(e)}`,B.setAttribute("aria-label",`${o.compassDirection||"Compass direction"} ${Q(e)}° ${ie(e)}`),B.hidden=!1},xe=(e,t)=>{const n=g();if(n)if(n.classList.toggle("manual-direction-panel__status--accuracy",t!==null),t===null)n.textContent=o.accuracyUnavailable||"Accuracy unavailable";else{const I=document.createElement("span");I.textContent=o.accuracy||"Accuracy";const y=document.createElement("strong");y.textContent=`±${Q(t)}°`,n.replaceChildren(I,y)}const i=j();i&&(i.textContent=o.stopCapture||"Stop measuring direction")},Be=()=>{g()&&(q(),r()&&(r().dataset.state="measuring"),g().textContent=o.pointPhone||"Point the top of your phone toward the sound — direction will update live.",x=e=>{const t="webkitCompassHeading"in e,n=oe(e.webkitCompassHeading)?e.webkitCompassHeading:!t&&e.absolute&&oe(e.alpha)?(360-e.alpha)%360:null;if(n===null||n<0||n>=360)return;const i=oe(e.webkitCompassAccuracy)&&e.webkitCompassAccuracy>=0?e.webkitCompassAccuracy:null;O.value=n,Re.value=i===null?"":i,xe(n,i),We(n),window.clearTimeout(J)},window.addEventListener("deviceorientation",x),J=window.setTimeout(()=>{q();const e=j(),t=g();e&&(e.textContent=o.captureDirection||"Start measuring direction"),t&&(t.textContent=o.compassUnavailable||"Compass unavailable on this device."),r()&&(r().dataset.state="unavailable")},15e3))},Le=async()=>{var e;if(x){q(),j().textContent=o.captureAgain||"Measure again",r()&&(r().dataset.state=O.value?"captured":"ready");return}if((e=g())==null||e.classList.remove("manual-direction-panel__status--accuracy"),!window.isSecureContext){g().textContent=o.secureCompass||"Compass capture requires a secure HTTPS connection.",r()&&(r().dataset.state="unavailable");return}if(typeof window.DeviceOrientationEvent>"u"){g().textContent=o.compassUnavailable||"Compass unavailable on this device.",r()&&(r().dataset.state="unavailable");return}if(typeof DeviceOrientationEvent.requestPermission=="function"){g().textContent=o.compassPermission||"Requesting compass permission…";try{if(await DeviceOrientationEvent.requestPermission(!0)!=="granted"){g()&&(g().textContent=o.compassDenied||"Compass permission denied."),r()&&(r().dataset.state="unavailable");return}}catch{g()&&(g().textContent=o.compassDenied||"Compass permission denied."),r()&&(r().dataset.state="unavailable");return}}Be()},ae=async()=>{if(k(C.value),q(),h("submitting",o.sendingReport||"Sending…"),Y!=null&&Y.active){try{const e=await Y.clipForSubmission(),t=new FormData(m);e&&t.append("audio",e);const n=await fetch(m.action,{method:"POST",body:t,credentials:"same-origin"}),i=await n.text();me(i,n.ok)&&Y.submissionSucceeded()}catch{h("error",o.reportFailed||"Could not send the report. Please try again.")}return}if(window.htmx)try{htmx.ajax("POST",m.action,{source:m,target:"#manual-submission",swap:"outerHTML"})}catch{h("error",o.reportFailed||"Could not send the report. Please try again.")}else m.submit()};m.addEventListener("click",e=>{e.target.closest("#manual-capture-direction")&&Le(),e.target.closest(".manual-direction-panel__close")&&(q(),T&&T.append(B))});document.body.addEventListener("htmx:beforeSwap",e=>{var t;((t=e.detail.target)==null?void 0:t.id)==="manual-direction-panel"&&T&&T.append(B)});document.body.addEventListener("htmx:afterSwap",e=>{var n,i;if(((n=e.detail.target)==null?void 0:n.id)!=="manual-direction-panel")return;j()&&((i=r().querySelector(".manual-direction-panel__copy"))==null||i.after(B));const t=document.querySelector("#manual-direction-summary");if(t&&O.value!==""){const I=Number(O.value);t.textContent=`${ie(I)} · ${Q(I)}°`,r().dataset.state="captured"}});K.addEventListener("click",()=>{if(!K.disabled){if(h("submitting",o.requestingLocation||"Requesting your optional location…"),!navigator.geolocation){ae();return}navigator.geolocation.getCurrentPosition(e=>{Ge.value=e.coords.latitude,ve.value=e.coords.longitude,ae()},()=>ae(),{enableHighAccuracy:!1,maximumAge:3e5,timeout:1e4})}});m.addEventListener("submit",e=>{e.preventDefault(),K.disabled||K.click()});document.body.addEventListener("htmx:afterRequest",e=>{if(e.detail.elt!==m)return;const t=e.detail.xhr;t?t.status>=400?me(t.responseText,!1):h("submitted"):h("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:sendError",e=>{e.detail.elt===m&&h("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:afterSwap",()=>Ae(document.querySelector("#manual-submission"))); diff --git a/staticfiles/vite/assets/manual-report-DoPagyx-.js b/staticfiles/vite/assets/manual-report-DoPagyx-.js new file mode 100644 index 0000000..5c06cc9 --- /dev/null +++ b/staticfiles/vite/assets/manual-report-DoPagyx-.js @@ -0,0 +1 @@ +const qe=document.querySelector("#manual-report-form"),d=window.BOOMCAST_I18N||{};function Fe(){if(!qe)return null;const e=document.querySelector("#burst-start"),t=e.closest(".burst-listener"),n=e.closest(".manual-report__supporting"),i=document.querySelector("#burst-state"),r=document.querySelector("#burst-panel"),w=document.querySelector("#burst-heading"),H=document.querySelector("#burst-detail"),S=document.querySelector("#burst-waveform"),N=document.querySelector("#burst-preview"),we=document.querySelector("#burst-resume"),Se=document.querySelector("#burst-discard"),Be=document.querySelector("#burst-stop"),le=document.querySelector("#burst-error"),A=new Float32Array(300);let v=0,G="off",W,I,D,l,R,E,j,M;function ue(){const a=S.getContext("2d");a.clearRect(0,0,S.width,S.height),a.fillStyle="#ffbd62";const u=S.width/A.length,h=Math.max(.003,...A);for(let c=0;c{for(let ee=0;ee{if(u.type==="level"&&(G==="listening"||G==="tail"))A[v]=u.value,v=(v+1)%A.length,ue();else if(u.type==="trigger"&&G==="listening")q("tail");else if(u.type==="clip"){const h=new File([ke(u.samples,u.sampleRate)],He(),{type:"audio/wav"});M?(M(h),M=null):G==="tail"&&(de(),j=h,E=URL.createObjectURL(h),N.src=E,N.hidden=!1,q("captured"))}},D.connect(l),l.connect(R).connect(I.destination),await I.resume(),A.fill(0),v=0,ue(),q("listening")}catch(u){await _(),t&&(t.dataset.state="error"),n&&(n.dataset.state="error"),i&&(i.textContent=d.microphoneUnavailable||"Microphone unavailable"),le.textContent=u.name==="NotAllowedError"?d.microphoneDenied||"Microphone permission was denied. Manual reporting is still available.":d.microphoneFailed||"Microphone capture failed.",le.hidden=!1}finally{e.disabled=!1}}async function _(){M&&(M(null),M=null),de(),l==null||l.disconnect(),D==null||D.disconnect(),R==null||R.disconnect(),W==null||W.getTracks().forEach(a=>a.stop()),await(I==null?void 0:I.close()),W=I=D=l=R=null,A.fill(0),v=0,q("off")}function ge(){de(),A.fill(0),v=0,ue(),l==null||l.port.postMessage("reset"),l&&q("listening")}return e.addEventListener("click",Ee),Be.addEventListener("click",_),Se.addEventListener("click",ge),we.addEventListener("click",ge),window.addEventListener("pagehide",_),document.addEventListener("visibilitychange",()=>{document.hidden&&_()}),{get active(){return G!=="off"},async clipForSubmission(){return j||(G==="off"||!l?null:new Promise(a=>{M=a,l.port.postMessage("snapshot")}))},submissionSucceeded:ge}}const o=window.BOOMCAST_I18N||{},p=document.querySelector("#manual-report-form"),T=document.querySelector("#manual-submit"),K=document.querySelector("#manual-submit-label"),m=document.querySelector("#manual-occurrences"),xe=document.querySelector("#manual-decrease"),Ze=document.querySelector("#manual-increase"),Ye=document.querySelector("#manual-latitude"),ze=document.querySelector("#manual-longitude"),ne=document.querySelector("#manual-direction-degrees"),Ve=document.querySelector("#manual-direction-accuracy"),ce=()=>document.querySelector("#manual-capture-direction"),g=()=>document.querySelector("#manual-direction-status"),s=()=>document.querySelector("#manual-direction-panel"),k=document.querySelector("#manual-compass"),oe=document.querySelector("#manual-compass-home"),Y=document.querySelector("#manual-compass-rose"),Ke=document.querySelector("#manual-compass-heading"),te=document.querySelector("#manual-report-time"),ve=document.querySelector("#report-clock-hours"),Ge=document.querySelector("#report-clock-minutes"),ae=document.querySelector("#manual-occurred-at"),Ne=document.querySelector("#report-clock-mode-label"),Ce=document.querySelector("#report-clock-date"),Z=document.querySelector("#report-clock-edit"),V=document.querySelector("#report-clock-reset"),ye=document.querySelector("#report-clock-editor"),L=document.querySelector("#report-clock-draft-date"),O=document.querySelector("#report-clock-draft-time"),Ie=document.querySelector("#report-clock-apply"),me=document.querySelector("#report-clock-cancel"),U=document.querySelector("#report-clock-error"),b=document.querySelector("#manual-time-approximate");let C="NOW",J=null,Q=!1;const Re=document.querySelector("#manual-burst-status"),Me=document.querySelector("#manual-burst-duration");let B,ie,x=null;const z=Fe(),Ae=e=>Number.isFinite(e),be=e=>[o.north||"North",o.northeast||"Northeast",o.east||"East",o.southeast||"Southeast",o.south||"South",o.southwest||"Southwest",o.west||"West",o.northwest||"Northwest"][Math.floor((e+22.5)%360/45)],re=e=>Number(e.toFixed(1)).toString(),se=()=>{var r,w;if(!te)return;const e=C==="OVERRIDE"?J:new Date;te.dateTime=e.toISOString();const t=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e),n=(r=t.find(H=>H.type==="hour"))==null?void 0:r.value,i=(w=t.find(H=>H.type==="minute"))==null?void 0:w.value;!n||!i||!ve||!Ge||(ve.textContent=n,Ge.textContent=i,te.setAttribute("aria-label",`${n}:${i}`),Ce&&(Ce.hidden=C!=="OVERRIDE",C==="OVERRIDE"&&(Ce.textContent=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{day:"numeric",month:"long",year:"numeric"}).format(e))))};se();te&&window.setInterval(se,6e4);const Oe=(K==null?void 0:K.textContent)||"I heard fireworks",he=e=>{const t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`},We=()=>{U&&(U.hidden=!0,U.textContent="",L.removeAttribute("aria-invalid"),O.removeAttribute("aria-invalid"))},fe=()=>{ye.hidden=!0,Z.setAttribute("aria-expanded","false"),We(),Z.focus()};Z==null||Z.addEventListener("click",()=>{const[e,t]=he(C==="OVERRIDE"?J:new Date).split("T");L.value=e,O.value=t,b.checked=C==="OVERRIDE"&&Q,b.disabled=!1,We(),ye.hidden=!1,Z.setAttribute("aria-expanded","true"),L.focus()});me==null||me.addEventListener("click",()=>{b.checked=C==="OVERRIDE"&&Q,b.disabled=C==="NOW",fe()});Ie==null||Ie.addEventListener("click",()=>{const e=L.value,t=O.value.trim(),n=`${e}T${t}`,r=/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d$/.test(n)?new Date(n):null;if(!r||Number.isNaN(r.getTime())||he(r)!==n||r.getTime()>Date.now()+3e5){U.textContent=!r||Number.isNaN(r.getTime())||he(r)!==n?o.invalidReportTime||"Enter a valid date and time.":o.futureReportTime||"Report time cannot be in the future.",U.hidden=!1,L.setAttribute("aria-invalid","true"),O.setAttribute("aria-invalid","true"),(e?O:L).focus();return}J=r,Q=b.checked,C="OVERRIDE",ae.value=r.toISOString(),Ne.textContent=o.adjusted||"Adjusted",V.hidden=!1,se(),fe()});V==null||V.addEventListener("click",()=>{C="NOW",J=null,Q=!1,ae.value="",b.checked=!1,b.disabled=!0,Ne.textContent=o.now||"Now",V.hidden=!0,se(),ye.hidden||fe(),Z.focus()});const f=(e,t="")=>{if(p.dataset.state=e,T.disabled=e==="submitting",K&&(K.textContent=e==="submitting"?o.sendingReport||"Sending…":Oe),t){const n=document.querySelector("#manual-submission");n.className="manual-report__submission",n.textContent=t}},De=e=>{const t=e==null?void 0:e.dataset.nextNoteToken,n=document.querySelector("#manual-note-context");!t||!n||n.value===t||(n.value=t,window.htmx&&htmx.ajax("GET","/fireworks/notes/?token="+encodeURIComponent(t),{target:"#live-field-notes",swap:"outerHTML"}))},Xe=(e,t)=>{const n=new DOMParser().parseFromString(e,"text/html").querySelector("#manual-submission");return n?(document.querySelector("#manual-submission").replaceWith(n),t&&De(n),f(t?"submitted":"error"),t):(f("error",o.reportFailed||"Could not send the report. Please try again."),!1)},Le=()=>{const e=Number(m.value)>=3;Re&&(Re.textContent=e?o.burstEvent||"Burst Event":o.ordinaryReport||"Ordinary report"),Me&&(Me.hidden=!e)},$=e=>{const t=Number.parseInt(e,10);m.value=String(Math.min(1e3,Math.max(1,Number.isFinite(t)?t:1))),xe.disabled=m.value==="1",Ze.disabled=m.value==="1000",Le()};$(m.value);xe.addEventListener("click",()=>$(Number(m.value)-1));Ze.addEventListener("click",()=>$(Number(m.value)+1));m.addEventListener("change",()=>$(m.value));m.addEventListener("input",Le);const P=()=>{B&&window.removeEventListener("deviceorientation",B),window.clearTimeout(ie),B=null,ie=null,k.hidden=!0,x=null},Ue=e=>{const t=-e;if(x===null)x=t,Y.style.transition="none",Y.style.transform=`rotate(${x}deg)`,Y.offsetWidth,Y.style.transition="";else{const n=(t-x+540)%360-180;x+=n,Y.style.transform=`rotate(${x}deg)`}Ke.textContent=`${re(e)}° · ${be(e)}`,k.setAttribute("aria-label",`${o.compassDirection||"Compass direction"} ${re(e)}° ${be(e)}`),k.hidden=!1},Te=(e,t)=>{const n=g();if(n)if(n.classList.toggle("manual-direction-panel__status--accuracy",t!==null),t===null)n.textContent=o.accuracyUnavailable||"Accuracy unavailable";else{const r=document.createElement("span");r.textContent=o.accuracy||"Accuracy";const w=document.createElement("strong");w.textContent=`±${re(t)}°`,n.replaceChildren(r,w)}const i=ce();i&&(i.textContent=o.stopCapture||"Stop measuring direction")},Pe=()=>{g()&&(P(),s()&&(s().dataset.state="measuring"),g().textContent=o.pointPhone||"Point the top of your phone toward the sound — direction will update live.",B=e=>{const t="webkitCompassHeading"in e,n=Ae(e.webkitCompassHeading)?e.webkitCompassHeading:!t&&e.absolute&&Ae(e.alpha)?(360-e.alpha)%360:null;if(n===null||n<0||n>=360)return;const i=Ae(e.webkitCompassAccuracy)&&e.webkitCompassAccuracy>=0?e.webkitCompassAccuracy:null;ne.value=n,Ve.value=i===null?"":i,Te(n,i),Ue(n),window.clearTimeout(ie)},window.addEventListener("deviceorientation",B),ie=window.setTimeout(()=>{P();const e=ce(),t=g();e&&(e.textContent=o.captureDirection||"Start measuring direction"),t&&(t.textContent=o.compassUnavailable||"Compass unavailable on this device."),s()&&(s().dataset.state="unavailable")},15e3))},Je=async()=>{var e;if(B){P(),ce().textContent=o.captureAgain||"Measure again",s()&&(s().dataset.state=ne.value?"captured":"ready");return}if((e=g())==null||e.classList.remove("manual-direction-panel__status--accuracy"),!window.isSecureContext){g().textContent=o.secureCompass||"Compass capture requires a secure HTTPS connection.",s()&&(s().dataset.state="unavailable");return}if(typeof window.DeviceOrientationEvent>"u"){g().textContent=o.compassUnavailable||"Compass unavailable on this device.",s()&&(s().dataset.state="unavailable");return}if(typeof DeviceOrientationEvent.requestPermission=="function"){g().textContent=o.compassPermission||"Requesting compass permission…";try{if(await DeviceOrientationEvent.requestPermission(!0)!=="granted"){g()&&(g().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}catch{g()&&(g().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}Pe()},pe=async()=>{if(ae&&(ae.value=C==="OVERRIDE"?J.toISOString():""),b&&(b.checked=C==="OVERRIDE"&&Q,b.disabled=C==="NOW"),$(m.value),P(),f("submitting",o.sendingReport||"Sending…"),z!=null&&z.active){try{const e=await z.clipForSubmission(),t=new FormData(p);e&&t.append("audio",e);const n=await fetch(p.action,{method:"POST",body:t,credentials:"same-origin"}),i=await n.text();Xe(i,n.ok)&&z.submissionSucceeded()}catch{f("error",o.reportFailed||"Could not send the report. Please try again.")}return}if(window.htmx)try{htmx.ajax("POST",p.action,{source:p,target:"#manual-submission",swap:"outerHTML"})}catch{f("error",o.reportFailed||"Could not send the report. Please try again.")}else p.submit()};p.addEventListener("click",e=>{e.target.closest("#manual-capture-direction")&&Je(),e.target.closest(".manual-direction-panel__close")&&(P(),oe&&oe.append(k))});document.body.addEventListener("htmx:beforeSwap",e=>{var t;((t=e.detail.target)==null?void 0:t.id)==="manual-direction-panel"&&oe&&oe.append(k)});document.body.addEventListener("htmx:afterSwap",e=>{var n,i;if(((n=e.detail.target)==null?void 0:n.id)!=="manual-direction-panel")return;ce()&&((i=s().querySelector(".manual-direction-panel__copy"))==null||i.after(k));const t=document.querySelector("#manual-direction-summary");if(t&&ne.value!==""){const r=Number(ne.value);t.textContent=`${be(r)} · ${re(r)}°`,s().dataset.state="captured"}});T.addEventListener("click",()=>{if(!T.disabled){if(f("submitting",o.requestingLocation||"Requesting your optional location…"),!navigator.geolocation){pe();return}navigator.geolocation.getCurrentPosition(e=>{Ye.value=e.coords.latitude,ze.value=e.coords.longitude,pe()},()=>pe(),{enableHighAccuracy:!1,maximumAge:3e5,timeout:1e4})}});p.addEventListener("submit",e=>{e.preventDefault(),T.disabled||T.click()});document.body.addEventListener("htmx:afterRequest",e=>{if(e.detail.elt!==p)return;const t=e.detail.xhr;t?t.status>=400?Xe(t.responseText,!1):f("submitted"):f("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:sendError",e=>{e.detail.elt===p&&f("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:afterSwap",()=>De(document.querySelector("#manual-submission"))); diff --git a/staticfiles/vite/assets/manual-report-DqrR4OFn.js b/staticfiles/vite/assets/manual-report-DqrR4OFn.js new file mode 100644 index 0000000..c04b1c0 --- /dev/null +++ b/staticfiles/vite/assets/manual-report-DqrR4OFn.js @@ -0,0 +1 @@ +const Ee=document.querySelector("#manual-report-form"),u=window.BOOMCAST_I18N||{};function qe(){if(!Ee)return null;const e=document.querySelector("#burst-start"),t=e.closest(".burst-listener"),n=e.closest(".manual-report__supporting"),i=document.querySelector("#burst-state"),m=document.querySelector("#burst-panel"),f=document.querySelector("#burst-heading"),k=document.querySelector("#burst-detail"),S=document.querySelector("#burst-waveform"),N=document.querySelector("#burst-preview"),we=document.querySelector("#burst-resume"),fe=document.querySelector("#burst-discard"),Le=document.querySelector("#burst-stop"),ce=document.querySelector("#burst-error"),A=new Float32Array(300);let v=0,G="off",W,C,X,c,R,E,j,M;function le(){const a=S.getContext("2d");a.clearRect(0,0,S.width,S.height),a.fillStyle="#ffbd62";const l=S.width/A.length,h=Math.max(.003,...A);for(let r=0;r{for(let _=0;_{if(l.type==="level"&&(G==="listening"||G==="tail"))A[v]=l.value,v=(v+1)%A.length,le();else if(l.type==="trigger"&&G==="listening")q("tail");else if(l.type==="clip"){const h=new File([Be(l.samples,l.sampleRate)],He(),{type:"audio/wav"});M?(M(h),M=null):G==="tail"&&(ue(),j=h,E=URL.createObjectURL(h),N.src=E,N.hidden=!1,q("captured"))}},X.connect(c),c.connect(R).connect(C.destination),await C.resume(),A.fill(0),v=0,le(),q("listening")}catch(l){await $(),t&&(t.dataset.state="error"),n&&(n.dataset.state="error"),i&&(i.textContent=u.microphoneUnavailable||"Microphone unavailable"),ce.textContent=l.name==="NotAllowedError"?u.microphoneDenied||"Microphone permission was denied. Manual reporting is still available.":u.microphoneFailed||"Microphone capture failed.",ce.hidden=!1}finally{e.disabled=!1}}async function $(){M&&(M(null),M=null),ue(),c==null||c.disconnect(),X==null||X.disconnect(),R==null||R.disconnect(),W==null||W.getTracks().forEach(a=>a.stop()),await(C==null?void 0:C.close()),W=C=X=c=R=null,A.fill(0),v=0,q("off")}function de(){ue(),A.fill(0),v=0,le(),c==null||c.port.postMessage("reset"),c&&q("listening")}return e.addEventListener("click",ke),Le.addEventListener("click",$),fe.addEventListener("click",de),we.addEventListener("click",de),window.addEventListener("pagehide",$),document.addEventListener("visibilitychange",()=>{document.hidden&&$()}),{get active(){return G!=="off"},async clipForSubmission(){return j||(G==="off"||!c?null:new Promise(a=>{M=a,c.port.postMessage("snapshot")}))},submissionSucceeded:de}}const o=window.BOOMCAST_I18N||{},p=document.querySelector("#manual-report-form"),U=document.querySelector("#manual-submit"),K=document.querySelector("#manual-submit-label"),I=document.querySelector("#manual-occurrences"),Me=document.querySelector("#manual-decrease"),xe=document.querySelector("#manual-increase"),Fe=document.querySelector("#manual-latitude"),Ye=document.querySelector("#manual-longitude"),te=document.querySelector("#manual-direction-degrees"),ze=document.querySelector("#manual-direction-accuracy"),re=()=>document.querySelector("#manual-capture-direction"),d=()=>document.querySelector("#manual-direction-status"),s=()=>document.querySelector("#manual-direction-panel"),H=document.querySelector("#manual-compass"),ne=document.querySelector("#manual-compass-home"),Y=document.querySelector("#manual-compass-rose"),Ve=document.querySelector("#manual-compass-heading"),ee=document.querySelector("#manual-report-time"),Se=document.querySelector("#report-clock-hours"),ve=document.querySelector("#report-clock-minutes"),oe=document.querySelector("#manual-occurred-at"),Ze=document.querySelector("#report-clock-mode-label"),ge=document.querySelector("#report-clock-date"),Z=document.querySelector("#report-clock-edit"),V=document.querySelector("#report-clock-reset"),he=document.querySelector("#report-clock-editor"),L=document.querySelector("#report-clock-draft"),Ce=document.querySelector("#report-clock-apply"),Ie=document.querySelector("#report-clock-cancel"),O=document.querySelector("#report-clock-error"),b=document.querySelector("#manual-time-approximate");let g="NOW",T=null,J=!1;const Ge=document.querySelector("#manual-burst-status"),Re=document.querySelector("#manual-burst-duration");let B,ae,x=null;const z=qe(),me=e=>Number.isFinite(e),pe=e=>[o.north||"North",o.northeast||"Northeast",o.east||"East",o.southeast||"Southeast",o.south||"South",o.southwest||"Southwest",o.west||"West",o.northwest||"Northwest"][Math.floor((e+22.5)%360/45)],ie=e=>Number(e.toFixed(1)).toString(),se=()=>{var m,f;if(!ee)return;const e=g==="OVERRIDE"?T:new Date;ee.dateTime=e.toISOString();const t=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e),n=(m=t.find(k=>k.type==="hour"))==null?void 0:m.value,i=(f=t.find(k=>k.type==="minute"))==null?void 0:f.value;!n||!i||!Se||!ve||(Se.textContent=n,ve.textContent=i,ee.setAttribute("aria-label",`${n}:${i}`),ge&&(ge.hidden=g!=="OVERRIDE",g==="OVERRIDE"&&(ge.textContent=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{day:"numeric",month:"long",year:"numeric"}).format(e))))};se();ee&&window.setInterval(se,6e4);const Ke=(K==null?void 0:K.textContent)||"I heard fireworks",be=e=>{const t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`},Ne=()=>{O&&(O.hidden=!0,O.textContent="",L.removeAttribute("aria-invalid"))},ye=()=>{he.hidden=!0,Z.setAttribute("aria-expanded","false"),Ne(),Z.focus()};Z==null||Z.addEventListener("click",()=>{L.value=be(g==="OVERRIDE"?T:new Date),b.checked=g==="OVERRIDE"&&J,b.disabled=!1,Ne(),he.hidden=!1,Z.setAttribute("aria-expanded","true"),L.focus()});Ie==null||Ie.addEventListener("click",()=>{b.checked=g==="OVERRIDE"&&J,b.disabled=g==="NOW",ye()});Ce==null||Ce.addEventListener("click",()=>{const e=L.value,t=e?new Date(e):null;if(!t||Number.isNaN(t.getTime())||be(t)!==e||t.getTime()>Date.now()+3e5){O.textContent=!e||!t||Number.isNaN(t.getTime())||be(t)!==e?o.invalidReportTime||"Enter a valid date and time.":o.futureReportTime||"Report time cannot be in the future.",O.hidden=!1,L.setAttribute("aria-invalid","true"),L.focus();return}T=t,J=b.checked,g="OVERRIDE",oe.value=t.toISOString(),Ze.textContent=o.adjusted||"Adjusted",V.hidden=!1,se(),ye()});V==null||V.addEventListener("click",()=>{g="NOW",T=null,J=!1,oe.value="",b.checked=!1,b.disabled=!0,Ze.textContent=o.now||"Now",V.hidden=!0,se(),he.hidden||ye(),Z.focus()});const w=(e,t="")=>{if(p.dataset.state=e,U.disabled=e==="submitting",K&&(K.textContent=e==="submitting"?o.sendingReport||"Sending…":Ke),t){const n=document.querySelector("#manual-submission");n.className="manual-report__submission",n.textContent=t}},We=e=>{const t=e==null?void 0:e.dataset.nextNoteToken,n=document.querySelector("#manual-note-context");!t||!n||n.value===t||(n.value=t,window.htmx&&htmx.ajax("GET","/fireworks/notes/?token="+encodeURIComponent(t),{target:"#live-field-notes",swap:"outerHTML"}))},Xe=(e,t)=>{const n=new DOMParser().parseFromString(e,"text/html").querySelector("#manual-submission");return n?(document.querySelector("#manual-submission").replaceWith(n),t&&We(n),w(t?"submitted":"error"),t):(w("error",o.reportFailed||"Could not send the report. Please try again."),!1)},De=()=>{const e=Number(I.value)>=3;Ge&&(Ge.textContent=e?o.burstEvent||"Burst Event":o.ordinaryReport||"Ordinary report"),Re&&(Re.hidden=!e)},Q=e=>{const t=Number.parseInt(e,10);I.value=String(Math.min(1e3,Math.max(1,Number.isFinite(t)?t:1))),Me.disabled=I.value==="1",xe.disabled=I.value==="1000",De()};Q(I.value);Me.addEventListener("click",()=>Q(Number(I.value)-1));xe.addEventListener("click",()=>Q(Number(I.value)+1));I.addEventListener("change",()=>Q(I.value));I.addEventListener("input",De);const P=()=>{B&&window.removeEventListener("deviceorientation",B),window.clearTimeout(ae),B=null,ae=null,H.hidden=!0,x=null},Oe=e=>{const t=-e;if(x===null)x=t,Y.style.transition="none",Y.style.transform=`rotate(${x}deg)`,Y.offsetWidth,Y.style.transition="";else{const n=(t-x+540)%360-180;x+=n,Y.style.transform=`rotate(${x}deg)`}Ve.textContent=`${ie(e)}° · ${pe(e)}`,H.setAttribute("aria-label",`${o.compassDirection||"Compass direction"} ${ie(e)}° ${pe(e)}`),H.hidden=!1},Ue=(e,t)=>{const n=d();if(n)if(n.classList.toggle("manual-direction-panel__status--accuracy",t!==null),t===null)n.textContent=o.accuracyUnavailable||"Accuracy unavailable";else{const m=document.createElement("span");m.textContent=o.accuracy||"Accuracy";const f=document.createElement("strong");f.textContent=`±${ie(t)}°`,n.replaceChildren(m,f)}const i=re();i&&(i.textContent=o.stopCapture||"Stop measuring direction")},Pe=()=>{d()&&(P(),s()&&(s().dataset.state="measuring"),d().textContent=o.pointPhone||"Point the top of your phone toward the sound — direction will update live.",B=e=>{const t="webkitCompassHeading"in e,n=me(e.webkitCompassHeading)?e.webkitCompassHeading:!t&&e.absolute&&me(e.alpha)?(360-e.alpha)%360:null;if(n===null||n<0||n>=360)return;const i=me(e.webkitCompassAccuracy)&&e.webkitCompassAccuracy>=0?e.webkitCompassAccuracy:null;te.value=n,ze.value=i===null?"":i,Ue(n,i),Oe(n),window.clearTimeout(ae)},window.addEventListener("deviceorientation",B),ae=window.setTimeout(()=>{P();const e=re(),t=d();e&&(e.textContent=o.captureDirection||"Start measuring direction"),t&&(t.textContent=o.compassUnavailable||"Compass unavailable on this device."),s()&&(s().dataset.state="unavailable")},15e3))},Te=async()=>{var e;if(B){P(),re().textContent=o.captureAgain||"Measure again",s()&&(s().dataset.state=te.value?"captured":"ready");return}if((e=d())==null||e.classList.remove("manual-direction-panel__status--accuracy"),!window.isSecureContext){d().textContent=o.secureCompass||"Compass capture requires a secure HTTPS connection.",s()&&(s().dataset.state="unavailable");return}if(typeof window.DeviceOrientationEvent>"u"){d().textContent=o.compassUnavailable||"Compass unavailable on this device.",s()&&(s().dataset.state="unavailable");return}if(typeof DeviceOrientationEvent.requestPermission=="function"){d().textContent=o.compassPermission||"Requesting compass permission…";try{if(await DeviceOrientationEvent.requestPermission(!0)!=="granted"){d()&&(d().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}catch{d()&&(d().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}Pe()},Ae=async()=>{if(oe&&(oe.value=g==="OVERRIDE"?T.toISOString():""),b&&(b.checked=g==="OVERRIDE"&&J,b.disabled=g==="NOW"),Q(I.value),P(),w("submitting",o.sendingReport||"Sending…"),z!=null&&z.active){try{const e=await z.clipForSubmission(),t=new FormData(p);e&&t.append("audio",e);const n=await fetch(p.action,{method:"POST",body:t,credentials:"same-origin"}),i=await n.text();Xe(i,n.ok)&&z.submissionSucceeded()}catch{w("error",o.reportFailed||"Could not send the report. Please try again.")}return}if(window.htmx)try{htmx.ajax("POST",p.action,{source:p,target:"#manual-submission",swap:"outerHTML"})}catch{w("error",o.reportFailed||"Could not send the report. Please try again.")}else p.submit()};p.addEventListener("click",e=>{e.target.closest("#manual-capture-direction")&&Te(),e.target.closest(".manual-direction-panel__close")&&(P(),ne&&ne.append(H))});document.body.addEventListener("htmx:beforeSwap",e=>{var t;((t=e.detail.target)==null?void 0:t.id)==="manual-direction-panel"&&ne&&ne.append(H)});document.body.addEventListener("htmx:afterSwap",e=>{var n,i;if(((n=e.detail.target)==null?void 0:n.id)!=="manual-direction-panel")return;re()&&((i=s().querySelector(".manual-direction-panel__copy"))==null||i.after(H));const t=document.querySelector("#manual-direction-summary");if(t&&te.value!==""){const m=Number(te.value);t.textContent=`${pe(m)} · ${ie(m)}°`,s().dataset.state="captured"}});U.addEventListener("click",()=>{if(!U.disabled){if(w("submitting",o.requestingLocation||"Requesting your optional location…"),!navigator.geolocation){Ae();return}navigator.geolocation.getCurrentPosition(e=>{Fe.value=e.coords.latitude,Ye.value=e.coords.longitude,Ae()},()=>Ae(),{enableHighAccuracy:!1,maximumAge:3e5,timeout:1e4})}});p.addEventListener("submit",e=>{e.preventDefault(),U.disabled||U.click()});document.body.addEventListener("htmx:afterRequest",e=>{if(e.detail.elt!==p)return;const t=e.detail.xhr;t?t.status>=400?Xe(t.responseText,!1):w("submitted"):w("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:sendError",e=>{e.detail.elt===p&&w("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:afterSwap",()=>We(document.querySelector("#manual-submission"))); diff --git a/staticfiles/vite/assets/manual-report-T9fTmp3F.css b/staticfiles/vite/assets/manual-report-T9fTmp3F.css new file mode 100644 index 0000000..4f35bb8 --- /dev/null +++ b/staticfiles/vite/assets/manual-report-T9fTmp3F.css @@ -0,0 +1 @@ +.manual-report__supporting{padding:1rem;border:1px solid #514282;border-radius:1rem;background:#11152c}.manual-report__supporting-header{display:flex;align-items:center;gap:.7rem}.manual-report__microphone{display:grid;width:2.5rem;height:2.5rem;flex:none;place-items:center;border-radius:.7rem;background:#2a2051;font-size:1.3rem}.burst-listener__state{display:block;margin-top:.15rem;color:#b9addb;font-size:.84rem}.manual-report__supporting[data-state=listening] .burst-listener__state{color:#8fe5cc}.manual-report__supporting[data-state=error] .burst-listener__state{color:#ffbd9d}.burst-listener{width:100%;margin-top:.85rem}.burst-listener__button,.burst-listener__actions button{min-height:2.75rem;padding:.65rem 1rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#292148;cursor:pointer}.burst-listener__button{width:100%}.burst-listener__panel{color:#f0eaff}.burst-listener__panel strong{font-size:.92rem}.burst-listener__panel canvas{display:block;width:100%;height:4rem;margin:.7rem 0 .35rem;border-radius:.5rem;background:linear-gradient(90deg,#191738,#241b44)}.burst-listener__panel p{margin:.35rem 0 .75rem;color:#b9addb;font-size:.82rem}.burst-listener__panel audio{width:100%;margin-bottom:.75rem}.burst-listener__actions{display:flex;flex-wrap:wrap;gap:.5rem}.burst-listener__actions button{flex:1 1 10rem}.burst-listener__actions #burst-stop{border-color:#fb9b72;color:#ffd8c4;background:#2e1b31}.burst-listener [hidden]{display:none!important}.burst-listener [role=alert]{margin:.65rem 0 0;color:#ffd1b6}.burst-listener button:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__microphone{background:#ead2eb}:root[data-theme=light] .burst-listener__state,:root[data-theme=light] .burst-listener__panel p{color:#694b68}:root[data-theme=light] .burst-listener__panel{color:#321d42}:root[data-theme=light] .burst-listener__button,:root[data-theme=light] .burst-listener__actions button{border-color:#b68bb5;color:#321d42;background:#ead2eb}:root[data-theme=light] .burst-listener__actions #burst-stop{border-color:#cf7957;color:#71331d;background:#ffe9de}.manual-compass{display:grid;justify-items:center;width:7rem;margin:.6rem 0 0 auto;color:#fff3d7;font-size:.78rem;font-weight:850;font-variant-numeric:tabular-nums}.manual-compass[hidden]{display:none}.manual-compass__dial{position:relative;width:5.75rem;aspect-ratio:1;border:2px solid #f2d7a8;border-radius:50%;background:radial-gradient(circle,#342441 0,#342441 28%,#211a32 75%);box-shadow:0 .35rem 1rem #09061566,inset 0 0 0 .25rem #ffffff12}.manual-compass__rose{position:absolute;top:0;right:0;bottom:0;left:0;transition:transform .12s ease-out}.manual-compass__rose span{position:absolute;line-height:1}.manual-compass__north{top:.38rem;left:50%;color:#ff9e78;transform:translate(-50%)}.manual-compass__east{right:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__south{bottom:.38rem;left:50%;transform:translate(-50%)}.manual-compass__west{left:.47rem;top:50%;transform:translateY(-50%)}.manual-compass__pointer{position:absolute;top:-.55rem;left:50%;width:0;height:0;border-right:.37rem solid transparent;border-bottom:.65rem solid #ffbd62;border-left:.37rem solid transparent;transform:translate(-50%);filter:drop-shadow(0 .1rem .15rem #160d1b)}.manual-compass__center{position:absolute;top:50%;left:50%;width:.5rem;aspect-ratio:1;border-radius:50%;background:#ffbd62;transform:translate(-50%,-50%)}.manual-compass__heading{margin-top:.5rem;white-space:nowrap}:root[data-theme=light] .manual-compass{color:#43243d}:root[data-theme=light] .manual-compass__dial{border-color:#996a9b;background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 28%,#e8d7e9 75%)}:root[data-theme=light] .manual-compass__east,:root[data-theme=light] .manual-compass__south,:root[data-theme=light] .manual-compass__west{color:#43243d}@media(prefers-reduced-motion:reduce){.manual-compass__rose{transition:none}}.manual-report__header{max-width:42rem}.manual-report{--manual-report-section-gap: 1rem}.manual-report__duration{display:grid;gap:.55rem;max-width:36rem;margin-bottom:var(--manual-report-section-gap);padding:.85rem 1rem;border:1px solid #584891;border-radius:1rem;background:#151932;color:#e9def8}.manual-report__duration input[type=datetime-local],.manual-report__duration input[type=number]{width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #725da4;border-radius:.55rem;color:#f5f0ff;background:#211d3d;font:inherit;color-scheme:dark}.manual-report__duration small{color:#cbbce5}.manual-report__duration[hidden]{display:none}.manual-report__check{display:flex;align-items:center;gap:.5rem;color:#e9def8}.manual-report__burst-status{margin:.5rem 0 0;color:#ffbf72;font-weight:750}.manual-submission__edit{display:grid;gap:.4rem;max-width:18rem;margin-top:1rem}.manual-submission__edit input[type=number]{min-height:2.5rem;padding:.4rem;border-radius:.5rem}.manual-submission__edit button{min-height:2.5rem;cursor:pointer}.manual-report__primary{display:grid;gap:var(--manual-report-section-gap);max-width:36rem}.manual-report__quantity{padding:1rem;border:1px solid #584891;border-radius:1rem;background:#151932}.manual-report .manual-report__quantity #manual-occurrences{width:100%;min-width:0;min-height:3.75rem;margin:0;padding:0;border:0;color:#f5f0ff;font-size:clamp(2.25rem,8vw,3.5rem);font-weight:850;text-align:center;background:transparent;-webkit-appearance:textfield;appearance:textfield;-moz-appearance:textfield}.manual-report__quantity #manual-occurrences::-webkit-inner-spin-button,.manual-report__quantity #manual-occurrences::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.manual-report__stepper{display:grid;grid-template-columns:3.5rem minmax(0,1fr) 3.5rem;align-items:center;gap:.5rem}.manual-report__stepper button{display:grid;place-items:center;width:3.5rem;height:3.5rem;min-height:0;padding:0;border:1px solid #6d54ac;border-radius:50%;color:#f5f0ff;font:inherit;font-size:2rem;line-height:1;background:#302553;cursor:pointer}.manual-report__stepper button:disabled{opacity:.4;cursor:default}.manual-report .manual-report__primary .manual-direction-panel{width:100%;margin:0;border-radius:1rem;background:#1a1739}.manual-direction-panel[data-state=measuring]{border-color:#a27cff}.manual-direction-panel[data-state=captured]{border-color:#68dba1}.manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}.manual-direction-panel__topline{display:flex;align-items:center;justify-content:space-between;gap:1rem}.manual-direction-panel__summary{margin:.35rem 0 .8rem;color:#f5f0ff;font-weight:700}.manual-report .manual-direction-panel__status--accuracy{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin:.75rem 0;padding:.55rem .75rem;border:1px solid #5d4d92;border-radius:.7rem;color:#d9cfee;background:#191630;font-size:.85rem}.manual-direction-panel__status--accuracy strong{color:#f5edff;font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.manual-direction-panel__open,.manual-direction-panel__close{min-height:2.75rem;border:1px solid #8d77d2;border-radius:.7rem;color:#e8dcff;font:inherit;font-weight:750;background:#302553;cursor:pointer}.manual-direction-panel__open{padding:.5rem .85rem}.manual-direction-panel__close{min-width:2.75rem;font-size:1.4rem}.manual-report #manual-submit{width:100%;max-width:36rem;min-height:4.5rem;margin-top:var(--manual-report-section-gap)}.manual-report__submit:disabled{cursor:wait;opacity:.72}.manual-submission{display:grid;justify-items:center;gap:.5rem;max-width:36rem;margin-top:1rem;padding:1.3rem;border:1px solid #4caa82;border-radius:1rem;color:#eafff2;text-align:center;background:#10352e}.manual-submission__icon{display:grid;width:3.5rem;height:3.5rem;place-items:center;border:2px solid #6ce4a8;border-radius:50%;color:#eafff2;font-size:2rem;background:#226c51}.manual-submission strong{font-size:1.35rem}.manual-submission p{margin:0;line-height:1.45}.manual-submission__summary{margin-top:.35rem!important;color:#b2e8cf;font-size:.9rem}.manual-submission--error{border-color:#d37c6a;color:#fff0e8;background:#3a1c2b}.manual-submission--error .manual-submission__icon{border-color:#ffac8c;background:#9b493a}.manual-report__submission:empty{display:none}.manual-report button:focus-visible,.manual-report input:focus-visible{outline:3px solid #c9b4ff;outline-offset:3px}.manual-report__supporting{max-width:36rem;margin-top:var(--manual-report-section-gap);padding-top:1.25rem;border-top:1px solid #584891}.manual-report__supporting h3{margin:0;color:#d8cffd;font-size:1rem}.manual-report__supporting .burst-listener{width:100%}:root[data-theme=light] .manual-report__quantity{border-color:#d9b4d8;background:#fff8fb}:root[data-theme=light] .manual-report__quantity #manual-occurrences{border:0!important;color:#321d42!important;background:transparent!important}:root[data-theme=light] .manual-report__stepper button,:root[data-theme=light] .manual-direction-panel__open,:root[data-theme=light] .manual-direction-panel__close{color:#321d42;border-color:#b68bb5;background:#ead2eb}:root[data-theme=light] .manual-direction-panel__summary{color:#321d42}:root[data-theme=light] .manual-report .manual-direction-panel__status--accuracy{border-color:#cfaad1;color:#694b68;background:#fff8fb}:root[data-theme=light] .manual-direction-panel__status--accuracy strong{color:#321d42}:root[data-theme=light] .manual-submission{border-color:#54a67b;color:#164d34;background:#e8fff2}:root[data-theme=light] .manual-submission__icon{color:#fff}:root[data-theme=light] .manual-submission__summary{color:#2b6b48}:root[data-theme=light] .manual-submission--error{border-color:#ca7d65;color:#743520;background:#fff0e8}:root[data-theme=light] .manual-report__supporting{border-color:#d9b4d8}:root[data-theme=light] .manual-report__supporting h3{color:#492846}@media(max-width:42rem){.home-grid{grid-template-columns:minmax(0,1fr)}body:not(.dashboard-page){padding:max(1rem,env(safe-area-inset-top,0px)) max(.5rem,env(safe-area-inset-right,0px)) max(1rem,env(safe-area-inset-bottom,0px)) max(.5rem,env(safe-area-inset-left,0px))}.home-grid .manual-report,.dashboard-report,.dashboard-report .manual-report{overflow:visible}.manual-report{padding:1.25rem}.dashboard-report .manual-report{padding:0}.manual-report__header{padding-right:2.5rem}.manual-report form{padding-bottom:calc(5rem + env(safe-area-inset-bottom,0px))}.manual-report #manual-submit{position:sticky;bottom:calc(.5rem + env(safe-area-inset-bottom,0px));z-index:10;box-shadow:0 .7rem 1.6rem #070a18b3}body:has(#manual-occurrences:focus) .manual-report #manual-submit{position:static}.dashboard-intro{margin-bottom:1rem}.dashboard-intro h1{font-size:clamp(2rem,8vw,2.8rem)}.dashboard-intro p:last-child{margin-top:.75rem;font-size:.95rem;line-height:1.4}.dashboard-section{margin-top:1rem}.dashboard-shell{padding-bottom:calc(2rem + env(safe-area-inset-bottom,0px))}.manual-report__stepper{grid-template-columns:3.5rem minmax(0,1fr) 3.5rem}}@media(max-width:23.5rem){.manual-report{padding:1rem}.manual-report__quantity{padding:.75rem}.manual-report__stepper{grid-template-columns:3rem minmax(0,1fr) 3rem;gap:.25rem}.manual-report__stepper button{width:3rem;height:3rem}}.manual-report__heading-row{display:flex;align-items:center;gap:.7rem}.manual-report__fire{flex:none;font-size:clamp(1.8rem,5vw,2.5rem);filter:drop-shadow(0 .2rem .65rem rgba(255,112,59,.5333333333))}.manual-report__intro,.dashboard-report .manual-report__intro{margin-bottom:.85rem}.report-clock{box-sizing:border-box;width:100%;max-width:36rem;margin:0 0 1rem;padding:.65rem .95rem .7rem;border:1px solid #69539d;border-radius:.85rem;background:linear-gradient(115deg,#17162d,#10182c);box-shadow:inset 0 1px #ffffff0a}.report-clock__label{color:#cbbce5;font-size:.66rem;font-weight:750;letter-spacing:.13em;text-transform:uppercase}.report-clock__display{display:flex;align-items:end;justify-content:space-between;gap:.75rem}.report-clock__controls{display:flex;align-items:center;gap:.4rem}.report-clock__edit,.report-clock__reset,.report-clock__actions button{min-height:2.25rem;padding:.35rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#302553;font:inherit;cursor:pointer}.report-clock__edit{min-width:2.25rem;font-size:1.2rem;line-height:1}.report-clock__date{display:block;margin-top:.25rem;color:#e9def8;font-size:.85rem}.report-clock__reset{margin-top:.6rem}.report-clock__editor{display:grid;gap:.5rem;margin-top:.8rem;padding-top:.8rem;border-top:1px solid #69539d;color:#f5f0ff}.report-clock__editor label{font-weight:650}.report-clock__editor input[type=datetime-local]{width:100%;min-height:2.75rem;padding:.45rem .65rem;border:1px solid #936ea8;border-radius:.55rem;color:#f5f0ff;background:#211d3d;color-scheme:dark;font:inherit}.report-clock__actions{display:flex;flex-wrap:wrap;gap:.5rem}.report-clock__error{margin:0;color:#ffb9a9}.report-clock [hidden]{display:none!important}@media(max-width:25rem){.report-clock__display{align-items:center}.report-clock__now{font-size:.6rem}}.report-clock__time{display:inline-flex;align-items:center;color:#ffbf72;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:clamp(2rem,9vw,2.45rem);font-weight:700;line-height:1.1;letter-spacing:0;font-variant-numeric:tabular-nums;text-shadow:0 0 .7rem rgba(255,150,59,.3333333333);white-space:nowrap}.report-clock__time span{display:inline-block}.report-clock__time #report-clock-hours,.report-clock__time #report-clock-minutes{width:2ch}.report-clock__colon{width:1ch;flex:none;margin-inline:-.08em;line-height:1;text-align:center;transform:translateY(-.06em);animation:report-clock-blink 2s steps(1,end) infinite}.report-clock__now{display:inline-flex;align-items:center;gap:.4rem;flex:none;padding:.2rem .45rem;border:1px solid #93634d;border-radius:999px;color:#ffd2a2;font-size:.7rem;font-weight:750;letter-spacing:.08em;text-transform:uppercase}.report-clock__dot{width:.4rem;height:.4rem;border-radius:50%;background:#ffab5d}@keyframes report-clock-blink{50%{opacity:0}}.manual-direction-panel__open{width:100%;text-align:left}.manual-direction-panel--open .manual-compass{width:100%;margin:.5rem auto 1rem}.manual-direction-panel--open .manual-compass__dial{width:min(100%,12rem);border-color:#8b67d4;background:radial-gradient(circle,#302054 0,#302054 20%,#17132d 70%);box-shadow:0 0 0 .35rem #6640a228,0 0 2rem #ac6aff35}.manual-direction-panel--open .manual-compass__pointer{border-bottom-color:#ff925f}.manual-direction-panel--open .manual-compass__heading{font-size:1.1rem}.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:transform .15s ease,box-shadow .15s ease,filter .15s ease}.manual-report__stepper button:not(:disabled):active,.manual-direction-panel__open:active,.manual-report__submit:not(:disabled):active{transform:scale(.97)}.manual-report__submit:not(:disabled):hover{filter:brightness(1.05)}.manual-submission--success .manual-submission__icon{animation:manual-confirm .35s ease-out both}@keyframes manual-confirm{0%{transform:scale(.75);opacity:.3}to{transform:scale(1);opacity:1}}:root[data-theme=dark] .home-grid .manual-report,:root[data-theme=dark] .dashboard-report{border-color:#7256ab;background:radial-gradient(circle at 88% 5%,rgba(88,37,74,.3333333333),transparent 13rem),linear-gradient(155deg,#151326,#0d1022 72%);box-shadow:0 1rem 3rem #02041399}:root[data-theme=dark] .manual-report__title{color:#fff8f3}:root[data-theme=dark] .manual-report__intro{color:#d6cce4}:root[data-theme=dark] .manual-report__quantity{border-color:#514896;background:linear-gradient(145deg,#19183a,#121834);box-shadow:inset 0 0 0 1px #ffffff08}:root[data-theme=dark] .home-grid .manual-direction-panel,:root[data-theme=dark] .dashboard-report .manual-direction-panel{border-color:#59499b;background:linear-gradient(145deg,#211945,#151835)}:root[data-theme=dark] .manual-report__supporting{border-color:#493d7d;background:linear-gradient(145deg,#15142f,#10162d)}:root[data-theme=dark] .manual-report__stepper button{box-shadow:0 .25rem .7rem #07041655}:root[data-theme=dark] .manual-report__submit{background:linear-gradient(110deg,#ffc276,#ff7654);box-shadow:0 .55rem 1.35rem #e2633a4d}:root[data-theme=dark] .manual-direction-panel[data-state=measuring]{border-color:#a27cff}:root[data-theme=dark] .manual-direction-panel[data-state=captured]{border-color:#68dba1}:root[data-theme=dark] .manual-direction-panel[data-state=unavailable]{border-color:#d38b7a}:root[data-theme=light] .report-clock{border-color:#8b6bab;background:linear-gradient(115deg,#221b37,#182039)}:root[data-theme=light] .manual-direction-panel--open .manual-compass__dial{background:radial-gradient(circle,#f8ebf8 0,#f8ebf8 25%,#e8d7e9 75%)}@media(prefers-reduced-motion:reduce){.manual-report__stepper button,.manual-direction-panel__open,.manual-direction-panel__close,.manual-report__submit{transition:none}.manual-submission--success .manual-submission__icon{animation:none}.report-clock__colon{animation:none;opacity:1}} diff --git a/staticfiles/vite/assets/manual-report-v3jdwBHW.js b/staticfiles/vite/assets/manual-report-v3jdwBHW.js new file mode 100644 index 0000000..5c06cc9 --- /dev/null +++ b/staticfiles/vite/assets/manual-report-v3jdwBHW.js @@ -0,0 +1 @@ +const qe=document.querySelector("#manual-report-form"),d=window.BOOMCAST_I18N||{};function Fe(){if(!qe)return null;const e=document.querySelector("#burst-start"),t=e.closest(".burst-listener"),n=e.closest(".manual-report__supporting"),i=document.querySelector("#burst-state"),r=document.querySelector("#burst-panel"),w=document.querySelector("#burst-heading"),H=document.querySelector("#burst-detail"),S=document.querySelector("#burst-waveform"),N=document.querySelector("#burst-preview"),we=document.querySelector("#burst-resume"),Se=document.querySelector("#burst-discard"),Be=document.querySelector("#burst-stop"),le=document.querySelector("#burst-error"),A=new Float32Array(300);let v=0,G="off",W,I,D,l,R,E,j,M;function ue(){const a=S.getContext("2d");a.clearRect(0,0,S.width,S.height),a.fillStyle="#ffbd62";const u=S.width/A.length,h=Math.max(.003,...A);for(let c=0;c{for(let ee=0;ee{if(u.type==="level"&&(G==="listening"||G==="tail"))A[v]=u.value,v=(v+1)%A.length,ue();else if(u.type==="trigger"&&G==="listening")q("tail");else if(u.type==="clip"){const h=new File([ke(u.samples,u.sampleRate)],He(),{type:"audio/wav"});M?(M(h),M=null):G==="tail"&&(de(),j=h,E=URL.createObjectURL(h),N.src=E,N.hidden=!1,q("captured"))}},D.connect(l),l.connect(R).connect(I.destination),await I.resume(),A.fill(0),v=0,ue(),q("listening")}catch(u){await _(),t&&(t.dataset.state="error"),n&&(n.dataset.state="error"),i&&(i.textContent=d.microphoneUnavailable||"Microphone unavailable"),le.textContent=u.name==="NotAllowedError"?d.microphoneDenied||"Microphone permission was denied. Manual reporting is still available.":d.microphoneFailed||"Microphone capture failed.",le.hidden=!1}finally{e.disabled=!1}}async function _(){M&&(M(null),M=null),de(),l==null||l.disconnect(),D==null||D.disconnect(),R==null||R.disconnect(),W==null||W.getTracks().forEach(a=>a.stop()),await(I==null?void 0:I.close()),W=I=D=l=R=null,A.fill(0),v=0,q("off")}function ge(){de(),A.fill(0),v=0,ue(),l==null||l.port.postMessage("reset"),l&&q("listening")}return e.addEventListener("click",Ee),Be.addEventListener("click",_),Se.addEventListener("click",ge),we.addEventListener("click",ge),window.addEventListener("pagehide",_),document.addEventListener("visibilitychange",()=>{document.hidden&&_()}),{get active(){return G!=="off"},async clipForSubmission(){return j||(G==="off"||!l?null:new Promise(a=>{M=a,l.port.postMessage("snapshot")}))},submissionSucceeded:ge}}const o=window.BOOMCAST_I18N||{},p=document.querySelector("#manual-report-form"),T=document.querySelector("#manual-submit"),K=document.querySelector("#manual-submit-label"),m=document.querySelector("#manual-occurrences"),xe=document.querySelector("#manual-decrease"),Ze=document.querySelector("#manual-increase"),Ye=document.querySelector("#manual-latitude"),ze=document.querySelector("#manual-longitude"),ne=document.querySelector("#manual-direction-degrees"),Ve=document.querySelector("#manual-direction-accuracy"),ce=()=>document.querySelector("#manual-capture-direction"),g=()=>document.querySelector("#manual-direction-status"),s=()=>document.querySelector("#manual-direction-panel"),k=document.querySelector("#manual-compass"),oe=document.querySelector("#manual-compass-home"),Y=document.querySelector("#manual-compass-rose"),Ke=document.querySelector("#manual-compass-heading"),te=document.querySelector("#manual-report-time"),ve=document.querySelector("#report-clock-hours"),Ge=document.querySelector("#report-clock-minutes"),ae=document.querySelector("#manual-occurred-at"),Ne=document.querySelector("#report-clock-mode-label"),Ce=document.querySelector("#report-clock-date"),Z=document.querySelector("#report-clock-edit"),V=document.querySelector("#report-clock-reset"),ye=document.querySelector("#report-clock-editor"),L=document.querySelector("#report-clock-draft-date"),O=document.querySelector("#report-clock-draft-time"),Ie=document.querySelector("#report-clock-apply"),me=document.querySelector("#report-clock-cancel"),U=document.querySelector("#report-clock-error"),b=document.querySelector("#manual-time-approximate");let C="NOW",J=null,Q=!1;const Re=document.querySelector("#manual-burst-status"),Me=document.querySelector("#manual-burst-duration");let B,ie,x=null;const z=Fe(),Ae=e=>Number.isFinite(e),be=e=>[o.north||"North",o.northeast||"Northeast",o.east||"East",o.southeast||"Southeast",o.south||"South",o.southwest||"Southwest",o.west||"West",o.northwest||"Northwest"][Math.floor((e+22.5)%360/45)],re=e=>Number(e.toFixed(1)).toString(),se=()=>{var r,w;if(!te)return;const e=C==="OVERRIDE"?J:new Date;te.dateTime=e.toISOString();const t=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e),n=(r=t.find(H=>H.type==="hour"))==null?void 0:r.value,i=(w=t.find(H=>H.type==="minute"))==null?void 0:w.value;!n||!i||!ve||!Ge||(ve.textContent=n,Ge.textContent=i,te.setAttribute("aria-label",`${n}:${i}`),Ce&&(Ce.hidden=C!=="OVERRIDE",C==="OVERRIDE"&&(Ce.textContent=new Intl.DateTimeFormat(document.documentElement.lang||void 0,{day:"numeric",month:"long",year:"numeric"}).format(e))))};se();te&&window.setInterval(se,6e4);const Oe=(K==null?void 0:K.textContent)||"I heard fireworks",he=e=>{const t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`},We=()=>{U&&(U.hidden=!0,U.textContent="",L.removeAttribute("aria-invalid"),O.removeAttribute("aria-invalid"))},fe=()=>{ye.hidden=!0,Z.setAttribute("aria-expanded","false"),We(),Z.focus()};Z==null||Z.addEventListener("click",()=>{const[e,t]=he(C==="OVERRIDE"?J:new Date).split("T");L.value=e,O.value=t,b.checked=C==="OVERRIDE"&&Q,b.disabled=!1,We(),ye.hidden=!1,Z.setAttribute("aria-expanded","true"),L.focus()});me==null||me.addEventListener("click",()=>{b.checked=C==="OVERRIDE"&&Q,b.disabled=C==="NOW",fe()});Ie==null||Ie.addEventListener("click",()=>{const e=L.value,t=O.value.trim(),n=`${e}T${t}`,r=/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d$/.test(n)?new Date(n):null;if(!r||Number.isNaN(r.getTime())||he(r)!==n||r.getTime()>Date.now()+3e5){U.textContent=!r||Number.isNaN(r.getTime())||he(r)!==n?o.invalidReportTime||"Enter a valid date and time.":o.futureReportTime||"Report time cannot be in the future.",U.hidden=!1,L.setAttribute("aria-invalid","true"),O.setAttribute("aria-invalid","true"),(e?O:L).focus();return}J=r,Q=b.checked,C="OVERRIDE",ae.value=r.toISOString(),Ne.textContent=o.adjusted||"Adjusted",V.hidden=!1,se(),fe()});V==null||V.addEventListener("click",()=>{C="NOW",J=null,Q=!1,ae.value="",b.checked=!1,b.disabled=!0,Ne.textContent=o.now||"Now",V.hidden=!0,se(),ye.hidden||fe(),Z.focus()});const f=(e,t="")=>{if(p.dataset.state=e,T.disabled=e==="submitting",K&&(K.textContent=e==="submitting"?o.sendingReport||"Sending…":Oe),t){const n=document.querySelector("#manual-submission");n.className="manual-report__submission",n.textContent=t}},De=e=>{const t=e==null?void 0:e.dataset.nextNoteToken,n=document.querySelector("#manual-note-context");!t||!n||n.value===t||(n.value=t,window.htmx&&htmx.ajax("GET","/fireworks/notes/?token="+encodeURIComponent(t),{target:"#live-field-notes",swap:"outerHTML"}))},Xe=(e,t)=>{const n=new DOMParser().parseFromString(e,"text/html").querySelector("#manual-submission");return n?(document.querySelector("#manual-submission").replaceWith(n),t&&De(n),f(t?"submitted":"error"),t):(f("error",o.reportFailed||"Could not send the report. Please try again."),!1)},Le=()=>{const e=Number(m.value)>=3;Re&&(Re.textContent=e?o.burstEvent||"Burst Event":o.ordinaryReport||"Ordinary report"),Me&&(Me.hidden=!e)},$=e=>{const t=Number.parseInt(e,10);m.value=String(Math.min(1e3,Math.max(1,Number.isFinite(t)?t:1))),xe.disabled=m.value==="1",Ze.disabled=m.value==="1000",Le()};$(m.value);xe.addEventListener("click",()=>$(Number(m.value)-1));Ze.addEventListener("click",()=>$(Number(m.value)+1));m.addEventListener("change",()=>$(m.value));m.addEventListener("input",Le);const P=()=>{B&&window.removeEventListener("deviceorientation",B),window.clearTimeout(ie),B=null,ie=null,k.hidden=!0,x=null},Ue=e=>{const t=-e;if(x===null)x=t,Y.style.transition="none",Y.style.transform=`rotate(${x}deg)`,Y.offsetWidth,Y.style.transition="";else{const n=(t-x+540)%360-180;x+=n,Y.style.transform=`rotate(${x}deg)`}Ke.textContent=`${re(e)}° · ${be(e)}`,k.setAttribute("aria-label",`${o.compassDirection||"Compass direction"} ${re(e)}° ${be(e)}`),k.hidden=!1},Te=(e,t)=>{const n=g();if(n)if(n.classList.toggle("manual-direction-panel__status--accuracy",t!==null),t===null)n.textContent=o.accuracyUnavailable||"Accuracy unavailable";else{const r=document.createElement("span");r.textContent=o.accuracy||"Accuracy";const w=document.createElement("strong");w.textContent=`±${re(t)}°`,n.replaceChildren(r,w)}const i=ce();i&&(i.textContent=o.stopCapture||"Stop measuring direction")},Pe=()=>{g()&&(P(),s()&&(s().dataset.state="measuring"),g().textContent=o.pointPhone||"Point the top of your phone toward the sound — direction will update live.",B=e=>{const t="webkitCompassHeading"in e,n=Ae(e.webkitCompassHeading)?e.webkitCompassHeading:!t&&e.absolute&&Ae(e.alpha)?(360-e.alpha)%360:null;if(n===null||n<0||n>=360)return;const i=Ae(e.webkitCompassAccuracy)&&e.webkitCompassAccuracy>=0?e.webkitCompassAccuracy:null;ne.value=n,Ve.value=i===null?"":i,Te(n,i),Ue(n),window.clearTimeout(ie)},window.addEventListener("deviceorientation",B),ie=window.setTimeout(()=>{P();const e=ce(),t=g();e&&(e.textContent=o.captureDirection||"Start measuring direction"),t&&(t.textContent=o.compassUnavailable||"Compass unavailable on this device."),s()&&(s().dataset.state="unavailable")},15e3))},Je=async()=>{var e;if(B){P(),ce().textContent=o.captureAgain||"Measure again",s()&&(s().dataset.state=ne.value?"captured":"ready");return}if((e=g())==null||e.classList.remove("manual-direction-panel__status--accuracy"),!window.isSecureContext){g().textContent=o.secureCompass||"Compass capture requires a secure HTTPS connection.",s()&&(s().dataset.state="unavailable");return}if(typeof window.DeviceOrientationEvent>"u"){g().textContent=o.compassUnavailable||"Compass unavailable on this device.",s()&&(s().dataset.state="unavailable");return}if(typeof DeviceOrientationEvent.requestPermission=="function"){g().textContent=o.compassPermission||"Requesting compass permission…";try{if(await DeviceOrientationEvent.requestPermission(!0)!=="granted"){g()&&(g().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}catch{g()&&(g().textContent=o.compassDenied||"Compass permission denied."),s()&&(s().dataset.state="unavailable");return}}Pe()},pe=async()=>{if(ae&&(ae.value=C==="OVERRIDE"?J.toISOString():""),b&&(b.checked=C==="OVERRIDE"&&Q,b.disabled=C==="NOW"),$(m.value),P(),f("submitting",o.sendingReport||"Sending…"),z!=null&&z.active){try{const e=await z.clipForSubmission(),t=new FormData(p);e&&t.append("audio",e);const n=await fetch(p.action,{method:"POST",body:t,credentials:"same-origin"}),i=await n.text();Xe(i,n.ok)&&z.submissionSucceeded()}catch{f("error",o.reportFailed||"Could not send the report. Please try again.")}return}if(window.htmx)try{htmx.ajax("POST",p.action,{source:p,target:"#manual-submission",swap:"outerHTML"})}catch{f("error",o.reportFailed||"Could not send the report. Please try again.")}else p.submit()};p.addEventListener("click",e=>{e.target.closest("#manual-capture-direction")&&Je(),e.target.closest(".manual-direction-panel__close")&&(P(),oe&&oe.append(k))});document.body.addEventListener("htmx:beforeSwap",e=>{var t;((t=e.detail.target)==null?void 0:t.id)==="manual-direction-panel"&&oe&&oe.append(k)});document.body.addEventListener("htmx:afterSwap",e=>{var n,i;if(((n=e.detail.target)==null?void 0:n.id)!=="manual-direction-panel")return;ce()&&((i=s().querySelector(".manual-direction-panel__copy"))==null||i.after(k));const t=document.querySelector("#manual-direction-summary");if(t&&ne.value!==""){const r=Number(ne.value);t.textContent=`${be(r)} · ${re(r)}°`,s().dataset.state="captured"}});T.addEventListener("click",()=>{if(!T.disabled){if(f("submitting",o.requestingLocation||"Requesting your optional location…"),!navigator.geolocation){pe();return}navigator.geolocation.getCurrentPosition(e=>{Ye.value=e.coords.latitude,ze.value=e.coords.longitude,pe()},()=>pe(),{enableHighAccuracy:!1,maximumAge:3e5,timeout:1e4})}});p.addEventListener("submit",e=>{e.preventDefault(),T.disabled||T.click()});document.body.addEventListener("htmx:afterRequest",e=>{if(e.detail.elt!==p)return;const t=e.detail.xhr;t?t.status>=400?Xe(t.responseText,!1):f("submitted"):f("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:sendError",e=>{e.detail.elt===p&&f("error",o.reportFailed||"Could not send the report. Please try again.")});document.body.addEventListener("htmx:afterSwap",()=>De(document.querySelector("#manual-submission"))); diff --git a/templates/js_translations.html b/templates/js_translations.html index f7e146a..d8b9357 100644 --- a/templates/js_translations.html +++ b/templates/js_translations.html @@ -1,6 +1,10 @@ {% load i18n %}