{% extends "webadmin/admin_base.html" %}
{% load i18n %}
{% load common_tags %}

{% comment %}
<!--
  Copyright (C) 2011 University of Dundee & Open Microscopy Environment.
  All rights reserved.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
{% endcomment %}

{% block title %}{% trans "OMERO Users" %}{% endblock %}

{% block link %}
    {{ block.super }}

    <link rel="stylesheet" href="{% static "webgateway/css/ome.table.css"|add:url_suffix %}" type="text/css" media="screen"/>
    <link rel="stylesheet" href="{% static "3rdparty/jquery.tablesorter-2.0.3/jquery.tablesorter.css" %}" type="text/css" media="screen"/>

{% endblock %}

{% block script %}
    {{ block.super }}
    
    <script type="text/javascript" src="{% static "3rdparty/jquery.tablesorter-2.0.3/jquery.tablesorter.js" %}"></script>
    <script type="text/javascript" src="{% static "3rdparty/jquery.quicksearch-1.0.js" %}"></script>
    
    <script type="text/javascript">
        $(document).ready(function() 
            {
                $("#experimenterTable").tablesorter( {
                    //sortList: [[1,0]],
                    headers: {0: { sorter: 'digit' } }
                } );
                $('input#id_search').quicksearch('table#experimenterTable tbody tr', {
                    'delay': 300,
                    'loader': 'span.loading'
                });
            })
    </script>
    
    
{% endblock %}

{% block center_details %}
{{ block.super }}

<div id="experimenters_content">

{% if experimenterList %}

<div class="one_column_header">

    {% if can_modify_user and ome.can_create %}
    <div class="btn blue">
        <a href="{% url 'wamanageexperimenterid' "new" %}">
            <span>{% trans "Add new User" %}</span>
        </a>
    </div>
    {% endif %}

    <form class="search filtersearch" id="filtersearch" action="#" style="margin-left:20px; width: 160px">
        <input type="text" id="id_search" style="width: 100%">
        <input type="submit" value="Go" />
        <span class="loading">
            <img class="loader" alt="Loading" src="{% static "webgateway/img/spinner.gif" %}">
        </span>
    </form>

</div>


<table id="experimenterTable" class="tablesorter tablesorter_basic">
    <thead>
        <tr>
            <th>{% trans "ID" %}</th>
            <th>{% trans "Full name" %}</th>
            <th>{% trans "Username" %}</th>
            <th>{% trans "Institution" %}</th>
            <th>{% trans "Roles" %}</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    {% for experimenter in experimenterList %}
        <tr>
            <td>
                {{ experimenter.id }}
            </td>
            <td>{{ experimenter.getFullName }}</td>
            <td>{{ experimenter.omeName }}</td>
            <td>{{ experimenter.institution|default:"-"|truncatewords:"3" }}</td>
            <td>
                  {% if experimenter.isAdmin %}<img src="{% static "webadmin/image/admin.png" %}" alt="admin" title="admin"> {% endif %}
                  {% if experimenter.isGuest %}<img src="{% static "webadmin/image/guest.png" %}" alt="guest" title="guest"> {% endif %}
                  {% if experimenter.ldap %}<img src="{% static "webadmin/image/ldap.png" %}" alt="ldap" title="ldap"> {% endif %}
                  {% if experimenter.isActive %}<img src="{% static "webadmin/image/active.png" %}" alt="active" title="active">{% else %}<img src="{% static "webadmin/image/notactive.png" %}" alt="inactive" title="inactive">{% endif %}
            </td>
            <td>
                {% if experimenter.isEditable %}
                <a href="{% url 'wamanageexperimenterid' "edit" experimenter.id %}" title="Edit User" class="btn silver btn_edit">
                    <span></span>
                </a>
                {% endif %}
            </td>
        </tr>
    {% endfor %}
  </tbody>
</table>

{% else %}
<p>{% trans "No scientists in OMERO." %}</p>
{% endif %}
</div>

{% endblock %}

{% block metadata_details %}

    <div>
        <img src="{% static "webadmin/image/admin.png" %}" alt="admin" title="admin"> - Admin; 
        <img src="{% static "webadmin/image/guest.png" %}" alt="guest" title="guest"> - Guest; 
        <img src="{% static "webadmin/image/ldap.png" %}" alt="ldap" title="ldap"> - ldap; 
        <img src="{% static "webadmin/image/active.png" %}" alt="active" title="active"> - active; 
        <img src="{% static "webadmin/image/notactive.png" %}" alt="notactive" title="notactive"> - not active;
    <div>
        
{% endblock %}
