diff --git a/public/js/app.js b/public/js/app.js index a7487c88c6076430fe62a5fc132998094463824a..2519f4493755db6957b5b25f2c755daf6a1d6862 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -866,6 +866,11 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.closed_indices = data.closed_indices; $scope.special_indices = data.special_indices; $scope.shardAllocation = data.shard_allocation; + if (!$scope.unassigned_shards && + !$scope.relocating_shards && + !$scope.initializing_shards) { + $scope.indices_filter.healthy = true; + } }, function(error) { AlertService.error('Error while loading data', error); diff --git a/src/app/components/overview/controller.js b/src/app/components/overview/controller.js index 98689528d01f677d75f915dd1a898625921ba2ac..d8e9da0181a8fee3e7e9c2a009ff154772148d05 100644 --- a/src/app/components/overview/controller.js +++ b/src/app/components/overview/controller.js @@ -59,6 +59,11 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.closed_indices = data.closed_indices; $scope.special_indices = data.special_indices; $scope.shardAllocation = data.shard_allocation; + if (!$scope.unassigned_shards && + !$scope.relocating_shards && + !$scope.initializing_shards) { + $scope.indices_filter.healthy = true; + } }, function(error) { AlertService.error('Error while loading data', error); diff --git a/tests/controllers/overview.tests.js b/tests/controllers/overview.tests.js index e237c9f88c10caa2eaff914a9268a121fe5cd95b..53a4a55ad653199f95eab49502bc4ce4d0a8d159 100644 --- a/tests/controllers/overview.tests.js +++ b/tests/controllers/overview.tests.js @@ -76,7 +76,7 @@ describe('OverviewController', function() { }; this.OverviewDataService.getOverview = function(success, error) { success(data); - } + }; spyOn(this.OverviewDataService, 'getOverview').and.callThrough(); spyOn(this.scope, 'setIndices').and.returnValue(true); spyOn(this.scope, 'setNodes').and.returnValue(true); @@ -93,6 +93,25 @@ describe('OverviewController', function() { expect(this.scope.data).toEqual(data); } ); + + it('clears health filter if no unhealthy indices exist', + function() { + var data = { + indices: ['someIndex'], + nodes: ['someNode'], + unassigned_shards: 0, + relocating_shards: 0, + initializing_shards: 0 + }; + this.OverviewDataService.getOverview = function(success, error) { + success(data); + }; + this.scope.indices_filter.healthy = false; + spyOn(this.OverviewDataService, 'getOverview').and.callThrough(); + this.scope.refresh(); + expect(this.scope.indices_filter.healthy).toEqual(true); + } + ); it('cleans state and alerts users if refreshing data fails', function() {