{% extends "web/_base.html" %}
{% block title %}List of tokens{% endblock %}
{% block content %}
    <h1>List of tokens</h1>
    <p>
        Here you can generate and maintain the API tokens that are needed to
        <a href="https://freexian-team.pages.debian.net/debusine/howtos/set-up-debusine-client.html">set up debusine-client</a>
        to access this instance of Debusine.
    </p>
    <p>
        Here is an example <tt>~/.config/debusine/client/config.ini</tt> file you can use:
        <pre>
    [General]
    default-server = {{DEBUSINE_FQDN}}

    [server:{{DEBUSINE_FQDN}}]
    api-url = https://{{DEBUSINE_FQDN}}/api
    token = generated-token-goes-here
    </pre>
    </p>
    {% if token_list %}
        <table class="table table-sm">
            <thead>
                <tr>
                    <th>Enabled</th>
                    <th>Created at</th>
                    <th>Comment</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                {% for token in token_list %}
                    <tr>
                        <td>{% include "web/_check_icon.html" with value=token.enabled only %}</td>
                        <td>{{ token.created_at }}</td>
                        <td>{{ token.comment }}</td>
                        <td>
                            <a href="{% url "user:token-delete" pk=token.pk %}">Delete</a>&nbsp;|&nbsp;<a href="{% url "user:token-edit" pk=token.pk %}">Edit</a>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="5">
                        <a class="btn btn-primary btn-sm"
                           type="button"
                           href="{% url "user:token-create" %}">Create another token</a>
                    </td>
                </tr>
            </tfoot>
        </table>
    {% else %}
        <p>
            You do not currently have any tokens:
            {% if user.is_authenticated %}
                <a href="{% url "user:token-create" %}">create a new token</a>
                to be able to use debusine-client.
            {% else %}
                you can authenticate to create one.
            {% endif %}
        </p>
    {% endif %}
{% endblock %}
