Fix refresh on system & sensors overview pages
Partially resolves openbmc/openbmc#2927
Change-Id: I7f449c41ef645b67253c5d3c2ed6c8b1984f0408
Signed-off-by: CamVan Nguyen <ctnguyen@us.ibm.com>
diff --git a/app/overview/controllers/system-overview-controller.js b/app/overview/controllers/system-overview-controller.js
index 93aa71d..2382a2a 100644
--- a/app/overview/controllers/system-overview-controller.js
+++ b/app/overview/controllers/system-overview-controller.js
@@ -13,12 +13,13 @@
angular
.module('app.overview')
.controller('systemOverviewController', [
+ '$rootScope',
'$scope',
'$window',
'APIUtils',
'dataService',
'$q',
- function($scope, $window, APIUtils, dataService, $q){
+ function($rootScope, $scope, $window, APIUtils, dataService, $q){
$scope.dataService = dataService;
$scope.dropdown_selected = false;
$scope.tmz = 'EDT';
@@ -90,8 +91,16 @@
APIUtils.setLEDState(toggleState, function(status){
});
}
+
+ var refreshDataListener = $rootScope.$on('refresh-data', function(event, args) {
+ loadOverviewData();
+ });
+
+ $scope.$on('$destroy', function() {
+ refreshDataListener();
+ });
}
]
);
-})(angular);
\ No newline at end of file
+})(angular);
diff --git a/app/server-health/controllers/sensors-overview-controller.js b/app/server-health/controllers/sensors-overview-controller.js
index 04502ca..0a9d0d2 100644
--- a/app/server-health/controllers/sensors-overview-controller.js
+++ b/app/server-health/controllers/sensors-overview-controller.js
@@ -12,13 +12,14 @@
angular
.module('app.overview')
.controller('sensorsOverviewController', [
+ '$rootScope',
'$scope',
'$log',
'$window',
'APIUtils',
'dataService',
'Constants',
- function($scope, $log, $window, APIUtils, dataService, Constants){
+ function($rootScope, $scope, $log, $window, APIUtils, dataService, Constants){
$scope.dataService = dataService;
$scope.dropdown_selected = false;
@@ -133,8 +134,16 @@
};
$scope.loadSensorData();
+
+ var refreshDataListener = $rootScope.$on('refresh-data', function(event, args) {
+ $scope.loadSensorData();
+ });
+
+ $scope.$on('$destroy', function() {
+ refreshDataListener();
+ });
}
]
);
-})(angular);
\ No newline at end of file
+})(angular);