<table class="table">
  <thead>
    <tr>
      <th>ID</th>
      <th>Operation</th>
      <th>State</th>
      {% if show_user %}<th>User</th>{% endif %}
      {% if show_server %}<th>Server</th>{% endif %}
      <th>Created</th>
      <th>Finished</th>
      {% if show_cancel %}<th>Action</th>{% endif %}
    </tr>
  </thead>
  <tbody>
    {% for job, user, server in rows %}
    <tr>
      <td><a href="/jobs/{{ job.id }}">#{{ job.id }}</a></td>
      <td>{{ job.operation }}</td>
      <td>{{ job.state }}</td>
      {% if show_user %}<td>{{ user.username if user else "system" }}</td>{% endif %}
      {% if show_server %}<td>{% if server %}<a href="/servers/{{ server.id }}">{{ server.name }}</a>{% else %}-{% endif %}</td>{% endif %}
      <td>{{ job.created_at | timeago }}</td>
      <td>{% if job.finished_at %}{{ job.finished_at | timeago }}{% else %}-{% endif %}</td>
      {% if show_cancel %}
      <td>
        {% if job.state in ["queued", "running"] %}
        <form method="post" action="/jobs/{{ job.id }}/cancel" class="inline-form">
          <input type="hidden" name="csrf_token" value="{{ session.get('csrf_token', '') }}">
          <input type="hidden" name="next" value="{{ cancel_next or request.path }}">
          <button class="danger" type="submit">cancel</button>
        </form>
        {% else %}
        <span class="muted">-</span>
        {% endif %}
      </td>
      {% endif %}
    </tr>
    {% else %}
    <tr><td colspan="8" class="muted">No jobs found.</td></tr>
    {% endfor %}
  </tbody>
</table>
