<commit_before>{% extends 'AppBundle:Layouts:application.html.twig' %}

{% trans_default_domain "admin" %}

{% block htmlTitle %}Administration - Users{% endblock %}
{% block pageTitle %}Admin{% endblock %}

{% block pageContent %}
    <style type="text/css">
        .user-table td {
            font-size: 0.8em;
        }
    </style>
    <h1 class="form-title heading-large">
        USER MANAGEMENT
    </h1>

    <h2 class="form-title heading-medium">SEARCH</h2>

    <div class="jump-to-user">
        {{ form_start(form, {attr: {novalidate: 'novalidate' }}) }}
        {{ form_input(form.q, 'Search', {
            'labelRaw': true,
            'labelText':'Search',
            'hintText':'user email OR first or last name of the user OR first or last name of the client OR full case number'}) }}
        {{ form_select(form.role_name, '', {'labelText': 'Role'}) }}
        {{ form_checkbox(form.odr_enabled, '', {'labelText': 'NDR enabled'}) }}
        {{ form_submit(form.search, 'Search', {'labelText': 'Search'}) }}
        {{ form_end(form) }}
    </div>
    <hr>

    {# LIST #}

    <div class="behat-region-users user-list">

        <h2 class="form-title heading-medium" id="users-list-title">
            User list
        </h2>
        <p class="text">
            [<a href="{{ path('admin_add_user') }}" class="behat-link-user-add-new">Add a new user</a>]
            [<a href="{{ path('admin_homepage') }}">Clear filters</a>]
        </p>

        {# simple paginator #}
        <div style="float: right">
            {% if users | length  == filters.limit %}
                Results limited to 100 users. Use search to filter the wanted users
            {% else %}
                Found {{ users | length }} users
            {% endif %}
        </div>

        {# user list #}
        <table class="user-table">
            <thead>
            <tr>
                <th scope="col">Name</th>
                <th scope="col">Email</th>
                <th scope="col">Role</th>
                <th scope="col">NDR Enabled</th>
                <th scope="col">Active</th>
                <th scope="col">Registration date</th>
            </tr>
            </thead>
            <tbody>
            {% for user in users %}
                <tr class="behat-region-user-{{ user.email | behat_namify }}">
                    <td>
                        {% if user.roleName != 'ROLE_ADMIN' or is_granted('ROLE_ADMIN') %}
                            <a href='{{ path('admin_editUser', { what: 'user_id', filter: user.id }) }}'
                                class="behat-link-user-{{ user.email }}">{{ user.firstname }}<br/>{{ user.lastname }}</a>
                        {% endif %}


                    </td>
                    <td>{{ user.adManaged ? '-' : user.email }}</td>
                    <td nowrap>
                        {{ user.roleFullName }}
                        {% if user.adManaged %} Assisted{% endif %}
                        {% if app.user.id == user.id %} (currenty logged){% endif %}
                        {% if is_granted('ROLE_AD') and user.roleName == 'ROLE_LAY_DEPUTY' %}
                            [<a href="{{ path('ad_view_user', { what: 'user_id', filter: user.id }) }}">View</a>]
                        {% endif %}

                    </td>
                    <td class="behat-region-{{ user.email | behat_namify }}-odr-enabled">
                        {{ user.odrEnabled ? 'yes' : '-' }}
                    </td>
                    <td>
                        {% if user.active %}
                            YES
                        {% else %}
                            NO
                            <br/><a data-role="ajax-link" class="behat-link-send-activation-email"
                                    href="{{ path('admin_send_activation_link', {'email': user.email}) }}">
                            (Re)send activation email
                        </a>
                        {% endif %}

                    </td>
                    <td>{{ user.registrationDate ? user.registrationDate | date("d/m/Y") : 'n.a.' }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>

    {# simple JS script to transform data-role="ajax-link" links
    into loading the URL with AJAX and replace the response with the HTTP response #}
    <script>
        $(document).ready(function () {
            $('[data-role="ajax-link"]').click(function (e) {
                e.preventDefault();
                var link = $(this);
                $.get(link.attr('href'), function (data) {
                    link.replaceWith(data);
                });
            });
        });
    </script>

{% endblock %}<commit_msg>DDPB-1038 dataType set as html on ajax call<commit_after>{% extends 'AppBundle:Layouts:application.html.twig' %}

{% trans_default_domain "admin" %}

{% block htmlTitle %}Administration - Users{% endblock %}
{% block pageTitle %}Admin{% endblock %}

{% block pageContent %}
    <style type="text/css">
        .user-table td {
            font-size: 0.8em;
        }
    </style>
    <h1 class="form-title heading-large">
        USER MANAGEMENT
    </h1>

    <h2 class="form-title heading-medium">SEARCH</h2>

    <div class="jump-to-user">
        {{ form_start(form, {attr: {novalidate: 'novalidate' }}) }}
        {{ form_input(form.q, 'Search', {
            'labelRaw': true,
            'labelText':'Search',
            'hintText':'user email OR first or last name of the user OR first or last name of the client OR full case number'}) }}
        {{ form_select(form.role_name, '', {'labelText': 'Role'}) }}
        {{ form_checkbox(form.odr_enabled, '', {'labelText': 'NDR enabled'}) }}
        {{ form_submit(form.search, 'Search', {'labelText': 'Search'}) }}
        {{ form_end(form) }}
    </div>
    <hr>

    {# LIST #}

    <div class="behat-region-users user-list">

        <h2 class="form-title heading-medium" id="users-list-title">
            User list
        </h2>
        <p class="text">
            [<a href="{{ path('admin_add_user') }}" class="behat-link-user-add-new">Add a new user</a>]
            [<a href="{{ path('admin_homepage') }}">Clear filters</a>]
        </p>

        {# simple paginator #}
        <div style="float: right">
            {% if users | length  == filters.limit %}
                Results limited to 100 users. Use search to filter the wanted users
            {% else %}
                Found {{ users | length }} users
            {% endif %}
        </div>

        {# user list #}
        <table class="user-table">
            <thead>
            <tr>
                <th scope="col">Name</th>
                <th scope="col">Email</th>
                <th scope="col">Role</th>
                <th scope="col">NDR Enabled</th>
                <th scope="col">Active</th>
                <th scope="col">Registration date</th>
            </tr>
            </thead>
            <tbody>
            {% for user in users %}
                <tr class="behat-region-user-{{ user.email | behat_namify }}">
                    <td>
                        {% if user.roleName != 'ROLE_ADMIN' or is_granted('ROLE_ADMIN') %}
                            <a href='{{ path('admin_editUser', { what: 'user_id', filter: user.id }) }}'
                                class="behat-link-user-{{ user.email }}">{{ user.firstname }}<br/>{{ user.lastname }}</a>
                        {% endif %}


                    </td>
                    <td>{{ user.adManaged ? '-' : user.email }}</td>
                    <td nowrap>
                        {{ user.roleFullName }}
                        {% if user.adManaged %} Assisted{% endif %}
                        {% if app.user.id == user.id %} (currenty logged){% endif %}
                        {% if is_granted('ROLE_AD') and user.roleName == 'ROLE_LAY_DEPUTY' %}
                            [<a href="{{ path('ad_view_user', { what: 'user_id', filter: user.id }) }}">View</a>]
                        {% endif %}

                    </td>
                    <td class="behat-region-{{ user.email | behat_namify }}-odr-enabled">
                        {{ user.odrEnabled ? 'yes' : '-' }}
                    </td>
                    <td>
                        {% if user.active %}
                            YES
                        {% else %}
                            NO
                            <br/><a data-role="ajax-link" class="behat-link-send-activation-email"
                                    href="{{ path('admin_send_activation_link', {'email': user.email}) }}">
                            (Re)send activation email
                        </a>
                        {% endif %}

                    </td>
                    <td>{{ user.registrationDate ? user.registrationDate | date("d/m/Y") : 'n.a.' }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>

    {# simple JS script to transform data-role="ajax-link" links
    into loading the URL with AJAX and replace the response with the HTTP response #}
    <script>
        $(document).ready(function () {
            $('[data-role="ajax-link"]').click(function (e) {
                e.preventDefault();
                var link = $(this);
                $.get(link.attr('href'), function (data) {
                    link.replaceWith(data);
                }, "html");
            });
        });
    </script>

{% endblock %}
{'fraction_non_alphanumeric': 0.16098484848484848, 'fraction_numerical': 0.002735690235690236, 'mean_word_length': 1.408768373035986, 'pattern_counts': {'":': 0, '<': 133, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5006693', 'n_tokens_mistral': 2869, 'n_tokens_neox': 2619, 'n_words': 588}