{% extends "base.html" %}
{% load filters_deploys %}

{% block header %}
<h1>Events</h1>
{% endblock %}

{% block content %}
<div class="container-fluid">
  <div class="row">
    <div class="col-md-12">
      <form action="" method="GET">
        <select name="kindName">
          <option value="">all events</option>
          {% for kind in kinds %}
          <option value="{{ kind.Name }}">{{ kind.Name }}</option>
          {% endfor %}
        </select>
        <button>filter</button>
      </form>
      <table class="events table" id="list">
        <thead>
          <tr>
            <th>Action</th>
            <th>Target</th>
            <th>Start</th>
            <th>End</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 'event-info' event.UniqueID %}">
              {{ event.Kind.Name }}
              </a>
            </td>
            <td>
              <a href="{% url 'event-info' event.UniqueID %}">
              {{ event.Target.Type }}: {{ event.Target.Value }}
              </a>
            </td>
            <td>
              {% if event.StartTime %}
              <a href="{% url 'event-info' event.UniqueID %}">
              {{ event.StartTime|string_to_date|date:" d-m-Y H:i:s " }}
              </a>
              {% endif %}
            </td>
            <td>
              {% if event.EndTime %}
              <a href="{% url 'event-info' event.UniqueID %}">
              {{ event.EndTime|string_to_date|date:" d-m-Y H:i:s " }}
              </a>
              {% endif %}
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}
