Add toast to LED page

Toast error notification alerts user if LED light switch was
not successful.

Change-Id: I4f7af80276b6fefa93c8d0f0f50f8b28a06bced3
Signed-off-by: beccabroek <beccabroek@gmail.com>
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 9e458aa..0de6b1f 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -838,29 +838,14 @@
                   });
           return deferred.promise;
         },
-        setLEDState: function(state, callback) {
-          $http({
+        setLEDState: function(state) {
+          return $http({
             method: 'PUT',
             url: DataService.getHost() +
                 '/xyz/openbmc_project/led/groups/enclosure_identify/attr/Asserted',
             withCredentials: true,
             data: JSON.stringify({'data': state})
           })
-              .then(
-                  function(response) {
-                    var json = JSON.stringify(response.data);
-                    var content = JSON.parse(json);
-                    if (callback) {
-                      return callback(content.status);
-                    }
-                  },
-                  function(error) {
-                    if (callback) {
-                      callback(error);
-                    } else {
-                      console.log(error);
-                    }
-                  });
         },
         bmcReboot: function(callback) {
           $http({
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 @@
   '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 @@
             (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();
+                })
       };
     }
   ]);