{% extends "base_list.html" %}

{% block title %}Last 10 scrobble imports by source{% endblock %}

{% block lists %}
{% if tsv_imports %}
<div class="row">
    <h3>Audioscrobbler</h3>
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            <tbody>
                {% for obj in tsv_imports %}
                <tr>
                    <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                    <td>{{obj.processed_finished}}</td>
                    <td>{{obj.process_count}}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endif %}

{% if lastfm_imports %}
<div class="row">
    <h3>LastFM</h3>
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            {% for obj in lastfm_imports %}
            <tr>
                <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                <td>{{obj.processed_finished}}</td>
                <td>{{obj.process_count}}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endif %}

{% if retroarch_imports %}
<div class="row">
    <h3>Retroarch</h3>
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            {% for obj in retroarch_imports %}
            <tr>
                <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                <td>{{obj.processed_finished}}</td>
                <td>{{obj.process_count}}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endif %}

{% if birding_csv_imports %}
<div class="row">
    <h3>eBird</h3>
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            {% for obj in birding_csv_imports %}
            <tr>
                <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                <td>{{obj.processed_finished}}</td>
                <td>{{obj.process_count}}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endif %}

{% if bgstats_imports %}
<div class="row">
    <h3>BG Stats</h3>
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            {% for obj in bgstats_imports %}
            <tr>
                <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                <td>{{obj.processed_finished}}</td>
                <td>{{obj.process_count}}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endif %}

{% if koreader_imports %}
<div class="row">
    <h3>KOReader</h3>
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            {% for obj in koreader_imports %}
            <tr>
                <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                <td>{{obj.processed_finished}}</td>
                <td>{{obj.process_count}}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endif %}

{% if birding_csv_imports %}
<div class="row">
    <h3>eBird</h3>
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            <tbody>
                {% for obj in birding_csv_imports %}
                <tr>
                    <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                    <td>{{obj.processed_finished}}</td>
                    <td>{{obj.process_count}}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endif %}

<div class="row">
    <h3>Scale</h3>
    {% if scale_csv_imports %}
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            <tbody>
                {% for obj in scale_csv_imports %}
                <tr>
                    <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                    <td>{{obj.processed_finished}}</td>
                    <td>{{obj.process_count}}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% endif %}
    <form action="{% url 'scrobbles:scale-csv-upload' %}" method="post" enctype="multipart/form-data" style="margin-top: 10px;">
        {% csrf_token %}
        <input type="file" name="csv_file" accept=".csv" required>
        <input type="submit" value="Import Scale CSV">
    </form>
</div>

<div class="row">
    <h3>Trail GPX</h3>
    {% if trail_gpx_imports %}
    <div class="table-responsive">
        <table class="table table-striped table-sm">
            <thead>
                <tr>
                    <th scope="col">Started</th>
                    <th scope="col">Finished</th>
                    <th scope="col">Scrobbles</th>
                </tr>
            </thead>
            <tbody>
                {% for obj in trail_gpx_imports %}
                <tr>
                    <td><a href="{{obj.get_absolute_url}}">{{obj.human_start}}</a></td>
                    <td>{{obj.processed_finished}}</td>
                    <td>{{obj.process_count}}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% endif %}
    <form action="{% url 'scrobbles:trail-gpx-upload' %}" method="post" enctype="multipart/form-data" style="margin-top: 10px;">
        {% csrf_token %}
        <input type="file" name="gpx_file" accept=".gpx,.fit" required>
        <input type="submit" value="Import Trail GPX">
    </form>
</div>
{% endblock %}
