blob: a91094d9ba3ec53bff6963e7f6a41c03e3bbbbe1 [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', [
Gunnar Millseedefd32018-02-28 17:02:34 -060016 '$scope',
17 '$window',
18 'APIUtils',
Iftekharul Islamcd789502017-04-19 14:37:55 -050019 'dataService',
Iftekharul Islam96bbf312017-08-22 13:44:38 -050020 function($scope, $window, APIUtils, dataService){
Iftekharul Islamcd789502017-04-19 14:37:55 -050021 $scope.dataService = dataService;
Michael Davis11dbb822017-08-11 16:42:47 -050022
Iftekharul Islam96bbf312017-08-22 13:44:38 -050023 APIUtils.getLEDState().then(function(state){
24 $scope.displayLEDState(state);
25 });
26
27 $scope.displayLEDState = function(state){
28 if(state == APIUtils.LED_STATE.on){
29 dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
30 }else{
31 dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
32 }
Michael Davis11dbb822017-08-11 16:42:47 -050033 }
Iftekharul Islam96bbf312017-08-22 13:44:38 -050034
Michael Davis11dbb822017-08-11 16:42:47 -050035 $scope.toggleLED = function(){
36 var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
37 APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
38 dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
39 APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
40 APIUtils.setLEDState(toggleState, function(status){
41 });
42 }
Iftekharul Islamcd789502017-04-19 14:37:55 -050043 }
44 ]
45 );
46
47})(angular);