{% extends "layout.html" %}
{% block headers %}
<script src="/static/js/jquery-3.6.0.min.js"></script>
<script src="/static/js/jquery.dataTables.min.js"></script>
<script src="/static/js/utils.js?cache=1741959850"></script>
<link href="/static/css/jquery.dataTables.min.css" rel="stylesheet">
<style>
#users-table .fa-user-secret { color: #000; }
#users-table .fa-user-secret:hover { color: #666; }
#users-table .fa-user-secret:active { color: #999; }
#users-table { display: none; }
#users-table_wrapper { margin-top: 1em; }
</style>
<script>
function clear_accounts_cache (event) {
    if (event !== null) {
        event.preventDefault();
        event.stopPropagation();
    }
    jQuery.ajax({
        url:         "/v3/admin/accounts/clear-cache",
        type:        "GET",
        accept:      "application/json",
    }).done(function () { location.reload();
    }).fail(function () {
        show_message ("failure", "<p>Failed to clear the accounts cache.</p>");
    });
}
jQuery(document).ready(function () {
    jQuery(".hide-for-javascript").removeClass("hide-for-javascript");
    jQuery("#users-table").DataTable({
        columnDefs: [{ orderable: false,  targets: 3 }],
        pageLength: 25
    });
    jQuery("#users-table").show();
    jQuery("#remove-cache").on("click", function (event) {
        clear_accounts_cache (event);
    });
});
</script>
{% endblock %}
{% block submenu %}
<ul>
  <li ><a href="/admin/dashboard">Dashboard</a>
  <li class="active corporate-identity-submenu-active">Users
  <li><a href="/admin/exploratory">Exploratory</a>
  <li><a href="/admin/reports">Reports</a>
  {% if may_query %}<li><a href="/admin/sparql">Query</a>{% endif %}
  {% if may_review_quotas %}<li><a href="/admin/quota-requests">Quota requests</a>{% endif %}
</ul>
{% endblock %}
{% block body %}
<noscript>
  <p class="no-script">Sorry, this page requires JavaScript to function properly.</p>
</noscript>
<div class="hide-for-javascript">
<h1>Manage users<span class="no-select"> &nbsp;<a id="remove-cache" href="#" class="fas fa-sync"></a></span></h1>
<table id="users-table" class="corporate-identity-table">
  <thead><tr><th>Name</th><th>E-mail</th><th>Group</th><th>Actions</th></tr></thead>
  <tbody>
    {%- for account in accounts: %}
    <tr>
      <td>{{account.first_name | default("", False)}} {{account.last_name | default("", False)}}</td>
      <td>{{account.email | default("-", False)}}</td>
      <td>{{account.group_id | default("-", False)}}</td>
      <td>{% if may_impersonate %}<a href="/admin/impersonate/{{account.uuid}}" class="fas fa-user-secret" title="Impersonate"><span class="hidden">Impersonate</span></a>{% endif %}</td>
    </tr>
    {%- endfor %}
  </tbody>
</table>
</div>
{% endblock %}
