Added hardware sensors functionality

Change-Id: I99435613bb77fc0ff72f046c2dc047b13962a7a3
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/app/common/directives/app-navigation.html b/app/common/directives/app-navigation.html
index 4891c61..7a48757 100644
--- a/app/common/directives/app-navigation.html
+++ b/app/common/directives/app-navigation.html
@@ -1,4 +1,4 @@
-<nav>
+<nav class="nav__wrapper">
 	<ul id="nav__top-level" ng-style="navStyle">
 		<li>
 			<a class="btn-overview" ng-class="{opened: firstLevel == 'overview'}" href="#/overview/system" ng-click="change('overview')" tabindex="1">
diff --git a/app/common/directives/log-filter.js b/app/common/directives/log-filter.js
index fcbffe4..b760308 100644
--- a/app/common/directives/log-filter.js
+++ b/app/common/directives/log-filter.js
@@ -10,7 +10,9 @@
                 'controller': ['$rootScope', '$scope','dataService', '$location', function($rootScope, $scope, dataService, $location){
                     $scope.dataService = dataService;
                     $scope.toggleSeverityAll = function(){
-                        $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+                        if($scope.selectedSeverity.all !== true){
+                          $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+                        }
 
                         if($scope.selectedSeverity.all){
                             $scope.selectedSeverity.low = false;
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 3b8b7e0..0f3b729 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -369,12 +369,9 @@
                 });
               },
               getAllSensorStatus: function(callback){
-                /**
-                GET   https://9.3.185.156/xyz/openbmc_project/sensors/enumerate
-                */
                 $http({
                   method: 'GET',
-                  url: "/assets/mocks/sensors.json",
+                  url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/sensors/enumerate",
                   headers: {
                       'Accept': 'application/json',
                       'Content-Type': 'application/json'
@@ -385,101 +382,93 @@
                       var content = JSON.parse(json);
                       var dataClone = JSON.parse(JSON.stringify(content.data));
                       var sensorData = [];
-                      var allSensorSeveries = [];
-                      var allSensorRows = [];
-                      var total = 0;
-                      var status = 'normal';
-                      var data = {
-                                   total: 0,
-                                   status: '',
-                                   sensors: [{
-                                      title: 'All Sensors',
-                                      type: 'all',
-                                      status: '',
-                                      severity_flags: {},
-                                      search_text: '',
-                                      display_headers: ['Sensor (Unit)', 'Reading', 'State'],
-                                      data: []
-                                   }]
-                                 };
+                      var severity = {};
+                      var title = "";
+                      var tempKeyParts = [];
+                      var order = 0;
 
                       function getSensorStatus(reading){
-                        var severityFlags = {critical: false, warning: false, normal: false}, severityText = '';
-                        if(reading.Value >= reading.CriticalLow && reading.Value <= reading.CriticalHigh){
+                        var severityFlags = {critical: false, warning: false, normal: false}, severityText = '', order = 0;
+
+                        if(reading.hasOwnProperty('CriticalLow') && 
+                          reading.Value < reading.CriticalLow
+                          ){
                           severityFlags.critical = true;
                           severityText = 'critical';
-                        }
-                        else if(reading.Value >= reading.WarningLow && reading.Value <= reading.WarningHigh){
+                          order = 2;
+                        }else if(reading.hasOwnProperty('CriticalHigh') && 
+                          reading.Value > reading.CriticalHigh 
+                          ){
+                          severityFlags.critical = true;
+                          severityText = 'critical';
+                          order = 2;
+                        }else if(reading.hasOwnProperty('CriticalLow') && 
+                          reading.hasOwnProperty('WarningLow') && 
+                          reading.Value >= reading.CriticalLow && reading.Value <= reading.WarningLow){
                           severityFlags.warning = true;
                           severityText = 'warning';
+                          order = 1;
+                        }else if(reading.hasOwnProperty('WarningHigh') && 
+                          reading.hasOwnProperty('CriticalHigh') && 
+                          reading.Value >= reading.WarningHigh && reading.Value <= reading.CriticalHigh){
+                          severityFlags.warning = true;
+                          severityText = 'warning';
+                          order = 1;
                         }else{
                           severityFlags.normal = true;
                           severityText = 'normal';
                         }
-                        return { flags: severityFlags, severityText: severityText};
+                        return { flags: severityFlags, severityText: severityText, order: order};
                       }
 
                       for(var key in content.data){
                         if(content.data.hasOwnProperty(key) && content.data[key].hasOwnProperty('Unit')){
+
+                          severity = getSensorStatus(content.data[key]);
+
+                          if(!content.data[key].hasOwnProperty('CriticalLow')){
+                            content.data[key].CriticalLow = "--";
+                            content.data[key].CriticalHigh = "--";
+                          }
+
+                          if(!content.data[key].hasOwnProperty('WarningLow')){
+                            content.data[key].WarningLow = "--";
+                            content.data[key].WarningHigh = "--";
+                          }
+
+                          tempKeyParts = key.split("/");
+                          title = tempKeyParts.pop();
+                          title = tempKeyParts.pop() + '_' + title;
+                          title = title.split("_").map(function(item){
+                             return item.toLowerCase().charAt(0).toUpperCase() + item.slice(1);
+                          }).reduce(function(prev, el){
+                            return prev + " " + el;
+                          });
+
                           sensorData.push(Object.assign({
                             path: key,
                             selected: false,
                             confirm: false,
                             copied: false,
+                            title: title,
+                            unit: Constants.SENSOR_UNIT_MAP[content.data[key].Unit],
+                            severity_flags: severity.flags,
+                            status: severity.severityText,
+                            order: severity.order,
+                            search_text: (title + " " + content.data[key].Value + " " + 
+                               Constants.SENSOR_UNIT_MAP[content.data[key].Unit] + " " + 
+                               severity.severityText + " " + 
+                               content.data[key].CriticalLow + " " +
+                               content.data[key].CriticalHigh + " " +
+                               content.data[key].WarningLow + " " +
+                               content.data[key].WarningHigh + " "
+                               ).toLowerCase(),
                             original_data: {key: key, value: content.data[key]}
                           }, content.data[key]));
                         }
                       }
 
-                      Constants.SENSOR_DATA_TEMPLATE.sensors.forEach(function(sensor){
-                          var rowData = [];
-                          var severities = [];
-                          var thisSensorData = sensorData.filter(function(el){
-                            return el.path.indexOf('sensors/'+sensor.key_search) > -1;
-                          });
-
-                          for(var i = 0; i < thisSensorData.length; i++){
-
-                             var severity = getSensorStatus(thisSensorData[i]);
-                             severities.push(severity.severityText);
-                             rowData.push(Object.assign({
-                                title: sensor.sensor_row.title + (i+1),
-                                status: severity.severityText,
-                                severity_flags: severity.flags,
-                                reading: thisSensorData[i].Value + sensor.sensor_row.reading,
-                                search_text: (sensor.sensor_row.title + (i+1) + " " + severity.severityText + " " + thisSensorData[i].Value + sensor.sensor_row.reading).toLowerCase(),
-                                indicator: (severity.flags.critical) ? '90%' : ((severity.flags.warning) ? '15%' : '50%')
-                             }, thisSensorData[i]));
-                          }
-
-                          status = (severities.indexOf('critical') > -1) ? 'critical' : ((severities.indexOf('warning') > -1) ? 'warning' : 'normal');
-                          total += rowData.length;
-                          allSensorSeveries.push(status);
-                          var sevFlags =  {critical: false, warning: false, normal: false};
-                          sevFlags[status] = true;
-                          data.sensors.push({
-                            title: sensor.title,
-                            type: sensor.type,
-                            status: status,
-                            severity_flags: sevFlags,
-                            search_text: (sensor.title + " " + status).toLowerCase(),
-                            display_headers: sensor.display_headers,
-                            data: rowData
-                          });
-                          Array.prototype.push.apply(allSensorRows, rowData);
-                      });
-
-                      data.status = (allSensorSeveries.indexOf('critical') > -1) ? 'critical' : ((allSensorSeveries.indexOf('warning') > -1) ? 'warning' : 'normal');
-                      data.total = total;
-                      if(allSensorRows.length){
-                        data.sensors[0].status = data.status;
-                        data.sensors[0].data = allSensorRows;
-                        data.sensors[0].search_text = (data.sensors[0].title + " " + data.sensors[0].status).toLowerCase();
-                        var flags = {critical: false, warning: false, normal: false};
-                        flags[data.status] = true;
-                        data.sensors[0].severity_flags = flags;
-                      }
-                      callback(data, dataClone);
+                      callback(sensorData, dataClone);
                 }).error(function(error){
                   console.log(error);
                 });
@@ -680,11 +669,15 @@
                       }
 
                       function camelcaseToLabel(obj){
-                        var transformed = [], label = "";
+                        var transformed = [], label = "", value = "";
                         for(var key in obj){
                           label = key.replace(/([A-Z0-9]+)/g, " $1").replace(/^\s+/, "");
                           if(obj[key] !== ""){
-                            transformed.push({key:label, value: obj[key]});
+                            value = obj[key];
+                            if(value == 1 || value == 0){
+                              value = (value == 1) ? 'Yes' : 'No';
+                            }
+                            transformed.push({key:label, value: value});
                           }
                         }
 
diff --git a/app/common/services/constants.js b/app/common/services/constants.js
index 7d77ec0..a610ba9 100644
--- a/app/common/services/constants.js
+++ b/app/common/services/constants.js
@@ -59,7 +59,7 @@
                     Warning: 'Medium'
                 },
                 PAGINATION: {
-                    LOG_ITEMS_PER_PAGE: 25
+                    LOG_ITEMS_PER_PAGE: 4
                 },
                 HARDWARE: {
                   component_key_filter: '/xyz/openbmc_project/inventory/system',
@@ -70,93 +70,14 @@
                    'cpu', 'dimm'
                   ]
                 },
-                SENSOR_DATA_TEMPLATE: {
-                    sensors: [
-                        {
-                           type: 'fan',
-                           title: 'Fan Speed',
-                           key_search: 'fan_tach',
-                           display_headers: ['Fan Speed(RPM)', 'Reading', 'State'],
-                           sensor_row: {
-                                title: 'Fan Speed ',
-                                reading: ' rpms',
-                                status: '',
-                                indicator: ''
-                           }
-                        },
-                        {
-                           type: 'temperature',
-                           title: 'Temperature',
-                           'key_search': 'temperature',
-                           display_headers: ['Temperature (DegreesC)', 'Reading', 'State'],
-                           sensor_row: {
-                                title: 'Temperature ',
-                                reading: ' degreeC',
-                                status: '',
-                                indicator: ''
-                           }
-                        },
-                        {
-                           type: 'altitude',
-                           title: 'Altitude',
-                           'key_search': 'altitude',
-                           display_headers: ['Altitude (Meters)', 'Reading', 'State'],
-                           sensor_row: {
-                                title: 'Altitude ',
-                                reading: ' Meters',
-                                status: '',
-                                indicator: ''
-                           }
-                        },
-                        {
-                           type: 'voltage',
-                           title: 'Voltage',
-                           'key_search': 'voltage',
-                           display_headers: ['Temperature (Volts)', 'Reading', 'State'],
-                           sensor_row: {
-                                title: 'Voltage ',
-                                reading: ' volts',
-                                status: '',
-                                indicator: ''
-                           }
-                        },
-                        {
-                           type: 'current',
-                           title: 'Current',
-                           'key_search': 'current',
-                           display_headers: ['Current (Amperes)', 'Reading', 'State'],
-                           sensor_row: {
-                                title: 'Current ',
-                                reading: ' amperes',
-                                status: '',
-                                indicator: ''
-                           }
-                        },
-                        {
-                           type: 'power',
-                           title: 'Power',
-                           'key_search': 'power',
-                           display_headers: ['Power (Watts)', 'Reading', 'State'],
-                           sensor_row: {
-                                title: 'Power ',
-                                reading: ' watts',
-                                status: '',
-                                indicator: ''
-                           }
-                        },
-                        {
-                           type: 'energy',
-                           title: 'Energy',
-                           'key_search': 'energy',
-                           display_headers: ['Energy (Joules)', 'Reading', 'State'],
-                           sensor_row: {
-                                title: 'Energy ',
-                                reading: ' joules',
-                                status: '',
-                                indicator: ''
-                           }
-                        }
-                    ]
+                SENSOR_UNIT_MAP: {
+                  'xyz.openbmc_project.Sensor.Value.Unit.RPMS': 'rpms',
+                  'xyz.openbmc_project.Sensor.Value.Unit.DegreesC': 'C',
+                  'xyz.openbmc_project.Sensor.Value.Unit.Volts': 'volts',
+                  'xyz.openbmc_project.Sensor.Value.Unit.Meters': 'meters',
+                  'xyz.openbmc_project.Sensor.Value.Unit.Watts': 'watts',
+                  'xyz.openbmc_project.Sensor.Value.Unit.Amperes': 'amperes',
+                  'xyz.openbmc_project.Sensor.Value.Unit.Joules': 'joules'
                 }
             };
         });
diff --git a/app/common/services/userModel.js b/app/common/services/userModel.js
index 747b288..dba607d 100644
--- a/app/common/services/userModel.js
+++ b/app/common/services/userModel.js
@@ -41,8 +41,6 @@
                            response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS){
                             sessionStorage.removeItem('LOGIN_ID');
                             callback(true);
-                        }else if(response.status == APIUtils.API_RESPONSE.ERROR_STATUS){
-                            callback(false);
                         }else{
                             callback(false, error);
                         }
diff --git a/app/common/styles/base/buttons.scss b/app/common/styles/base/buttons.scss
index 4f79625..299c9b3 100644
--- a/app/common/styles/base/buttons.scss
+++ b/app/common/styles/base/buttons.scss
@@ -1,4 +1,4 @@
-button, .btn, .button, .submit {
+button, .button, .submit {
   font-size: 1em;
   @include fontFamilyBold;
   text-transform: none;
@@ -10,15 +10,13 @@
   &:hover {
     cursor: pointer;
   }
-}
-
-.disabled {
-  button, .button, input[type="submit"] {
+  &.disabled {
     opacity: 0.2;
     color: $btn__disabled-txt;
     &:hover {
       cursor: default;
       background: transparent;
+      text-decoration: none;
     }
   }
 }
@@ -39,7 +37,7 @@
       cursor: default;
     }
   }
-  i { // button symbol
+  i { //button symbol
     font-style: normal;
     text-transform: none;
     font-size: 1.5em;
diff --git a/app/common/styles/base/colors.scss b/app/common/styles/base/colors.scss
index 780e319..ac8e0ae 100644
--- a/app/common/styles/base/colors.scss
+++ b/app/common/styles/base/colors.scss
@@ -65,8 +65,8 @@
 
 // Threshold graphs
 $thresh-critical: $error-color;
-$thresh-warning: #ff806c;
-$thresh-normal: #8ee9d4;
+$thresh-warning: #ffb001;
+$thresh-normal: $lightgrey;
 
 //Inventory
 $active: #c6b6f5;
diff --git a/app/common/styles/base/icons.scss b/app/common/styles/base/icons.scss
index 27fe0e1..bac0be0 100644
--- a/app/common/styles/base/icons.scss
+++ b/app/common/styles/base/icons.scss
@@ -45,16 +45,16 @@
 }
 
 .icon__warning{
-  width: 30px;
-  height: 30px;
+  width: 40px;
+  height: 40px;
   background-image: url(/assets/images/icon-warning.svg);
   background-repeat: no-repeat;
   vertical-align: middle;
 }
 
 .icon__critical{
-  width: 30px;
-  height: 30px;
+  width: 40px;
+  height: 40px;
   background-image: url(/assets/images/icon-critical.svg);
   background-repeat: no-repeat;
   vertical-align: middle;
diff --git a/app/common/styles/base/mixins.scss b/app/common/styles/base/mixins.scss
index e868354..d13f2ce 100644
--- a/app/common/styles/base/mixins.scss
+++ b/app/common/styles/base/mixins.scss
@@ -85,12 +85,14 @@
   background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='32' height='24' viewBox='0 0 32 24'><polygon points='0,0 32,0 16,24' style='fill: #b8c1c1'></polygon></svg>");
 }
 
+@mixin calcColumn-5 {
+  min-width: calc(100% * (1/5) - 5px);
+}
 
 @mixin calcColumn-4 ($offset: 0) {
   min-width: calc(100% * (1/4) - #{$offset});
 }
 
-
 @mixin calcColumn-3 {
   min-width: calc(100% * (1/3) - 5px);
 }
diff --git a/app/common/styles/components/form-elements.scss b/app/common/styles/components/form-elements.scss
index d674bbc..2ce17ee 100644
--- a/app/common/styles/components/form-elements.scss
+++ b/app/common/styles/components/form-elements.scss
@@ -3,7 +3,7 @@
   position: relative;
   padding: .5em .8em;
   margin-top: -10px;
-  border: 1px solid $darkgrey;
+  border: 1px solid $input-border;
   min-width: 70px;
   padding-right: 25px;
   font-weight: 400;
diff --git a/app/common/styles/directives/app-navigation.scss b/app/common/styles/directives/app-navigation.scss
index 496fbf7..2d818a9 100644
--- a/app/common/styles/directives/app-navigation.scss
+++ b/app/common/styles/directives/app-navigation.scss
@@ -1,11 +1,18 @@
 $nav__toplvlWidth: 125px;
 $nav__seclvlWidth: 240px;
 
+.nav__wrapper {
+  height: 100%;
+  position: fixed;
+  top: 0;
+  z-index: 100;
+}
+
 // Top level navigation
 #nav__top-level {
   background: $nav__top-level-color;
-  height: 100%;
-  position: fixed;
+  //height: 100%;
+  position: absolute;
   left: 0;
   top: 0;
   bottom: 0;
@@ -14,6 +21,7 @@
   margin: 0;
   padding: 0;
   width: $nav__toplvlWidth;
+  overflow-y: auto;
   li {
     margin: 0;
   }
@@ -113,7 +121,7 @@
   background: $nav__second-level-color;
   top: 0;
   bottom: 0;
-  left: -$nav__toplvlWidth;
+  left: -245px;
   width: $nav__seclvlWidth;
   z-index: 97;
   padding: 0;
diff --git a/app/common/styles/elements/alerts.scss b/app/common/styles/elements/alerts.scss
index 76624b1..96f0a4c 100644
--- a/app/common/styles/elements/alerts.scss
+++ b/app/common/styles/elements/alerts.scss
@@ -13,7 +13,7 @@
   .close {
     color: $lightbg__primary;
     position: absolute;
-    right: 0%;
+    right: 0;
     top: 50%;
     transform: translateY(-50%);
     font-size: 1.5em;
@@ -24,7 +24,7 @@
     justify-content: center;
     flex-direction: column;
     background: transparent;
-    border: 0px;
+    border: 0;
     margin: 0;
     &:hover {
       color: $lightbg__accent;
diff --git a/app/common/styles/elements/content-search.scss b/app/common/styles/elements/content-search.scss
index a8ae381..e93bff0 100644
--- a/app/common/styles/elements/content-search.scss
+++ b/app/common/styles/elements/content-search.scss
@@ -7,7 +7,6 @@
   float: left;
   position: relative;
   margin-right: 1em;
-  margin-top: .5em;
   margin-bottom: .5em;
 
   #content__search-input {
@@ -43,6 +42,10 @@
     margin: 0;
     font-weight: 700;
     font-size: .8em;
+    border: 0;
+    &:hover {
+      cursor: pointer;
+    }
   }
 
   .tag-filter-label {
diff --git a/app/common/styles/elements/export.scss b/app/common/styles/elements/export.scss
index ea0ab92..66847ae 100644
--- a/app/common/styles/elements/export.scss
+++ b/app/common/styles/elements/export.scss
@@ -4,10 +4,10 @@
   font-size: .9em;
   font-weight: 700;
   position: relative;
-  padding: 0 0 1em 2em;
+  padding: 0 0 0 2em;
   margin-right: .6em;
   text-decoration: none;
-  margin-top: 7px;
+  margin-top: 0;
   &:hover {
     text-decoration: underline;
   }
diff --git a/app/common/styles/elements/index.scss b/app/common/styles/elements/index.scss
index d136134..7b1d1c5 100644
--- a/app/common/styles/elements/index.scss
+++ b/app/common/styles/elements/index.scss
@@ -11,4 +11,4 @@
 @import "thresholds";
 @import "export";
 @import "modals";
-@import "quicklinks";
\ No newline at end of file
+@import "quicklinks";
diff --git a/app/common/styles/elements/thresholds.scss b/app/common/styles/elements/thresholds.scss
deleted file mode 100644
index 52230ee..0000000
--- a/app/common/styles/elements/thresholds.scss
+++ /dev/null
@@ -1,78 +0,0 @@
-// Thresholds graph
-
-$threshColorLighten: 5%;
-.threshold-chart__wrapper {
-  position: relative;
-  .threshold__label {
-    position: absolute;
-    top: 38%;
-    transform: translateY(-50%);
-    font-weight: 700;
-    &.low {
-      margin-left: 0;
-    }
-    &.high {
-      right: 5px;
-    }
-  }
-  @include mediaQuery(large) {
-    max-width: 1000px;
-  }
-}
-
-.threshold-chart {
-  position: relative;
-  line-height: 0;
-  padding: .8em 0 2em 0;
-  margin: 0 2.5em 1em 2.5em;
- //margin: 0 auto;
-  .threshold__marker {
-    position: absolute;
-    top: 13px;
-    bottom: -15px;
-    width: 4px;
-    background-color: $black;
-    @include slowTransition-all;
-    .threshold__value {
-      position: absolute;
-      bottom: 3px;
-      right: 5px;
-      margin: 0;
-      color: $black;
-      padding: 3px 6px;
-      font-weight: 400;
-      font-size: 1em;
-      white-space: nowrap;
-    }
-  }
-
-  .threshold {
-    display: inline-block;
-    background-color: $thresh-normal;
-    min-width: 10%;
-    min-height: 25px;
-    margin: 0 -3px;
-    &.thresh__normal {
-      min-width: 60%;
-    }
-  }
-
-  .threshold__marker,
-  .threshold {
-    &.thresh__low-critical {
-      background-color: $thresh-critical;
-    }
-    &.thresh__low-warn {
-      background-color: $thresh-warning;
-    }
-    &.thresh__high-warn {
-      background-color: $thresh-warning;
-    }
-    &.thresh__high-critical {
-      background-color: $thresh-critical;
-    }
-    &.thresh__normal {
-      background-color: $thresh-normal;
-    }
-  }
-}
diff --git a/app/common/styles/elements/toggle-filter.scss b/app/common/styles/elements/toggle-filter.scss
index 1a7d602..7305414 100644
--- a/app/common/styles/elements/toggle-filter.scss
+++ b/app/common/styles/elements/toggle-filter.scss
@@ -1,6 +1,12 @@
 // toggle buttons for filtering
 .toggle-filter {
-  margin-top: 12px;
+  display: inline-block;
+  @media (min-width: 1300px) {
+    margin-top: -25px;
+  }
+  .content-label {
+    margin-bottom: .4em;
+  }
   .filter-label {
     color: darken($lightgrey, 10%);
     text-transform: uppercase;
@@ -18,6 +24,7 @@
     font-weight: 700;
     border-radius: 0;
     display: inline-block;
+    border-left: 0;
     &.first,
     &.last {
       border-radius: 3px;
@@ -26,5 +33,4 @@
   .btn-primary {
     border: 2px solid $primebtn__bg;
   }
-
 }
\ No newline at end of file
diff --git a/app/common/styles/layout/content.scss b/app/common/styles/layout/content.scss
index 326d896..b1a7942 100644
--- a/app/common/styles/layout/content.scss
+++ b/app/common/styles/layout/content.scss
@@ -37,10 +37,15 @@
   margin-top: 2em;
 }
 
-.content-label {
-  color: lighten($darkgrey, 15%);
+.content-label, label {
+  color: $darkgrey;
   text-transform: uppercase;
   font-weight: 700;
   font-size: .75em;
   margin-bottom: 0;
 }
+
+.subhead {
+  border-bottom: 1px solid $medgrey;
+  padding-bottom: .5em;
+}
\ No newline at end of file