{% extends "layout.html" %}
{% set title = "Dashboard - OD-Database" %}

{% block body %}
    <div class="container">
        <div class="card">
            <div class="card-header">Dashboard</div>
            <div class="card-body">

                <a href="/logs">Logs</a>
                <br>
                <hr>
                <h3>API Keys</h3>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Token</th>
                        <th>Action</th>
                    </tr>
                    </thead>

                    <tbody>
                    {% for token in api_tokens %}
                        <tr>
                            <td>{{ token.name }}</td>
                            <td><code>{{ token.token }}</code></td>
                            <td>
                                <form action="/del_token" method="post">
                                    <input type="hidden" value="{{ token.token }}" name="token">
                                    <input type="submit" class="btn btn-danger" value="Delete">
                                </form>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
                <form action="/generate_token" method="post">
                    <div class="form-row">
                        <div class="col col-md-10">
                            <input class="form-control" name="description" placeholder="Description">
                        </div>
                        <div class="col col-md-2">
                            <input type="submit" class="form-control btn btn-primary" value="Generate API token">
                        </div>
                    </div>
                </form>

                <br>
                <hr>
                <h3>Blacklist</h3>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>Netloc</th>
                        <th>Action</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for item in blacklist %}
                        <tr>
                            <td>{{ item.netloc }}</td>
                            <td><a class="btn btn-danger" href="/blacklist/{{ item.id }}/delete">Delete</a></td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
                <form class="form" action="/blacklist/add" method="POST">
                    <div class="form-row">
                        <div class="col col-md-10">
                            <input class="form-control" name="url" placeholder="Url">
                        </div>
                        <div class="col col-md-2">
                            <input type="submit" class="form-control btn btn-primary" value="Add">
                        </div>
                    </div>
                </form>

                <br>
                <hr>
                <h3>Misc actions</h3>

                <a class="btn btn-danger" href="/website/delete_empty">Delete websites with no associated files that are
                    not queued</a>

                <hr>
                <a class="btn btn-info" href="/logout">Logout</a>
            </div>
        </div>
    </div>
{% endblock body %}
