<!-- snippet status_hostlist_snippet.html starts -->
{% load adagiostags %}

<table class="table table-condensed well searchtable" id="hoststable" style="font-size:12px;">
    <thead>
    <tr>
        <th></th>
        <th>Host Name</th>
        <th>Address</th>
        <th>Last Check</th>
        <th>Host Status</th>
        <th>Service Status</th>
    </tr>
    </thead>
    <tbody>
    {% for row in hosts %}
        <tr class="mainrow" id="row_{{ forloop.counter }}" >
            <td class=small style="cursor: pointer;" onclick='$(".hostsubrow_{{ forloop.counter }}").toggle();'>
                <a href="#">
                <div class="hostsubrow_{{ forloop.counter }}">&#x25b7;</div>
                <div class="hostsubrow_{{ forloop.counter }} hide">&#x25bd;</div>
                </a>
            </td>
            <td>
                <a id="{{ row.name }}" href="{% url status.views.status_detail %}?host_name={{ row.name }}">
                    {{ row.name }}
                </a>
            </td>
            <td>{{ row.address }}</td>
            <td>
                {{ row.last_check|timestamp|timesince }} ago
            </td>
            {% if row.last_check == 0 %}
                <td class="alert alert-info">Pending</td>
            {% endif %}
            {% if row.last_check != 0 and row.state  == 0 %}
                <td class="alert alert-success">Host UP</td>
            {% endif %}
            {% if row.last_check != 0 and row.state  > 0 %}
                <td class="alert alert-danger">{% if row.childs %}Network outage {% else %}Host Down {% endif %}</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.services_with_info %}
            <tr class="subrow {{ row.name }} hostsubrow_{{ forloop.parentloop.counter }} hide">
                <td></td>
                <td colspan=5>
                    <div style="margin-left: 10px;" class="circle state_{{ i.1 }}"></div>
                    <span>
                    <a href="{% url status.views.status_detail %}?host_name={{ row.name }}&service_description={{ i.0 }}">{{i.0 }}</a> - {{ i.3 }}
                    </span>
                </td>
            </tr>
        {% endfor %}
    {% endfor %}
    </tbody>
</table>
<!-- snippet status_hostlist_snippet.html ends -->
