{% import "macros.html.j2" as macros %}
<h2>Files</h2>
{% with files = ctx.db.list_files(uid=None if ctx.is_admin else ctx.uid) %}
{% if files %}
{% for file in files %}
<div class="file row u-flex">
  <div class="details eight columns u-flex u-flex-wrap u-overflow-elipsis">
    <div class="file-name u-flex u-flex-break">
      <label for="filename">File</label>
      <span name="filename">{{ file.filename }}</span>
    </div>
    <div class="file-sucesses u-flex">
      <label>Successes</label>
      <span>{{ file.print_successes }}</span>
    </div>
    <div class="file-failures u-flex">
      <label>Failures</label>
      <span>{{ file.print_failures }}</span>
    </div>
    {% if file.user_id != ctx.uid %}
    <div class="file-user u-flex">
      <label>Owner</label>
      {{ ctx.db.fetch_user(uid=file.user_id).name }}
    </div>
    {% endif %}
  </div>
  <div class="controls u-flex u-ml-auto u-mv-auto">
    {{ macros.start_job(file.id) }}
    {{ macros.download_file(file.id) }}
    {{ macros.delete_file(file.id) }}
  </div>
</div>
{% endfor %}
{% else %}
  You don't have any files. Upload something!
{% endif %}
{% endwith %}
