diff options
Diffstat (limited to 'app/server-control/controllers/server-led-controller.js')
-rw-r--r-- | app/server-control/controllers/server-led-controller.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/server-control/controllers/server-led-controller.js b/app/server-control/controllers/server-led-controller.js index e30f3b3..96ea064 100644 --- a/app/server-control/controllers/server-led-controller.js +++ b/app/server-control/controllers/server-led-controller.js @@ -10,8 +10,8 @@ window.angular && (function(angular) { 'use strict'; angular.module('app.serverControl').controller('serverLEDController', [ - '$scope', '$window', 'APIUtils', 'dataService', - function($scope, $window, APIUtils, dataService) { + '$scope', '$window', '$route', 'APIUtils', 'dataService', 'ngToast', + function($scope, $window, $route, APIUtils, dataService, ngToast) { $scope.dataService = dataService; APIUtils.getLEDState().then(function(state) { @@ -35,7 +35,17 @@ window.angular && (function(angular) { (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on; - APIUtils.setLEDState(toggleState, function(status) {}); + APIUtils.setLEDState(toggleState) + .then( + function(response) {}, + function(errors) { + ngToast.danger( + 'Failed to turn LED light ' + + (toggleState ? 'on' : 'off')); + console.log(JSON.stringify(errors)); + // Reload to get correct current LED state + $route.reload(); + }) }; } ]); |