{% import "macros.html.j2" as macros %}
<h2>Job history</h2>
{% with jobs = ctx.db.list_job_history(uid=ctx.uid) %}
{% if jobs %}
{% for job in jobs %}
<div class="job row u-flex">
  <div class="details six columns u-flex">
    <div class="job-status u-flex">
      <label for="state">Job</label>
      <div class="dot {{ macros.job_state(job) }}" style="--dot-size: 1em;"> </div>
      <span name="state">{{ macros.job_state(job) }}</span>
    </div>
    {% if job.printer_id %}
    <div class="job-printer u-flex">
      <label for="printer">Printer</label>
      <span name="printer">{{ ctx.db.fetch_printer(job.printer_id).name }}</span>
    </div>
    {% endif %}
    <div class="job-filename u-flex">
      <label for="filename">File</label>
      <span name="filename">{{ctx.db.fetch_file(ctx.uid, job.file_id).filename}}</span>
    </div>
    </div>
  <div class="controls u-flex u-ml-auto">
    {{ macros.duplicate_job(job.id) }}
    {{ macros.delete_job(job.id) }}
  </div>
</div>
{% endfor %}
{% else %}
  <p>No job history to display.</p>
{% endif %}
{% endwith %}
