{% extends "admin/dj_celery_panel/base.html" %}
{% load i18n admin_urls static admin_list %}

{% block content %}
{% include "admin/dj_celery_panel/_tabs.html" %}

{% include "admin/dj_celery_panel/_backend_info.html" %}

<div class="module">
        <h2>{% trans 'Active Task Queues' %}</h2>
        
        {% if queues %}
        <div class="results">
            <table id="result_list">
                <thead>
                    <tr>
                        <th scope="col">{% trans 'Queue Name' %}</th>
                        <th scope="col">{% trans 'Messages' %}</th>
                        <th scope="col">{% trans 'Exchange' %}</th>
                        <th scope="col">{% trans 'Routing Key' %}</th>
                        <th scope="col">{% trans 'Workers' %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for queue in queues %}
                    <tr>
                        <td><a href="{% url 'dj_celery_panel:queue_detail' queue.name %}"><code class="queue-name">{{ queue.name }}</code></a></td>
                        <td>
                            {% if queue.message_count is not none %}
                                {{ queue.message_count }}
                            {% elif queue.broker_query_error %}
                                <span class="config-value-muted" title="{{ queue.broker_query_error }}">⚠️</span>
                            {% else %}
                                <span class="config-value-muted">—</span>
                            {% endif %}
                        </td>
                        <td>{{ queue.exchange }}</td>
                        <td><code class="routing-key">{{ queue.routing_key }}</code></td>
                        <td>
                            <div class="worker-list">
                                {% for worker in queue.workers %}
                                    <span class="worker-badge">{{ worker }}</span>
                                {% endfor %}
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% else %}
        <div class="empty-state-row">
            <div class="empty-state-message">
                <div class="empty-state-content">
                    <span class="empty-state-icon">📬</span>
                    <p class="empty-state-title">{% trans 'No Active Queues' %}</p>
                    <p class="empty-state-text">{% trans 'No workers are currently running or no queues have been configured.' %}</p>
                </div>
            </div>
        </div>
        {% endif %}
    </div>
{% endblock %}
