{% extends 'base.html' %}

{% block content %}
<div class="text-center mb-2">
    <h1 class="display-1">Groups</h1>
</div>
<div class="text-center border-bottom pb-4 mb-1">
    <a class="btn btn-primary"
        href="{{ url_for('usermanager.group_create') }}"
        role="button"
    ><i class="bi-people"></i> Create a new group</a>
</div>
{% if groups %}
<div class="table-responsive">
    <table class="table table-hover">
        <thead>
            <tr>
                <th class="text-center" scope="col">Group Name</th>
                <th class="text-center" scope="col">Number of Members</th>
                <th class="text-muted text-center" scope="col">DN</th>
            </tr>
        </thead>
        <tbody>
            {% for group in groups | sort %}
            <tr class="clickable" onclick="window.location='{{ url_for('usermanager.group_update', groupname=group.groupname) }}'" style="cursor: pointer">
                <th class="text-center" scope="row">
                    <a class="text-decoration-none fw-bold fs-4" href="{{ url_for('usermanager.group_update', groupname=group.groupname) }}">{{ group.groupname }}</a>
                </th>
                <td class="align-middle fs-5 text-center">
                    {{ group.members|length }}
                </td>
                <td class="align-middle fs-5 text-muted text-center">
                    {{ group.get_dn() }}
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% else %}
<div class="text-center">
    <p class="text-muted">There are currently no groups.</p>
</div>
{% endif %}
{% endblock content %}
