/**
 * Controller for unit Id
 *
 * @module app/serverHealth
 * @exports unitIdController
 * @name unitIdController
 */

window.angular && (function(angular) {
  'use strict';

  angular
    .module('app.serverHealth')
    .controller('unitIdController', [
      '$scope',
      '$window',
      'APIUtils',
      'dataService',
      function($scope, $window, APIUtils, dataService) {
        $scope.dataService = dataService;

        APIUtils.getLEDState().then(function(state) {
          $scope.displayLEDState(state);
        });

        $scope.displayLEDState = function(state) {
          if (state == APIUtils.LED_STATE.on) {
            dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
          }
          else {
            dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
          }
        };

        $scope.toggleLED = function() {
          var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
            APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
          dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
            APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
          APIUtils.setLEDState(toggleState, function(status) {});
        };
      }
    ]);

})(angular);
