diff --git a/app/server-health/controllers/diagnostics-controller.js b/app/server-health/controllers/diagnostics-controller.js
index b28d61f..0f6763f 100644
--- a/app/server-health/controllers/diagnostics-controller.js
+++ b/app/server-health/controllers/diagnostics-controller.js
@@ -9,16 +9,11 @@
 window.angular && (function(angular) {
   'use strict';
 
-  angular
-    .module('app.serverHealth')
-    .controller('diagnosticsController', [
-      '$scope',
-      '$window',
-      'APIUtils',
-      'dataService',
-      function($scope, $window, APIUtils, dataService) {
-        $scope.dataService = dataService;
-      }
-    ]);
+  angular.module('app.serverHealth').controller('diagnosticsController', [
+    '$scope', '$window', 'APIUtils', 'dataService',
+    function($scope, $window, APIUtils, dataService) {
+      $scope.dataService = dataService;
+    }
+  ]);
 
 })(angular);
diff --git a/app/server-health/controllers/inventory-controller.js b/app/server-health/controllers/inventory-controller.js
index 17c9057..df9ca1c 100644
--- a/app/server-health/controllers/inventory-controller.js
+++ b/app/server-health/controllers/inventory-controller.js
@@ -9,19 +9,14 @@
 window.angular && (function(angular) {
   'use strict';
 
-  angular
-    .module('app.serverHealth')
-    .controller('inventoryController', [
-      '$scope',
-      '$window',
-      'APIUtils',
-      'dataService',
-      function($scope, $window, APIUtils, dataService) {
-        $scope.dataService = dataService;
+  angular.module('app.serverHealth').controller('inventoryController', [
+    '$scope', '$window', 'APIUtils', 'dataService',
+    function($scope, $window, APIUtils, dataService) {
+      $scope.dataService = dataService;
 
-        // Force to top of page when viewing single group
-        $window.scrollTo(0, 0);
-      }
-    ]);
+      // Force to top of page when viewing single group
+      $window.scrollTo(0, 0);
+    }
+  ]);
 
 })(angular);
diff --git a/app/server-health/controllers/inventory-overview-controller.js b/app/server-health/controllers/inventory-overview-controller.js
index a0dad75..9705395 100644
--- a/app/server-health/controllers/inventory-overview-controller.js
+++ b/app/server-health/controllers/inventory-overview-controller.js
@@ -9,68 +9,64 @@
 window.angular && (function(angular) {
   'use strict';
 
-  angular
-    .module('app.serverHealth')
-    .controller('inventoryOverviewController', [
-      '$scope',
-      '$window',
-      'APIUtils',
-      'dataService',
-      function($scope, $window, APIUtils, dataService) {
-        $scope.dataService = dataService;
-        $scope.hardwares = [];
-        $scope.originalData = {};
+  angular.module('app.serverHealth').controller('inventoryOverviewController', [
+    '$scope', '$window', 'APIUtils', 'dataService',
+    function($scope, $window, APIUtils, dataService) {
+      $scope.dataService = dataService;
+      $scope.hardwares = [];
+      $scope.originalData = {};
+      $scope.customSearch = '';
+      $scope.searchTerms = [];
+      $scope.loading = false;
+
+      $scope.loading = true;
+      APIUtils.getHardwares(function(data, originalData) {
+        $scope.hardwares = data;
+        $scope.originalData = JSON.stringify(originalData);
+        $scope.loading = false;
+      });
+
+      $scope.clear = function() {
         $scope.customSearch = '';
         $scope.searchTerms = [];
-        $scope.loading = false;
+      };
 
-        $scope.loading = true;
-        APIUtils.getHardwares(function(data, originalData) {
-          $scope.hardwares = data;
-          $scope.originalData = JSON.stringify(originalData);
-          $scope.loading = false;
-        });
-
-        $scope.clear = function() {
-          $scope.customSearch = '';
-          $scope.searchTerms = [];
-        };
-
-        $scope.doSearchOnEnter = function(event) {
-          var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
-          if (event.keyCode === 13 &&
-            search.length >= 2) {
-            $scope.searchTerms = $scope.customSearch.split(' ');
+      $scope.doSearchOnEnter = function(event) {
+        var search =
+            $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        if (event.keyCode === 13 && search.length >= 2) {
+          $scope.searchTerms = $scope.customSearch.split(' ');
+        } else {
+          if (search.length == 0) {
+            $scope.searchTerms = [];
           }
-          else {
-            if (search.length == 0) {
-              $scope.searchTerms = [];
-            }
-          }
-        };
+        }
+      };
 
-        $scope.doSearchOnClick = function() {
-          var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
-          if (search.length >= 2) {
-            $scope.searchTerms = $scope.customSearch.split(' ');
+      $scope.doSearchOnClick = function() {
+        var search =
+            $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        if (search.length >= 2) {
+          $scope.searchTerms = $scope.customSearch.split(' ');
+        } else {
+          if (search.length == 0) {
+            $scope.searchTerms = [];
           }
-          else {
-            if (search.length == 0) {
-              $scope.searchTerms = [];
-            }
-          }
-        };
+        }
+      };
 
-        $scope.filterBySearchTerms = function(hardware) {
+      $scope.filterBySearchTerms = function(hardware) {
 
-          if (!$scope.searchTerms.length) return true;
+        if (!$scope.searchTerms.length) return true;
 
-          for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
-            if (hardware.search_text.indexOf($scope.searchTerms[i].toLowerCase()) == -1) return false;
-          }
-          return true;
-        };
-      }
-    ]);
+        for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
+          if (hardware.search_text.indexOf(
+                  $scope.searchTerms[i].toLowerCase()) == -1)
+            return false;
+        }
+        return true;
+      };
+    }
+  ]);
 
 })(angular);
diff --git a/app/server-health/controllers/log-controller.js b/app/server-health/controllers/log-controller.js
index 1a01242..4359c9c 100644
--- a/app/server-health/controllers/log-controller.js
+++ b/app/server-health/controllers/log-controller.js
@@ -8,190 +8,183 @@
 
 window.angular && (function(angular) {
   'use strict';
-  angular
-    .module('app.serverHealth')
-    .config(function(paginationTemplateProvider) {
-      paginationTemplateProvider.setString(require('../../common/directives/dirPagination.tpl.html'));
-    })
-    .controller('logController', [
-      '$scope',
-      '$window',
-      'APIUtils',
-      'dataService',
-      'Constants',
-      '$routeParams',
-      '$filter',
-      function($scope, $window, APIUtils, dataService, Constants, $routeParams, $filter) {
-        $scope.dataService = dataService;
-        $scope.logs = [];
-        $scope.tmz = 'EDT';
-        $scope.itemsPerPage = Constants.PAGINATION.LOG_ITEMS_PER_PAGE;
-        $scope.loading = false;
-        var expandedSelectedIdOnce = false;
+  angular.module('app.serverHealth')
+      .config(function(paginationTemplateProvider) {
+        paginationTemplateProvider.setString(
+            require('../../common/directives/dirPagination.tpl.html'));
+      })
+      .controller('logController', [
+        '$scope', '$window', 'APIUtils', 'dataService', 'Constants',
+        '$routeParams', '$filter',
+        function(
+            $scope, $window, APIUtils, dataService, Constants, $routeParams,
+            $filter) {
+          $scope.dataService = dataService;
+          $scope.logs = [];
+          $scope.tmz = 'EDT';
+          $scope.itemsPerPage = Constants.PAGINATION.LOG_ITEMS_PER_PAGE;
+          $scope.loading = false;
+          var expandedSelectedIdOnce = false;
 
-        var sensorType = $routeParams.type;
-        var eventId = $routeParams.id;
+          var sensorType = $routeParams.type;
+          var eventId = $routeParams.id;
 
-        // priority buttons
-        $scope.selectedSeverity = {
-          all: true,
-          low: false,
-          medium: false,
-          high: false
-        };
+          // priority buttons
+          $scope.selectedSeverity =
+              {all: true, low: false, medium: false, high: false};
 
-        if (sensorType == 'high') {
-          $scope.selectedSeverity.all = false;
-          $scope.selectedSeverity.high = true;
-        }
-
-        $scope.selectedStatus = {
-          all: true,
-          resolved: false
-        };
-
-        $scope.customSearch = '';
-        $scope.searchItems = [];
-        $scope.selectedEvents = [];
-
-
-        if (eventId) {
-          $scope.customSearch = '#' + eventId;
-          $scope.searchItems.push('#' + eventId);
-        }
-
-        $scope.loadLogs = function() {
-          $scope.loading = true;
-          APIUtils.getLogs().then(function(result) {
-            if (eventId && expandedSelectedIdOnce == false) {
-              var log = result.data.filter(function(item) {
-                return item.Id == eventId;
-              });
-
-              if (log.length) {
-                log[0].meta = true;
-              }
-              expandedSelectedIdOnce = true;
-            }
-            dataService.updateServerHealth(result.data);
-            $scope.logs = result.data;
-            $scope.originalData = result.original;
-            $scope.loading = false;
-          });
-        };
-        $scope.jsonData = function(data) {
-          return JSON.stringify(data);
-        };
-
-        $scope.filterBySeverity = function(log) {
-          if ($scope.selectedSeverity.all) return true;
-
-          return ((log.severity_flags.low && $scope.selectedSeverity.low) ||
-            (log.severity_flags.medium && $scope.selectedSeverity.medium) ||
-            (log.severity_flags.high && $scope.selectedSeverity.high)
-          );
-        };
-
-        $scope.filterByStatus = function(log) {
-          if ($scope.selectedStatus.all) return true;
-          return ((log.Resolved && $scope.selectedStatus.resolved) ||
-            (!log.Resolved && !$scope.selectedStatus.resolved)
-          );
-        };
-
-        $scope.filterByDate = function(log) {
-          var endDate;
-          if ($scope.end_date && typeof $scope.end_date.getTime === 'function') {
-            endDate = new Date($scope.end_date.getTime());
-            endDate.setTime(endDate.getTime() + 86399000);
+          if (sensorType == 'high') {
+            $scope.selectedSeverity.all = false;
+            $scope.selectedSeverity.high = true;
           }
 
-          if ($scope.start_date && endDate) {
-            var date = new Date($filter('date')(log.Timestamp, 'MM/dd/yyyy  HH:mm:ss', $scope.tmz));
-            return (date >= $scope.start_date &&
-              date <= endDate);
-          }
-          else {
-            return true;
-          }
-        };
+          $scope.selectedStatus = {all: true, resolved: false};
 
-        $scope.filterBySearchTerms = function(log) {
-          if (!$scope.searchItems.length) return true;
-
-          for (var i = 0, length = $scope.searchItems.length; i < length; i++) {
-            if (log.search_text.indexOf($scope.searchItems[i].toLowerCase()) == -1) return false;
-          }
-          return true;
-        };
-
-        $scope.addSearchItem = function(searchTerms) {
-          var terms = searchTerms.split(' ');
-          terms.forEach(function(searchTerm) {
-            if ($scope.searchItems.indexOf(searchTerm) == -1) {
-              $scope.searchItems.push(searchTerm);
-            }
-          });
-        };
-
-        $scope.clearSearchItem = function(searchTerm) {
+          $scope.customSearch = '';
           $scope.searchItems = [];
-        };
+          $scope.selectedEvents = [];
 
-        $scope.removeSearchItem = function(searchTerm) {
-          var termIndex = $scope.searchItems.indexOf(searchTerm);
-
-          if (termIndex > -1) {
-            $scope.searchItems.splice(termIndex, 1);
+          if (eventId) {
+            $scope.customSearch = '#' + eventId;
+            $scope.searchItems.push('#' + eventId);
           }
-        };
 
-        $scope.$watch('all', function() {
-          $scope.logs.forEach(function(item) {
-            item.selected = $scope.all;
-          });
-        });
+          $scope.loadLogs = function() {
+            $scope.loading = true;
+            APIUtils.getLogs().then(function(result) {
+              if (eventId && expandedSelectedIdOnce == false) {
+                var log = result.data.filter(function(item) {
+                  return item.Id == eventId;
+                });
 
-        function updateExportData() {
-          $scope.export_name = ($scope.selectedEvents.length == 1) ? $scope.selectedEvents[0].Id + '.json' : 'export.json';
-          var data = {};
-          $scope.selectedEvents.forEach(function(item) {
-            data[item.data.key] = item.data.value;
-          });
-          $scope.export_data = JSON.stringify(data);
-        }
+                if (log.length) {
+                  log[0].meta = true;
+                }
+                expandedSelectedIdOnce = true;
+              }
+              dataService.updateServerHealth(result.data);
+              $scope.logs = result.data;
+              $scope.originalData = result.original;
+              $scope.loading = false;
+            });
+          };
+          $scope.jsonData = function(data) {
+            return JSON.stringify(data);
+          };
 
+          $scope.filterBySeverity = function(log) {
+            if ($scope.selectedSeverity.all) return true;
 
-        $scope.accept = function() {
-          APIUtils.deleteLogs($scope.selectedEvents).then(function() {
-            $scope.confirm = false;
-            $scope.loadLogs();
-          });
-        };
+            return (
+                (log.severity_flags.low && $scope.selectedSeverity.low) ||
+                (log.severity_flags.medium && $scope.selectedSeverity.medium) ||
+                (log.severity_flags.high && $scope.selectedSeverity.high));
+          };
 
-        $scope.resolve = function() {
-          var events = $scope.selectedEvents.filter(function(item) {
-            return item.Resolved != 1;
-          });
+          $scope.filterByStatus = function(log) {
+            if ($scope.selectedStatus.all) return true;
+            return (
+                (log.Resolved && $scope.selectedStatus.resolved) ||
+                (!log.Resolved && !$scope.selectedStatus.resolved));
+          };
 
-          if (!events.length) return;
+          $scope.filterByDate = function(log) {
+            var endDate;
+            if ($scope.end_date &&
+                typeof $scope.end_date.getTime === 'function') {
+              endDate = new Date($scope.end_date.getTime());
+              endDate.setTime(endDate.getTime() + 86399000);
+            }
 
-          APIUtils.resolveLogs(events).then(function() {
-            events.forEach(function(item) {
-              item.Resolved = 1;
+            if ($scope.start_date && endDate) {
+              var date = new Date($filter('date')(
+                  log.Timestamp, 'MM/dd/yyyy  HH:mm:ss', $scope.tmz));
+              return (date >= $scope.start_date && date <= endDate);
+            } else {
+              return true;
+            }
+          };
+
+          $scope.filterBySearchTerms = function(log) {
+            if (!$scope.searchItems.length) return true;
+
+            for (var i = 0, length = $scope.searchItems.length; i < length;
+                 i++) {
+              if (log.search_text.indexOf(
+                      $scope.searchItems[i].toLowerCase()) == -1)
+                return false;
+            }
+            return true;
+          };
+
+          $scope.addSearchItem = function(searchTerms) {
+            var terms = searchTerms.split(' ');
+            terms.forEach(function(searchTerm) {
+              if ($scope.searchItems.indexOf(searchTerm) == -1) {
+                $scope.searchItems.push(searchTerm);
+              }
+            });
+          };
+
+          $scope.clearSearchItem = function(searchTerm) {
+            $scope.searchItems = [];
+          };
+
+          $scope.removeSearchItem = function(searchTerm) {
+            var termIndex = $scope.searchItems.indexOf(searchTerm);
+
+            if (termIndex > -1) {
+              $scope.searchItems.splice(termIndex, 1);
+            }
+          };
+
+          $scope.$watch('all', function() {
+            $scope.logs.forEach(function(item) {
+              item.selected = $scope.all;
             });
           });
-        };
 
-        $scope.$watch('logs', function() {
-          $scope.selectedEvents = $scope.logs.filter(function(item) {
-            return item.selected;
-          });
-          updateExportData();
-        }, true);
+          function updateExportData() {
+            $scope.export_name = ($scope.selectedEvents.length == 1) ?
+                $scope.selectedEvents[0].Id + '.json' :
+                'export.json';
+            var data = {};
+            $scope.selectedEvents.forEach(function(item) {
+              data[item.data.key] = item.data.value;
+            });
+            $scope.export_data = JSON.stringify(data);
+          }
 
-        $scope.loadLogs();
-      }
-    ]);
+          $scope.accept = function() {
+            APIUtils.deleteLogs($scope.selectedEvents).then(function() {
+              $scope.confirm = false;
+              $scope.loadLogs();
+            });
+          };
+
+          $scope.resolve = function() {
+            var events = $scope.selectedEvents.filter(function(item) {
+              return item.Resolved != 1;
+            });
+
+            if (!events.length) return;
+
+            APIUtils.resolveLogs(events).then(function() {
+              events.forEach(function(item) {
+                item.Resolved = 1;
+              });
+            });
+          };
+
+          $scope.$watch('logs', function() {
+            $scope.selectedEvents = $scope.logs.filter(function(item) {
+              return item.selected;
+            });
+            updateExportData();
+          }, true);
+
+          $scope.loadLogs();
+        }
+      ]);
 
 })(angular);
diff --git a/app/server-health/controllers/power-consumption-controller.js b/app/server-health/controllers/power-consumption-controller.js
index 9a74e6d..51882e4 100644
--- a/app/server-health/controllers/power-consumption-controller.js
+++ b/app/server-health/controllers/power-consumption-controller.js
@@ -9,16 +9,11 @@
 window.angular && (function(angular) {
   'use strict';
 
-  angular
-    .module('app.serverHealth')
-    .controller('powerConsumptionController', [
-      '$scope',
-      '$window',
-      'APIUtils',
-      'dataService',
-      function($scope, $window, APIUtils, dataService) {
-        $scope.dataService = dataService;
-      }
-    ]);
+  angular.module('app.serverHealth').controller('powerConsumptionController', [
+    '$scope', '$window', 'APIUtils', 'dataService',
+    function($scope, $window, APIUtils, dataService) {
+      $scope.dataService = dataService;
+    }
+  ]);
 
 })(angular);
diff --git a/app/server-health/controllers/sensors-controller.js b/app/server-health/controllers/sensors-controller.js
index 70f3e9c..5f687a0 100644
--- a/app/server-health/controllers/sensors-controller.js
+++ b/app/server-health/controllers/sensors-controller.js
@@ -9,133 +9,122 @@
 window.angular && (function(angular) {
   'use strict';
   var sensorData = [];
-  angular
-    .module('app.overview')
-    .controller('sensorsController', [
-      '$scope',
-      '$log',
-      '$window',
-      'APIUtils',
-      'dataService',
-      '$routeParams',
-      function($scope, $log, $window, APIUtils, dataService, $routeParams) {
-        $scope.dataService = dataService;
-        $scope.customSearch = '';
-        $scope.dropdown_selected = false;
-        $scope.$log = $log;
-        $scope.data = {};
-        $scope.searchTerms = [];
+  angular.module('app.overview').controller('sensorsController', [
+    '$scope', '$log', '$window', 'APIUtils', 'dataService', '$routeParams',
+    function($scope, $log, $window, APIUtils, dataService, $routeParams) {
+      $scope.dataService = dataService;
+      $scope.customSearch = '';
+      $scope.dropdown_selected = false;
+      $scope.$log = $log;
+      $scope.data = {};
+      $scope.searchTerms = [];
 
-        $scope.selectedSeverity = {
-          all: true,
-          normal: false,
-          warning: false,
-          critical: false
-        };
+      $scope.selectedSeverity =
+          {all: true, normal: false, warning: false, critical: false};
 
-        var sensorType = $routeParams.type;
+      var sensorType = $routeParams.type;
 
-        $scope.export_name = sensorType + '_sensors.json';
+      $scope.export_name = sensorType + '_sensors.json';
 
-        $scope.toggleSeverityAll = function() {
-          $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+      $scope.toggleSeverityAll = function() {
+        $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
 
-          if ($scope.selectedSeverity.all) {
-            $scope.selectedSeverity.normal = false;
-            $scope.selectedSeverity.warning = false;
-            $scope.selectedSeverity.critical = false;
-          }
-        };
+        if ($scope.selectedSeverity.all) {
+          $scope.selectedSeverity.normal = false;
+          $scope.selectedSeverity.warning = false;
+          $scope.selectedSeverity.critical = false;
+        }
+      };
 
-        $scope.toggleSeverity = function(severity) {
-          $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
+      $scope.toggleSeverity = function(severity) {
+        $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
 
-          if ($scope.selectedSeverity.normal &&
-            $scope.selectedSeverity.warning &&
+        if ($scope.selectedSeverity.normal && $scope.selectedSeverity.warning &&
             $scope.selectedSeverity.critical) {
-            $scope.selectedSeverity.all = true;
-            $scope.selectedSeverity.normal = false;
-            $scope.selectedSeverity.warning = false;
-            $scope.selectedSeverity.critical = false;
-          }
-          else {
-            $scope.selectedSeverity.all = false;
-          }
-        };
+          $scope.selectedSeverity.all = true;
+          $scope.selectedSeverity.normal = false;
+          $scope.selectedSeverity.warning = false;
+          $scope.selectedSeverity.critical = false;
+        } else {
+          $scope.selectedSeverity.all = false;
+        }
+      };
 
-        $scope.doSearchOnEnter = function(event) {
-          var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
-          if (event.keyCode === 13 &&
-            search.length >= 2) {
-            $scope.searchTerms = $scope.customSearch.split(' ');
-          }
-          else {
-            if (search.length == 0) {
-              $scope.searchTerms = [];
-            }
-          }
-        };
-
-        $scope.doSearchOnClick = function() {
-          var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
-          if (search.length >= 2) {
-            $scope.searchTerms = $scope.customSearch.split(' ');
-          }
-          else {
-            if (search.length == 0) {
-              $scope.searchTerms = [];
-            }
-          }
-        };
-
-        $scope.jsonData = function(data) {
-          var dt = {};
-          data.data.forEach(function(item) {
-            dt[item.original_data.key] = item.original_data.value;
-          });
-          return JSON.stringify(dt);
-        };
-
-        $scope.filterBySeverity = function(sensor) {
-          if ($scope.selectedSeverity.all) return true;
-
-          return ((sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
-            (sensor.severity_flags.warning && $scope.selectedSeverity.warning) ||
-            (sensor.severity_flags.critical && $scope.selectedSeverity.critical)
-          );
-        };
-        $scope.filterBySearchTerms = function(sensor) {
-
-          if (!$scope.searchTerms.length) return true;
-
-          for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
-            if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) == -1) return false;
-          }
-          return true;
-        };
-
-        function setSensorData() {
-          var data = dataService.sensorData.sensors.filter(function(item) {
-            return item.type == sensorType;
-          });
-          if (data.length) {
-            sensorData = data[0];
-            $scope.data = sensorData;
-            $scope.export_data = $scope.jsonData($scope.data);
+      $scope.doSearchOnEnter = function(event) {
+        var search =
+            $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        if (event.keyCode === 13 && search.length >= 2) {
+          $scope.searchTerms = $scope.customSearch.split(' ');
+        } else {
+          if (search.length == 0) {
+            $scope.searchTerms = [];
           }
         }
+      };
 
-        if (!dataService.sensorData.sensors) {
-          APIUtils.getAllSensorStatus(function(data, originalData) {
-            dataService.sensorData = data;
-            setSensorData();
-          });
+      $scope.doSearchOnClick = function() {
+        var search =
+            $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        if (search.length >= 2) {
+          $scope.searchTerms = $scope.customSearch.split(' ');
+        } else {
+          if (search.length == 0) {
+            $scope.searchTerms = [];
+          }
         }
-        else {
-          setSensorData();
-        }
+      };
 
+      $scope.jsonData = function(data) {
+        var dt = {};
+        data.data.forEach(function(item) {
+          dt[item.original_data.key] = item.original_data.value;
+        });
+        return JSON.stringify(dt);
+      };
+
+      $scope.filterBySeverity = function(sensor) {
+        if ($scope.selectedSeverity.all) return true;
+
+        return (
+            (sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
+            (sensor.severity_flags.warning &&
+             $scope.selectedSeverity.warning) ||
+            (sensor.severity_flags.critical &&
+             $scope.selectedSeverity.critical));
+      };
+      $scope.filterBySearchTerms = function(sensor) {
+
+        if (!$scope.searchTerms.length) return true;
+
+        for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
+          if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) ==
+              -1)
+            return false;
+        }
+        return true;
+      };
+
+      function setSensorData() {
+        var data = dataService.sensorData.sensors.filter(function(item) {
+          return item.type == sensorType;
+        });
+        if (data.length) {
+          sensorData = data[0];
+          $scope.data = sensorData;
+          $scope.export_data = $scope.jsonData($scope.data);
+        }
       }
-    ]);
+
+      if (!dataService.sensorData.sensors) {
+        APIUtils.getAllSensorStatus(function(data, originalData) {
+          dataService.sensorData = data;
+          setSensorData();
+        });
+      } else {
+        setSensorData();
+      }
+
+    }
+  ]);
 
 })(angular);
diff --git a/app/server-health/controllers/sensors-overview-controller.js b/app/server-health/controllers/sensors-overview-controller.js
index 683d071..77d2978 100644
--- a/app/server-health/controllers/sensors-overview-controller.js
+++ b/app/server-health/controllers/sensors-overview-controller.js
@@ -8,138 +8,127 @@
 
 window.angular && (function(angular) {
   'use strict';
-  angular
-    .module('app.overview')
-    .controller('sensorsOverviewController', [
-      '$scope',
-      '$log',
-      '$window',
-      'APIUtils',
-      'dataService',
-      'Constants',
-      function($scope, $log, $window, APIUtils, dataService, Constants) {
-        $scope.dataService = dataService;
+  angular.module('app.overview').controller('sensorsOverviewController', [
+    '$scope', '$log', '$window', 'APIUtils', 'dataService', 'Constants',
+    function($scope, $log, $window, APIUtils, dataService, Constants) {
+      $scope.dataService = dataService;
 
-        $scope.dropdown_selected = false;
+      $scope.dropdown_selected = false;
 
-        $scope.$log = $log;
+      $scope.$log = $log;
+      $scope.customSearch = '';
+      $scope.searchTerms = [];
+      $scope.messages = Constants.MESSAGES.SENSOR;
+      $scope.selectedSeverity =
+          {all: true, normal: false, warning: false, critical: false};
+      $scope.export_name = 'sensors.json';
+      $scope.loading = false;
+      $scope.jsonData = function(data) {
+        var dt = {};
+        data.data.forEach(function(item) {
+          dt[item.original_data.key] = item.original_data.value;
+        });
+        return JSON.stringify(dt);
+      };
+
+      $scope.clear = function() {
         $scope.customSearch = '';
         $scope.searchTerms = [];
-        $scope.messages = Constants.MESSAGES.SENSOR;
-        $scope.selectedSeverity = {
-          all: true,
-          normal: false,
-          warning: false,
-          critical: false
-        };
-        $scope.export_name = 'sensors.json';
-        $scope.loading = false;
-        $scope.jsonData = function(data) {
-          var dt = {};
-          data.data.forEach(function(item) {
-            dt[item.original_data.key] = item.original_data.value;
-          });
-          return JSON.stringify(dt);
-        };
+      };
 
-        $scope.clear = function() {
-          $scope.customSearch = '';
-          $scope.searchTerms = [];
-        };
-
-        $scope.doSearchOnEnter = function(event) {
-          var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
-          if (event.keyCode === 13 &&
-            search.length >= 2) {
-            $scope.searchTerms = $scope.customSearch.split(' ');
+      $scope.doSearchOnEnter = function(event) {
+        var search =
+            $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        if (event.keyCode === 13 && search.length >= 2) {
+          $scope.searchTerms = $scope.customSearch.split(' ');
+        } else {
+          if (search.length == 0) {
+            $scope.searchTerms = [];
           }
-          else {
-            if (search.length == 0) {
-              $scope.searchTerms = [];
-            }
+        }
+      };
+
+      $scope.doSearchOnClick = function() {
+        var search =
+            $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        if (search.length >= 2) {
+          $scope.searchTerms = $scope.customSearch.split(' ');
+        } else {
+          if (search.length == 0) {
+            $scope.searchTerms = [];
           }
-        };
+        }
+      };
 
-        $scope.doSearchOnClick = function() {
-          var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
-          if (search.length >= 2) {
-            $scope.searchTerms = $scope.customSearch.split(' ');
-          }
-          else {
-            if (search.length == 0) {
-              $scope.searchTerms = [];
-            }
-          }
-        };
+      $scope.toggleSeverityAll = function() {
+        $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
 
-        $scope.toggleSeverityAll = function() {
-          $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+        if ($scope.selectedSeverity.all) {
+          $scope.selectedSeverity.normal = false;
+          $scope.selectedSeverity.warning = false;
+          $scope.selectedSeverity.critical = false;
+        }
+      };
 
-          if ($scope.selectedSeverity.all) {
-            $scope.selectedSeverity.normal = false;
-            $scope.selectedSeverity.warning = false;
-            $scope.selectedSeverity.critical = false;
-          }
-        };
+      $scope.toggleSeverity = function(severity) {
+        $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
 
-        $scope.toggleSeverity = function(severity) {
-          $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
-
-          if (['normal', 'warning', 'critical'].indexOf(severity) > -1) {
-            if ($scope.selectedSeverity[severity] == false &&
+        if (['normal', 'warning', 'critical'].indexOf(severity) > -1) {
+          if ($scope.selectedSeverity[severity] == false &&
               (!$scope.selectedSeverity.normal &&
-                !$scope.selectedSeverity.warning &&
-                !$scope.selectedSeverity.critical
-              )) {
-              $scope.selectedSeverity.all = true;
-              return;
-            }
-          }
-
-          if ($scope.selectedSeverity.normal &&
-            $scope.selectedSeverity.warning &&
-            $scope.selectedSeverity.critical) {
+               !$scope.selectedSeverity.warning &&
+               !$scope.selectedSeverity.critical)) {
             $scope.selectedSeverity.all = true;
-            $scope.selectedSeverity.normal = false;
-            $scope.selectedSeverity.warning = false;
-            $scope.selectedSeverity.critical = false;
+            return;
           }
-          else {
-            $scope.selectedSeverity.all = false;
-          }
-        };
+        }
 
-        $scope.filterBySeverity = function(sensor) {
-          if ($scope.selectedSeverity.all) return true;
+        if ($scope.selectedSeverity.normal && $scope.selectedSeverity.warning &&
+            $scope.selectedSeverity.critical) {
+          $scope.selectedSeverity.all = true;
+          $scope.selectedSeverity.normal = false;
+          $scope.selectedSeverity.warning = false;
+          $scope.selectedSeverity.critical = false;
+        } else {
+          $scope.selectedSeverity.all = false;
+        }
+      };
 
-          return ((sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
-            (sensor.severity_flags.warning && $scope.selectedSeverity.warning) ||
-            (sensor.severity_flags.critical && $scope.selectedSeverity.critical)
-          );
-        };
-        $scope.filterBySearchTerms = function(sensor) {
+      $scope.filterBySeverity = function(sensor) {
+        if ($scope.selectedSeverity.all) return true;
 
-          if (!$scope.searchTerms.length) return true;
+        return (
+            (sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
+            (sensor.severity_flags.warning &&
+             $scope.selectedSeverity.warning) ||
+            (sensor.severity_flags.critical &&
+             $scope.selectedSeverity.critical));
+      };
+      $scope.filterBySearchTerms = function(sensor) {
 
-          for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
-            if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) == -1) return false;
-          }
-          return true;
-        };
+        if (!$scope.searchTerms.length) return true;
 
-        $scope.loadSensorData = function() {
-          $scope.loading = true;
-          APIUtils.getAllSensorStatus(function(data, originalData) {
-            $scope.data = data;
-            $scope.originalData = originalData;
-            dataService.sensorData = data;
-            $scope.export_data = JSON.stringify(originalData);
-            $scope.loading = false;
-          });
-        };
+        for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
+          if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) ==
+              -1)
+            return false;
+        }
+        return true;
+      };
 
-        $scope.loadSensorData();
-      }
-    ]);
+      $scope.loadSensorData = function() {
+        $scope.loading = true;
+        APIUtils.getAllSensorStatus(function(data, originalData) {
+          $scope.data = data;
+          $scope.originalData = originalData;
+          dataService.sensorData = data;
+          $scope.export_data = JSON.stringify(originalData);
+          $scope.loading = false;
+        });
+      };
+
+      $scope.loadSensorData();
+    }
+  ]);
 
 })(angular);
diff --git a/app/server-health/controllers/unit-id-controller.js b/app/server-health/controllers/unit-id-controller.js
index 4cd8055..7af4ca1 100644
--- a/app/server-health/controllers/unit-id-controller.js
+++ b/app/server-health/controllers/unit-id-controller.js
@@ -9,37 +9,35 @@
 window.angular && (function(angular) {
   'use strict';
 
-  angular
-    .module('app.serverHealth')
-    .controller('unitIdController', [
-      '$scope',
-      '$window',
-      'APIUtils',
-      'dataService',
-      function($scope, $window, APIUtils, dataService) {
-        $scope.dataService = dataService;
+  angular.module('app.serverHealth').controller('unitIdController', [
+    '$scope', '$window', 'APIUtils', 'dataService',
+    function($scope, $window, APIUtils, dataService) {
+      $scope.dataService = dataService;
 
-        APIUtils.getLEDState().then(function(state) {
-          $scope.displayLEDState(state);
-        });
+      APIUtils.getLEDState().then(function(state) {
+        $scope.displayLEDState(state);
+      });
 
-        $scope.displayLEDState = function(state) {
-          if (state == APIUtils.LED_STATE.on) {
-            dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
-          }
-          else {
-            dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
-          }
-        };
+      $scope.displayLEDState = function(state) {
+        if (state == APIUtils.LED_STATE.on) {
+          dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
+        } else {
+          dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
+        }
+      };
 
-        $scope.toggleLED = function() {
-          var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
-            APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
-          dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
-            APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
-          APIUtils.setLEDState(toggleState, function(status) {});
-        };
-      }
-    ]);
+      $scope.toggleLED = function() {
+        var toggleState =
+            (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
+            APIUtils.LED_STATE.off :
+            APIUtils.LED_STATE.on;
+        dataService.LED_state =
+            (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
+            APIUtils.LED_STATE_TEXT.off :
+            APIUtils.LED_STATE_TEXT.on;
+        APIUtils.setLEDState(toggleState, function(status) {});
+      };
+    }
+  ]);
 
 })(angular);
