{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}

{% load bootstrap %}
{% load i18n %}
{% load extras %}

  <h3>{% trans "Connections" %}</h3>

  <div class="btn-toolbar">
    <a href="{% url 'networks:scan' %}" class="btn btn-default"
       role="button" title="{% trans 'Nearby Wi-Fi Networks' %}">
      {% icon 'wifi' %}
      {% trans "Nearby Wi-Fi Networks" %}
    </a>
    <a href="{% url 'networks:add' %}" class="btn btn-default"
       role="button" title="{% trans 'Add Connection' %}">
      {% icon 'plus' %}
      {% trans "Add Connection" %}
    </a>
  </div>

  <div class="table-responsive">
    <table class="table">
      <tbody>
        {% for connection in connections %}
          <tr>
            <td class="connection-status-cell">
              {% if connection.is_active %}
                <span class="badge text-bg-success connection-status-label">
                  {% trans "Active" %}
                </span>
              {% else %}
                <span class="badge text-bg-warning connection-status-label">
                  {% trans "Inactive" %}
                </span>
              {% endif %}
            </td>

            <td>
              <a class="connection-show-label"
                 href="{% url 'networks:show' connection.uuid %}"
                 title="{% blocktrans with name=connection.name %}Show connection {{ name }}{% endblocktrans %}">
                {{ connection.name }}
              </a>
            </td>

            <td>
              <span class="connection-type-label">
                {{ connection.type_name }}
              </span>
            </td>

            <td class="connection-actions">
              {% if connection.is_active %}
                {% if not connection.primary %}
                  <form class="form form-action" method="post"
                        action="{% url 'networks:deactivate' connection.uuid %}">
                    {% csrf_token %}
                    <button type="submit" class="btn btn-default btn-sm">
                      {% trans "Deactivate" %}</button>
                  </form>
                {% endif %}
              {% else %}
                <form class="form form-action" method="post"
                      action="{% url 'networks:activate' connection.uuid %}">
                  {% csrf_token %}
                  <button type="submit" class="btn btn-default btn-sm">
                    {% trans "Activate" %}</button>
                </form>
              {% endif %}

              {% if not connection.primary %}
                <a href="{% url 'networks:delete' connection.uuid %}"
                   class="btn btn-default btn-sm"
                   role="button"
                   title="{% blocktrans with name=connection.name %}Delete connection {{ name }}{% endblocktrans %}">
                  {% icon 'trash-o' %}
                </a>
              {% endif %}
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
  {% include "connections_diagram.html" %}
