<div class="channels__channel channels__channel--wifi">
  <div class="channels-protocol-list">
    <div class="channels-protocol__item"
        ng-class="{'channels-protocol__item--active': wifi.active}">
      <div class="channels-protocol-title" translate>WiFi</div>
      <div class="channels-protocol-status-list">
        <channel-status-item ng-show="showChannelStatus()" active="wifi.active" error="isError()">
          <div class="channels-protocol-status-list__item-title"
               ng-switch="wifi.state">
            <span ng-switch-when="NONE" translate>Идет инициализация</span>
            <span ng-switch-when="WAIT_LINK" translate>Подключаемся к точке доступа</span>
            <span ng-switch-when="DHCP" translate>Идет получение настроек по DHCP</span>
            <span ng-switch-when="NO_LINK" ng-switch="getNoLinkStatus()">
              <span ng-switch-when="no_link_timeout" translate>Сеть не найдена</span>
              <span ng-switch-when="no_link_auth_failed" translate>Ошибка авторизации</span>
              <span ng-switch-when="no_link_dhcp" translate>Ошибка получения настроек по DHCP</span>
              <span ng-switch-default translate>Не удалось подключиться к точке доступа</span>
            </span>
            <span ng-switch-when="DHCP_FAILED" translate>Ошибка получения настроек по DHCP</span>
            <span ng-switch-when="SC_CONNECTION_FAILED">
              <span ng-if="!sambo.isActive()" translate>Ошибка подключения к «Центру охраны»</span>
              <span ng-if="sambo.isActive()" translate>Ошибка подключения к «Облачному пульту»</span>
            </span>
            <span ng-switch-when="STOPPED" translate>Канал остановлен</span>
          </div>
        </channel-status-item>

        <channel-status-item ng-show="showConnectionInfo()" active="wifi.active" error="isError()">
          <div class="channels-protocol-status-list__item-title"
              ng-switch="wifi.state">
            <span ng-switch-when="READY">
              <span ng-if="!sambo.isActive()" translate>Идет подключение к «Центру охраны»</span>
              <span ng-if="sambo.isActive()" translate>Идет подключение к «Облачному пульту»</span>
            </span>
            <span ng-switch-when="WORKING">
              <span ng-if="!sambo.isActive()" translate>Подключено к «Центру охраны»</span>
              <span ng-if="sambo.isActive()" translate>Подключено к «Облачному пульту»</span>
            </span>
            <span ng-switch-default>
              <span ng-if="!sambo.isActive()" translate>Нет подключения к «Центру охраны»</span>
              <span ng-if="sambo.isActive()" translate>Нет подключения к «Облачному пульту»</span>
            </span>
          </div>
          <div
              class="channels-protocol-status-list__item-subtitle">
            {[ utils.SCAddress(wifi.address_port_pair) ]}
          </div>
        </channel-status-item>

        <channel-status-item ng-show="showConnectionInfo()"
                             active="wifi.active" error="isError() || isCloudError()">
          <div class="channels-protocol-status-list__item-title"
              ng-switch="wifi.state">
            <span ng-switch-when="READY" translate>Идет подключение к Облаку</span>
            <span ng-switch-when="WORKING">
              <span ng-if="wifi.cloud_connected" translate>
                Подключено к Облаку
              </span>
              <span ng-if="!wifi.cloud_connected" translate>
                Нет подключения к Облаку
              </span>
            </span>
            <span ng-switch-default translate>Нет подключения к Облаку</span>
          </div>
          <div only-desktop
              class="channels-protocol-status-list__item-subtitle">
            {[ utils.cloudAddress() ]}
          </div>
        </channel-status-item>

        <!-- Сеть и уровень сигнала -->
        <div class="channels-wifi-network" ng-if="wifi.ssid">
          <span translate>Сеть:</span> {[ wifi.ssid ]}
          <img ng-if="showSignalBars()" ng-src="augeas/current/images/{[ getSignalIcon() ]}" class="channels-wifi-signal-icon" />
        </div>

        <!-- Дополнительная информация (спойлер) -->
        <div class="channels-wifi-extended" ng-if="hasExtendedInfo()">
          <div class="channels-wifi-spoiler-toggle" ng-click="toggleExtendedInfo()">
            <span class="channels-wifi-spoiler-arrow" ng-class="{'channels-wifi-spoiler-arrow--expanded': extendedInfoExpanded}">&#9654;</span>
            <span translate>Дополнительно...</span>
          </div>
          <div class="channels-wifi-spoiler-content" ng-show="extendedInfoExpanded">
            <div class="channels-wifi-info-row" ng-if="formatMac(wifi.bssid)">
              <span class="channels-wifi-info-label">BSSID:</span>
              <span class="channels-wifi-info-value">{[ formatMac(wifi.bssid) ]}</span>
            </div>
            <div class="channels-wifi-info-row" ng-if="wifi.rssi !== null && wifi.rssi !== undefined">
              <span class="channels-wifi-info-label">RSSI:</span>
              <span class="channels-wifi-info-value">{[ wifi.rssi ]} <span translate>dBm</span></span>
            </div>
            <div class="channels-wifi-info-row" ng-if="formatMac(wifi.hw_addr)">
              <span class="channels-wifi-info-label">MAC:</span>
              <span class="channels-wifi-info-value">{[ formatMac(wifi.hw_addr) ]}</span>
            </div>
            <div class="channels-wifi-info-row" ng-if="wifi.dhcp_enabled !== null && wifi.dhcp_enabled !== undefined">
              <span class="channels-wifi-info-label">DHCP:</span>
              <span class="channels-wifi-info-value" ng-if="wifi.dhcp_enabled" translate>включен</span>
              <span class="channels-wifi-info-value" ng-if="!wifi.dhcp_enabled" translate>выключен</span>
            </div>
            <div class="channels-wifi-info-row" ng-if="formatIp(wifi.ip_addr)">
              <span class="channels-wifi-info-label" translate>Локальный IP-адрес:</span>
              <span class="channels-wifi-info-value">{[ formatIp(wifi.ip_addr) ]}</span>
            </div>
            <div class="channels-wifi-info-row" ng-if="formatIp(wifi.netmask)">
              <span class="channels-wifi-info-label" translate>Маска подсети:</span>
              <span class="channels-wifi-info-value">{[ formatIp(wifi.netmask) ]}</span>
            </div>
            <div class="channels-wifi-info-row" ng-if="formatIp(wifi.gw)">
              <span class="channels-wifi-info-label" translate>IP-адрес шлюза:</span>
              <span class="channels-wifi-info-value">{[ formatIp(wifi.gw) ]}</span>
            </div>
            <div class="channels-wifi-info-row" ng-if="formatIp(wifi.dns1)">
              <span class="channels-wifi-info-label" translate>Основной DNS:</span>
              <span class="channels-wifi-info-value">{[ formatIp(wifi.dns1) ]}</span>
            </div>
            <div class="channels-wifi-info-row" ng-if="formatIp(wifi.dns2)">
              <span class="channels-wifi-info-label" translate>Вторичный DNS:</span>
              <span class="channels-wifi-info-value">{[ formatIp(wifi.dns2) ]}</span>
            </div>
          </div>
        </div>

      </div>
      <div class="channels-protocol-messages">{[ wifi.events_delivered ]}</div>
      <channel-activator channel-type="wifi" channel-num="0" channel-active="wifi.active"/>
    </div>
  </div>
</div>
