<div class="bottom-10">
  <div ng-show="!desktopMode" class="alert alert-warning" translate>
    Указанные настройки применятся только при подключённом модуле Ethernet.
  </div>
</div>

<div class="bottom-10">
  <div ng-show="!desktopMode" class="alert alert-danger" translate>
    Внимание! При записи некорректных сетевых настроек прибор перестанет передавать события и облачные сервисы будут недоступны. Внимательно проверьте настройки перед записью.
  </div>
</div>

<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title ng-binding" translate>Параметры Ethernet-модуля</h3>
  </div>
  <div class="panel-body">
    <form role="form" class="form-horizontal" name="EthernetForm">
      <div class="form-group"
           ng-class="EthernetForm.mac_addr.$invalid?'has-error':''"
           ng-if="showControlsForMAC()">
        <label class="control-label col-sm-3" translate>MAC-адрес</label>
        <div class="col-sm-3">
          <input type="text" class="form-control col-sm-3"
                 name="mac_addr"
                 required
                 ng-model="getEthernetSettings().mac"
                 mac
                 mac-zero-bit
                 ng-trim="false"
                 ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"
                 ng-change="formGuard(EthernetForm)">
        </div>
        <div class="col-sm-1">
          <button class="btn btn-default" type="button"
                  ng-click="generateMac(EthernetForm)">
            <span class="glyphicon glyphicon-refresh"></span>
          </button>
        </div>
        <div class="col-sm-5">
          <div ng-show="EthernetForm.mac_addr.$error.mac" class="help-block ng-hide" translate>
                Неверный формат (Пример: 00:11:22:AB:CD:EF)
          </div>
          <div ng-show="EthernetForm.mac_addr.$error.macZeroBit" class="help-block ng-hide" translate>
                Второй символ некорректный. Допустимые значения: 0, 2, 4, 6, 8, A, C, E.
          </div>
        </div>
      </div>
      <dev class="form-inline col-md-offset-3 col-md-7">
        <div class="form-group checkbox">
          <label>
            <input type="checkbox" ng-model="ethernet().dhcp_enabled"
                   ng-change="whenSelectedDHCP(EthernetForm)"
                   ng-true-value="1" ng-false-value="0">
            <translate>Получать настройки по DHCP</translate>
          </label>
        </div>
      </dev>
      <div class="form-group" ng-class="EthernetForm.ip_addr.$invalid?'has-error':''">
        <label class="control-label col-sm-3" translate>Локальный IP-адрес</label>
        <div class="col-sm-3">
          <input type="text" class="form-control col-sm-3"
                 name="ip_addr"
                 ng-model="getSettings().ip_addr"
                 ip
                 ng-trim="false"
                 masquerade="{from: '0.0.0.0', to: ''}"
                 ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"
                 ng-disabled="ethernet().dhcp_enabled"
                 ng-change="setSettings(); formGuard(EthernetForm)">
        </div>
        <div ng-show="EthernetForm.ip_addr.$invalid" class="help-block ng-hide col-sm-5" translate>
          Неверный формат (Пример: 192.168.0.1)
        </div>
      </div>
      <div class="form-group" ng-class="EthernetForm.ip_mask.$invalid?'has-error':''">
        <label class="control-label col-sm-3" translate>Маска подсети</label>
        <div class="col-sm-3">
          <input type="text" class="form-control"
                 name="ip_mask"
                 ng-model="getSettings().ip_mask"
                 subnetmask
                 ng-trim="false"
                 masquerade="{from: '0.0.0.0', to: ''}"
                 ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"
                 ng-disabled="ethernet().dhcp_enabled"
                 ng-change="setSettings(); formGuard(EthernetForm)">
        </div>
        <div ng-show="EthernetForm.ip_mask.$invalid" class="help-block ng-hide col-sm-5" translate>
          Неверный формат (Пример: 255.255.255.0)
        </div>
      </div>
      <div class="form-group" ng-class="EthernetForm.ip_gateway.$invalid?'has-error':''">
        <label class="control-label col-sm-3" translate>IP-адрес шлюза</label>
        <div class="col-sm-3">
          <input type="text" class="form-control"
                 name="ip_gateway"
                 ng-model="getSettings().ip_gateway"
                 ip
                 ng-trim="false"
                 masquerade="{from: '0.0.0.0', to: ''}"
                 ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"
                 ng-disabled="ethernet().dhcp_enabled"
                 ng-change="setSettings(); formGuard(EthernetForm)">
        </div>
        <div ng-show="EthernetForm.ip_gateway.$invalid" class="help-block ng-hide col-sm-5" translate>
          Неверный формат (Пример: 192.168.0.1)
        </div>
      </div>
      <div class="form-group" ng-class="EthernetForm.dns1.$invalid?'has-error':''">
        <label class="control-label col-sm-3" translate>Основной DNS</label>
        <div class="col-sm-3">
          <input type="text" class="form-control"
                 name="dns1"
                 ng-model="ethernet().dns1"
                 ip
                 ng-trim="false"
                 masquerade="{from: '0.0.0.0', to: ''}"
                 ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"
                 ng-change="formGuard(EthernetForm)">
        </div>
        <div ng-show="EthernetForm.dns1.$invalid" class="help-block ng-hide col-sm-5" translate>
          Неверный формат (Пример: 192.168.0.1)
        </div>
      </div>
      <div class="form-group" ng-class="EthernetForm.dns2.$invalid?'has-error':''">
        <label class="control-label col-sm-3" translate>Вторичный DNS</label>
        <div class="col-sm-3">
          <input type="text" class="form-control"
                 name="dns2"
                 ng-model="ethernet().dns2"
                 ip
                 ng-trim="false"
                 masquerade="{from: '0.0.0.0', to: ''}"
                 ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"
                 ng-change="formGuard(EthernetForm)">
        </div>
        <div ng-show="EthernetForm.dns2.$invalid" class="help-block ng-hide col-sm-5" translate>
          Неверный формат (Пример: 192.168.0.1)
        </div>
      </div>
    </form>
  </div>
</div>
