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

{% if hostgroups %}
    <table class="table well table-condensed searchtable" style="font-size:12px;" >
        <tr>
            <th class="small">
                <div class="btn-group" id="select_bar">
                    <a class="" data-toggle="dropdown" href="#">
                        <input style="margin-left: -1px; padding: 0px;" type="checkbox" id="select_many">
                    </a>
                    <ul class="dropdown-menu">
                        <li><a id="select_all"> All</a></li>
                        <li><a id="select_none"> None</a></li>
                        <li><a id="select_unhandled_problems" > Unhandled Problems</a></li>
                        <li><a id="select_problems"> All Problems</a></li>
                    </ul>
                </div>
            </th>
            <th ></th>
            <th>Hostgroup</th>
            <th>Child Hostgroups</th>
            <th>Parent Hostgroups</th>
            <th>Hosts</th>
            <th>Services</th>
            <th>Health</th>
            <th colspan=2>Service Status</th>
        </tr>
        {% for row in hostgroups %}
            {% if row.members|length > 0 %}
                <tr >
                    <td class="selectable small">
                        <input class="chkbox"  type="checkbox" name="hostgroup" value="{{ row.name }}" style="margin: -1px; padding: 0px;">
                    </td>

                    <td onclick='$(".subrow_{{ forloop.counter }}").toggle();'>
                        <div class="pull-right subrow_{{ forloop.counter }}"><a href="#">&#x25b7;</a></div>
                        <div class="pull-right subrow_{{ forloop.counter }} hide"><a href="#">&#x25bd;</a></div>
                    </td>
                    <td><a href="{% url status.views.status_hostgroup row.name %}">{{ row.name }}</a></td>
                    <td>
                        <div title="{{ row.child_hostgroups }}">
                            {{ row.child_hostgroups|length }}
                        </div>
                    </td>
                    <td>
                        <div title="{{ row.parent_hostgroups }}">
                            {{ row.parent_hostgroups|length }}
                        </div>
                    </td>
                    <td>
                        {{ row.members|length }}
                    </td>
                    <td>
                        {{ row.total }}
                    </td>

                    <td>
                        {% if row.health > -1 %}
                            {{ row.health|floatformat }}%
                        {% else %}
                            0
                        {% endif %}
                    </td>

                    <td>
                        <div title="{{ row.total  }} services -- {{ row.problems }} problems" 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_hostgroups %}
                    <tr  class="subrow subrow_{{ forloop.parentloop.counter }} hide">
                        <td></td>
                        <td colspan=7><a href="{% url status.views.status_hostgroup i %}">{{ i }}</a></td>
                    </tr>
                {% endfor %}

                {% for i in row.members_with_state %}
                    <tr  class="subrow subrow_{{ forloop.parentloop.counter }} hide">
                        <td></td>
                        <td colspan=7>
                            <div class="circle state_{{ i.1 }}"></div>
                            <span>
                                <a href="{% url status.views.status_detail %}?host_name={{ i.0 }}">{{ i.0 }}</a>
                            </span>
                        </td>
                    </tr>
                {% endfor %}
            {% else %}
                <!-- hostgroup {{ row.name }} was empty and therefor skipped -->
            {% endif %}
        {% endfor %}
    </table>
{% else %}
{% endif %}
<!-- snippet status_hostgrouplist_snippet.html ends -->
