Fix refresh for event log page

Coded the refresh button in log page so
that upon clicking on it will run the rest
command to get the latest event log data.
This sample code can be used to fetch the
relevant data for other pages when refresh
button is clicked.

Fixes openbmc/openbmc#3009

Change-Id: Iefdc3f77895881df44238142148eb298663c3b5a
Signed-off-by: Iftekharul Islam <iffy.ryan@ibm.com>
diff --git a/app/common/directives/app-header.js b/app/common/directives/app-header.js
index 69a9c7b..4c49501 100644
--- a/app/common/directives/app-header.js
+++ b/app/common/directives/app-header.js
@@ -63,7 +63,7 @@
 
                     $scope.refresh = function(){
                         loadData();
-
+                        $scope.$emit('refresh-data');
                         //Add flash class to header timestamp on click of refresh
                         var myEl = angular.element( document.querySelector( '.header__refresh' ) );
                         myEl.addClass('flash');
diff --git a/app/server-health/controllers/log-controller.js b/app/server-health/controllers/log-controller.js
index 7493ba5..d871778 100644
--- a/app/server-health/controllers/log-controller.js
+++ b/app/server-health/controllers/log-controller.js
@@ -15,6 +15,7 @@
             paginationTemplateProvider.setString(require('../../common/directives/dirPagination.tpl.html'));
         })
         .controller('logController', [
+            '$rootScope',
             '$scope',
             '$window',
             'APIUtils',
@@ -22,7 +23,7 @@
             'Constants',
             '$routeParams',
             '$filter',
-            function($scope, $window, APIUtils, dataService, Constants, $routeParams, $filter){
+            function($rootScope, $scope, $window, APIUtils, dataService, Constants, $routeParams, $filter){
                 $scope.dataService = dataService;
                 $scope.logs = [];
                 $scope.tmz = 'EDT';
@@ -191,6 +192,14 @@
                 }, true);
 
                 $scope.loadLogs();
+
+                var refreshDataListener = $rootScope.$on('refresh-data', function(event, args){
+                    $scope.loadLogs();
+                });
+
+                $scope.$on('$destroy', function() {
+                    refreshDataListener();
+                });
             }
         ]
     );