52 lines
4.4 KiB
HTML
52 lines
4.4 KiB
HTML
{% 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 "Sensor ID" %}</dt><dd><code>{{ sensor.pk }}</code></dd></div>
|
||
<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>
|