{% extends 'base.html' %}
{% load crispy_forms_tags %}

{% block content %}
    <div class='row'>
        <div class='{% if form_size %}{{ form_size }}{% else %}col-lg-6{% endif %}'>
            <div class="card card-primary card-outline">
                {% if page_title %}
                    <div class="card-header">
                        <h3 class="card-title">{{ page_title }}</h3>
                    </div>
                {% endif %}
                <div class="card-body row">
                    <div class="col-lg-12">
                        {% csrf_token %}
                        {% crispy form %}
                    </div>
                </div>
            </div>
        </div>

        <div class='{% if form_size %}{{ form_size }}{% else %}col-lg-6{% endif %}'>
            <div class="card card-primary card-outline">

                <div class="card-header">
                    <h3 class="card-title">Get Token from WireGuard WebAdmin</h3>
                </div>

                <div class="card-body row">
                    <div class="col-lg-12">

                        <strong>Generating an API Key:</strong>
                        <p>This steps should be reproduced on the host machine for wireguard_webadmin.</p>
                        <ul>
                            <li><strong>Outside the Container:</strong>
                                <pre><code>cat /proc/sys/kernel/random/uuid &gt; /var/lib/docker/volumes/wireguard_webadmin_wireguard/_data/routerfleet_key</code></pre>
                            </li>
                            <li><strong>Inside the Container:</strong>
                                <pre><code>cat /proc/sys/kernel/random/uuid &gt; /etc/wireguard/routerfleet_key</code></pre>
                            </li>
                        </ul>
                        <p>Remember, your <code>routerfleet_key</code> should be a valid UUID.</p>
                        <strong>Warning:</strong>
                        <p>Keep this KEY protected. Currently, It's used to authenticate users without password, including your own admin account.</p>

                        <strong>Disabling the API Key:</strong>
                        <p>If you ever need to disable your API key, you can generate a new one or simply delete the <code>routerfleet_key</code> file.</p>

                    </div>
                </div>
            </div>
        </div>

    </div>
{% endblock %}

{% block custom_page_scripts %}

    <script>
        function openCommandDialog(element) {
            var command = element.getAttribute('data-command');
            var confirmation = prompt("{% if delete_confirmation_message %}{{ delete_confirmation_message }}{% else %}Please type 'delete' to proceed.{% endif %}");
            if (confirmation) {
                var url = "?action=delete&confirmation=" + encodeURIComponent(confirmation);
                window.location.href = url;
            }
        }
    </script>


{% endblock %}