blob: 5494c618d6a3a5450338591b749cc4aadfd8cc1c [file] [log] [blame]
Iftekharul Islamcd789502017-04-19 14:37:55 -05001/**
2 * Controller for unit Id
3 *
4 * @module app/serverHealth
5 * @exports unitIdController
6 * @name unitIdController
7 * @version 0.1.0
8 */
9
10window.angular && (function (angular) {
11 'use strict';
12
13 angular
14 .module('app.serverHealth')
15 .controller('unitIdController', [
16 '$scope',
17 '$window',
18 'APIUtils',
19 'dataService',
20 function($scope, $window, APIUtils, dataService, userModel){
21 $scope.dataService = dataService;
22
23 $scope.getLEDState = function(){
24 APIUtils.getLEDState(function(state){
25 if(state == APIUtils.LED_STATE.on){
26 dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
27 }else{
28 dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
29 }
30 });
31 }
32 $scope.toggleLED = function(){
33 var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
34 APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
35 dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
36 APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
37 APIUtils.setLEDState(toggleState, function(status){
38 });
39 }
40
41 $scope.getLEDState();
42 }
43 ]
44 );
45
46})(angular);