Merge pull request #425 from jaredevantabor/login_cofig

LoadConfig fix to load config.js first and then local_settings.json
This commit is contained in:
jaredevantabor 2015-09-21 13:38:31 -04:00
commit 2fe97e526c
3 changed files with 33 additions and 25 deletions

2
.gitignore vendored
View File

@ -12,7 +12,7 @@ awx/public/media
awx/public/static
awx/ui/tests/test-results.xml
awx/ui/static/js/awx.min.js
awx/ui/static/js/local_config.js
awx/ui/static/js/local_settings.json
awx/ui/static/css/awx.min.css
awx/main/fixtures
awx/*.log

View File

@ -3,7 +3,7 @@
*
* All Rights Reserved
*************************************************/
/**
* @ngdoc function
* @name helpers.function:LoadConfig
@ -22,42 +22,51 @@
export default
angular.module('LoadConfigHelper', ['Utilities'])
.factory('LoadConfig', ['$log', '$rootScope', '$http', '$location', 'ProcessErrors', 'Store', function($log, $rootScope, $http, $location, ProcessErrors, Store) {
.factory('LoadConfig', ['$log', '$rootScope', '$http', '$location',
'ProcessErrors', 'Store',
function($log, $rootScope, $http, $location, ProcessErrors, Store) {
return function() {
if ($rootScope.removeLoadConfig) {
$rootScope.removeLoadConfig();
}
$rootScope.removeLoadConfig = $rootScope.$on('LoadConfig', function() {
// local_config.js not found, so we'll load config.js
$log.info('attempting to load config.js');
$http({ method:'GET', url: $basePath + 'config.js' })
.success(function(data) {
$log.info('loaded config.js');
$AnsibleConfig = eval(data);
Store('AnsibleConfig', $AnsibleConfig);
$rootScope.enteredPath = $location.path();
// Load js/local_settings.json
$http({ method:'GET', url: $basePath + 'local_settings.json' })
.then(function(response) {
$log.info('loaded local_settings.json');
if(angular.isObject(response.data)){
$AnsibleConfig = _.extend($AnsibleConfig, response.data);
Store('AnsibleConfig', $AnsibleConfig);
$rootScope.$emit('ConfigReady');
}
else {
$log.info('local_settings.json is not a valid object');
$rootScope.$emit('ConfigReady');
}
}, function(response) {
//local_settings.json not found
$log.info('local_settings.json not found');
$rootScope.$emit('ConfigReady');
})
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Failed to load ' + $basePath + '/config.js. GET status: ' + status
});
});
});
$rootScope.enteredPath = $location.path();
// Load js/local_config.js
$http({ method:'GET', url: $basePath + '/local_config.js' })
// load config.js
$log.info('attempting to load config.js');
$http({ method:'GET', url: $basePath + 'config.js' })
.success(function(data) {
$log.info('loaded local_config.js');
$log.info('loaded config.js');
$AnsibleConfig = eval(data);
Store('AnsibleConfig', $AnsibleConfig);
$rootScope.$emit('ConfigReady');
})
.error(function() {
//local_config.js not found
$log.info('local_config.js not found');
$rootScope.$emit('LoadConfig');
})
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Failed to load ' + $basePath + '/config.js. GET status: ' + status
});
});
};
}]);

View File

@ -15,7 +15,6 @@ export default
controller: authenticationController,
templateUrl: templateUrl('login/loginModal'),
link: function(scope, element, attrs) {
console.log('here you mfers');
// Display the login dialog
$('#login-modal').modal({
show: true,