<div class="printers">
  <h2>Printers</h2>
  {% with printers = ctx.db.list_printers() %}
    {% if printers %}
      {% for printer in printers %}
        {% with id, name, url, _api_key, last_poll, status = printer %}
          <div class="printer row u-flex">
            <div class="details six columns">
              <span class="printer-name">{{name}}</span>
              <span class="printer-url"><code>{{url}}</code></span>
              <span class="printer-status">{{status}}</span>
              <span class="printer-date">{{last_poll}}</span>
            </div>
            {# FIXME: How should these action buttons work? #}
            <div class="controls u-flex u-ml-auto">
              <a class="button" href="/printers/test?id={{id}}">Test</a>
              <a class="button" href="/printers/edit?id={{id}}">Edit</a>
              <a class="button" href="/printers/delete?id={{id}}">Remove</a>
            </div>
          </div>
        {% endwith %}
      {% endfor %}
      {% if ctx.is_admin %}
        <a class="button" href="/printers/add">Add a printer</a>
      {% endif %}
    {% else %}
      No printers available. {% if ctx.is_admin %}<a href="/printers/add">Configure one!</a>{% else %}Ask the admin to configure one!{% endif %}
    {% endif %}
  {% endwith %}
</div>
