{% 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 Groups" %}{% 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()
            { 
                $("#groupTable").tablesorter( {
                    //sortList: [[1,0]]
                    headers: {0: { sorter: 'digit' } }
                    } );
                $('input#id_search').quicksearch('table#groupTable tbody tr', {
                    'delay': 300,
                    'loader': 'span.loading'
                });
        })
    </script>
    
{% endblock %}

{% block center_details %}
{{ block.super }}
    
<div id="Group_content">

{% if groups %}

<div class="one_column_header">

    {% if can_modify_group and ome.can_create %}
        <div class="btn blue">
            <a href="{% url 'wamanagegroupid' "new" %}">
                <span>{% trans "Add new Group" %}</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="groupTable" class="tablesorter tablesorter_basic">
    <thead>
        <tr>
            <th>{% trans "ID" %}</th>
            <th>{% trans "Group Name" %}</th>
            <th>{% trans "Permission" %}</th>
            <th>{% trans "Description" %}</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    {% for group in groups %}
        <tr>
            <td>{{ group.id }}</td>
            <td>{{ group.name }}</td>
            <td>{{ group.getPermissions }} ({{ group.details.permissions }})</td>
            <td>{{ group.description|default:"-"|truncatewords:"5" }}</td>
            <td>
                {% if group.isEditable %}
                    <a href="{% url 'wamanagegroupid' "edit" group.id %}" class="btn silver btn_edit">
                      <span></span>
                    </a>
                {% else %}

        {% endif %}
            </td>
        </tr>
    {% endfor %}
  </tbody>
</table>

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

</div>


<div id="metadata_details" class="overflow">
    <p>{% trans "<strong>Private (rw----)</strong>: All data in this group is only visible to the user who owns it and the group owner. Other users cannot see who else is in the group or view their data. The group owner can view the data for other group members but not make any edits (same as read-only behaviour)." %}</p>

    <p>{% trans "<strong>Read-Only (rwr---)</strong>: Users in groups with this permission setting can view each others' data, but cannot edit or annotate another user's data. You can view another users' images but not comment, rate or tag their images." %}</p>

    <p>{% trans "<strong>Read-Annotate (rwra--)</strong>: Users in a Read-Annotate group can view and annotate the data belonging to other users. You can tag another user's images or use their tags to annotate your own images. You can add comments to their images and save your own rendering settings for each image. However, you cannot edit the names of their images, projects, datasets or tags etc." %}</p>

    <p>{% trans "<strong>Read-Write (rwrw--)</strong>: Users in a Read-Write group have permission to edit and delete the data belonging to other users." %}</p>

<div>
        
{% endblock %}
