{% load i18n %}
{% load form_helpers %}

<div class="container-fluid tab-pane{% if active %} active{% endif %}"
     id="tab-{{ form.prefix }}">
  <div class="form form-inline"><fieldset class="well">
    {% include 'horizon/common/_form_errors.html' with form=form %}
    <h4>{% trans "Node Detail" %}</h4>
    <div class="param-section">
      <h5>{% trans "Power Management" %}</h5>
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.driver required=True %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_address required=True %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_username %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_password %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_address required=True %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_username required=True %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_key_contents required=True %}
    </div>
    <div class="param-section">
      <h5>{% trans "Networking" %}</h5>
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.mac_addresses required=True %}
    </div>
    <div class="param-section">
      <h5>{% trans "Hardware" %}</h5>
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.cpu_arch %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.cpus extra_text=_('units') %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.memory_mb extra_text=_('MB') %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.local_gb extra_text=_('GB') %}
    </div>
    <div class="param-section">
      <h5>{% trans "Deployment Images" %}</h5>
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.deployment_kernel %}
      {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.deployment_ramdisk %}
    </div>
  </fieldset></div>
</div>

<script type="text/javascript">
(window.$ || window.addHorizonLoadEvent)(function () {
  var form_prefix = '{{ form.prefix|escapejs }}';
  var $form = $('#tab-' + form_prefix);
  var undefined_name = '{{ form.get_name|escapejs }}';

  $form.find('input[name$="_address"]').change(function () {
    var $nav_link = $('a[href="#' + $form.attr('id') + '"]');
    $nav_link.html($(this).val() || undefined_name);
  });
});
</script>
