{% extends "base.html" %}

{% block title %}
{{ application_name }} Development Console - Task Queue Viewer{% endblock %}

{% block head %}
  <style type="text/css">{% include "css/queues.css" %}</style>
{% endblock %}

{% block breadcrumbs %}
  <span class="item"><a href="">Queue Viewer</a></span>
{% endblock %}

{% block body %}
<h3>Task Queues</h3>

{% if queues %}
  <p>
  Select a queue to run tasks manually.
  </p>

  <table id="ah-queues" class="ae-table ae-table-striped">
    <thead>
      <tr>
        <th>Queue Name</th>
        <th>Maximum Rate</th>
        <th>Bucket Size</th>
        <th>Oldest Task (UTC)</th>
        <th>Tasks in Queue</th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      {% for queue in queues %}
        <tr class="{% cycle ae-odd,ae-even %}">
          <td valign="top">
            <a href="/_ah/admin/tasks?queue={{ queue.name|escape }}">
            {{ queue.name|escape }}</a>
          </td>
          <td valign="top">
            {{ queue.max_rate|escape }}
          </td>
          <td valign="top">
            {{ queue.bucket_size|escape }}
          </td>
          <td valign="top">
            {% if queue.oldest_task %}
              {{ queue.oldest_task|escape }}<br/>
              ({{ queue.eta_delta|escape }})
            {% else %}
              None
            {% endif %}
          </td>
          <td valign="top">
            {{ queue.tasks_in_queue|escape }}
          </td>
          <td valign="top">
            <form id="purgeform" action="/_ah/admin/queues" method="post">
            <input type="hidden" name="queue" value="{{ queue.name|escape }}"/>
            <input type="submit" name="action:purgequeue" value="Purge Queue"
             onclick="return confirm('Are you sure you want to purge all ' +
                                     'tasks from {{ queue.name|escape }}?');"/>
            </form>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% else %}
  This application doesn't define any task queues. See the documentation for more.
{% endif %}


{% endblock %}

