Add error message when image fails to activate

If an image fails to activate a toast message is displayed.

Tested on Witherspoon with master build image and
field mode turned on. When image fails to activate,
the failed activation status response returns a 200
ok and an error toast is displayed. Tested with field
mode turned off to verify image activates and BMC reboots.
Tested on all browsers.

Signed-off-by: Dixsie Wolmers <dixsiew@gmail.com>
Change-Id: I517f184549673e7b807cc0a553a728d05d6dbba1
diff --git a/app/configuration/controllers/firmware-controller.js b/app/configuration/controllers/firmware-controller.js
index 6f8ec07..89cf9c6 100644
--- a/app/configuration/controllers/firmware-controller.js
+++ b/app/configuration/controllers/firmware-controller.js
@@ -59,12 +59,18 @@
         pollActivationTimer = $interval(function() {
           APIUtils.getActivation(imageId).then(
               function(state) {
-                //@TODO: display an error message if image "Failed"
-                if (((/\.Active$/).test(state.data)) ||
-                    ((/\.Failed$/).test(state.data))) {
+                let imageStateActive = (/\.Active$/).test(state.data);
+                let imageStateFailed = (/\.Failed$/).test(state.data);
+                if (imageStateActive || imageStateFailed) {
                   $interval.cancel(pollActivationTimer);
                   pollActivationTimer = undefined;
+                }
+                if (imageStateActive) {
                   deferred.resolve(state);
+                } else if (imageStateFailed) {
+                  console.log('Image failed to activate: ', imageStateFailed);
+                  toastService.error('Image failed to activate.');
+                  deferred.reject(error);
                 }
               },
               function(error) {