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 |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 9 | window.angular && (function(angular) { |
| 10 | 'use strict'; |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 11 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 12 | angular |
| 13 | .module('app.serverHealth') |
| 14 | .controller('unitIdController', [ |
| 15 | '$scope', |
| 16 | '$window', |
| 17 | 'APIUtils', |
| 18 | 'dataService', |
| 19 | function($scope, $window, APIUtils, dataService) { |
| 20 | $scope.dataService = dataService; |
Michael Davis | 11dbb82 | 2017-08-11 16:42:47 -0500 | [diff] [blame] | 21 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 22 | APIUtils.getLEDState().then(function(state) { |
| 23 | $scope.displayLEDState(state); |
| 24 | }); |
Iftekharul Islam | 96bbf31 | 2017-08-22 13:44:38 -0500 | [diff] [blame] | 25 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 26 | $scope.displayLEDState = function(state) { |
| 27 | if (state == APIUtils.LED_STATE.on) { |
| 28 | dataService.LED_state = APIUtils.LED_STATE_TEXT.on; |
| 29 | } |
| 30 | else { |
| 31 | dataService.LED_state = APIUtils.LED_STATE_TEXT.off; |
| 32 | } |
| 33 | }; |
Iftekharul Islam | 96bbf31 | 2017-08-22 13:44:38 -0500 | [diff] [blame] | 34 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [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 | } |
| 43 | ]); |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 44 | |
| 45 | })(angular); |