{% extends 'console/metrics_base.html' %}
{% load console_tags %}

{% block content %}

    <h3><b>{{ tag }}</b> Tag</h3>
    {% if tagged_containers %}
        <h4>Containers</h4>

        <ul class="nav nav-tabs">
          <li class="{% if not active_panel %}active{% endif %}">
              <a href="#container_list" data-toggle="tab">List</a>
          </li>
          <li{% if active_panel == 'metrics' %} class="active"{% endif %}>
              <a href="#container_metrics" data-toggle="tab">Metrics</a>
          </li>
        </ul>

        <!-- Tab panes -->
    <div class="tab-content">

        <!-- Container List -->
        <div class="tab-pane{% if not active_panel %} active{% endif %}" id="container_list">
            <div class="table-responsive">
                <table class="table table-hover table-bordered tablesorter">
                    <thead>
                        <tr>
                            <th>UID</th>
                            <th>Name</th>
                            <th>Hostname</th>
                            <th>Server</th>
                            <th>Tags</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for c in tagged_containers %}
                        <tr>
                            <td><a href="{% url 'console_containers' id=c.uid %}">{{ c.uid }}</a></td>
                            <td>{{ c.name }}</td>
                            <td>{{ c.hostname }}</td>
                            <td>{{ c.server }}</td>
                            <td>
                                {% for t in c.tags %}
                                    <a href="{% url 'console_tag' t %}">{{ t }}</a>{% if not forloop.last %}, {% endif %}
                                {% endfor %}
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>


        <!--Container Metrics -->
        <div class="tab-pane{% if active_panel == 'container_metrics' %} active{% endif %}" id="container_metrics">
            {% get_metrics_list container_per_tag as metrics %}
            {% include "console/metrics.html" with arg=tag id='containers' calendar=calendar_containers %}
        </div>
    </div>

    {% else %}
        No Containers tagged<br/>
    {% endif %}

    {% if tagged_domains %}
        <h4>Domains</h4>
        <ul class="nav nav-tabs">
          <li class="{% if not active_panel %}active{% endif %}">
              <a href="#domain_list" data-toggle="tab">Info</a>
          </li>
          <li{% if active_panel == 'domain_metrics' %} class="active"{% endif %}>
              <a href="#domain_metrics" data-toggle="tab">Metrics</a>
          </li>
        </ul>


        <!-- Tab panes -->
        <div class="tab-content">

            <!-- DOMAIN LIST -->
            <div class="tab-pane{% if not active_panel %} active{% endif %}" id="domain_list">
                <div class="table-responsive">
                    <table class="table table-hover table-bordered tablesorter">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Name</th>
                                <th>UUID</th>
                                <th>Tags</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for d in tagged_domains %}
                            <tr>
                                <td><a href="{% url 'console_domain' id=d.id %}">{{ d.id }}</a></td>
                                <td>{{ d.name }}</td>
                                <td>{{ d.uuid }}</td>
                                <td>
                                    {% for t in d.tags %}
                                        <a href="{% url 'console_tag' t %}">{{ t }}</a>{% if not forloop.last %}, {% endif %}
                                    {% endfor %}
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>

            <!-- DOMAIN METRICS -->
            <div class="tab-pane{% if active_panel == 'domain_metrics' %} active{% endif %}" id="domain_metrics">
                {% get_metrics_list domain_per_tag as metrics %}
            {% include "console/metrics.html" with arg=tag id='domains' calendar=calendar_domains %}
            </div>
        </div>
    {% else %}
        No Domains tagged<br/>
    {% endif %}
{% endblock %}

{% block footer_js %}
    {{ block.super }}
    <script>
        var subject = '{{ tag }}';
    </script>
    <script src="{{ STATIC_URL }}console/js/multiple_metrics.js"></script>

{% endblock %}

