blob: 806f024164568ca0d88b733e4be3a51e6f5c3743 [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
Iftekharul Islamcd789502017-04-19 14:37:55 -05007 */
8
9window.angular && (function (angular) {
10 'use strict';
11
12 angular
13 .module('app.serverHealth')
14 .controller('unitIdController', [
Gunnar Millseedefd32018-02-28 17:02:34 -060015 '$scope',
16 '$window',
17 'APIUtils',
Iftekharul Islamcd789502017-04-19 14:37:55 -050018 'dataService',
Iftekharul Islam96bbf312017-08-22 13:44:38 -050019 function($scope, $window, APIUtils, dataService){
Iftekharul Islamcd789502017-04-19 14:37:55 -050020 $scope.dataService = dataService;
Michael Davis11dbb822017-08-11 16:42:47 -050021
Iftekharul Islam96bbf312017-08-22 13:44:38 -050022 APIUtils.getLEDState().then(function(state){
23 $scope.displayLEDState(state);
24 });
25
26 $scope.displayLEDState = function(state){
27 if(state == APIUtils.LED_STATE.on){
28 dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
29 }else{
30 dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
31 }
Michael Davis11dbb822017-08-11 16:42:47 -050032 }
Iftekharul Islam96bbf312017-08-22 13:44:38 -050033
Michael Davis11dbb822017-08-11 16:42:47 -050034 $scope.toggleLED = function(){
35 var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
36 APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
37 dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
38 APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
39 APIUtils.setLEDState(toggleState, function(status){
40 });
41 }
Iftekharul Islamcd789502017-04-19 14:37:55 -050042 }
43 ]
44 );
45
46})(angular);