{% extends "base_status.html" %}

{% block title %}State History{% endblock %}
{% block smallheader %}{% endblock %}
{% block largeheader %}State History
{% endblock %}
{% block nav1 %}{{ block.super }}{% endblock %}
{% block nav2 %}<a href="{% url status.views.state_history %}">State History</a>{% endblock %}
{% load adagiostags %}
{% block toolbar %}{% endblock %}
{% block content %}
    {{ log|length }} lines in logfile
    <table class="table">
    <tr>
        <th title="{{  start_time}}">Start Time: {{ start_time|timestamp|date:'Y-m-d H:i' }}</th>
        <th>End Time: {{ end_time|timestamp|date:'Y-m-d H:i' }}</th>
        <th>Total Duration: {{ total_duration }}</th>
    </tr>
    </table>
    <table class="table table-condensed well">
    <tr style="white-space: nowrap">
        <th>Host</th>
        <th>Service </th>
        <th>SLA %</th>
        <th># alerts</th>
        <th>Timeline</th>
    </tr>

    {% for service in services.values %}
        {% if service.num_problems > 1 %}
        <tr>
        <td>
            <a href="{% url adagios.status.views.status_detail %}?host_name={{ service.host_name }}">{{ service.host_name }}</a>
        </td>
        <td class="nowrap">
            {% if service.service_description %}
                <a href="{% url adagios.status.views.status_detail %}?host_name={{ service.host_name }}&service_description={{ service.service_description }}">{{ service.service_description }}</a>
            {% else %}
                <a href="{% url adagios.status.views.status_detail %}?host_name={{ service.host_name }}">Host Status</a>
            {% endif %}
        </td>
        <td>{{ service.sla|floatformat }}%</td>
            <td><a href="{% url status.views.status_log %}?host_name={{ service.host_name }}&service_description={{ service.service_description }}">{{ service.num_problems }}</a></td>
            <td width=500px>

            <div width="500px" class="progress">
            {% for line in service.log %}
                {%  if line.time != line.end_time or 1 == 1 %}
                <div title="{{ line.time|timestamp|date:'Y-m-d H:i' }} - {{ line.status }} - {{ line.plugin_output }}"  class="bar bar-{{ line.bootstrap_status }}" style=" width: {{ line.duration_percent }}%;"></div>
                {% endif %}
            {% endfor %}

            </div>
        <!--
                <table border=1>
            {% for line in service.log %}
                <tr>
                <td>{{ line.time|timestamp|date:'Y-m-d H:i' }}</td>
                <td>{{ line.end_time|timestamp|date:'Y-m-d H:i' }}</td>
                <td>{{ line.duration }}</td>
                    <td>{{ line.duration_percent }}</td>
                </tr>
            {% endfor %}
                </table>
            -->




        </td>
        </tr>
        {% endif %}
    {% endfor %}
    </table>
{% endblock %}


{% block footer %} {{ block.super }} {% endblock %}