Show a warning in the superuser panel if a container restart is required, and provide a button to do so. This change also moves the restart and monitoring code into a service

This commit is contained in:
Joseph Schorr 2015-01-26 13:46:57 -05:00
parent c88d97cf8b
commit 6a0158d361
5 changed files with 164 additions and 47 deletions

View file

@ -1,4 +1,4 @@
function SetupCtrl($scope, $timeout, ApiService, Features, UserService, AngularPollChannel, CoreDialog) {
function SetupCtrl($scope, $timeout, ApiService, Features, UserService, ContainerService, CoreDialog) {
if (!Features.SUPER_USERS) {
return;
}
@ -102,6 +102,11 @@ function SetupCtrl($scope, $timeout, ApiService, Features, UserService, AngularP
}
});
$scope.restartContainer = function(state) {
$scope.currentStep = state;
ContainerService.restartContainer();
};
$scope.showSuperuserPanel = function() {
$('#setupModal').modal('hide');
window.location = '/superuser';
@ -160,37 +165,6 @@ function SetupCtrl($scope, $timeout, ApiService, Features, UserService, AngularP
CoreDialog.fatal(title, message);
};
$scope.restartContainer = function(restartState) {
$scope.currentStep = restartState;
ApiService.scShutdownContainer(null, null).then(function(resp) {
$timeout(function() {
$scope.checkStatus();
}, 2000);
}, ApiService.errorDisplay('Cannot restart container. Please report this to support.'))
};
$scope.scheduleStatusCheck = function() {
$timeout(function() {
$scope.checkStatus();
}, 3000);
};
$scope.checkStatus = function() {
var errorHandler = function(resp) {
if (resp.status == 404 || resp.status == 502) {
// Container has not yet come back up, so we schedule another check.
$scope.scheduleStatusCheck();
return;
}
return ApiService.errorDisplay('Cannot load status. Please report this to support')(resp);
};
ApiService.scRegistryStatus(null, null).then(function(resp) {
$scope.currentStep = resp['status'];
}, errorHandler, /* background */true);
};
$scope.parseDbUri = function(value) {
if (!value) { return null; }
@ -276,6 +250,12 @@ function SetupCtrl($scope, $timeout, ApiService, Features, UserService, AngularP
}, ApiService.errorDisplay('Cannot validate database. Please report this to support'));
};
$scope.checkStatus = function() {
ContainerService.checkStatus(function(resp) {
$scope.currentStep = resp['status'];
});
};
// Load the initial status.
$scope.checkStatus();
}