{% macro get_sidebar(realms, realm=None) -%}
    {#    <div class="col-2 col-xl-3 sidebar">#}
    <div class="bg-light border-right sidebar-wrapper">
        <h2 class="sidebar-heading">Realms</h2>
        <div class="list-group list-group-flush">
            <a href="#" class="list-group-item list-group-item-action bg-light">Dashboard</a>
            {% for realm_item in realms %}
                <a href="{{ url('realm-detail', args=[realm_item.id]) }}">{{ realm_item.name }}</a>
                {#                    {% if request.user.is_superuser %}#}
                {#                        <a href="{{ url('realm-delete', args=[realm_item.id]) }}">Delete</a>#}
                {#                    {% endif %}#}
            {% endfor %}
            {% if realm %}
                <h2>{{ realm.name }}</h2>
                {#                <a href="{{ }}">Users</a>#}
                {#                <a href="{{ }}">Groups</a>#}
            {% endif %}
        </div>
    </div>
    {#    </div>#}
{% endmacro %}

{% macro get_user_table(realm, users) -%}
    <div class="table-search-field form-group w-25 float-right">
        <input type="text"
               class="form-control"
               id="data-table-search-input">
        <label for="data-table-search-input">Suche</label>
    </div>
    <table class="table table-hover table-striped table-inverse table-bordered data-table">
        <thead>
        <tr>
            <th scope="col">Nutzername</th>
            <th scope="col">E-Mail</th>
            <th scope="col">Vorname</th>
            <th scope="col">Nachname</th>
            <th scope="col">Aktiv</th>
            <th scope="col">Letzer Login</th>
            <th scope="col">Löschdatum</th>
        </tr>
        </thead>
        <tbody>
        {% for user in users %}
            <tr class="{% if user.deleted_user %}bg-warning{% endif %}">
                <td>
                    <a href="{{ url('realm-user-detail', args=[realm.id, user.user.dn]) }}">{{ user.user.username }}</a>
                </td>
                <td><a href="mailto:{{ user.user.email }}">{{ user.user.email }}</a></td>
                <td>{{ user.user.first_name }}</td>
                <td>{{ user.user.last_name }}</td>
                <td class="text-center">{% if user.active %}
                    <i class="fas fa-check-circle text-success"></i><span class="d-none">-</span>{% else %}
                    <i class="far fa-times-circle text-warning"></i><span class="d-none">+</span>{% endif %}</td>
                <td class="text-center">
                    {% if user.user.last_login %}
                        {{ user.user.last_login.strftime('%Y-%m-%d') }}
                    {% else %}
                        <i class="far fa-times-circle text-danger"></i><span class="d-none">+</span>
                    {% endif %}
                </td>
                <td class="text-center">
                    {% if user.deleted_user %}
                        {{ user.deleted_user.deletion_date.strftime('%Y-%m-%d') }}
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endmacro %}

{% macro get_realm_table(realms) -%}
    <div class="table-search-field form-group w-25 float-right">
        <input type="text"
               class="form-control"
               id="data-table-search-input">
        <label for="data-table-search-input">Suche</label>
    </div>
    <table class="table table-hover table-striped table-inverse table-bordered data-table text-center">
        <thead>
        <tr>
            <th scope="col">Bereichsname</th>
            <th scope="col">Ldap Basis DN</th>
            <th scope="col">Mailadresse</th>
            <th scope="col">Admingruppe</th>
            <th scope="col">Defaultgruppe</th>
            <th scope="col">Nutzeranzahl</th>
            <th scope="col">Gruppenanzahl</th>
        </tr>
        </thead>
        <tbody>
        {% for realm_wrapper in realms %}
            <tr>
                <td>
                    <a href="{{ url('realm-detail', args=[realm_wrapper.realm.id]) }}">{{ realm_wrapper.realm.name }}</a>
                </td>
                <td>{{ realm_wrapper.realm.ldap_base_dn }}</td>
                <td>
                    {% if realm_wrapper.realm.email %}
                        <a href="mailto:{{ realm_wrapper.realm.email }}">{{ realm_wrapper.realm.email }}</a>
                    {% else %}
                        <span class="text-danger"><i class="fas fa-exclamation-circle"></i></span>
                    {% endif %}
                </td>
                <td>
                    {% if realm_wrapper.realm.admin_group %}
                        {{ realm_wrapper.realm.admin_group }}
                    {% else %}
                        <span class="text-warning"><i class="fas fa-exclamation-circle"></i></span>
                    {% endif %}
                </td>
                <td>
                    {% if realm_wrapper.realm.default_group %}
                        {{ realm_wrapper.realm.default_group }}
                    {% else %}
                        <span class="text-warning"><i class="fas fa-exclamation-circle align-middle"></i></span>
                    {% endif %}
                </td>
                <td>{{ realm_wrapper.user_count }}</td>
                <td>{{ realm_wrapper.group_count }}</td>
            </tr>

        {% endfor %}
        </tbody>
    </table>
{% endmacro %}

{% macro get_warning_box(error_text) -%}
    {% if error_text %}
        <div class="alert alert-warning">{{ error_text }}</div>
    {% endif %}
{% endmacro %}

{% macro get_data_table_search_field(input_id="data-table-search-input") -%}
    <div class="form-group w-25 float-right">
        <input type="text"
               class="form-control"
               id="{{ input_id }}">
        <label for="{{ input_id }}">Suche</label>
    </div>
{% endmacro %}

