<!--

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.

-->
{% extends "stats/base.html" %}

{% load humanize %}
{% load table %}
{% load stats_extras %}

{% block title %}Brokers{% endblock %}

{% block content %}

<div class="module filtered" id="changelist">
<div id="changelist-filter">
    <h2>Clusters</h2>
<ul>
   <li {% if not selectedCluster %}class="selected"{% endif %}>
       <a href="{% url 'brokers' %}">All</a></li>

   {% for cluster in clusters.all %}
      <li {% if selectedCluster == cluster.name %}class="selected"{% endif %}
          ><a href="{% url 'brokers_cluster' cluster %}">{{cluster}}</a></li>
   {% endfor %}

   <li>
</ul>
</div>
</div>

<table>
<thead>
    <tr>
        {% column_header brokers 'url' 'Broker' %}
        {% column_header brokers 'numBundles' 'Bundles' %}
        {% column_header brokers 'numTopics' 'Topics' %}
        {% column_header brokers 'numProducers' 'Producers' %}
        {% column_header brokers 'numSubscriptions' 'Subscriptions' %}
        {% column_header brokers 'numConsumers' 'Consumers' %}
        {% column_header brokers 'rateIn' 'Rate In' %}
        {% column_header brokers 'rateOut' 'Rate Out' %}
        {% column_header brokers 'throughputIn' 'Mbps In' %}
        {% column_header brokers 'throughputOut' 'Mbps Out' %}
        {% column_header brokers 'backlog' 'Backlog' %}
    </tr>
</thead>
<tbody>

{% for broker in brokers.results %}
    <tr class="{% cycle 'row1' 'row2' %}">
        <th>
            <a href="{% url 'broker' broker.url %}">{{broker.url}}</a>
        </th>
        <td>{{broker.numBundles | safe_intcomma}}</td>
        <td>{{broker.numTopics | safe_intcomma}}</td>
        <td>{{broker.numProducers | safe_intcomma}}</td>
        <td>{{broker.numSubscriptions | safe_intcomma}}</td>
        <td>{{broker.numConsumers | safe_intcomma}}</td>
        <td>{{broker.rateIn | safe_intcomma}}</td>
        <td>{{broker.rateOut | safe_intcomma}}</td>
        <td>{{broker.throughputIn | mbps | floatformat | intcomma}}</td>
        <td>{{broker.throughputOut | mbps | floatformat | intcomma}}</td>
        <td>{{broker.backlog | safe_intcomma}}</td>
    </tr>
{% empty %}
    <tr><td>No Brokers</td></tr>
{% endfor %}
</tbody>
</table>

{% table_footer brokers %}

{% endblock %}
