{% extends "web/_base.html" %}
{% block navbar_left %}
    {{ block.super }}
    {% include "web/_collection-menu.html" with collection=collection only %}
{% endblock %}
{% block title %}Collection {{ collection.name }}{% endblock %}
{% block content %}
    <h1>{{ collection.name }} {{ collection.category }} collection</h1>
    <h2>Details</h2>
    <table class="table table-hover">
        <tbody>
            <tr>
                <th>Full history retention period (days)</th>
                <td>{{ collection.full_history_retention_period.days|default:"Always" }}</td>
            </tr>
            <tr>
                <th>Metadata only retention period (days)</th>
                <td>{{ collection.full_history_retention_period.days|default:"Always" }}</td>
            </tr>
            <tr>
                <th>Retains artifacts</th>
                <td>{{ collection.retains_artifacts }}</td>
            </tr>
            <tr>
                <th>Workspace</th>
                <td>
                    <a href="{% url 'workspaces:detail' wname=collection.workspace.name %}">{{ collection.workspace.name }}</a>
                </td>
            </tr>
            {% if collection.workflow %}
                <tr>
                    <th>Workflow</th>
                    <td>
                        <a href="{% url 'work_requests:detail' pk=collection.workflow.pk %}">{{ collection.workflow }}</a>
                    </td>
                </tr>
            {% endif %}
            {% if data_yaml %}
                <tr>
                    <th>Data</th>
                    <td>
                        <pre>{{data_yaml}}</pre>
                    </td>
                </tr>
            {% endif %}
        </tbody>
    </table>
    <h2>Contents</h2>
    {% if not collections and not artifacts %}
        <p>The collection is empty</p>
    {% else %}
        <a class="btn btn-primary"
           href="{% url 'workspaces:collections:search' wname=collection.workspace.name cname=collection.name ccat=collection.category %}">Search collection</a>
    {% endif %}
    {% if collections %}
        <h3>Collections</h3>
        <table class="table table-sm table-hover">
            <thead>
                <tr>
                    <th>Category</th>
                    <th>Count</th>
                </tr>
            </thead>
            <tbody>
                {% for a in collections %}
                    <tr>
                        <th>{{ a.category }}</th>
                        <td>{{ a.count }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% if artifacts %}
        <h3>Artifacts</h3>
        <table class="table table-sm table-hover">
            <thead>
                <tr>
                    <th>Category</th>
                    <th>Count</th>
                </tr>
            </thead>
            <tbody>
                {% for a in artifacts %}
                    <tr>
                        <th>{{ a.category }}</th>
                        <td>{{ a.count }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endblock %}
