<!--

    Copyright (C) 2015-2016 Jeeva Kandasamy (jkandasa@gmail.com)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="container mc-top-space-1x">

  <!-- Loading icon disaplay -->
  <div ng-hide="mySensorsSettings.$resolved">
    <div ng-include src="'partials/common-html/loading.html'"></div>
  </div>

  <div ng-show="mySensorsSettings.$resolved"> <!-- Main Message -->

    <!-- MySensors -->
    <div class="col-md-12">
      <div class="card-pf card-pf-accented">
        <div class="card-pf-heading"><h2 class="card-pf-title"><i class="fa fa-star-o fa-lg"></i> {{ 'MY_SENSORS' | translate }}</h2></div>
        <div class="card-pf-body">
          <form class="form-horizontal">

            <div class="form-group">
              <label class="col-sm-2 control-label">{{ 'DEFAULT_FIRMWARE' | translate }}</label>
              <div class="col-sm-5">
                <span ng-hide="editEnable.mySensors">{{defaultFirmware || 'NOT_SET' | translate }}</span>
                <div ng-show="editEnable.mySensors">
                  <select class="form-control" pf-select data-live-search="true" ng-options="firmware.id as firmware.displayName for firmware in firmwares" ng-model="mySensorsSettings.defaultFirmware">
                    <option value="" ng-hide="true"></option>
                  </select>
                </div>
              </div>
            </div>

            <div class="form-group">
              <label class="col-sm-2 control-label" uib-tooltip="{{ 'ENABLE_DEFAULT_ON_NO_FIRMWARE_TOOLTIP' | translate }}" tooltip-placement="bottom">{{ 'ENABLE_DEFAULT_ON_NO_FIRMWARE' | translate }}</label>
              <div class="col-sm-5">
                <input bs-switch ng-change="editEnable.mySensors = true" ng-model="mySensorsSettings.enbaledDefaultOnNoFirmware" type="checkbox"
                      switch-animate="true" switch-handle-width="55px" switch-label-width="3px"
                      switch-off-color="default" switch-on-color="primary" ng-true-value="true"
                      ng-false-value="false" switch-on-text="{{ 'ENABLED' | translate }}" switch-off-text="{{ 'DISABLED' | translate }}">
              </div>
            </div>

          </form>

          <div class="form-actions text-right">
            <button type="button" class="btn btn-default" class="button" ng-hide="editEnable.mySensors" ng-click="editEnable.mySensors = true">{{ 'EDIT' | translate }}</button>
            <button type="button" class="btn btn-default" class="button" ng-show="editEnable.mySensors" ng-click="updateSettingsMySensors();editEnable.mySensors = false">{{ 'CANCEL' | translate }}</button>
            <button type="button" class="btn btn-primary" ng-click="saveMySensors()"  ng-show="editEnable.mySensors" ng-disabled="saveProgress.mySensors">
              <div ng-show="saveProgress.mySensors" class="spinner spinner-xs"></div>
              {{saveProgress.mySensors ? 'SAVING' : 'SAVE' | translate}}
            </button>
          </div>
        </div>
      </div>
    </div>

  </div> <!-- Main Message -->

</div> <!-- Container -->
