1*4129f402SGunnar Mills/** 2*4129f402SGunnar Mills * Controller for server LED 3*4129f402SGunnar Mills * 4*4129f402SGunnar Mills * @module app/serverControl 5*4129f402SGunnar Mills * @exports serverLEDController 6*4129f402SGunnar Mills * @name serverLEDController 7*4129f402SGunnar Mills */ 8*4129f402SGunnar Mills 9*4129f402SGunnar Millswindow.angular && (function(angular) { 10*4129f402SGunnar Mills 'use strict'; 11*4129f402SGunnar Mills 12*4129f402SGunnar Mills angular.module('app.serverControl').controller('serverLEDController', [ 13*4129f402SGunnar Mills '$scope', '$window', 'APIUtils', 'dataService', 14*4129f402SGunnar Mills function($scope, $window, APIUtils, dataService) { 15*4129f402SGunnar Mills $scope.dataService = dataService; 16*4129f402SGunnar Mills 17*4129f402SGunnar Mills APIUtils.getLEDState().then(function(state) { 18*4129f402SGunnar Mills $scope.displayLEDState(state); 19*4129f402SGunnar Mills }); 20*4129f402SGunnar Mills 21*4129f402SGunnar Mills $scope.displayLEDState = function(state) { 22*4129f402SGunnar Mills if (state == APIUtils.LED_STATE.on) { 23*4129f402SGunnar Mills dataService.LED_state = APIUtils.LED_STATE_TEXT.on; 24*4129f402SGunnar Mills } else { 25*4129f402SGunnar Mills dataService.LED_state = APIUtils.LED_STATE_TEXT.off; 26*4129f402SGunnar Mills } 27*4129f402SGunnar Mills }; 28*4129f402SGunnar Mills 29*4129f402SGunnar Mills $scope.toggleLED = function() { 30*4129f402SGunnar Mills var toggleState = 31*4129f402SGunnar Mills (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 32*4129f402SGunnar Mills APIUtils.LED_STATE.off : 33*4129f402SGunnar Mills APIUtils.LED_STATE.on; 34*4129f402SGunnar Mills dataService.LED_state = 35*4129f402SGunnar Mills (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 36*4129f402SGunnar Mills APIUtils.LED_STATE_TEXT.off : 37*4129f402SGunnar Mills APIUtils.LED_STATE_TEXT.on; 38*4129f402SGunnar Mills APIUtils.setLEDState(toggleState, function(status) {}); 39*4129f402SGunnar Mills }; 40*4129f402SGunnar Mills } 41*4129f402SGunnar Mills ]); 42*4129f402SGunnar Mills 43*4129f402SGunnar Mills})(angular); 44