{% extends "allianceauth/base.html" %}
{% load staticfiles %}
{% load i18n %}

{% block page_title %}{% trans "Groups Membership" %}{% endblock page_title %}
{% block extra_css %}{% endblock extra_css %}

{% block content %}
    <div class="col-lg-12">
        <br>
        {% include 'groupmanagement/menu.html' %}
        <div class="panel panel-default">
            <div class="panel-heading">
                {% trans "Groups" %}
            </div>
            <div class="panel-body">
                {% if groups %}                    
                    <div class="table-responsive">
                        <table class="table table-aa">
                            <thead>
                                <tr>
                                    <th class="text-center">{% trans "Name" %}</th>
                                    <th class="text-center">{% trans "Description" %}</th>
                                    <th class="text-center">{% trans "Status" %}</th>
                                    <th class="text-center">{% trans "Member Count" %}</th>
                                    <th class="text-center"></th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for group in groups %}
                                    <tr>
                                        <td class="text-center">
                                            <a href="{% url 'groupmanagement:membership_list' group.id %}">{{ group.name }}</a>
                                        </td>
                                        <td class="text-center">{{ group.authgroup.description }}</td>
                                        <td class="text-center">
                                            {% if group.authgroup.hidden %}
                                                <span class="label label-info">{% trans "Hidden" %}</span>
                                            {% elif group.authgroup.open %}
                                                <span class="label label-success">{% trans "Open" %}</span>
                                            {% else %}
                                                <span class="label label-default">{% trans "Requestable" %}</span>
                                            {% endif %}
                                        </td>
                                        <td class="text-center">
                                            {{ group.num_members }}
                                        </td>
                                        <td class="text-center">
                                            <a href="{% url 'groupmanagement:membership_list' group.id %}" class="btn btn-primary"
                                                title="{% trans "View Members" %}">
                                                    <i class="glyphicon glyphicon-eye-open"></i>
                                            </a>
                                            <a href="{% url "groupmanagement:audit_log" group.id %}" class="btn btn-info" title="{% trans "Audit Members" %}">
                                                <i class="glyphicon glyphicon-list-alt"></i>
                                            </a>
                                            <a id="clipboard-copy" data-clipboard-text="{{ request.scheme }}://{{request.get_host}}{% url 'groupmanagement:request_add' group.id %}" class="btn btn-warning" title="{% trans "Copy Direct Join Link" %}">
                                                <i class="glyphicon glyphicon-copy"></i>
                                            </a>

                                        </td>
                                    </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                {% else %}
                    <div class="alert alert-warning text-center">
                        {% trans "No groups to list." %}
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
{% endblock content %}
{% block extra_javascript %}    
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js"></script>
<script>
    new ClipboardJS('#clipboard-copy');
</script>
{% endblock %}