2.5 KiB · text History 63417ef
{% extends "root.html" %}

{% block content %}
<div class="space-y-6 text-left max-w-3xl">
  <h2 class="text-2xl font-bold text-accent">Devices</h2>
  <p class="opacity-70 text-sm">
    The Android app signs in with a token paired from here, one per device, so
    losing a phone costs one revoke. A device reaches what you can see here
    and nothing else, stays paired while it's in use, and is signed out after
    {{ sliding_days }} days without. Tokens are also what scripts send as
    <code class="text-xs">Authorization: Bearer &lt;token&gt;</code>.
  </p>

  <form method="post" action="/devices" class="card bg-base-200 p-4 flex flex-col sm:flex-row gap-2 sm:items-end">
    <label class="form-control grow">
      <span class="label-text text-xs">Name (optional)</span>
      <input class="input input-bordered input-sm" name="label" maxlength="80" placeholder="e.g. Pixel 8"/>
    </label>
    <button class="btn btn-primary btn-sm" type="submit">
      <i class="fas fa-qrcode mr-1"></i> Pair a device
    </button>
  </form>

  {% if devices | length == 0 %}
    <p class="opacity-70 text-sm">No devices paired.</p>
  {% else %}
  <ul class="space-y-2">
    {% for d in devices %}
    <li class="card bg-base-200 p-3 {% if d.expired %}opacity-60{% endif %}">
      <div class="flex flex-wrap items-center gap-2">
        <form method="post" action="/devices/{{ d.id }}/rename" class="flex items-center gap-1 grow m-0">
          <input class="input input-ghost input-sm font-semibold grow min-w-0" name="label" maxlength="80"
                 value="{{ d.label or '' }}" placeholder="Unnamed device" aria-label="Device name"/>
          <button class="btn btn-ghost btn-xs" type="submit" title="Rename"><i class="fas fa-check"></i></button>
        </form>
        <form method="post" action="/devices/{{ d.id }}/delete" class="m-0"
              onsubmit="return confirm('Revoke this device? It stops working immediately.')">
          <button class="btn btn-ghost btn-xs text-error" type="submit" title="Revoke">
            <i class="fas fa-trash"></i> Revoke
          </button>
        </form>
      </div>
      <div class="text-xs opacity-70 flex flex-wrap gap-x-4 px-3">
        <span>Paired {{ d.created }}</span>
        <span>Last used {{ d.last_used or "never" }}</span>
        {% if d.expired %}<span class="badge badge-warning badge-xs">expired</span>
        {% elif d.expires %}<span>Expires {{ d.expires }} unless used</span>
        {% else %}<span>Never expires</span>{% endif %}
      </div>
    </li>
    {% endfor %}
  </ul>
  {% endif %}
</div>
{% endblock %}