{% extends "sentry/bases/explore.html" %}

{% load i18n %}
{% load sentry_helpers %}
{% load sentry_plugins %}

{% block title %}Users | {{ block.super }}{% endblock %}

{% block inner %}
    {% paginator tag_list from request as tag_list %}
    {% querystring from request without sort as sort_querystring %}

    <div class="btn-toolbar">
        <div class="btn-group">
            <a href="#" class="btn dropdown-toggle" data-toggle="dropdown">{% blocktrans with sort_label as label %}Sort by: {{ label }}{% endblocktrans %} <span class="caret"></span></a>
            <ul class="dropdown-menu">
                <li{% ifequal sort 'recent' %} class="active"{% endifequal %}><a href="?{{ sort_querystring }}&amp;sort=recent">{{ SORT_OPTIONS.recent }}</a></li>
                <li{% ifequal sort 'newest' %} class="active"{% endifequal %}><a href="?{{ sort_querystring }}&amp;sort=newest">{{ SORT_OPTIONS.newest }}</a></li>
                <li{% ifequal sort 'events' %} class="active"{% endifequal %}><a href="?{{ sort_querystring }}&amp;sort=events">{{ SORT_OPTIONS.events }}</a></li>
            </ul>
        </div>
        <div class="btn-group pull-right">
            <a class="btn prev{% if not tag_list.paginator.has_previous %} disabled{% else %}" href="?{{ tag_list.query_string|escape }}&amp;p={{ tag_list.paginator.previous_page }}{% endif %}"><span>{% trans "Previous" %}</span></a>
            <a class="btn next{% if not tag_list.paginator.has_next %} disabled{% else %}" href="?{{ tag_list.query_string|escape }}&amp;p={{ tag_list.paginator.next_page }}{% endif %}"><span>{% trans "Next" %}</span></a>
        </div>
    </div>

    {% if not tag_list.paginator.objects %}
        <p>{% blocktrans %}You dont seem to have any user data recorded. For more information on how to send this information consult your client's documentation.{% endblocktrans %}</p>
    {% else %}
        <table class="table table-bordered table-striped">
            <thead>
                <tr>
                    <th>{% trans "User" %}</th>
                    <th style="width:150px;text-align:center">{% trans "Last Seen" %}</th>
                    <th style="width:100px;text-align:center">{% trans "Events Seen" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for tag in tag_list.paginator.objects %}
                    <tr>
                        <td><a href="{% url 'sentry-user-details' organization.slug project.slug tag.id %}">{{ tag.get_label }}</a></td>
                        <td style="text-align:center">{{ tag.last_seen|timesince }}</td>
                        <td style="text-align:center">{{ tag.times_seen|small_count }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>

        <div class="btn-toolbar">
            <div class="btn-group pull-right">
                <a class="btn prev{% if not tag_list.paginator.has_previous %} disabled{% else %}" href="?{{ tag_list.query_string|escape }}&amp;p={{ tag_list.paginator.previous_page }}{% endif %}"><span>{% trans "Previous" %}</span></a>
                <a class="btn next{% if not tag_list.paginator.has_next %} disabled{% else %}" href="?{{ tag_list.query_string|escape }}&amp;p={{ tag_list.paginator.next_page }}{% endif %}"><span>{% trans "Next" %}</span></a>
            </div>
        </div>
    {% endif %}
{% endblock %}
