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

<table class="table table-condensed well searchtable" id="datatable" style="font-size:12px;">
    <thead>
        <tr>
            <th>Time</th>
            <th>Author</th>
            <th colspan=2>Host</th>
            <th colspan=2>Service</th>
            <th>Start Time</th>
            <th>End Time</th>
            <th>Duration</th>
            <th>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.contact_detail i.author %}">{{ i.author }}</a>
            </td>
            <td class=small>
                <div class="circle state_{{ i.host_state }}"></div>
            </td>
            <td>
                <a href="{% url status.views.status_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.status_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 -->
