
{% extends 'base.html' %}
{% block title %}Admin Dashboard{% endblock %}
{% block content %}
<div class="page-header">
  <div>
    <h1>Admin Dashboard</h1>
    <p>Streams og brugere</p>
  </div>
  <a class="button" href="{{ url_for('main.create_streamer') }}">+ Opret streamer</a>
</div>
<section class="card">
  <h2>Streams</h2>
  <table class="stream-table">
    <thead><tr><th>Navn</th><th>Slug</th><th>Ejer</th><th>Status</th><th>Aktiv</th><th>Handlinger</th></tr></thead>
    <tbody>
      {% for s in streams %}
      {% set p = path_map.get(s.slug) %}
      {% set live = p and (p.ready or p.online) %}
      <tr>
        <td>{{ s.name }}</td>
        <td>/{{ s.slug }}</td>
        <td>{{ s.user.display_name }}</td>
        <td><span class="badge {{ 'live' if live else 'offline' }}">{{ 'LIVE' if live else 'OFFLINE' }}</span></td>
        <td>{{ 'Ja' if s.active else 'Nej' }}</td>
        <td><a class="button secondary" href="{{ url_for('main.stream_detail_admin', stream_id=s.id) }}">Detaljer</a></td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</section>
<section class="card space-top">
  <h2>Brugere</h2>
  <table class="stream-table">
    <thead><tr><th>Navn</th><th>Brugernavn</th><th>E-mail</th><th>Rolle</th><th>Status</th><th>Handlinger</th></tr></thead>
    <tbody>
      {% for u in users %}
      <tr>
        <td>{{ u.display_name }}</td>
        <td>{{ u.username }}</td>
        <td>{{ u.email }}</td>
        <td>{{ u.role }}</td>
        <td>{{ 'Aktiv' if u.active else 'Deaktiv' }}</td>
        <td>
          {% if u.role == 'streamer' %}
          <form method="post" action="{{ url_for('main.admin_send_reset', user_id=u.id) }}">
            <button type="submit" class="secondary">Send reset</button>
          </form>
          {% endif %}
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</section>
{% endblock %}
