{% extends "base.html" %}

{% set active_page = "logged-in-user" %}

{% block title %} Your user overview {% endblock %}

{% block divs %}


    <h2> Overview for logged-in user: {{ logged_in_user.username }} </h2>

    <div class="container-fluid">
        <div class="row">
        <div class="col-sm-1">
            <form action="/logout" method="get">
                <button class="btn btn-sm btn-responsive btn-info" type="submit">Log out</button>
            </form>
        </div>
        <div class="col-sm-2">
            <form action="/users/reset_password_for/{{ logged_in_user.id }}" method="get">
                <button class="btn btn-sm btn-responsive btn-info" type="submit">Send password reset instructions</button>
            </form>
        </div>
        <div class="col-sm-9">
            {% if user_is_admin %}
            <form action="/users" method="get">
                <button class="btn btn-sm btn-responsive btn-info" type="submit">List active users</button>
            </form>
            {% endif %}
        </div>

        <div class="row" style="margin-top: 4em;">
            <div class="col-sm-12">
                <table class="table">
                    <tbody>
                        <tr>
                            <td>
                                Email address
                            </td>
                            <td>
                                {{logged_in_user.email }}
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Account
                            </td>
                            <td>
                                {{ logged_in_user.account.name }}
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Time Zone
                            </td>
                            <td>
                                {{logged_in_user.timezone }}
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Last login was
                            </td>
                            <td>
                                {{ logged_in_user.last_login_at | localized_datetime }}
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Assets owned
                            </td>
                            <td>
                                <a href="/assets">{{ num_assets }}</a>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Roles
                            </td>
                            <td>
                                {{ roles }}
                            </td>
                        </tr>
                        {% if not user_is_anonymous %}
                        <tr>
                            <td>
                                Fresh access token
                            </td>
                            <td>
                                {{ logged_in_user.get_auth_token() }}
                            </td>
                        </tr>
                        {% endif %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

{% endblock %}
