{% extends "panel.html.twig" %}

{% block head %}
    {{ parent() }}

    <script src="/js/clipboard.min.js"></script>
    <script src="/js/pages/invites.js"></script>
{% endblock %}

{% block panel_contents %}
    <h1>Servers</h1>
    {% if message %}
        <div class="error-message">{{ message }}</div>
    {% endif %}
    <ul class="servers">
        {% for server in servers %}
            <li>
                <div class="text">
                    {{ server.getFQDN() }}
                </div>
                <div class="actions">
                    <span class="details"><a target="_blank" href="/panel/server/{{ server.getFingerprint() }}/config">download config</a></span>
                    <span class="details"><a href="/panel/server/{{ server.getFingerprint() }}">details</a></span>
                    {% if user.isSuperUser() %}
                        <span class="edit"><a href="/panel/server/{{ server.getFingerprint() }}/edit">edit</a></span>
                    {% endif %}
                </div>
            </li>
        {% else %}
            <li>
                There are no servers :(
            </li>
        {% endfor %}
    </ul>
    {% if superuser %}
        <h1>Registered servers</h1>
        <ul class="servers">
        {% for server in registered_servers %}
            <li>
                <div class="text">
                    {{ server.getFingerprint() }}
                </div>
                <div class="actions">
                    <span class="delete">
                        <form action="/panel/server/remove" method="post">
                            <input type="hidden" value="{{ server.getFingerprint() }}" name="fingerprint">
                            <button type="submit">remove</button>
                        </form>
                    </span>
                    <span class="edit" >
                        <a href="/panel/server/{{ server.getFingerprint() }}/edit">edit</a>
                    </span>
                </div>
            </li>
        {% else %}
            <li>No servers registered</li>
        {% endfor %}
        </ul>
    {% endif %}
{% endblock %}