{% extends "apps/base.html" %}
{% load filters_deploys %}
{% load staticfiles %}

{% block navbar %}
{% include "apps/navbar.html" with active="events" %}
{% endblock %}

{% block app-content %}
<div class="row">
  <div class="col-md-12" id="deploy-box">
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <table class="events table" id="list">
      <thead>
        <tr>
          <th>Action</th>
          <th>Owner</th>
          <th>Start</th>
          <th>Duration</th>
        </tr>
      </thead>
      <tbody>
        {% for event in events %}
        <tr>
          <tr class="{% if event.Running %}bg-info{% endif %}{% if event.CancelInfo.Canceled %}bg-warning{% else %}{% if event.Error %}bg-danger{% endif %}{% endif %}">
            <td>
              <a href="{% url 'app-event' app.name event.UniqueID %}">
                {{ event.Kind.Name }}
              </a>
            </td>
            <td>
              {{ event.Owner.Type }}{% if event.Owner.Name %}: {{ event.Owner.Name }}{% endif %}
            </td>
            <td>
              {% if event.StartTime %}
              {{ event.StartTime|date:" d-m-Y H:i:s " }}
              {% endif %}
            </td>
            <td>
              {% if event.EndTime and event.StartTime %}
              {{ event.StartTime|timesince:event.EndTime }}
              {% endif %}
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
      <div class="pager">
        {% if previous %}
        <span class="page">
          <a href="?page={{ previous }}">&lt; Prev</a>
        </span>
        {% endif %}

        {% if next %}
        <span class="page">
          <a href="?page={{ next }}">Next &gt;</a>
        </span>
        {% endif %}
      </div>
    </div>
  </div>
</div>
{% endblock %}
