{% extends 'base_templates/page_base_half.html' %}

{% block content %}

<div class="row mb-2">
  <div class="col text-right">
    <div class="dropdown">
      <button class="btn {{ config['BUTTON_STYLE'] }}secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-bars"></i> {{ word('Menu') }}</button>
      <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
        <a class="dropdown-item" href="{{ url_for('user_add') }}"><i class="fas fa-user-plus fa-fw"></i> {{ word('Add a user') }}</a>
        <a class="dropdown-item" href="{{ url_for('invite') }}"><i class="fas fa-envelope fa-fw"></i> {{ word('Invite a user') }} </a>
        <a class="dropdown-item" href="{{ url_for('privilege_list') }}"><i class="fas fa-edit fa-fw"></i> {{ word('Edit privileges') }}</a>
      </div>
    </div>
  </div>
</div>

<table class="table table-striped">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">{{ word('E-mail') }}</th>
      <th scope="col">{{ word('Name') }}</th>
      <th scope="col" style="text-align:right;">Actions</th>
    </tr>
  </thead>
  <tbody>
  {%- for user_info in users %}
    <tr>
      {%- if user_info['active'] %}
      <td>{{ user_info['id'] }}</td>
      {%- else %}
      <td class="text-danger">{{ user_info['id'] }}</td>
      {%- endif %}
      <td>
      {%- if user_info['active'] %}
        {%- if user_info['high_priv'] == 'advocate' %}
      <i class="fas fa-user-circle" title="{{ word('Advocate privilege') }}"></i>
        {%- elif user_info['high_priv'] == 'admin' %}
      <i class="fas fa-cog" title="{{ word('Administrator privilege') }}"></i>
        {%- elif user_info['high_priv'] == 'developer' %}
      <i class="fas fa-code" title="{{ word('Developer privilege') }}"></i>
        {%- elif user_info['high_priv'] == 'trainer' %}
      <i class="fas fa-comment" title="{{ word('Trainer privilege') }}"></i>
        {%- else %}
      &nbsp;
        {%- endif %}
      </td>
      {%- else %}
      <i class="fas fa-ban text-danger" title="{{ word('Account disabled') }}"></i>
      {%- endif %}
      {%- if user_info['active'] %}
      <td>{{ user_info['email'] }}</td>
      <td>{{ user_info['name'] }}</td>
      {%- else %}
      <td class="text-danger">{{ user_info['email'] }}</td>
      <td class="text-danger">{{ user_info['name'] }}</td>
      {%- endif %}
      <td style="text-align:right;"><a class="btn {{ config['BUTTON_STYLE'] }}success" href="{{ url_for('edit_user_profile_page', id=user_info['id']) }}">{{ word('Edit') }}</a></td>
    </tr>
  {%- endfor %}
  </tbody>
</table>
{%- if prev_page > 0 or next_page %}
<div class="row">
  <div class="col-xs-8 mx-auto">
    <nav class="text-center">
      <ul class="pagination">
        {%- if prev_page > 0 %}
        <li class="page-item"><a class="page-link" href="?page={{ prev_page }}" aria-label="{{ word('Back') }}"><i class="fas fa-chevron-left"></i> {{ word('Back') }}</a></li>
        {%- endif %}
        {%- if next_page %}
        <li class="page-item"><a class="page-link" href="?page={{ next_page }}" aria-label="{{ word('Next') }}">{{ word('Next') }} <i class="fas fa-chevron-right"></i></a></li>
        {%- endif %}
      </ul>
    </nav>
  </div>
<div>
{%- endif %}

{% endblock %}
