{% extends "base.html" %}
{% block title %}Events · iVistaar{% endblock %}
{% block content %}
<div class="page-head">
  <div>
    <h1>Events</h1>
    <p class="muted">Deployment history with actor, source change time, and optional file owner.</p>
  </div>
</div>

<form method="get" class="filter-bar">
  <label>
    Project
    <select name="slug" onchange="this.form.submit()">
      <option value="">All projects</option>
      {% for d in deployments %}
      <option value="{{ d.slug }}" {% if filter_slug == d.slug %}selected{% endif %}>{{ d.name }} ({{ d.slug }})</option>
      {% endfor %}
    </select>
  </label>
</form>

{% if events %}
<table class="table">
  <thead>
    <tr>
      <th>When</th>
      <th>Project</th>
      <th>Actor</th>
      <th>Event</th>
      <th>Status</th>
      <th>Source mtime</th>
      <th>Source owner</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    {% for e in events %}
    <tr>
      <td>{{ e.created_at }}</td>
      <td><a href="{{ url_for('admin.deploy_detail', slug=e.slug) }}">{{ e.slug }}</a></td>
      <td><code>{{ e.actor or '—' }}</code></td>
      <td><span class="event-type">{{ e.event_type }}</span></td>
      <td><span class="status status-{{ e.status }}">{{ e.status }}</span></td>
      <td>{{ e.source_mtime or '—' }}</td>
      <td>{{ e.source_owner or '—' }}</td>
      <td class="msg-cell">{{ e.message or '—' }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% else %}
<div class="empty"><p>No events yet. Connect a project and deploy to start the record.</p></div>
{% endif %}
{% endblock %}
