{# Source code of the Ubuntu-it website
 # Copyright (C) 2018  Pietro Albini <pietroalbini@ubuntu.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published
 # by the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; witout even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU Affero General Public License for more details.
 #
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #}

{% extends "layout.html" %}

{% block title %}Dettagli sessione{% endblock %}

{% block content %}
    <div class="page">
        <div class="row">
            <div class="col">
                <h1>Dettagli sessione</h1>

                <div class="table">
                    <table>
                        <tr>
                            <td>Nome utente</td>
                            <td><b>{{ session.nickname }}</b></td>
                        </tr>
                        <tr>
                            <td>Indirizzo IP</td>
                            <td>{{ session.ip }}</td>
                        </tr>
                        <tr>
                            <td>Scadenza</td>
                            <td>{{ session.expires_at|format_timestamp }}</td>
                        </tr>
                        <tr>
                            <td>Team</td>
                            <td>
                                {% for team in session.teams %}
                                    <a href="https://launchpad.net/~{{ team }}">
                                        ~{{ team -}}
                                    </a>
                                    {%- if not loop.last %},{% endif %}
                                {% endfor %}
                            </td>
                        </tr>
                    </table>
                </div>

                {% if g.auth_id != session.id %}
                <a class="btn" href="{{ url_for(".sessions_revoke", id=session.id) }}">
                    Disabilita sessione
                </a>
                {% endif %}
            </div>
        </div>
        {% if others %}
        <div class="row">
            <div class="col">
                <h2>Altre sessioni dell'utente</h2>
                <div class="table">
                    <table>
                        <tr>
                            <th>Indirizzo IP</th>
                            <th>Scadenza</th>
                            <th></th>
                            <th></th>
                        </tr>
                        {% for session in others %}
                        <tr>
                            <td>{{ session.ip }}</td>
                            <td>{{ session.expires_at|format_timestamp }}
                            <td>
                                <a href="{{ url_for(".sessions_show", id=session.id) }}">
                                    Dettagli
                                </a>
                            </td>
                            <td>
                                {% if session.id == g.auth_id %}
                                Sessione corrente
                                {% else %}
                                <a href="{{ url_for(".sessions_revoke", id=session.id) }}">
                                    Disabilita sessione
                                </a>
                                {% endif %}
                            </td>
                        </tr>
                        {% endfor %}
                    </table>
                </div>
            </div>
        </div>
        {% endif %}
    </div>
{% endblock %}
