resolve config with a promise on the login route

This commit is contained in:
John Mitchell 2015-11-03 21:58:01 -05:00
parent 688d933df7
commit e05988ff5d
3 changed files with 12 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',
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) {
@ -1063,8 +1063,8 @@ var tower = angular.module('Tower', [
if (!$AnsibleConfig) {
// there may be time lag when loading the config file, so temporarily use what's in local storage
$AnsibleConfig = Store('AnsibleConfig');
// create a promise that will resolve when $AnsibleConfig is loaded
$rootScope.loginConfig = $q.defer();
}
//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,19 @@ angular.module('LoadConfigHelper', ['Utilities'])
if(angular.isObject(response.data)){
$AnsibleConfig = _.extend($AnsibleConfig, response.data);
Store('AnsibleConfig', $AnsibleConfig);
$rootScope.loginConfig.resolve('config loaded');
$rootScope.$emit('ConfigReady');
}
else {
$log.info('local_settings.json is not a valid object');
$rootScope.loginConfig.resolve('config loaded');
$rootScope.$emit('ConfigReady');
}
}, function() {
//local_settings.json not found
$log.info('local_settings.json not found');
$rootScope.loginConfig.resolve('config loaded');
$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.customLoginInfoPresent = (scope.customLoginInfo) ? true : false;
scope.customLoginInfo = $AnsibleConfig.custom_login_info;
scope.customLoginInfoPresent = ($AnsibleConfig.customLoginInfo) ? true : false;
});
// Reset the login form
//scope.loginForm.login_username.$setPristine();