Skip to content

Commit 9b05963

Browse files
committed
Don't poll for scavenges
- Remove scavengeNotificationService from Run and logIn controllers so that the UI no longer polls for scavenge status. This prevents the 404 messages that show up in the UI if a scavenge has not been run. - If a 404 is received on the admin screen, stop the scavenge status poller. - Trigger the scavenge status poller if the scavenge button is clicked. This will allow the UI to update the scavenge status once a scavenge has been triggered. - If a scavenge was triggered any other way (through curl for example), the UI will need to be refreshed to see status updates.
1 parent 433ca84 commit 9b05963

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/js/modules/admin/controllers/AdminCtrl.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ define(['./_module'], function (app) {
1010

1111
$scope.noSubSystemsText = 'No sub systems are running.';
1212
$scope.noScavengeHistoryText = 'No scavenges have been run.';
13+
$scope.polling = false;
1314

1415
adminService.getSubsystems()
1516
.then(function(res){
@@ -46,7 +47,9 @@ define(['./_module'], function (app) {
4647
$scope.scavenge = function ($event) {
4748
stop($event);
4849

49-
adminService.scavenge().then(null, function (error) {
50+
adminService.scavenge().then(function() {
51+
setupScavengeStatusPoller();
52+
}, function (error) {
5053
msg.failure('Scavenge failed: ' + error.message);
5154
});
5255
};
@@ -102,6 +105,10 @@ define(['./_module'], function (app) {
102105
var scavengeQuery = {};
103106
var timeout;
104107
function setupScavengeStatusPoller() {
108+
if ($scope.polling === true) {
109+
return;
110+
}
111+
$scope.polling = true;
105112
scavengeQuery = poller.create({
106113
interval: constants.scavengeStatus.pollInterval,
107114
action: adminService.scavengeStatus,
@@ -113,6 +120,12 @@ define(['./_module'], function (app) {
113120
function(error) {
114121
if(error.statusCode === 401){
115122
$scope.noScavengeHistoryText = 'You are not authorized to view the scavenge history';
123+
$scope.polling = false;
124+
return;
125+
}
126+
if (error.statusCode === 404) {
127+
$scope.noScavengeHistoryText = "No scavenges have been run.";
128+
$scope.polling = false;
116129
return;
117130
}
118131
if(timeout){

src/js/modules/security/controllers/SignInCtrl.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ define(['./_module'], function (app) {
33
'use strict';
44

55
return app.controller('SignInCtrl', [
6-
'$scope', '$rootScope', '$state', '$location', 'AuthService', 'MessageService', 'InfoService', 'ScavengeNotificationService',
7-
function ($scope, $rootScope, $state, $location, authService, msg, infoService, scavengeNotificationService) {
6+
'$scope', '$rootScope', '$state', '$location', 'AuthService', 'MessageService', 'InfoService',
7+
function ($scope, $rootScope, $state, $location, authService, msg, infoService) {
88

99
$scope.log = {
1010
username: '',
@@ -33,7 +33,6 @@ define(['./_module'], function (app) {
3333
};
3434

3535
function setSingleNodeOrCluster(){
36-
scavengeNotificationService.start();
3736
infoService.getOptions().then(function(res){
3837
var options = res.data;
3938
for (var index in options) {

src/js/run.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ define(['es-ui'], function (app) {
88
});
99
}]);
1010
return app.run([
11-
'$rootScope', '$location', '$state', '$stateParams', 'AuthService', 'InfoService', 'ScavengeNotificationService', 'MessageService','$http',
12-
function ($rootScope, $location, $state, $stateParams, authService, infoService, scavengeNotificationService, msg, $http) {
11+
'$rootScope', '$location', '$state', '$stateParams', 'AuthService', 'InfoService', 'MessageService','$http',
12+
function ($rootScope, $location, $state, $stateParams, authService, infoService, msg, $http) {
1313
$rootScope.baseUrl = $location.protocol() + '://' + $location.host() + ':' + $location.port();
1414
/*$rootScope.baseUrl = 'https://127.0.0.1:2113'; //uncomment during development*/
1515
$rootScope.projectionsEnabled = false;
@@ -77,7 +77,6 @@ define(['es-ui'], function (app) {
7777
});
7878

7979
function setSingleNodeOrCluster(){
80-
scavengeNotificationService.start();
8180
infoService.getOptions().then(function onGetOptions(response){
8281
var options = response.data;
8382
for (var index in options) {

0 commit comments

Comments
 (0)