WebUI: Adding Filters support to system logs

Adding Filter support to system logs page
 - Severity filter.
 - Date filter with start and end date.
 - Filter by Sensort Type.

Tested By:
  Loaded System logs page with type selection
  'Event' and check all filters.

Change-Id: I41eba4cd59c0f3c2933637bf0e207a3eca3214f1
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/app/server-health/controllers/syslog-controller.js b/app/server-health/controllers/syslog-controller.js
index cec1d99..c073320 100644
--- a/app/server-health/controllers/syslog-controller.js
+++ b/app/server-health/controllers/syslog-controller.js
@@ -29,10 +29,17 @@
           $scope.recordTypeList =
               ['SEL', 'Event', 'Oem'];        // From Redfish specification.
           $scope.selectedRecordType = 'SEL';  // Default Select to SEL.
+          $scope.typeFilter = false;
+          $scope.selectedSeverityList = [];
+          $scope.severityList = ['All', 'Critical', 'Warning', 'Ok'];
+          $scope.filterTypes = [];
+          $scope.selectedType = 'All';
 
           $scope.selectRecordType = function(recordType) {
             $scope.selectedRecordType = recordType;
             $scope.showLogDropdown = false;
+            $scope.filterTypes = [];
+
             APIUtils.getSystemLogs(recordType)
                 .then(
                     function(res) {
@@ -102,7 +109,9 @@
           };
 
           $scope.filterBySearchTerms = function(log) {
-            if (!$scope.searchTerms.length) return true;
+            if (!$scope.searchTerms.length) {
+              return true;
+            }
 
             for (var i = 0, length = $scope.searchTerms.length; i < length;
                  i++) {
@@ -116,6 +125,32 @@
             return true;
           };
 
+          $scope.filterBySeverity = function(log) {
+            if ($scope.selectedSeverityList.length == 0) {
+              return true;
+            }
+
+            return ($scope.selectedSeverityList.indexOf(log.Severity) > -1);
+          };
+
+          $scope.filterByType = function(log) {
+            if ($scope.selectedType == 'All') {
+              return true;
+            }
+
+            return (($scope.selectedType == log.SensorType));
+          };
+
+          $scope.filterByDate = function(log) {
+            var logDate = new Date(log.Created);
+            if ($scope.start_date && $scope.end_date) {
+              return (
+                  logDate >= $scope.start_date && logDate <= $scope.end_date);
+            } else {
+              return true;
+            }
+          };
+
           setTimeout($scope.selectRecordType($scope.selectedRecordType), 2000);
         }
       ]);