{% extends "base.html" %}

{% load i18n %}

{% block title %}{% trans "Add Host" %}{% endblock %}
{% block smallheader %}{% trans "Add" %}{% endblock %}
{% block largeheader %}{% trans "Host" %}{% endblock %}
{% block toolbar %}{% endblock %}
{% block nav2 %}<a href="{% url "adagios.okconfig_.views.addhost" %}">{% trans "Add Host" %}</a>{% endblock %}

{% block content %}
    <br/>
	<form action="#" method="post" class="form-horizontal">{% csrf_token %}
        {% include "bootstrap_fields.html" with fields=form %}
        <div class="form-actions">
            <button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
        </div>
	</form>
{% endblock %}



{% block footer %}
    {{ block.super }}
    <!-- DNS lookup for the address field -->
    <script>
        $('#id_host_name').focusout(function() {
            if ($('#id_address').val() == "") {
                var parameters = {};
                parameters['host_name'] = $(this).val();
                adagios.rest.pynag.dnslookup(parameters)
                        .done( function(data) {
                            $('#id_address').val(data['addresslist'][0]);
                        }
                );
            }
        });
    </script>

{% endblock %}
