<!--

    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 %}Clusters{% endblock %}

{% block content %}


<table>
<thead>
    <tr>
        {% column_header clusters 'name' 'Cluster' %}
        {% column_header clusters 'numTopics' 'Topics' %}

        {% column_header clusters 'localRateIn' 'Local Rate In' %}
        {% column_header clusters 'localRateOut' 'Local Rate Out' %}
        {% column_header clusters 'replicationRateIn' 'Replication Rate In' %}
        {% column_header clusters 'replicationRateOut' 'Replication Rate Out' %}

        {% column_header clusters 'localBacklog' 'Local Backlog' %}
        {% column_header clusters 'replicationBacklog' 'Replication Backlog' %}
        {% column_header clusters 'storage' 'Storage' %}
    </tr>
</thead>
<tbody>

{% for cluster in clusters.results %}
    <tr class="{% cycle 'row1' 'row2' %}">
        <th>{{cluster.name}}</th>

        <td>{{cluster.numTopics | intcomma}}</td>
        <td>{{cluster.localRateIn | intcomma}}</td>
        <td>{{cluster.localRateOut | intcomma}}</td>
        <td>{{cluster.replicationRateIn | intcomma}}</td>
        <td>{{cluster.replicationRateOut | intcomma}}</td>

        <td>{{cluster.localBacklog | intcomma}}</td>
        <td>{{cluster.replicationBacklog | intcomma}}</td>
        <td>{{cluster.storage | filesizeformat}}</td>
    </tr>

    <tr class="{% cycle 'row1' 'row2' %}">
        <td></td>
        <td colspan="6">
            <table>
            <thead>
                <tr>
                    <th>Remote Cluster</th>
                    <th title="Msg/s">Rate in</th>
                    <th title="Msg/s">Rate out</th>
                    <th>Mbps in</th>
                    <th>Mbps out</th>
                    <th title="Messages">Replication backlog</th>
                </tr>
            </thead>
            <tbody>
            {% for peer in cluster.peers %}
                <tr>
                    <td>{{peer.remote_cluster__name}}</td>
                    <td title="{{peer.remote_cluster__name}} ⟶ {{cluster.name}}">{{peer.msgRateIn__sum | intcomma}}</td>
                    <td title="{{cluster.name}} ⟶ {{peer.remote_cluster__name}}">{{peer.msgRateOut__sum | intcomma}}</td>
                    <td title="{{peer.remote_cluster__name}} ⟶ {{cluster.name}}">{{peer.msgThroughputIn__sum | mbps | floatformat | intcomma}}</td>
                    <td title="{{cluster.name}} ⟶ {{peer.remote_cluster__name}}">{{peer.msgThroughputOut__sum | mbps | floatformat | intcomma}}</td>
                    <td title="{{cluster.name}} ⟶ {{peer.remote_cluster__name}}">{{peer.replicationBacklog__sum | intcomma}}</td>
                </tr>
            {% empty %}
                <tr><td>No replication</tr></td>
            {% endfor %}
            </tbody>
            </table>
        </td>
    </tr>


{% empty %}
    <tr><td>No Clusters</td></tr>
{% endfor %}
</tbody>
</table>

{% table_footer clusters %}

{% endblock %}
