Add fixes for cold reboot

This fixes the cold reboot issue with the following steps

- It applies the command to shut off the chassis.
- Then verify the chassis is off. It checks for every 5 seconds.
  During this time the spinner displays. A 5min timeout has been
  added.
- Once the chassis is off, it turns on the host.

fixes openbmc/openbmc#2795

Change-Id: I119a1c95e57c10ccee27be1512a1fc38cde307fa
Signed-off-by: Iftekharul Islam <iffy.ryan@ibm.com>
Signed-off-by: CamVan Nguyen <ctnguyen@us.ibm.com>
diff --git a/app/common/directives/app-header.js b/app/common/directives/app-header.js
index 1ba55ba..2a34381 100644
--- a/app/common/directives/app-header.js
+++ b/app/common/directives/app-header.js
@@ -24,7 +24,7 @@
                         if(!userModel.isLoggedIn()){
                             return;
                         }
-                        APIUtils.getHostState(function(status){
+                        APIUtils.getHostState().then(function(status){
                             if(status == 'xyz.openbmc_project.State.Host.HostState.Off'){
                                 dataService.setPowerOffState();
                             }else if(status == 'xyz.openbmc_project.State.Host.HostState.Running'){
@@ -32,6 +32,8 @@
                             }else{
                                 dataService.setBootingState();
                             }
+                        }, function(error){
+                            dataService.activateErrorModal();
                         });
                     }
 
diff --git a/app/common/directives/errors.html b/app/common/directives/errors.html
index 0fd2234..f3e98b6 100644
--- a/app/common/directives/errors.html
+++ b/app/common/directives/errors.html
@@ -1,17 +1,17 @@
 <!-- Unexpected error -->
-<section class="modal" aria-hidden="true" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog" ng-class="{'active': display_error}">
+<section class="modal" aria-hidden="true" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog" ng-class="{'active': dataService.displayErrorModal}">
     <div class="modal__upload-fail" role="document">
-        <div class="screen-reader-offscreen modal-description">Unexpected error</div><!-- accessibility only; used for screen readers -->
+        <div class="screen-reader-offscreen modal-description">{{dataService.errorModalDetails.title}}</div><!-- accessibility only; used for screen readers -->
         <div class="page-header ">
-            <span class="icon icon__warning inline"><span class="accessible-text" role="alert">Unexpected error</span></span>
-            <h1 class="modal-title h4 inline">Unexpected error</h1>
+            <span class="icon icon__warning inline"><span class="accessible-text" role="alert">{{dataService.errorModalDetails.title}}</span></span>
+            <h1 class="modal-title h4 inline">{{dataService.errorModalDetails.title}}</h1>
         </div>
         <div class="modal__content">
-            <p>Oops! An unexpected error occurred. Record specific details of the issue, then contact your company support services.</p>
+            <p>{{dataService.errorModalDetails.description}}</p>
         </div>
         <div class="modal__button-wrapper">
-            <button class="inline btn-primary" ng-click="display_error = false;">Close</button>
+            <button class="inline btn-primary" ng-click="dataService.deactivateErrorModal()">Close</button>
         </div>
     </div>
 </section>
-<div class="modal-overlay" tabindex="-1" ng-class="{'active': (multi_server_recent)}"></div>
\ No newline at end of file
+<div class="modal-overlay" tabindex="-1" ng-class="{'active': dataService.displayErrorModal}"></div>
diff --git a/app/common/directives/errors.js b/app/common/directives/errors.js
new file mode 100644
index 0000000..2c9b109
--- /dev/null
+++ b/app/common/directives/errors.js
@@ -0,0 +1,18 @@
+window.angular && (function (angular) {
+    'use strict';
+
+    angular
+        .module('app.common.directives')
+        .directive('errors', ['APIUtils', function (APIUtils) {
+            return {
+                'restrict': 'E',
+                'template': require('./errors.html'),
+                'scope': {
+                   'path': '='
+                },
+                'controller': ['$scope','dataService', function($scope, dataService){
+                    $scope.dataService = dataService;
+                }]
+            };
+        }]);
+})(window.angular);