{% extends 'series-layout.html' %}

{% block menu %}
{{ series_menu('Exports') }}
{% endblock %}

{% block series_title %}
<h2 class="h4">Exports</h2>
{% endblock %}

{% block series_content %}
{% if exports|count > 0 %}
<ul class="list-group"></ul>
{% for export in exports|sort(attribute='date', reverse=True) %}
{% if export.date %}
    <li class="list-group-item">
        <form method='POST' >
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <input type="hidden" name="fileid" value="{{ export.db_id }}">
            <input type="hidden" name="filename" value="{{ export.filename }}">
            <div class="row align-items-center">
                <div class="col-lg">
                    <div class="row">
                        <span> {{ export.query_parameters.frame_types|join(', ') }} </span>
                    </div>
                    <div class="row">
                        <small>From {{ export.query_parameters.start_date|ts_datetime }} to {{ export.query_parameters.end_date|ts_datetime }}</small>
                    </div>
                    <div class="row">
                        <small class='text-muted'> Exported: {{ export.date|ts_datetime }}</small>
                    </div>
                </div>
                <div class="col-lg-auto mt-lg-0 mt-2">
                    <div class='btn-group'>
                        <button type='submit' class="btn btn-primary" formaction="{{ url_for('.download') }}">Download</button>
                        <button
                            type="button"
                            class="btn btn-primary dropdown-toggle dropdown-toggle-split"
                            data-bs-toggle="dropdown"
                            aria-expanded="false">
                                <span class="visually-hidden">Toggle Dropdown</span>
                          </button>
                          <ul class="dropdown-menu">
                            <li>
                                <button
                                    type="submit"
                                    class="dropdown-item"
                                    formaction="{{ url_for('.remove_export', seriesid=series.series_id, blockevaluationid=block_evaluation.db_id, sourcename=source_name) }}">
                                    Remove
                                </button>
                            </li>
                          </ul>
                    </div>
                </div>
            </div>
        </form>
    </li>
{% endif %}
{% endfor %}
</ul>
{% else %}
<div class="alert alert-info">
    No exports available.
</div>
{% endif %}
{% endblock %}
