{% extends "layout.html" %}
{% from "_formhelpers.html" import render_field %}
{% block content %}
          <div class="row">
            <div class="col-xs-12 col-md-6 col-lg-6">
              <div class="panel panel-default panel-border-color panel-border-color-primary">
                <div class="panel-heading panel-heading-divider">Network Configuration</div>
                <div class="panel-body">
                  {% if not is_network_configuration_enabled %}
                    <div role="alert" class="alert alert-primary alert-dismissible">
                      <button type="button" data-dismiss="alert" aria-label="Close" class="close">
                        <span aria-hidden="true" class="mdi mdi-close"></span></button>
                      <span class="icon mdi mdi-info-outline"></span>Network configuration is disabled (for developer protection). Actual changes will not be applied
                    </div>
                  {% endif %}
                  {% if not is_network_configuration_supported %}
                    <div role="alert" class="alert alert-danger alert-dismissible">
                      <button type="button" data-dismiss="alert" aria-label="Close" class="close">
                        <span aria-hidden="true" class="mdi mdi-close"></span></button>
                      <span class="icon mdi mdi-close-circle-o"></span>Network configuration is not supported for this platform
                    </div>
                  {% elif not network_interface %}
                    <div role="alert" class="alert alert-danger alert-dismissible">
                      <button type="button" data-dismiss="alert" aria-label="Close" class="close">
                        <span aria-hidden="true" class="mdi mdi-close"></span></button>
                      <span class="icon mdi mdi-close-circle-o"></span>Network interface for configuration could not be reliably determined (probably multiple interfaces were detected)
                      {% if settings.is_debug_mode() %}
                          <p>Consider setting interface name explicitly in <pre>{{ settings.get_settings_filename() }}</pre> with <code>configurable_network_interface</code> parameter (this message is shown in debug mode only)</p>
                      {% endif %}
                    </div>
                  {% else %}
                    <form method="post" novalidate="" class="form-horizontal group-border-dashed">
                      {{ form.csrf_token }}
                      {{ form.network_interface }}
                      {{ render_field(form.dhcp) }}
                      <div id="static_ip_fields">
                        {{ render_field(form.ip_address, placeholder='Enter IP Address') }}
                        {{ render_field(form.subnet_mask, placeholder='Enter Subnet Mask') }}
                        {{ render_field(form.default_gateway, placeholder='Enter Default Gateway') }}
                        {{ render_field(form.name_servers, placeholder='Enter Name Servers (comma separated)') }}
                      </div>
                      <div>
                        <p class="text-right">
                          <button type="submit" class="btn btn-space btn-primary">Apply and reboot</button>
                          {% if is_network_configuration_supported and is_configuration_restorable %}
                            <button type="submit" name="action" value="network_reset" class="btn btn-space btn-primary"
                                    onclick="return confirm('Are you sure you want to reset network configuration?');">Reset and reboot</button>
                          {% endif %}
                          <a href="javascript:window.location.href=window.location.href" class="btn btn-space btn-default">Cancel</a>
                        </p>
                      </div>
                    </form>
                  {% endif %}
                </div>
              </div>
            </div>
          </div>
{% endblock %}
{% block extra_js %}
  <script src="/assets/js/network.js" type="text/javascript"></script>
{% endblock %}
