blob: 4cd80552387fbe3562687992ac3243db11e9f4ff [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
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07009window.angular && (function(angular) {
10 'use strict';
Iftekharul Islamcd789502017-04-19 14:37:55 -050011
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070012 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 Davis11dbb822017-08-11 16:42:47 -050021
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070022 APIUtils.getLEDState().then(function(state) {
23 $scope.displayLEDState(state);
24 });
Iftekharul Islam96bbf312017-08-22 13:44:38 -050025
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070026 $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 Islam96bbf312017-08-22 13:44:38 -050034
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070035 $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 Islamcd789502017-04-19 14:37:55 -050044
45})(angular);