<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Queues - Oxanus</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-950 text-gray-100 min-h-screen">
    <div class="max-w-[88rem] mx-auto px-4 sm:px-6 lg:px-8 py-8">
        <div class="mb-6">
            <h1 class="text-2xl font-bold tracking-tight">Oxanus Dashboard</h1>
        </div>

        {% include "_tabs.html" %}

        {% include "_stats_cards.html" %}

        <h2 class="text-lg font-semibold mb-4">Queues ({{ stats.queues.len() }})</h2>

        {% if stats.queues.is_empty() %}
        <div class="bg-gray-900 border border-gray-800 rounded-lg p-6 text-center text-gray-500">
            No queues
        </div>
        {% else %}
        <div class="overflow-x-auto">
            <table class="w-full text-sm">
                <thead>
                    <tr class="border-b border-gray-800 text-left text-xs text-gray-400 uppercase tracking-wide">
                        <th class="pb-3 pr-4"><a href="{{ base_path }}/queues?sort=key&dir={{ self.next_dir("key") }}" class="hover:text-gray-200">Queue{{ self.sort_arrow("key") }}</a></th>
                        <th class="pb-3 pr-4 text-right"><a href="{{ base_path }}/queues?sort=concurrency&dir={{ self.next_dir("concurrency") }}" class="hover:text-gray-200">Concurrency{{ self.sort_arrow("concurrency") }}</a></th>
                        <th class="pb-3 pr-4 text-right"><a href="{{ base_path }}/queues?sort=enqueued&dir={{ self.next_dir("enqueued") }}" class="hover:text-gray-200">Enqueued{{ self.sort_arrow("enqueued") }}</a></th>
                        <th class="pb-3 pr-4 text-right"><a href="{{ base_path }}/queues?sort=processed&dir={{ self.next_dir("processed") }}" class="hover:text-gray-200">Processed{{ self.sort_arrow("processed") }}</a></th>
                        <th class="pb-3 pr-4 text-right"><a href="{{ base_path }}/queues?sort=succeeded&dir={{ self.next_dir("succeeded") }}" class="hover:text-gray-200">Succeeded{{ self.sort_arrow("succeeded") }}</a></th>
                        <th class="pb-3 pr-4 text-right"><a href="{{ base_path }}/queues?sort=failed&dir={{ self.next_dir("failed") }}" class="hover:text-gray-200">Failed{{ self.sort_arrow("failed") }}</a></th>
                        <th class="pb-3 pr-4 text-right"><a href="{{ base_path }}/queues?sort=panicked&dir={{ self.next_dir("panicked") }}" class="hover:text-gray-200">Panicked{{ self.sort_arrow("panicked") }}</a></th>
                        <th class="pb-3 text-right"><a href="{{ base_path }}/queues?sort=latency&dir={{ self.next_dir("latency") }}" class="hover:text-gray-200">Latency{{ self.sort_arrow("latency") }}</a></th>
                    </tr>
                </thead>
                <tbody>
                    {% for queue in &stats.queues %}
                    <tr class="border-b border-gray-800/50 hover:bg-gray-900/50">
                        <td class="py-3 pr-4 font-mono text-sm">{% if queue.queues.is_empty() %}<a href="{{ base_path }}/queues/{{ queue.key|urlencode }}" class="text-blue-400 hover:text-blue-300 hover:underline">{{ queue.key }}</a>{% else %}{{ queue.key }}{% endif %}</td>
                        <td class="py-3 pr-4 text-right text-gray-400">{{ self.concurrency_for(&queue.key) }}</td>
                        <td class="py-3 pr-4 text-right text-blue-400">{{ queue.enqueued }}</td>
                        <td class="py-3 pr-4 text-right text-green-400">{{ queue.processed }}</td>
                        <td class="py-3 pr-4 text-right text-green-300">{{ queue.succeeded }}</td>
                        <td class="py-3 pr-4 text-right text-red-400">{{ queue.failed }}</td>
                        <td class="py-3 pr-4 text-right text-red-300">{{ queue.panicked }}</td>
                        <td class="py-3 text-right text-purple-400">{{ queue.latency_s|format_latency }}</td>
                    </tr>
                    {% for dq in &queue.queues %}
                    <tr class="border-b border-gray-800/50 hover:bg-gray-900/50 text-gray-500">
                        <td class="py-2 pr-4 pl-10 font-mono text-xs">&#8627; <a href="{{ base_path }}/queues/{{ queue.key }}%23{{ dq.suffix|urlencode }}" class="text-blue-400 hover:text-blue-300 hover:underline">{{ dq.suffix }}</a></td>
                        <td class="py-2 pr-4 text-right text-xs text-gray-500">{{ self.concurrency_for(&queue.key) }}</td>
                        <td class="py-2 pr-4 text-right text-xs">{{ dq.enqueued }}</td>
                        <td class="py-2 pr-4 text-right text-xs">{{ dq.processed }}</td>
                        <td class="py-2 pr-4 text-right text-xs">{{ dq.succeeded }}</td>
                        <td class="py-2 pr-4 text-right text-xs">{{ dq.failed }}</td>
                        <td class="py-2 pr-4 text-right text-xs">{{ dq.panicked }}</td>
                        <td class="py-2 text-right text-xs">{{ dq.latency_s|format_latency }}</td>
                    </tr>
                    {% endfor %}
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% endif %}
    </div>
</body>
</html>
