{% extends '_base.html' %}
{% load static from staticfiles %}
{% load form_helpers %}

{% block content %}
<form action="." method="post" class="form form-horizontal">
    {% csrf_token %}
    {% for field in form.hidden_fields %}
        {{ field }}
    {% endfor %}
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            {% if form.non_field_errors %}
                <div class="panel panel-danger">
                    <div class="panel-heading"><strong>Errors</strong></div>
                    <div class="panel-body">
                        {{ form.non_field_errors }}
                    </div>
                </div>
            {% endif %}
            <div class="panel panel-default">
                <div class="panel-heading">{% block title %}Connect {{ consoleserverport.device }} {{ consoleserverport }}{% endblock %}</div>
                <div class="panel-body">
                    <ul class="nav nav-tabs" role="tablist">
                        <li role="presentation" class="active"><a href="#search" aria-controls="search" role="tab" data-toggle="tab">Search</a></li>
                        <li role="presentation"><a href="#select" aria-controls="home" role="tab" data-toggle="tab">Select</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="search">
                            {% render_field form.livesearch %}
                        </div>
                        <div class="tab-pane" id="select">
                            {% render_field form.site %}
                            {% render_field form.rack %}
                            {% render_field form.device %}
                        </div>
                    </div>
                    {% render_field form.port %}
                    {% render_field form.connection_status %}
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-9 col-md-offset-3">
                    <button type="submit" name="_update" class="btn btn-primary">Connect</button>
                    <a href="{{ return_url }}" class="btn btn-default">Cancel</a>
                </div>
            </div>
        </div>
    </div>
</form>
{% endblock %}

{% block javascript %}
<script src="{% static 'js/livesearch.js' %}?v{{ settings.VERSION }}"></script>
{% endblock %}
