{% load helpers %}
{% load i18n %}
<div class="card">
  <h5 class="card-header d-flex justify-content-between align-items-center">
    {% trans "Progress" %}
    {% url 'plugins:ipfabric_netbox:ipfabricingestion_progress' pk=job.object_id as progress_url %}
    {% include 'ipfabric_netbox/partials/stage_switcher_buttons.html' with base_url=progress_url hx_target="#ingestion_progress" hx_swap="outerHTML" active_stage=active_stage merge_job=merge_job %}
  </h5>
  <div class="card-body">
    {% if not job %}
      {% trans "Cannot show progress, no sync Job exists anymore." %}
    {% else %}
      {% if statistics %}
      <table class="table table-hover attr-table">
        {% for model, util in statistics.items %}
        <tr>
          <th scope="row">{{ model }}</th>
          <td>{% utilization_graph util %}</td>
        </tr>
        {% endfor %}
      </table>
      {% else %}
        <p class="text-muted mb-0">
          {% if active_stage == 'merge' %}
            {% trans "Merge progress pending..." %}
          {% else %}
            {% trans "Ingestion progress pending..." %}<br>
            <small class="text-muted">{% trans "Last updated" %} {% now "H:i:s" %}</small>
          {% endif %}
        </p>
      {% endif %}
    {% endif %}
  </div>
</div>
