{% extends "stampo.htm" %}
{% block title %}Riassunti{% endblock %}
{% block content %}
    <br>
    <h3>Lista dei riassunti disponibili</h3>
    <table class="table table-hover">
        <thead>
        <tr>
            <th scope="col">Nome</th>
            <th scope="col">Autore</th>
            <th scope="col">Azioni</th>
        </tr>
        </thead>
        <tbody>
        {% for riassunto in riassunti %}
            <tr>
                <th> {{ riassunto.nome }}</th>
                <th> {{ riassunto.autore.nome }} {{ riassunto.autore.cognome }}</th>
                <th>
                    <button type="button" class="btn btn-primary" data-toggle="modal"
                            data-target="#exampleModalCenter{{ riassunto.sid }}">
                        <i class="fas fa-binoculars"></i>
                    </button>

                    <!-- Modal -->
                    <div class="modal fade" id="exampleModalCenter{{ riassunto.sid }}" tabindex="-1" role="dialog"
                         aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-centered" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title"
                                        id="exampleModalLongTitle{{ riassunto.sid }}">{{ riassunto.nome }}</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    {{ riassunto.descrizione }}
                                    <br>
                                    <h6>N° download: {{ riassunto.downloads }}</h6>
                                    <br>
                                    <h6>Modifiche al file:</h6>
                                    {% for commit in riassunto.commit %}
                                        <ul>{{ commit.data.day }}/{{ commit.data.month }}/{{ commit.data.year }} {{ commit.data.hour }}:{{ commit.data.minute }} - {{ commit.descrizione }}</ul>
                                    {% endfor %}
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
                                    <a type="button" class="btn btn-primary"
                                       href="{{ url_for("page_inspect_riassunto", sid=riassunto.sid) }}" target="_blank">Download</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </th>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endblock %}
