Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Controller for unit Id |
| 3 | * |
| 4 | * @module app/serverHealth |
| 5 | * @exports unitIdController |
| 6 | * @name unitIdController |
| 7 | * @version 0.1.0 |
| 8 | */ |
| 9 | |
| 10 | window.angular && (function (angular) { |
| 11 | 'use strict'; |
| 12 | |
| 13 | angular |
| 14 | .module('app.serverHealth') |
| 15 | .controller('unitIdController', [ |
Gunnar Mills | eedefd3 | 2018-02-28 17:02:34 -0600 | [diff] [blame] | 16 | '$scope', |
| 17 | '$window', |
| 18 | 'APIUtils', |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 19 | 'dataService', |
Iftekharul Islam | 96bbf31 | 2017-08-22 13:44:38 -0500 | [diff] [blame] | 20 | function($scope, $window, APIUtils, dataService){ |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 21 | $scope.dataService = dataService; |
Michael Davis | 11dbb82 | 2017-08-11 16:42:47 -0500 | [diff] [blame] | 22 | |
Iftekharul Islam | 96bbf31 | 2017-08-22 13:44:38 -0500 | [diff] [blame] | 23 | 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 Davis | 11dbb82 | 2017-08-11 16:42:47 -0500 | [diff] [blame] | 33 | } |
Iftekharul Islam | 96bbf31 | 2017-08-22 13:44:38 -0500 | [diff] [blame] | 34 | |
Michael Davis | 11dbb82 | 2017-08-11 16:42:47 -0500 | [diff] [blame] | 35 | $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 Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 43 | } |
| 44 | ] |
| 45 | ); |
| 46 | |
| 47 | })(angular); |