{% extends "layout/base.html" %}
{% set active_page = "arrivals" %}

{% block title %}Recent Arrivals{% endblock %}

{% block content %}
    <div class="panel highlight">
        <h2 class="followed lonesome">Recent Dataset Arrivals</h2>
        <span class="header-follow">
            over {{ period_length.days }} days
            <a href="{{ url_for('pages.arrivals_csv') }}" class="badge header-badge">
                csv
                <i class="fa-solid fa-file-csv" aria-hidden="true"></i>
            </a>
            <a href="{{ url_for('stac.arrivals') }}" class="badge header-badge">
                As Stac Catalog
                <i class="fa-solid fa-file-text" aria-hidden="true"></i>
            </a>
        </span>
    </div>
    <div class="panel overflowable">
        <table class="data-table">
                <thead>
                    <tr>
                        <th>Product</th>
                        <th class="numeric">New Datasets</th>
                        <th>Examples</th>
                    </tr>
                </thead>
            {% for day, arrivals in arrival_days %}
                <thead>
                    <tr class="section-header">
                        <th colspan="3">{{ day.strftime('%d %B %Y') }}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for arrival in arrivals %}
                        <tr>
                            <td>{{- arrival.product_name | product_link  -}}</td>
                            <td class="numeric important-column">{{  '{:,d}'.format(arrival.dataset_count) }}</td>
                            <td>
                                {% for dataset_id in arrival.sample_dataset_ids -%}
                                    <a href="{{ url_for('dataset.dataset_page', id_=dataset_id) }}"
                                       class="badge"
                                       title="Example {{ arrival.product_name }} arrival {{ loop.index }}"
                                    ><i class="fa-solid fa-image" aria-hidden="true"></i></a>&nbsp;
                                {% endfor %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            {% else %}
                <tr><td>No datasets in index</td></tr>
            {% endfor %}
        </table>
    </div>

{% endblock %}
