{% extends "base/base.html" %}

{% block content %}
<div>
  <h1 class="h3 mb-3">Workers</h1>
  <div
    id="content"
    hx-get="/workers"
    hx-trigger="load delay:5s"
    hx-target="#content"
    hx-select="#content"
  >
    <table class="table table-bordered table-striped">
      <thead>
      <tr>
        <th>Worker Tags</th>
        <th>Queues</th>
      </tr>
      </thead>
      <tbody>
      {% for worker in workers %}
        <tr>
          <td>
            <ul class="list-inline mb-0">
              {% for tag in worker.tags|sort %}
                <li class="list-inline-item">
                  <span class="badge bg-secondary">{{ tag }}</span>
                </li>
              {% endfor %}
              {% if worker.is_leader %}
                <li class="list-inline-item">
                  <span class="badge bg-primary">Cluster Leader</span>
                </li>
              {% endif %}
            </ul>
          </td>
          <td>
            <ul class="list-inline mb-0">
              {% for queue in worker.queues %}
                <li class="list-inline-item">
                  <a href="{{ url_for('queue', queue_name=queue) }}">
                    <span class="badge bg-success">
                      {{ queue }}
                    </span>
                  </a>
                </li>
              {% endfor %}
            </ul>
          </td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock content %}