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

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

    <script src="/js/edit_server.js"></script>
{% endblock %}

{% block content %}
    <div class="container">
        <div data-fingerprint="{{ server.getFingerprint() }}" class="row server-form">
            <div class="col-md-6 col-md-offset-3">
                <div class="row">
                    <h2>Editing server '{{ server.getFqdn() }}'</h2>
                </div>
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="control-label col-md-4" for="fqdn">Hostname</label>
                        <div class="col-md-8">
                            <input name="fqdn" id="fqdn" type="text" class="form-control" value="{{ server.getFqdn() }}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="external-ip">External IP</label>
                        <div class="col-md-8">
                            <input name="external-ip" id="external-ip" type="text" min="-1" class="form-control" value="{{ server.getExternalIp() }}">
                        </div>
                    </div>
                    <h3>Details</h3>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="location">Location</label>
                        <div class="col-md-8">
                            <input name="location" id="location" type="text" class="form-control" value="{{ server.getLocation() }}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="speed">Speed</label>
                        <div class="col-md-8">
                            <input name="speed" id="speed" type="number" min="-1" class="form-control" value="{{ server.getSpeed() }}">
                        </div>
                    </div>
                    <h3>Config</h3>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="internal-ip">Internal IP</label>
                        <div class="col-md-8">
                            <input name="internal-ip" id="internal-ip" type="text" min="-1" class="form-control" value="{{ server.getInternalIp() ?: '10.24.0.0' }}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="speed">Netmask</label>
                        <div class="col-md-8">
                            <input name="netmask" id="netmask" type="number" min="8" max="24" class="form-control" value="{{ server.getNetmask() ?: 16 }}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="port">Port</label>
                        <div class="col-md-8">
                            <input name="port" id="port" type="number" class="form-control" value="{{ server.getPort() ?: 1194 }}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="protocol">Protocol</label>
                        <div class="col-md-8">
                            <select name="protocol" id="protocol" class="form-control">
                                <option value="udp" {{ server.getProtocol() == 'udp' ? 'selected' }}>UDP</option>
                                <option value="tcp" {{ server.getProtocol() == 'tcp' ? 'selected' }}>TCP</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="first-dns">First DNS</label>
                        <div class="col-md-8">
                            <input name="first-dns" id="first-dns" type="text" class="form-control" value="{{ server.getFirstDns() ?: '8.8.8.8' }}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-4" for="second-dns">second DNS</label>
                        <div class="col-md-8">
                            <input name="second-dns" id="first-dns" type="text" class="form-control" value="{{ server.getSecondDns() ?: '8.8.4.4' }}">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-12">
                            <div class="pull-right">
                                <button type="button" class="btn save">Save</button>
                                {% if server.getStatus() == 'registered' %}
                                    <button type="button" class="btn btn-primary save-and-sign">Sign and save</button>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}