<!DOCTYPE html>

<!--
Keel - PSH Middleware
Copyright 2017-2018 Purism SPC
https://source.puri.sm/liberty/psh_middleware
SPDX-License-Identifier: AGPL-3.0
-->

<html lang="en">
<head>
    <link rel="stylesheet" href="{% static 'layout.css' %}"/>
    <link rel="stylesheet" href="{% static 'theme.css' %}"/>
    <title>{% trans "User profile" %}</title>
    <link rel="icon" sizes="960x960" href="{% static 'favicon.png' %}"/>
    <meta name="application-name" content="{{ site_title }}"/>
    <meta charset="UTF-8"/>
</head>

<body>

<header>

    <div id="title_box">
        <a href="{% url 'home' %}"><img class="logo" src="{% static 'logo.png' %}" alt="{{ site_title }}"/></a>
        <div id="title_text">
            <h1>{% trans "User profile" %}</h1>
            <p>{% trans "Service credit and profile management" %}</p>
        </div>
    </div>

    <div id="log_state">
        {% if request.user.is_authenticated %}
        {% trans "Logged in as" %} {{ username }}<br/>
        <em>{% trans "Profile" %}</em> |

        {% if request.user.is_superuser %}
        <a href="{% url 'admin:index' %}">{% trans "Admin" %}</a> |
        {% endif %}

        <a href="{% url 'auth_logout' %}">{% trans "Log out" %}</a>
        {% else %}
        {% trans "You are not logged in." %}<br/>
        <a href="{% url 'auth_login' %}">{% trans "Log in" %}</a> {% trans "or" %}
        <a href="{% url 'registration_register' %}">{% trans "register." %}</a>
        {% endif %}
    </div>

</header>

<hr/>

<main>
    <article>

        <h2>{% trans "Services" %}</h2>

        <table>

            <thead>
            <tr>
                <th>{% trans "Service" %}</th>
                <th>{% trans "Active" %}</th>
                <th>{% trans "Renews/Expires" %}</th>
                <th>{% trans "Credit" %}</th>
            </tr>
            </thead>

            <tbody>
            {% for limit in limits %}

            <tr>
                <th class="row_header">{{ limit.service_label() }}</th>
                <td>{{ limit.active_label() }}</td>
                <td title="{{ limit.endpoint_full_label() }}">{{ limit.endpoint_short_label() }}</td>
                <td>{{ limit.credit_label() }}</td>
            </tr>

            {% endfor %}
            </tbody>

        </table>

        <h2>{% trans "Downloads" %}</h2>

        <ul>
            {% if has_limit["TUNNEL"] %}
            <li><a href="{% url 'ovpn_userfile' %}">{% trans "Tunnel certificate" %}</a></li>
            <li><a href="https://source.puri.sm/liberty/services/wikis/tunnel-desktop" target="_blank">{% trans "Tunnel
                setup instructions"
                %}</a>
            </li>
            {% endif %}
            {% if has_limit["NONE"] %}
            <li>None. If you have just subscribed, please refresh after 5 mins and your downloads will appear.</li>
            {% endif %}
        </ul>

        {% if DEBUG_CHANGE_PASSWORD %}
        <h2>{% trans "Profile management" %}</h2>

        <ul>
            <li><a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a></li>
        </ul>
        {% endif %}

    </article>

    <nav>
        <ul>

            {% for section, link_ordered_dict in link_profile_ordered_dict.items() %}
            <li>
                {{ section }}
                <ul>

                    {% for name, link in link_ordered_dict.items() %}
                    <li><a href="{{ link }}" class="page">{{ name }}</a></li>
                    {% endfor %}

                </ul>
            </li>
            {% endfor %}

        </ul>
    </nav>

</main>

<footer>
    <div id="footer_block">

        <p>
            <em>{{ site_title }}</em> provided by <a href="{{ site_provider_link }}">{{ site_provider }}</a><br/>
            <em>Keel - PSH Middleware</em> copyright 2017-2018 Purism SPC; shared under AGPL-3.0-or-later
            (<a href="https://source.puri.sm/liberty/psh_middleware">project</a>,
            <a href="{% url 'download-zip' %}">source</a>,
            <a href="{% url 'jslicense' %}" rel="jslicense">javascript</a>)
        </p>

    </div>
</footer>

</body>
</html>

