{% load humanize %}
{% load helpers %}
{% load log_levels %}
{% load i18n %}

<div class="htmx-container">
  <p>
    {% if job.started %}
      {% trans "Started" %}: <strong>{{ job.started|annotated_date }}</strong>
    {% elif job.scheduled %}
      {% trans "Scheduled for" %}: <strong>{{ job.scheduled|annotated_date }}</strong> ({{ job.scheduled|naturaltime }})
    {% else %}
      {% trans "Created" %}: <strong>{{ job.created|annotated_date }}</strong>
    {% endif %}
    {% if job.completed %}
      {% trans "Duration" %}: <strong>{{ job.duration }}</strong>
    {% endif %}
    <span id="pending-result-label">{% badge job.get_status_display job.get_status_color %}</span>
  </p>
  {% if job.completed %}
    {% if tests %}
      {# Summary of test methods #}
      <div class="card">
        <h5 class="card-header">{% trans "Test Summary" %}</h5>
        <table class="table table-hover">
          {% for test, data in tests.items %}
            <tr>
              <td class="font-monospace"><a href="#{{ test }}">{{ test }}</a></td>
              <td class="text-end report-stats">
                <span class="badge text-bg-success">{{ data.success }}</span>
                <span class="badge text-bg-info">{{ data.info }}</span>
                <span class="badge text-bg-warning">{{ data.warning }}</span>
                <span class="badge text-bg-danger">{{ data.failure }}</span>
              </td>
            </tr>
          {% endfor %}
        </table>
      </div>
    {% endif %}

    {% if table %}
    <div class="card">
      <div class="table-responsive" id="object_list">
        <h5 class="card-header">{% trans "Log" %}</h5>
        {% include 'htmx/table.html' %}
      </div>
    </div>
    {% endif %}

    {# Script output. Legacy reports will not have this. #}
    {% if 'output' in job.data %}
      <div class="card mb-3">
      <h5 class="card-header">{% trans "Output" %}</h5>
        {% if job.data.output %}
          <pre class="card-body font-monospace">{{ job.data.output }}</pre>
        {% else %}
          <div class="card-body text-muted">{% trans "None" %}</div>
        {% endif %}
      </div>
    {% endif %}

  {% elif job.started %}
    {% include 'extras/inc/result_pending.html' %}
  {% endif %}
</div>
