{% extends 'layouts/base.html' %}
{% load i18n %}
{% load static %}
{% load ooi_extra %}

{% block content %}
  {% include 'header.html' %}
  <main id="main-content">
    <section>
      <div>
        {% include 'tasks/partials/tab_navigation.html' with view="normalizers_tasks" %}
        <h1>{% translate 'Normalizers' %}</h1>
        {% if not object_list %}
          <p class="emphasized">
            {% translate 'There are no tasks for normalizers' %}
          </p>
        {% else %}
          <p class="emphasized">
            {% translate 'List of tasks for normalizers' %}
          </p>
          <div class="horizontal-scroll">
            <table rf-selector="table-normalizers">
              <caption>{% translate 'List of tasks for ' %}{{ request.active_organization }}</caption>
              <thead>
                <tr>
                  <th scope="col">{% translate 'OOI' %}</th>
                  <th scope="col">{% translate 'Boefje' %}</th>
                  <th scope="col">{% translate 'Normalizer' %}</th>
                  <th scope="col">{% translate 'Status' %}</th>
                  <th scope="col">{% translate 'Created date' %}</th>
                  <th scope="col">{% translate 'Download task detail' %}</th>
                </tr>
              </thead>
              <tbody>
                {% for task in object_list %}
                  <tr>
                    <td>
                      <a href="{% ooi_url 'ooi_detail' task.task.item.boefje_meta.input_ooi %}">{{ task.task.item.boefje_meta.input_ooi }}</a>
                    </td>
                    <td>{{ task.task.item.boefje_meta.boefje.id }}</td>
                    <td>{{ task.task.item.normalizer.name }}</td>
                    {% if task.status.value == 'completed' %}
                      <td class="confirmation">{{ task.status.value|capfirst }}</td>
                    {% elif task.status.value == 'failed' %}
                      <td class="warning">{{ task.status.value|capfirst }}</td>
                    {% else %}
                      <td>{{ task.status.value|capfirst }}</td>
                    {% endif %}
                    <td>{{ task.created_at }}</td>
                    <td>
                      <a href="{% url 'download_task_meta' task.id %}">{% translate 'Download' %}</a>
                    </td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          </div>
        {% endif %}
      </div>
    </section>
  </main>
{% endblock %}
