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

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

  <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' %}">
      <span class="fa fa-wifi" aria-hidden="true"></span>
      {% trans "Nearby Wi-Fi Networks" %}
    </a>
    <a href="{% url 'networks:add' %}" class="btn btn-default"
       role="button" title="{% trans 'Add Connection' %}">
      <span class="fa fa-plus" aria-hidden="true"></span>
      {% trans "Add Connection" %}
    </a>
  </div>

  <div class="list-group">
    {% for connection in connections %}
      <div class="list-group-item clearfix">
        <a href="{% url 'networks:delete' connection.uuid %}"
           class="btn btn-default btn-sm pull-right"
           role="button"
           title="{% blocktrans with name=connection.name %}Delete connection {{ name }}{% endblocktrans %}">
          <span class="fa fa-trash-o"
                aria-hidden="true"></span>
        </a>

        {% if connection.is_active %}
          <form class="form form-action pull-right" method="post"
                action="{% url 'networks:deactivate' connection.uuid %}">
            {% csrf_token %}

            <button type="submit" class="btn btn-default btn-sm">
              {% trans "Deactivate" %}</button>
          </form>
        {% else %}
          <form class="form form-action pull-right" 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 connection.is_active %}
          <span class="label label-success connection-status-label">
            {% trans "Active" %}</span>
        {% else %}
          <span class="label label-warning connection-status-label">
            {% trans "Inactive" %}</span>
        {% endif %}

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

        <span class="connection-type-label">{{ connection.type_name }}</span>
      </div>
    {% endfor %}
  </div>
  {% include "connections_diagram.html" %}
