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

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

<table class="statustable table table-condensed well searchtable" id="datatable">
    <thead>
    <tr>
        <th class="small">
            <div class="btn-group" class="select_bar">
                <a class="" data-toggle="dropdown" href="#">
                    <input 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 class="hidden-phone">{% trans "Host" %}</th>
        <th>{% trans "Service Check" %}</th>
        <td class="small"></td>
        <th class="hidden-phone">{% trans "Duration" %}</th>
        <th class="hidden-phone">{% trans "Last Check" %}</th>
    </tr>
    </thead>
    <tbody class="">
        {% for service in services %}
            <tr class="mainrow">
                <td class="selectable">
                    <input class="chkbox {{ service.tags }}"  type="checkbox" name="service" value="{{ service.host_name }}/{{ service.description }}" data-host_name="{{ service.host_name }}" data-object_type="service" data-service_description="{{ service.description }}" data-backend="{{ service.backend }}">
                    <input type="hidden" class="input_hostname" name="host_name" value="{{ service.host_name }}">
                    <input type="hidden" class="input_service_description" name="service_description" value="{{ service.description }}">
                </td>

                <td class="host hidden-phone">
                    {% ifchanged service.host_name %}
                        <div title="{{ service.host_plugin_output }}" class="circle  host state_{{ service.host_state }}"></div>
                        <a href="{% url 'status.views.detail' %}?host_name={{ service.host_name }}&backend={{ service.backend }}" title='{% blocktrans with host=service.host_name %}Details for host {{ host }}{% endblocktrans %}'>{{ service.host_name }}</a>
                        <span class="pull-right right-of-host"></span>
                    {% else %}
                        <div class="repeated_content hide">
                            <div title="{{ service.host_plugin_output }}" class="circle host state_{{ service.host_state }}"></div>
                            <a href="{% url 'status.views.detail' %}?host_name={{ service.host_name }}&backend={{ service.backend }}" title='{% blocktrans with host=service.host_name %}Details for host {{ host }}{% endblocktrans %}'>{{ service.host_name }}</a>
                        </div>
                    {% endifchanged %}
                </td>
                <td class="service">
                    <!-- Show hostname inside this table if we are on a phone layout -->
                    <div class="visible-phone">
                        <div title="{{ service.host_plugin_output }}" class="circle  host state_{{ service.host_state }}"></div>
                        <a href="{% url 'status.views.detail' %}?host_name={{ service.host_name }}&backend={{ service.backend }}" title='{% blocktrans with host=service.host_name %}Details for host {{ host }}{% endblocktrans %}'>{{ service.host_name }}</a>
                        <span class="pull-right right-of-host"></span>
                    </div>
                    <!-- Here is the service description -->
                    <a href="{% url 'status.views.detail' %}?host_name={{ service.host_name }}&service_description={{ service.description }}&backend={{ service.backend }}" title='{% blocktrans with status=service.status last_change=service.last_state_change|timestamp|timesince %}{{ status }} for the past {{ last_change }}{% endblocktrans %}'>
                        <div class="circle circle_{{ service.unhandled }}  state_{{ service.state }}{{ service.unhandled }}"> </div> {{ service.description }}
                    </a>

                    <!-- Here is plugin output -->
                    <!-- TODO: Instead of all this slicing crap... proper ellipse effect in CSS -->
                    <span>
		      <span style="overflow: hidden;" title="{{ service.plugin_output }}" class="visible-desktop service_description_short plugin_output">
                        {{ service.plugin_output|slice:"50" }}
                      </span>
		    </span>

                    <span class="pull-right right-of-service"></span>
                </td>
                <td class="small">
                    {% if service.comments_with_info  %}
                        <i class="glyph-chat glyph-grey" data-placement=left rel=tooltip title="Comments" data-content="{% for i in service.comments_with_info %}<div class='alert alert-info'><b>{{ i.1 }}:</b> {{ i.2 }}</div>{% endfor %}"></i>
                    {% endif %}
                </td>
                <td class="service_small hidden-phone">
                    {% if service.last_state_change != 0 %}
                        <span title="{{ service.last_state_change|timestamp|date:'Y-m-d H:i' }}">
                            {{ service.last_state_change|timestamp|timesince }}
                        </span>
                    {% endif %}
                </td>
                <td class="service_small hidden-phone">
                    {% if service.last_check != 0 %}
                        <span title="{{ service.last_check|timestamp|date:'Y-m-d H:i' }}">
                            {% blocktrans with lc=service.last_check|timestamp|timesince %}{{ lc }} ago{% endblocktrans %}
			</span>
                    {% else %}
                    {% trans "never" %}
                    {% endif %}
                </td>
                <!-- <td class="state_{{ service.state }}"><b>{{ service.status }}</b></td> -->
            </tr>
        {% endfor %}
    </tbody>
</table>
{% if services|length == settings.livestatus_limit %}
    {% blocktrans with length=services|length %}Results limited to {{ length }} services{% endblocktrans %}
    <a href="{{ request.get_full_path }}?&limit=0">{% blocktrans %}See all{% endblocktrans %}</a>

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

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