latest changes before manual submissions redesign

This commit is contained in:
Joren de Graaf
2026-10-06 19:31:30 +02:00
parent d427d73b8d
commit d86c7c9250
130 changed files with 1025 additions and 112 deletions
+1
View File
@@ -24,6 +24,7 @@
{% if next %}<input type="hidden" name="next" value="{{ next }}">{% endif %}
<button type="submit">{% trans "Sign in" %}</button>
</form>
<p class="intro">{% trans "New here?" %} <a href="{% url 'register' %}{% if next %}?next={{ next|urlencode }}{% endif %}">{% trans "Create an account" %}</a></p>
<p class="intro">{% trans "You will return to the page you requested." %}</p>
</main>
</body>
@@ -0,0 +1,50 @@
{% load i18n %}
<div class="sensor-detail">
<div class="sensor-detail__header">
<div><p class="eyebrow">{% trans "Sensor settings" %}</p><h2 id="sensors-title">{{ sensor.name }}</h2></div>
<a class="sensor-close" href="{% url 'user_settings' %}" hx-get="{% url 'sensor_list' %}" hx-target="#sensor-card-content" hx-swap="innerHTML" aria-label="{% trans 'Close sensor settings' %}"><span aria-hidden="true">×</span> {% trans "Close" %}</a>
</div>
{% if messages %}<ul class="messages sensor-messages" role="status">{% for message in messages %}<li class="alert {% if message.tags == 'error' %}alert--error{% else %}alert--success{% endif %}">{{ message }}</li>{% endfor %}</ul>{% endif %}
{% if token %}<section class="token-once" aria-label="{% trans 'New API token' %}">
<strong>{% trans "Copy this token now. For security reasons it will not be shown again." %}</strong>
<code id="sensor-token">{{ token }}</code>
<button class="button button--secondary" type="button" data-copy-sensor-token>{% trans "Copy token" %}</button>
</section>{% endif %}
<section class="sensor-detail__overview" aria-label="{% trans 'Sensor overview' %}">
{% with status=heartbeat %}<span class="sensor-status sensor-status--{{ status.0 }}">● {{ status.1 }}</span>{% endwith %}
<dl class="sensor-detail__facts">
<div><dt>{% trans "Last heartbeat" %}</dt><dd>{{ sensor.last_heartbeat|date:"j M Y, H:i"|default:"—" }}</dd></div>
<div><dt>{% trans "Last submission" %}</dt><dd>{{ sensor.last_submission|date:"j M Y, H:i"|default:"—" }}</dd></div>
<div><dt>{% trans "Token prefix" %}</dt><dd><code>{{ sensor.token_prefix|default:"—" }}</code></dd></div>
<div><dt>{% trans "Created" %}</dt><dd>{{ sensor.created_at|date:"j M Y, H:i" }}</dd></div>
</dl>
</section>
<div class="sensor-detail__actions">
<section class="sensor-detail__section"><h3>{% trans "Rename" %}</h3>
<form class="settings-form" method="post" action="{% url 'rename_sensor' sensor.pk %}" hx-post="{% url 'rename_sensor' sensor.pk %}" hx-target="#sensor-card-content" hx-swap="innerHTML">{% csrf_token %}
<div class="field"><label for="id_name">{% trans "Device name" %}</label>{{ form.name }}{{ form.name.errors }}</div>
<button class="button" type="submit">{% trans "Save name" %}</button>
</form>
</section>
<section class="sensor-detail__section"><h3>{% trans "Device access" %}</h3>
<p class="help">{% if sensor.is_active %}{% trans "Enabled" %}{% else %}{% trans "Disabled" %}{% endif %}</p>
<form method="post" action="{% url 'toggle_sensor' sensor.pk %}" hx-post="{% url 'toggle_sensor' sensor.pk %}" hx-target="#sensor-card-content" hx-swap="innerHTML">{% csrf_token %}
<button class="button button--secondary" type="submit">{% if sensor.is_active %}{% trans "Disable sensor" %}{% else %}{% trans "Enable sensor" %}{% endif %}</button>
</form>
</section>
<section class="sensor-detail__section"><h3>{% trans "Reissue API token" %}</h3>
<p class="help">{% trans "The old token will immediately stop authenticating." %}</p>
<form method="post" action="{% url 'rotate_sensor' sensor.pk %}" hx-post="{% url 'rotate_sensor' sensor.pk %}" hx-target="#sensor-card-content" hx-swap="innerHTML">{% csrf_token %}
<label class="sensor-confirm"><input type="checkbox" name="confirm" value="rotate" required>{% trans "I understand the old token will stop working" %}</label>
<button class="button button--secondary" type="submit">{% trans "Reissue token" %}</button>
</form>
</section>
<section class="sensor-detail__section"><h3>{% trans "Remove sensor" %}</h3>
<p class="help">{% trans "This disables the device and revokes its token. Historical events remain linked to it." %}</p>
<form method="post" action="{% url 'remove_sensor' sensor.pk %}" hx-post="{% url 'remove_sensor' sensor.pk %}" hx-target="#sensor-card-content" hx-swap="innerHTML">{% csrf_token %}
<label class="sensor-confirm"><input type="checkbox" name="confirm" value="remove" required>{% trans "I understand this device will be removed" %}</label>
<button class="button button--danger" type="submit">{% trans "Remove sensor" %}</button>
</form>
</section>
</div>
</div>
@@ -0,0 +1,27 @@
{% load i18n %}
<div class="sensor-list__intro"><div><p class="eyebrow">{% trans "Connected devices" %}</p><h2 id="sensors-title">{% trans "My sensors" %}</h2><p class="help">{% trans "Manage the devices that authenticate with BoomCast." %}</p></div></div>
{% if messages %}<ul class="messages sensor-messages" role="status">{% for message in messages %}<li class="alert {% if message.tags == 'error' %}alert--error{% else %}alert--success{% endif %}">{{ message }}</li>{% endfor %}</ul>{% endif %}
<div class="sensor-list">
{% for sensor in sensors %}
<article class="sensor-card">
<div class="sensor-card__heading"><h3>{{ sensor.name }}</h3>{% with status=sensor.heartbeat_status %}<span class="sensor-status sensor-status--{{ status.0 }}">● {{ status.1 }}</span>{% endwith %}</div>
<span class="sensor-access {% if not sensor.is_active %}sensor-access--off{% endif %}">{% if sensor.is_active %}{% trans "Enabled" %}{% else %}{% trans "Disabled" %}{% endif %}</span>
<dl class="sensor-card__facts">
<div><dt>{% trans "Last heartbeat" %}</dt><dd>{{ sensor.last_heartbeat|date:"j M Y, H:i"|default:"—" }}</dd></div>
<div><dt>{% trans "Created" %}</dt><dd>{{ sensor.created_at|date:"j M Y" }}</dd></div>
<div><dt>{% trans "Token prefix" %}</dt><dd><code>{{ sensor.token_prefix|default:"—" }}</code></dd></div>
</dl>
<a class="button button--secondary" href="{% url 'manage_sensor' sensor.pk %}" hx-get="{% url 'manage_sensor' sensor.pk %}" hx-target="#sensor-card-content" hx-swap="innerHTML">{% trans "Manage" %}</a>
</article>
{% empty %}
<p class="sensor-empty">{% trans "No sensors yet. Add a device to receive an API token for hardware submissions." %}</p>
{% endfor %}
</div>
<form class="settings-form sensor-form" method="post" action="{% url 'create_sensor' %}" hx-post="{% url 'create_sensor' %}" hx-target="#sensor-card-content" hx-swap="innerHTML">
{% csrf_token %}
<div><h3>{% trans "Add a sensor" %}</h3><p class="help">{% trans "Give your device a name so you can recognise it later." %}</p></div>
<div class="sensor-form__controls">
<div class="field"><label for="new-sensor-name">{% trans "Device name" %}</label><input id="new-sensor-name" name="name" type="text" maxlength="100" required></div>
<button class="button" type="submit">{% trans "Add sensor" %}</button>
</div>
</form>
+31
View File
@@ -0,0 +1,31 @@
{% load i18n vite %}
<!doctype html>
<html lang="{{ request.LANGUAGE_CODE|default:'en' }}" data-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% trans "Create an account · Sound Signal" %}</title>
{% vite_asset "frontend/src/entries/login.js" %}
{% include "js_translations.html" %}
</head>
<body>
<main class="card">
<p>✦ Sound Signal</p>
<h1>{% trans "Create an account" %}</h1>
<p class="intro">{% trans "Only a username and password are needed." %}</p>
<form method="post">
{% csrf_token %}
{% if next %}<input type="hidden" name="next" value="{{ next }}">{% endif %}
{{ form.non_field_errors }}
<label for="{{ form.username.id_for_label }}">{% trans "Username" %}</label>
{{ form.username }} {{ form.username.errors }}
<label for="{{ form.password1.id_for_label }}">{% trans "Password" %}</label>
{{ form.password1 }} {{ form.password1.errors }}
<label for="{{ form.password2.id_for_label }}">{% trans "Confirm password" %}</label>
{{ form.password2 }} {{ form.password2.errors }}
<button type="submit">{% trans "Create account" %}</button>
</form>
<p class="intro">{% trans "Already have an account?" %} <a href="{% url 'login' %}{% if next %}?next={{ next|urlencode }}{% endif %}">{% trans "Sign in" %}</a></p>
</main>
</body>
</html>
+12 -43
View File
@@ -5,48 +5,17 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ sensor.name }} · {% trans "Settings" %}</title>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
{% vite_asset "frontend/src/entries/settings.js" %}
{% include "js_translations.html" %}
</head>
<body><main class="card">
<a href="{% url 'user_settings' %}">← {% trans "Settings" %}</a>
<h1>{{ sensor.name }}</h1>
{% if messages %}<ul class="messages">{% for message in messages %}<li class="alert alert--error">{{ message }}</li>{% endfor %}</ul>{% endif %}
{% if token %}<section class="token-once" aria-label="{% trans 'New API token' %}">
<strong>{% trans "Copy this token now. For security reasons it will not be shown again." %}</strong>
<code id="sensor-token">{{ token }}</code>
<button class="button button--secondary" type="button" onclick="navigator.clipboard.writeText(document.getElementById('sensor-token').textContent)">{% trans "Copy token" %}</button>
</section>{% endif %}
<section class="section">
{% with status=heartbeat %}<p class="sensor-status sensor-status--{{ status.0 }}">● {{ status.1 }}</p>{% endwith %}
<p>{% trans "Last heartbeat" %}: {{ sensor.last_heartbeat|date:"j M Y, H:i"|default:"—" }}</p>
<p>{% trans "Last submission" %}: {{ sensor.last_submission|date:"j M Y, H:i"|default:"—" }}</p>
<p>{% trans "Token prefix" %}: {{ sensor.token_prefix|default:"—" }}</p>
<p>{% trans "Created" %}: {{ sensor.created_at|date:"j M Y, H:i" }}</p>
</section>
<section class="section"><h2>{% trans "Rename" %}</h2>
<form method="post" action="{% url 'rename_sensor' sensor.pk %}">{% csrf_token %}
<label for="id_name">{% trans "Device name" %}</label>{{ form.name }}{{ form.name.errors }}
<button class="button" type="submit">{% trans "Save name" %}</button>
</form>
</section>
<section class="section"><h2>{% trans "Device access" %}</h2>
<p>{% if sensor.is_active %}{% trans "Enabled" %}{% else %}{% trans "Disabled" %}{% endif %}</p>
<form method="post" action="{% url 'toggle_sensor' sensor.pk %}">{% csrf_token %}
<button class="button button--secondary" type="submit">{% if sensor.is_active %}{% trans "Disable sensor" %}{% else %}{% trans "Enable sensor" %}{% endif %}</button>
</form>
</section>
<section class="section"><h2>{% trans "Reissue API token" %}</h2>
<p class="help">{% trans "The old token will immediately stop authenticating." %}</p>
<form method="post" action="{% url 'rotate_sensor' sensor.pk %}">{% csrf_token %}
<div class="check"><input type="checkbox" id="confirm-rotate" name="confirm" value="rotate" required><label for="confirm-rotate">{% trans "I understand the old token will stop working" %}</label></div>
<button class="button" type="submit">{% trans "Reissue token" %}</button>
</form>
</section>
<section class="section"><h2>{% trans "Remove sensor" %}</h2>
<p class="help">{% trans "This disables the device and revokes its token. Historical events remain linked to it." %}</p>
<form method="post" action="{% url 'remove_sensor' sensor.pk %}">{% csrf_token %}
<div class="check"><input type="checkbox" id="confirm-remove" name="confirm" value="remove" required><label for="confirm-remove">{% trans "I understand this device will be removed" %}</label></div>
<button class="button button--danger" type="submit">{% trans "Remove sensor" %}</button>
</form>
</section>
</main></body></html>
<body>
<main class="settings-shell">
{% include "fireworks_detect/includes/navigation.html" %}
<div class="settings-content">
<div class="settings-heading"><p class="eyebrow">{% trans "Your preferences" %}</p><h1>{% trans "Settings" %}</h1></div>
<section class="card" id="sensor-card" aria-labelledby="sensors-title"><div id="sensor-card-content">{% include "members/partials/sensor_detail.html" %}</div></section>
</div>
</main>
</body>
</html>
+35 -44
View File
@@ -9,55 +9,46 @@
{% vite_asset "frontend/src/entries/settings.js" %}
{% include "js_translations.html" %}</head>
<body>
<main class="card">
<h1>{% trans "Settings" %}</h1>
<p class="intro">{% trans "Manage your personal preferences." %}</p>
{% if messages %}<ul class="messages">{% for message in messages %}<li class="alert alert--success">{{ message }}</li>{% endfor %}</ul>{% endif %}
<form method="post" action="{% url 'user_settings' %}">
{% csrf_token %}
<section class="section" aria-labelledby="language-title">
<main class="settings-shell">
{% include "fireworks_detect/includes/navigation.html" %}
<div class="settings-content">
<div class="settings-heading">
<p class="eyebrow">{% trans "Your preferences" %}</p>
<h1>{% trans "Settings" %}</h1>
<p class="intro">{% trans "Manage your personal preferences." %}</p>
</div>
{% if messages %}<ul class="messages" role="status">{% for message in messages %}<li class="alert alert--success">{{ message }}</li>{% endfor %}</ul>{% endif %}
<form class="card settings-form" method="post" action="{% url 'user_settings' %}">
{% csrf_token %}
<h2 id="language-title">{% trans "Language" %}</h2>
<label for="{{ language_form.preferred_language.id_for_label }}">{% trans "Preferred language" %}</label>
{{ language_form.preferred_language }}
{{ language_form.preferred_language.errors }}
</section>
<button class="button" type="submit" name="save_language" value="1">{% trans "Save language" %}</button>
</form>
<form method="post" action="{% url 'user_settings' %}">
{% csrf_token %}
<section class="section" aria-labelledby="ntfy-title">
<div class="field">
<label for="{{ language_form.preferred_language.id_for_label }}">{% trans "Preferred language" %}</label>
{{ language_form.preferred_language }}
{{ language_form.preferred_language.errors }}
</div>
<button class="button" type="submit" name="save_language" value="1">{% trans "Save language" %}</button>
</form>
<form class="card settings-form" method="post" action="{% url 'user_settings' %}">
{% csrf_token %}
<h2 id="ntfy-title">{% trans "Notifications / ntfy" %}</h2>
<p class="help">{% trans "Use a topic URL from your ntfy server. Test the current URL before saving it." %}</p>
<label for="ntfy-url">{% trans "Topic URL" %}</label>
{{ form.ntfy_url }}
{{ form.ntfy_url.errors }}
<div class="check">{{ form.ntfy_enabled }}<label for="{{ form.ntfy_enabled.id_for_label }}">{% trans "Enable ntfy notifications" %}</label></div>
<p class="help">{% trans "Use a topic URL from your ntfy server. Test the URL before enabling notifications." %}</p>
<div class="field">
<label for="ntfy-url">{% trans "Topic URL" %}</label>
{{ form.ntfy_url }}
{{ form.ntfy_url.errors }}
</div>
<label class="switch-row" for="{{ form.ntfy_enabled.id_for_label }}">
<span class="switch-copy"><strong>{% trans "Enable ntfy notifications" %}</strong><small>{% trans "Save below to apply this change." %}</small></span>
<span class="switch-control">{{ form.ntfy_enabled }}<span class="switch-track" aria-hidden="true"></span></span>
</label>
<button class="button button--secondary" type="button" hx-post="{% url 'ntfy_test_notification' %}" hx-include="#ntfy-url, [name='csrfmiddlewaretoken']" hx-target="#ntfy-test-result" hx-swap="innerHTML">{% trans "Test notification" %}</button>
<div id="ntfy-test-result" aria-live="polite"></div>
</section>
<button class="button" type="submit">{% trans "Save settings" %}</button>
</form>
<section class="section" aria-labelledby="sensors-title">
<h2 id="sensors-title">{% trans "My sensors" %}</h2>
<p class="help">{% trans "Manage the devices that authenticate with BoomCast." %}</p>
{% for sensor in sensors %}
<div class="sensor-card">
<strong>{{ sensor.name }}</strong>
{% with status=sensor.heartbeat_status %}<span class="sensor-status sensor-status--{{ status.0 }}">● {{ status.1 }}</span>{% endwith %}
<p>{% if sensor.is_active %}{% trans "Enabled" %}{% else %}{% trans "Disabled" %}{% endif %} · {% trans "Token prefix" %}: {{ sensor.token_prefix|default:"—" }}</p>
<p>{% trans "Last heartbeat" %}: {{ sensor.last_heartbeat|date:"j M Y, H:i"|default:"—" }} · {% trans "Created" %}: {{ sensor.created_at|date:"j M Y" }}</p>
<a class="button button--secondary" href="{% url 'manage_sensor' sensor.pk %}">{% trans "Manage" %}</a>
</div>
{% empty %}
<p class="help">{% trans "No sensors yet. Add a device to receive an API token for hardware submissions." %}</p>
{% endfor %}
<form method="post" action="{% url 'create_sensor' %}">
{% csrf_token %}
<label for="new-sensor-name">{% trans "Device name" %}</label>
<input id="new-sensor-name" name="name" type="text" maxlength="100" required>
<button class="button" type="submit">{% trans "Add sensor" %}</button>
<button class="button" type="submit">{% trans "Save settings" %}</button>
</form>
</section>
<section class="card" id="sensor-card" aria-labelledby="sensors-title">
<div id="sensor-card-content">{% include "members/partials/sensor_list.html" %}</div>
</section>
</div>
</main>
</body>
</html>