{% extends "sentry/layout.html" %}

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

{% block heading %}{% trans "Dashboard" %}{% endblock %}

{% block sidebar %}
    {% if chart_url %}
        <h2>{% trans "Last 24 Hours" %}</h2>
        <img src="{{ chart_url }}" class="chart" alt="chart"/>
    {% endif %}

    {% for filter in filters %}
        <div class="sidebar-module sidebar-module-{{ filter.column }}">
            {% if filter.show_label %}
                <h2>{% trans filter.label %}</h2>
            {% endif %}
            <form method="get" action="{{ filter.get_query_string|safe }}">
                {{ filter.render }}
            </form>
        </div>
    {% endfor %}
{% endblock %}

{% block main %}
    {% paginate message_list from request as message_list per_page 15 %}

    <div class="paging-wrap">
        <div class="clearfix">
            <form method="GET" action="">
                {% for k, v in request.GET.iteritems %}
                    <input type="hidden" name="{{ k }}" value="{{ v }}"/>
                {% endfor %}
                <div class="sort-by">{% trans "Sort by" %} <select name="sort" onchange="this.form.submit()">
                    <option value=""{% ifequal sort 'priority' %} selected="selected"{% endifequal %}>{% trans "Priority" %}</option>
                    <option value="date"{% ifequal sort 'date' %} selected="selected"{% endifequal %}>{% trans "Last Seen" %}</option>
                    <option value="new"{% ifequal sort 'new' %} selected="selected"{% endifequal %}>{% trans "First Seen" %}</option>
                    <option value="freq"{% ifequal sort 'freq' %} selected="selected"{% endifequal %}>{% trans "Frequency" %}</option>
                </select>
                </div>
            </form>
            {% if has_realtime %}
                <a id="sentry_realtime" class="realtime realtime-pause">Pause Feed</a>
            {% endif %}
            {{ message_list.paging }}
        </div>
    </div>
    
    {% if message_list.objects %}
        <ul class="messages" id="message_list">
            {% for group, priority in message_list.objects|with_priority %}
                {% include "sentry/partial/_group.html" %}
            {% endfor %}
        </ul>
    {% else %}
        <ul class="messages" id="message_list">
            <li class="no-messages" id="no_messages">{% trans "No messages match your filters." %}</li>
        </ul>
    {% endif %}

    <div class="clearfix">
        {{ message_list.paging }}
    </div>
{% endblock %}
