{% extends "passerelle/manage.html" %}
{% load i18n passerelle %}

{% block breadcrumb %}
  {{ block.super }}
  <a href="{% url 'apiuser-list' %}">{% trans 'Access Management' %}</a>
{% endblock %}

{% block appbar %}
  <h2>{% trans 'Access Management' %}</h2>
  <span class="actions">
    {% if perms.base.add_apiuser %}
      <a href="{% url 'apiuser-add' %}">{% trans 'Add API User' %}</a>
    {% endif %}
  </span>
{% endblock %}

{% block content %}

  <table class="main">
    <thead>
      <tr>
        <th>{% trans 'Name' %}</th>
        <th>{% trans 'Key Type' %}</th>
        <th>{% trans 'IP Restriction' %}</th>
        {% if perms.base.delete_apiuser %}<th></th>{% endif %}
      </tr>
    </thead>
    <tbody>
      {% for object in object_list %}
        <tr>
          {% if perms.base.change_apiuser %}
            <td><a href="{% url 'apiuser-edit' pk=object.id %}">{{ object.fullname }}</a></td>
          {% else %}
            <td>{{ object.fullname }}</td>
          {% endif %}
          <td>{% if object.keytype %}{{ object.keytype }}{% else %} - {% endif %}</td>
          <td>{% if object.ipsource %}{{ object.ipsource }}{% else %} - {% endif %}</td>
          {% if perms.base.delete_apiuser %}
            <td><a rel="popup" class="icon-remove-sign" href="{% url 'apiuser-delete' pk=object.id %}"></a></td>
          {% endif %}
        </tr>
      {% endfor %}
    </tbody>
  </table>

  {% include "gadjo/pagination.html" %}

  {% if trusted_services %}
    <h3>{% trans 'Trusted services:' %}</h3>
    <table class="main">
      <thead>
        <tr>
          <th>{% trans 'Name' %}</th>
          <th>{% trans 'Key Type' %}</th>
          <th>{% trans 'Type' %}</th>
          <th>{% trans 'Identifier' %}</th>
          <th>{% trans 'URL' %}</th>
        </tr>
      </thead>
      <tbody>
        {% for trusted_service in trusted_services %}
          <tr>
            <td>{{ trusted_service.title }} ({{ trusted_service.verif_orig }})</td>
            <td>SIGN</td>
            <td>{{ trusted_service.service_type }}</td>
            <td>{{ trusted_service.slug }}</td>
            <td><a href="{{ trusted_service.url }}">{{ trusted_service.url }}</a></td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endif %}

{% endblock %}
