{% extends "admin/base_site.html" %}

{% block title %}Queues {{ block.super }}{% endblock %}

{% block extrastyle %}
    {{ block.super }}
    <style>table {
        width: 100%;
    }</style>
{% endblock %}

{% block content_title %}<h1>RQ Queues</h1>{% endblock %}

{% block breadcrumbs %}
    <div class="breadcrumbs">
        <a href="{% url 'admin:index' %}">Home</a> &rsaquo;
        <a href="{% url 'queues_home' %}">Queues</a>
    </div>
{% endblock %}

{% block content %}

    <div id="content-main">

        <div class="module">
            <table>
                <thead>
                <tr>
                    <th>Name</th>
                    <th>Queued Jobs</th>
                    <th>Oldest Queued Job</th>
                    <th>Active Jobs</th>
                    <th>Deferred Jobs</th>
                    <th>Finished Jobs</th>
                    <th>Failed Jobs</th>
                    <th>Scheduled Jobs</th>
                    <th>Canceled Jobs</th>
                    <th>Workers</th>
                    <th>Host</th>
                    <th>Port</th>
                    <th>DB</th>
                    {% if queue.scheduler_pid is not False %}
                        <th>Scheduler PID</th>
                    {% endif %}
                </tr>
                </thead>
                <tbody>
                {% for queue in queues %}
                    <tr class="{% cycle 'row1' 'row2' %}">
                        <th>
                            <a href="{% url 'queue_registry_jobs' queue.name 'queued' %}">
                                {{ queue.name }}
                            </a>
                        </th>
                        <td>
                            <a href="{% url 'queue_registry_jobs' queue.name 'queued' %}">
                                {{ queue.jobs }}
                            </a>
                        </td>
                        <td>{{ queue.oldest_job_timestamp }}</td>
                        <th>
                            <a href="{% url 'queue_registry_jobs' queue.name 'started' %}">
                                {{ queue.started_jobs }}
                            </a>
                        </th>
                        <th>
                            <a href="{% url 'queue_registry_jobs' queue.name 'deferred' %}">
                                {{ queue.deferred_jobs }}
                            </a>
                        </th>
                        <th>
                            <a href="{% url 'queue_registry_jobs' queue.name 'finished' %}">
                                {{ queue.finished_jobs }}
                            </a>
                        </th>
                        <th>
                            <a href="{% url 'queue_registry_jobs' queue.name 'failed' %}">
                                {{ queue.failed_jobs }}
                            </a>
                        </th>
                        <th>
                            <a href="{% url 'queue_registry_jobs' queue.name 'scheduled' %}">
                                {{ queue.scheduled_jobs }}
                            </a>
                        </th>
                        <th>
                            <a href="{% url 'queue_registry_jobs' queue.name 'canceled' %}">
                                {{ queue.canceled_jobs }}
                            </a>
                        </th>
                        <th><a href="{% url 'queue_workers' queue.name %}">
                            {{ queue.workers }}
                        </a>
                        </th>
                        <td>{{ queue.connection_kwargs.host }}</td>
                        <td>{{ queue.connection_kwargs.port }}</td>
                        <td>{{ queue.connection_kwargs.db }}</td>
                        {% if queue.scheduler_pid is not False %}
                            <td>{{ queue.scheduler_pid|default_if_none:"Inactive" }}</td>
                        {% endif %}
                    </tr>
                {% endfor %}
                </tbody>
            </table>
            <br/>
            <a href="{% url 'queues_home_json' %}">View as JSON</a>
        </div>
    </div>

{% endblock %}
