{% extends "base.html" %}

{% block title %}Repo: {{ repo.repo_id }} - Airut Dashboard{% endblock %}

{% block body %}
<div class="page" hx-ext="sse" sse-connect="/api/events/stream?format=html&repo_id={{ repo.repo_id }}">
    <div class="card">
        <h1>{{ repo.repo_id }}</h1>

        <div class="field">
            <div class="field-label">Status</div>
            <div class="field-value">
                {% include "components/repo_status_badge.html" %}
            </div>
        </div>

        <div class="field">
            <div class="field-label">Git Repository</div>
            <div class="field-value mono">{{ repo.git_repo_url }}</div>
        </div>
        {% if repo.channels %}
        {% for ch in repo.channels %}
        <div class="field">
            <div class="field-label">Channel: {{ ch.channel_type }}</div>
            <div class="field-value mono">
                {% if ch.detail %}{{ ch.detail }} <span class="field-hint">({{ ch.info }})</span>
                {% else %}{{ ch.info }}{% endif %}
            </div>
        </div>
        {% endfor %}
        {% else %}
        <div class="field">
            <div class="field-label">Channels</div>
            <div class="field-value mono">(none)</div>
        </div>
        {% endif %}
        <div class="field">
            <div class="field-label">Storage Directory</div>
            <div class="field-value mono">{{ repo.storage_dir }}</div>
        </div>
        <div id="error-section" sse-swap="repo-error" hx-swap="innerHTML">
            {% include "components/repo_error_section.html" %}
        </div>
    </div>
</div>
<div id="stream-status" class="stream-status">Connecting...</div>
{% endblock %}

{% block scripts %}
<script src="{{ static_url('vendor/htmx.min.js') }}"></script>
<script src="{{ static_url('vendor/sse.min.js') }}"></script>
<script src="{{ static_url('js/sse-fallback.js') }}"></script>
{% endblock %}
