{% extends "statusboard/base.html" %}

{% load humanize %}
{% load statusboard_extras %}
{% load i18n %}

{% block content %}
<div class="container">
    {% for m in maintenances %}
    <div class="alert alert-info" role="alert">
        <p>
        <strong>{{ m.name }} - {% trans 'scheduled in' %} <abbr title="{{ m.scheduled|date:"r" }}">{{ m.scheduled|naturaltime }}</abbr></strong>
        {% if perms.statusboard.delete_maintenance %}
        <small><a href="{% url 'statusboard:maintenance:delete' pk=m.id %}">{% trans 'delete' %}</a></small>
        {% endif %}
        {% if perms.statusboard.edit_maintenance %}
        <small><a href="{% url 'statusboard:maintenance:edit' pk=m.id %}">{% trans 'edit' %}</a></small>
        {% endif %}
        </p>
        <p>
            {{ m.description }}
        </p>
    </div>
    {% endfor %}
    {% if worst_status != None %}
    <div class="alert alert-{{ worst_status|service_status_class:"" }}" role="alert">
        {{ worst_status|service_status_summary_text:"" }}
    </div>
    {% endif %}
    {% for grp in statusgroups %}
    <div class="servicegroup">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>{{ grp.name }}</strong>
                {% if perms.statusboard.delete_servicegroup %}
                <small><a href="{% url 'statusboard:servicegroup:delete' pk=grp.id %}">{% trans 'delete' %}</a></small>
                {% endif %}
                {% if perms.statusboard.edit_servicegroup %}
                <small><a href="{% url 'statusboard:servicegroup:edit' pk=grp.id %}">{% trans 'edit' %}</a></small>
                {% endif %}
        </div>
        <ul class="list-group">
            {% for srv in grp.services.all %}
            <li class="list-group-item clearfix">
                {% if srv.href %}
                <a href="{{ srv.href }}">{{ srv.name }}</a>
                {% else %}
                <span>{{ srv.name }}</span>
                {% endif %}

                {% if perms.statusboard.delete_service %}
                <small><a href="{% url 'statusboard:service:delete' pk=srv.id %}">{% trans 'delete' %}</a></small>
                {% endif %}
                {% if perms.statusboard.edit_service %}
                <small><a href="{% url 'statusboard:service:edit' pk=srv.id %}">{% trans 'edit' %}</a></small>
                {% endif %}

                <span class="label label-{{ srv.status|service_status_class:"" }} pull-right">{{ srv.get_status_display }}</span>
                <br/><small class="timeinfo">last update <abbr title="{{ srv.modified|date:"r" }}">{{ srv.modified|naturaltime }}</abbr></small>
            </li>
            {% endfor %}
        </ul>
        </div>
    </div>
    {% endfor %}

    {% if incidents %}
    <div class="incidents">
        <h2>
            {% trans 'Past Incidents' %}
            {% if perms.statusboard.incident_create %}
            <small><a href="{% url "statusboard:incident:create" %}">{% trans 'create' %}</a></small>
            {% endif %}
        </h2>
        {% include "statusboard/incident/list_snippet.html" with incidents=incidents perms=perms only %}
    </div>
    {% endif %}
</div>
{% endblock %}
