{% extends 'admin.html' %}
{% from 'include/datatables.html' import datatables %}
{% block title %}
  {% trans %}User management{% endtrans %}
{% endblock %}
{% set admin_nav_active="repos" %}
{% block content %}
  {% set filter_buttons = [
  (_('Healthy'), 2, 'ok'),
  (_('Failed'), 2, 'failed'),
  (_('Interrupted'), 2, 'interrupted'),
  (_('In progress'), 2, 'in_progress')] %}
  {% call() datatables(_('Repository list'), filter_buttons) %}
    <thead>
      <tr>
        <th scope="col">{% trans %}Display Name{% endtrans %}</th>
        <th scope="col">{% trans %}Owner{% endtrans %}</th>
        <th scope="col" data-type="num">{% trans %}Status{% endtrans %}</th>
        <th scope="col" data-sortable="false">{% trans %}Actions{% endtrans %}</th>
      </tr>
    </thead>
    <tbody>
      {% for repo in repos %}
        <tr class="{{ 'table-warning' if repo.status[0] != 'ok' else '' }}">
          <td data-search="{{ repo.display_name }}">
            {% if repo.status[0] != 'ok' %}
              <i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
            {% else %}
              <i class="fa fa-archive" aria-hidden="true"></i>
            {% endif %}
            <a href="{{ url_for('browse', repo) }}">{{ repo.display_name }}</a>
          </td>
          <td data-search="{{ repo.owner }}">{{ repo.owner }}</td>
          <td data-search="{{ repo.status[0] }}"
              data-order="{{ repo.last_backup_date.epoch }}">
            {% if repo.last_backup_date %}
              {% trans %}Updated {% endtrans %}
              <time datetime="{{ repo.last_backup_date }}">{{ repo.last_backup_date | lastupdated }}</time>
            {% endif %}
            {% if repo.status[0] != 'ok' %}{{ repo.status[1] }}{% endif %}
          </td>
          <td data-search="">
            <a class="btn btn-secondary"
               href="{{ url_for('settings', repo) }}"
               role="button">{% trans %}Settings{% endtrans %}</a>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  {% endcall %}
{% endblock %}
