Updating server health icon in header based on event log status

Change-Id: Iae10d39428b6ce6a228e775aa68fb7805dd61ecb
Signed-off-by: Iftekharul Islam <iffy.ryan@ibm.com>
diff --git a/app/common/directives/app-navigation.html b/app/common/directives/app-navigation.html
index 6784990..c2c6f67 100644
--- a/app/common/directives/app-navigation.html
+++ b/app/common/directives/app-navigation.html
@@ -64,8 +64,8 @@
 				<span>Users</span>
 			</span>
 		</li>
-		<li>
-			<a class="btn-multi-server" ng-class="{opened: firstLevel == 'multi-server'}" href="#/multi-server/overview" ng-click="change('multi-server')">
+		<li class="btn-multi-server">
+			<a ng-class="{opened: firstLevel == 'multi-server'}" href="#/multi-server/overview" ng-click="change('multi-server')">
 				<span>
 					<svg class="nav-icon" version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 24 24" xml:space="preserve">
 <path d="M12.8,7.3h4c0.2,1.5,1.5,2.8,3.1,2.8c1.7,0,3.1-1.4,3.1-3.1s-1.4-3.1-3.1-3.1c-1.5,0-2.7,1-3,2.4h-4C12.4,3.3,9.9,1,6.9,1
diff --git a/app/common/directives/app-navigation.js b/app/common/directives/app-navigation.js
index 00c3ec7..daccb2f 100644
--- a/app/common/directives/app-navigation.js
+++ b/app/common/directives/app-navigation.js
@@ -12,6 +12,7 @@
                     'showNavigation': '='
                 },
                 'controller': ['$scope', '$location', 'dataService', function($scope, $location, dataService){
+                    $scope.dataService = dataService;
                     $scope.showSubMenu = false;
                     $scope.change = function(firstLevel){
                         if(firstLevel != $scope.firstLevel) {
@@ -24,6 +25,15 @@
                     $scope.closeSubnav = function(){
                         $scope.showSubMenu = false;
                     };
+                    $scope.$watch('path', function(){
+                        var urlRoot = $location.path().split("/")[1];
+                        if(urlRoot != ""){
+                            $scope.firstLevel = urlRoot;
+                        }else{
+                            $scope.firstLevel = 'overview';
+                        }
+                        $scope.showSubMenu = false;
+                    });
                     $scope.$watch('showNavigation', function(){
                         var paddingTop = 0;
                         var urlRoot = $location.path().split("/")[1];
diff --git a/app/common/directives/errors.html b/app/common/directives/errors.html
new file mode 100644
index 0000000..0fd2234
--- /dev/null
+++ b/app/common/directives/errors.html
@@ -0,0 +1,17 @@
+<!-- Unexpected error -->
+<section class="modal" aria-hidden="true" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog" ng-class="{'active': display_error}">
+    <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="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>
+        </div>
+        <div class="modal__content">
+            <p>Oops! An unexpected error occurred. Record specific details of the issue, then contact your company support services.</p>
+        </div>
+        <div class="modal__button-wrapper">
+            <button class="inline btn-primary" ng-click="display_error = false;">Close</button>
+        </div>
+    </div>
+</section>
+<div class="modal-overlay" tabindex="-1" ng-class="{'active': (multi_server_recent)}"></div>
\ No newline at end of file
diff --git a/app/common/directives/log-filter.js b/app/common/directives/log-filter.js
index 81abc7d..527d347 100644
--- a/app/common/directives/log-filter.js
+++ b/app/common/directives/log-filter.js
@@ -10,9 +10,7 @@
                 'controller': ['$rootScope', '$scope','dataService', '$location', function($rootScope, $scope, dataService, $location){
                     $scope.dataService = dataService;
                     $scope.toggleSeverityAll = function(){
-                        if($scope.selectedSeverity.all !== true){
-                          $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
-                        }
+                        $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
 
                         if($scope.selectedSeverity.all){
                             $scope.selectedSeverity.low = false;
diff --git a/app/common/services/constants.js b/app/common/services/constants.js
index 1c92e38..7ffbd82 100644
--- a/app/common/services/constants.js
+++ b/app/common/services/constants.js
@@ -20,7 +20,7 @@
                     password: "testpass",
                 },
                 API_CREDENTIALS: {
-                    host: 'https://9.3.185.164',
+                    host: 'https://9.3.181.64',
                     mock_host: 'http://localhost:3000'
                 },
                 API_RESPONSE: {
@@ -53,10 +53,25 @@
                     on: 'on',
                     off: 'off'
                 },
+                SEVERITY_TO_HEALTH_MAP:{
+                    Emergency: 'Critical',
+                    Alert: 'Critical',
+                    Critical: 'Critical',
+                    Error: 'Warning',
+                    Warning: 'Warning',
+                    Notice: 'Good',
+                    Debug: 'Good',
+                    Informational: 'Good'
+                },
                 SEVERITY_TO_PRIORITY_MAP:{
-                    Informational: 'Low',
+                    Emergency: 'High',
+                    Alert: 'High',
+                    Critical: 'High',
                     Error: 'High',
-                    Warning: 'Medium'
+                    Warning: 'Medium',
+                    Notice: 'Low',
+                    Debug: 'Low',
+                    Informational: 'Low'
                 },
                 PAGINATION: {
                     LOG_ITEMS_PER_PAGE: 25
@@ -78,8 +93,14 @@
                   'xyz.openbmc_project.Sensor.Value.Unit.Watts': 'watts',
                   'xyz.openbmc_project.Sensor.Value.Unit.Amperes': 'amperes',
                   'xyz.openbmc_project.Sensor.Value.Unit.Joules': 'joules'
+                },
+                SERVER_HEALTH: {
+                    critical: 'Critical',
+                    warning: 'Warning',
+                    good: 'Good',
+                    unknown: 'Unknown'
                 }
             };
         });
 
-})(window.angular);
+})(window.angular);
\ No newline at end of file
diff --git a/app/common/services/dataService.js b/app/common/services/dataService.js
index 6640ddb..00ea1ba 100644
--- a/app/common/services/dataService.js
+++ b/app/common/services/dataService.js
@@ -15,7 +15,7 @@
         .module('app.common.services')
         .service('dataService', ['Constants', function (Constants) {
             this.app_version = "V.0.0.1";
-            this.server_health = 'Error';
+            this.server_health = Constants.SERVER_HEALTH.unknown;
             this.server_state = 'Unreachable';
             this.server_status = -2;
             this.chassis_state = 'On';
@@ -33,6 +33,7 @@
 
             this.hostname = "";
             this.mac_address = "";
+            this.remote_window_active = false;
 
             this.setNetworkInfo = function(data){
                 this.hostname = data.hostname;
@@ -58,6 +59,36 @@
                 this.server_state = Constants.HOST_STATE_TEXT.unreachable;
                 this.server_status = Constants.HOST_STATE.unreachable;
             }
+
+            this.setRemoteWindowActive = function(){
+                this.remote_window_active = true;
+            }
+
+            this.setRemoteWindowInactive = function(){
+                this.remote_window_active = false;
+            }
+
+            this.updateServerHealth = function(logs){
+                var criticals = logs.filter(function(item){
+                    return item.health_flags.critical == true;
+                });
+
+                if(criticals.length){
+                    this.server_health = Constants.SERVER_HEALTH.critical;
+                    return;
+                }
+
+                var warnings = logs.filter(function(item){
+                    return item.health_flags.warning == true;
+                });
+
+                if(warnings.length){
+                    this.server_health = Constants.SERVER_HEALTH.warning;
+                    return;
+                }
+
+                this.server_health = Constants.SERVER_HEALTH.good;
+            }
         }]);
 
 })(window.angular);
\ No newline at end of file