{% extends "base_status.html" %}

{% load i18n %}

{% block title %}{% trans "Network Parents" %}{% endblock %}
{% block nav2 %}<a href="{% url 'status.views.network_parents' %}">{% trans "Network Parents" %}</a>{% endblock %}
{% block smallheader %}{% endblock %}
{% block largeheader %}

{% trans "Network Parents" %}
{% endblock %}

{% load adagiostags %}

{% block content %}
{% if hosts %}

    <table class="table table-condensed well" style="line-height:6px; font-size: 12px" >
    <thead>
        <tr>
        <td>
            <div class="btn-group" class="select_bar">
                <a class="" data-toggle="dropdown" href="#">
                    <input style="margin-left: -2px; padding: 0px;" type="checkbox">
                </a>
                <ul class="dropdown-menu">
                    <li><a href=""> {% trans "All" %}</a></li>
                    <li><a href=""> {% trans "None" %}</a></li>
                    <li><a href=""> {% trans "Unhandled Problems" %}</a></li>
                    <li><a href=""> {% trans "All Problems" %}</a></li>
                </ul>
            </div>
        </td>
        <th>{% trans "Host Name" %}</th>
        <th>{% trans "Address" %}</th>
        <th>{% trans "Children" %}</th>
        <th>{% trans "Duration" %}</th>
        <th>{% trans "Last Check" %}</th>
        <th>{% trans "Status" %}</th>
        <th>{% trans "Child Host Health" %}</th>
    </tr>
    </thead>
    <tbody>
        {% for row in hosts %}
        <tr onclick='$(".host_{{ forloop.counter }}").toggle();'>
            <td class=small >
                <a href="#">
                    <div class="host_{{ forloop.counter }}">&#x25b7;</div>
                    <div class="host_{{ forloop.counter }} hide">&#x25bd;</div>
                </a>
            </td>

            <td><a style="color: black" href="{% url 'status.views.detail' %}?host_name={{ row.name }}">{{ row.name }}</a></td>

            <td>{{ row.address }}</td>
            <td>
                {{ row.childs|length }}
            </td>
            <td>
                {% if row.last_state_change != 0 %}
                    <span title="{{ row.last_state_change|timestamp|date:'Y-m-d H:i' }}">
                        {{ row.last_state_change|timestamp|timesince }}
                    </span>
                {% endif %}
            </td>
            <td>
            {% if row.last_check != 0 %}
                <span title="{{ row.last_state_change|timestamp|date:'Y-m-d H:i' }}">
                {{ row.last_check|timestamp|timesince }} ago
                </span>
            {% else %}
                never
            {% endif %}
            </td>
            {% if row.state  == 0 %}
                <td class="alert alert-success">UP</td>
            {% else %}
                <td class="alert alert-danger">Down</td>
            {% endif %}
            <td>
                <div class="progress">
                    <div class="bar bar-success" style="width: {{ row.percent_ok }}%;"></div>
                    <div class="bar bar-warning" style="width: {{ row.percent_warn }}%;"></div>
                    <div class="bar bar-danger" style="width: {{ row.percent_crit }}%;"></div>
                    <div class="bar bar-unknown" style="width: {{ row.percent_unknown }}%;"></div>
                </div>
            </td>
        </tr>
            {% for i in row.child_hosts %}
                <tr style="background-color: #fafaff; font-size: 90%;" class="{{ row.name }} host_{{ forloop.parentloop.counter }} hide">
                    <td colspan=7><div style="margin-left: 10px;" class="circle state_{{ i.state }}"></div> <a href="{% url 'status.views.detail' %}?host_name={{ i.name }}">{{ i.name }}</a></td>
                </tr>
            {% endfor %}

    {% endfor %}
    </tbody>
    </table>

{% else %}
    {% trans "No Network parents found." %}
{% endif %}

{% endblock %}




