{% extends 'settings/layout.html' %}
{% load i18n %}
{% block title %}{% trans "Add instance" %}{% endblock %}

{% block header %}
{% trans "Add instance" %}
<a href="{% url 'settings-federation' %}" class="has-text-weight-normal help">{% trans "Back to instance list" %}</a>
{% endblock %}

{% block panel %}

<div class="tabs">
    <ul>
        {% url 'settings-import-blocklist' as url %}
        <li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
            <a href="{{ url }}">{% trans "Import block list" %}</a>
        </li>
        {% url 'settings-add-federated-server' as url %}
        <li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
            <a href="{{ url }}">{% trans "Add instance" %}</a>
        </li>
    </ul>
</div>

<form method="POST" action="{% url 'settings-add-federated-server' %}">
    {% csrf_token %}
    <div class="columns">
        <div class="column is-half">
            <div class="field">
                <label class="label" for="id_server_name">
                    {% trans "Instance:" %}
                </label>
                <input type="text" name="server_name" maxlength="255" class="input" required id="id_server_name" value="{{ form.server_name.value|default:'' }}" placeholder="domain.com" aria-describedby="desc_server_name">
                
                {% include 'snippets/form_errors.html' with errors_list=form.server_name.errors id="desc_server_name" %}
            </div>
        </div>
        <div class="column is-half">
            <div class="field">
                <label class="label" for="id_status">{% trans "Status:" %}</label>
                <div class="select">
                    <select name="status" class="" id="id_status">
                        <option value="federated" {% if form.status.value == "federated" %}selected=""{% endif %}>{% trans "Federated" %}</option>
                        <option value="blocked" {% if form.status.value == "blocked" or not form.status.value %}selected{% endif %}>{% trans "Blocked" %}</option>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="columns">
        <div class="column is-half">
            <div class="field">
                <label class="label" for="id_application_type">
                    {% trans "Software:" %}
                </label>
                <input type="text" name="application_type" maxlength="255" class="input" id="id_application_type" value="{{ form.application_type.value|default:'' }}" aria-describedby="desc_application_type">
                
                {% include 'snippets/form_errors.html' with errors_list=form.application_type.errors id="desc_application_type" %}
            </div>
        </div>
        <div class="column is-half">
            <div class="field">
                <label class="label" for="id_application_version">
                    {% trans "Version:" %}
                </label>
                <input type="text" name="application_version" maxlength="255" class="input" id="id_application_version" value="{{ form.application_version.value|default:'' }}" aria-describedby="desc_application_version">
                
                {% include 'snippets/form_errors.html' with errors_list=form.application_version.errors id="desc_application_version" %}
            </div>
        </div>
    </div>
    <div class="field">
        <label class="label" for="id_notes">
            {% trans "Notes:" %}
        </label>
        <textarea name="notes" cols="40" rows="5" class="textarea" id="id_notes">
            {{ form.notes.value|default:'' }}
        </textarea>
    </div>

    <button type="submit" class="button is-primary">
        {% trans "Save" %}
    </button>
</form>

{% endblock %}
