{% extends "base.html" %}
{% block content %}

    <h1>⚙️ Admin Panel</h1>

    <!-- USERS -->
    <div class="card">

        <h2>👤 Users</h2>

        <p class="small">
            Create, edit and manage system users and permissions.
        </p>

        <a href="{{ url_for('users.list_users') }}" class="btn">
            Open User Management
        </a>

    </div>


    <!-- KNOWLEDGE -->
    <div class="card">

        <h2>🔐 Knowledge Governance</h2>

        <p class="small">
            Invalidate outdated knowledge or manually add validated information to the RAG base.
        </p>

        <a href="{{ url_for('admin.invalidate_page') }}" class="btn">
            Open Governance Tools
        </a>

    </div>

    <div class="card">

        <h2>♻️ Maintenance</h2>

        <p class="small">
            Reload all knowledge indexes, embeddings and caches without restarting the server.
        </p>

        <button class="btn" onclick="rebootSystem()">
            Reload Knowledge
        </button>

        <pre id="rebootResult" style="margin-top:10px;"></pre>

    </div>
    <script>
        async function rebootSystem() {

            const box = document.getElementById("rebootResult");
            box.textContent = "⏳ Reloading...";

            const res = await fetch("/admin/reboot", {
                method: "POST"
            });

            const data = await res.json();

            box.textContent = "✅ " + data.message;
        }
    </script>
{% endblock %}