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

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

<table class="table table-condensed well searchtable" id="datatable" style="font-size:12px;">
    <thead>
        <tr>
            <th>{% trans "Time" %}</th>
            <th>{% trans "Author" %}</th>
            <th colspan=2>{% trans "Host" %}</th>
            <th colspan=2>{% trans "Service" %}</th>
            <th>{% trans "Start Time" %}</th>
            <th>{% trans "End Time" %}</th>
            <th>{% trans "Duration" %}</th>
            <th>{% trans "Comment" %}</th>
        </tr>
    </thead>
    <tbody>
    {% for i in downtimes %}
        <tr class="mainrow" id="downtime_{{ i.id }}">
            <td class="nowrap">{{ i.entry_time|timestamp|date:'Y-m-d H:i' }}</td>
            <td>
                <a href="{% url 'status.views.detail' %}?contact_name={{ i.author }}">{{ i.author }}</a>
            </td>
            <td class=small>
                <div class="circle state_{{ i.host_state }}"></div>
            </td>
            <td>
                <a href="{% url 'status.views.detail' %}?host_name={{ i.host_name }}">
                    {{ i.host_display_name }}
                </a>
            </td>
            <td class=small>
                <div class="circle state_{{ i.service_state }}"></div>
            </td>
            <td>
                <a href="{% url 'status.views.detail' %}?host_name={{ i.host_name }}&service_description={{ i.service_description }}">
                    {{ i.service_display_name}}
                </a>
            </td>
            <td>
                {{ i.start_time|timestamp|date:'Y-m-d H:i' }}
            </td>
            <td>
                {{ i.end_time|timestamp|date:'Y-m-d H:i' }}

            </td>
            <td>
                {{ i.duration|duration }}
            </td>
            <td>{{ i.comment }}</td>
            <td>
                <button class="close delete_downtime" data-dismiss="alert" title="Delete downtime {{ i.id }}" onclick="remove_downtime('{{ i.id }}', '{{ i.is_service }}');">
                    <i class="glyph-bin"></i>
                </button>
            </td>

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

</table>
<script>
    function remove_downtime(downtime_id, is_service) {
        var args = {};
        args['downtime_id'] = downtime_id;
        args['is_service'] = is_service;
        adagios.rest.status.delete_downtime(args)
                .done(function(data) {
                    $("#downtime_" + downtime_id).hide();
                });
    }
</script>
<!-- snippet status_downtimelist_snippet.html ends -->
