<!-- snippet status_hostlist_snippet.html starts -->

{% load adagiostags %}
{% load i18n %}

<table class="table table-condensed well searchtable" id="hoststable" style="font-size:12px;">
    <thead>
    <tr>
        <th class="small">
            <div class="btn-group" class="select_bar">
                <a class="" data-toggle="dropdown" href="#">
                    <input style="margin-left: -1px; padding: 0px;" type="checkbox" class="select_many">
                </a>
                <ul class="dropdown-menu">
                    <li><a class="select_all">{% trans " All" %}</a></li>
                    <li><a class="select_none">{% trans " None" %}</a></li>
                    <li><a class="select_unhandled_problems" >{% trans " Unhandled Problems" %}</a></li>
                    <li><a class="select_problems">{% trans " All Problems" %}</a></li>
                </ul>
            </div>
        </th>
        <th></th>
        <th>{% trans "Host Name" %}</th>
        <th>{% trans "Address" %}</th>
        <th>{% trans "Duration" %}</th>
        <th>{% trans "Last Check" %}</th>
        <th>{% trans "Host Status" %}</th>
        <th>{% trans "Service Status" %}</th>
    </tr>
    </thead>
    <tbody>
    {% for row in hosts %}
        <tr class="mainrow" id="row_{{ forloop.counter }}" >
            <td class="selectable small">
                <input class="chkbox"  type="checkbox" name="host" data-host_name="{{ row.name }}" data-object_type="host" value="{{ row.name }}" style="margin: -1px; padding: 0px;">
                <input type="hidden" class="input_hostname" name="host_name" value="{{ row.name }}">
            </td>
            <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.detail' %}?host_name={{ row.name }}">
                    {{ row.name }}
                </a>
            </td>
            <td>{{ row.address }}</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.last_check == 0 %}
            <td class="alert alert-info">{% trans "Pending" %}</td>
            {% else %}
                {% if row.state  == 0 %}
                <td class="alert alert-success">{% trans "Host UP" %}</td>
                {% else %}
                    {% if row.state  == 3 %}
                        <td class="alert alert-success">{% trans "Pending" %}</td>
                    {% else %}
                        <td class="alert alert-danger">{% if row.childs %}{% trans "Network outage" %} {% else %}{% trans "Host Down" %} {% endif %}</td>
                    {% endif %}
                {% endif %}
            {% 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.detail' %}?host_name={{ row.name }}&service_description={{ i.0 }}">{{i.0 }}</a> - {{ i.3 }}
                    </span>
                </td>
            </tr>
        {% endfor %}
    {% endfor %}
    </tbody>
</table>
{% if hosts|length == settings.livestatus_limit %}
    {% blocktrans with length=hosts|length %}Results limited to {{ length }} hosts{% endblocktrans %}
    <a href="{{ request.get_full_path }}?&limit=0">{% blocktrans %}See all{% endblocktrans %}</a>

{% else %}
    {% blocktrans with length=hosts|length %}{{ length }} hosts found.{% endblocktrans %}
{% endif %}

<!-- snippet status_hostlist_snippet.html ends -->
