GUACAMOLE-1756: Clean up assignment of application state.

This commit is contained in:
Michael Jumper
2023-03-23 00:16:32 -07:00
committed by Mike Jumper
parent a1fbe5f0a4
commit 89c3433f51

View File

@@ -228,6 +228,22 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
}, true); }, true);
/**
* Sets the current overall state of the client side of the
* application to the given value. Possible values are defined by
* {@link ApplicationState}. The title and class associated with the
* current page are automatically reset to the standard values applicable
* to the application as a whole (rather than any specific page).
*
* @param {!string} state
* The state to assign, as defined by {@link ApplicationState}.
*/
const setApplicationState = function setApplicationState(state) {
$scope.applicationState = state;
$scope.page.title = 'APP.NAME';
$scope.page.bodyClassName = '';
};
/** /**
* Navigates the user back to the root of the application (or reloads the * Navigates the user back to the root of the application (or reloads the
* current route and controller if the user is already there), effectively * current route and controller if the user is already there), effectively
@@ -250,9 +266,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
// Display login screen if a whole new set of credentials is needed // Display login screen if a whole new set of credentials is needed
$scope.$on('guacInvalidCredentials', function loginInvalid(event, parameters, error) { $scope.$on('guacInvalidCredentials', function loginInvalid(event, parameters, error) {
$scope.applicationState = ApplicationState.AWAITING_CREDENTIALS; setApplicationState(ApplicationState.AWAITING_CREDENTIALS);
$scope.page.title = 'APP.NAME';
$scope.page.bodyClassName = '';
$scope.loginHelpText = null; $scope.loginHelpText = null;
$scope.acceptedCredentials = {}; $scope.acceptedCredentials = {};
@@ -263,9 +277,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
// Prompt for remaining credentials if provided credentials were not enough // Prompt for remaining credentials if provided credentials were not enough
$scope.$on('guacInsufficientCredentials', function loginInsufficient(event, parameters, error) { $scope.$on('guacInsufficientCredentials', function loginInsufficient(event, parameters, error) {
$scope.applicationState = ApplicationState.AWAITING_CREDENTIALS; setApplicationState(ApplicationState.AWAITING_CREDENTIALS);
$scope.page.title = 'APP.NAME';
$scope.page.bodyClassName = '';
$scope.loginHelpText = error.translatableMessage; $scope.loginHelpText = error.translatableMessage;
$scope.acceptedCredentials = parameters; $scope.acceptedCredentials = parameters;
@@ -283,10 +295,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|| error.type === Error.Type.INVALID_CREDENTIALS) || error.type === Error.Type.INVALID_CREDENTIALS)
return; return;
$scope.applicationState = ApplicationState.AUTOMATIC_LOGIN_REJECTED; setApplicationState(ApplicationState.AUTOMATIC_LOGIN_REJECTED);
$scope.page.title = 'APP.NAME';
$scope.page.bodyClassName = '';
$scope.reAuthenticating = false; $scope.reAuthenticating = false;
$scope.fatalError = error; $scope.fatalError = error;
@@ -295,13 +304,8 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
// Replace absolutely all content with an error message if the page itself // Replace absolutely all content with an error message if the page itself
// cannot be displayed due to an error // cannot be displayed due to an error
$scope.$on('guacFatalPageError', function fatalPageError(error) { $scope.$on('guacFatalPageError', function fatalPageError(error) {
setApplicationState(ApplicationState.FATAL_ERROR);
$scope.applicationState = ApplicationState.FATAL_ERROR;
$scope.page.title = 'APP.NAME';
$scope.page.bodyClassName = '';
$scope.fatalError = error; $scope.fatalError = error;
}); });
// Replace the overall user interface with an informational message if the // Replace the overall user interface with an informational message if the