Merge pull request #486 from jlmitch5/promiseConfig

Promise config
This commit is contained in:
jlmitch5
2015-11-04 15:09:35 -05:00
3 changed files with 18 additions and 7 deletions

View File

@@ -834,9 +834,9 @@ var tower = angular.module('Tower', [
}]); }]);
}]) }])
.run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket', .run(['$q', '$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket',
'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', 'pendoService', 'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', 'pendoService',
function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket, function ($q, $compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket,
LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp, pendoService) { LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp, pendoService) {
@@ -1063,8 +1063,8 @@ var tower = angular.module('Tower', [
if (!$AnsibleConfig) { if (!$AnsibleConfig) {
// there may be time lag when loading the config file, so temporarily use what's in local storage // create a promise that will resolve when $AnsibleConfig is loaded
$AnsibleConfig = Store('AnsibleConfig'); $rootScope.loginConfig = $q.defer();
} }
//the authorization controller redirects to the home page automatcially if there is no last path defined. in order to override //the authorization controller redirects to the home page automatcially if there is no last path defined. in order to override

View File

@@ -39,16 +39,25 @@ angular.module('LoadConfigHelper', ['Utilities'])
if(angular.isObject(response.data)){ if(angular.isObject(response.data)){
$AnsibleConfig = _.extend($AnsibleConfig, response.data); $AnsibleConfig = _.extend($AnsibleConfig, response.data);
Store('AnsibleConfig', $AnsibleConfig); Store('AnsibleConfig', $AnsibleConfig);
if ($rootScope.loginConfig) {
$rootScope.loginConfig.resolve('config loaded');
}
$rootScope.$emit('ConfigReady'); $rootScope.$emit('ConfigReady');
} }
else { else {
$log.info('local_settings.json is not a valid object'); $log.info('local_settings.json is not a valid object');
if ($rootScope.loginConfig) {
$rootScope.loginConfig.resolve('config loaded');
}
$rootScope.$emit('ConfigReady'); $rootScope.$emit('ConfigReady');
} }
}, function() { }, function() {
//local_settings.json not found //local_settings.json not found
$log.info('local_settings.json not found'); $log.info('local_settings.json not found');
if ($rootScope.loginConfig) {
$rootScope.loginConfig.resolve('config loaded');
}
$rootScope.$emit('ConfigReady'); $rootScope.$emit('ConfigReady');
}); });
}); });

View File

@@ -111,10 +111,12 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l
}); });
scope.customLogo = ($AnsibleConfig.custom_logo) ? "custom_console_logo.png" : "tower_console_logo.png"; $rootScope.loginConfig.promise.then(function () {
scope.customLogo = ($AnsibleConfig.custom_logo) ? "custom_console_logo.png" : "tower_console_logo.png";
scope.customLoginInfo = $AnsibleConfig.custom_login_info; scope.customLoginInfo = $AnsibleConfig.custom_login_info;
scope.customLoginInfoPresent = (scope.customLoginInfo) ? true : false; scope.customLoginInfoPresent = ($AnsibleConfig.customLoginInfo) ? true : false;
});
// Reset the login form // Reset the login form
//scope.loginForm.login_username.$setPristine(); //scope.loginForm.login_username.$setPristine();