From f88320a5f7e2328794801299fd3d2aed91fc591c Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 16 Sep 2015 16:36:36 -0400 Subject: [PATCH 1/2] LoadConfig fix to load config.js first and then local_settings.json --- .gitignore | 2 +- awx/ui/client/src/helpers/LoadConfig.js | 54 +++++++++++-------- .../client/src/login/loginModal.directive.js | 1 - 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index aa37a6f1d1..e47a9df7cb 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/awx/ui/client/src/helpers/LoadConfig.js b/awx/ui/client/src/helpers/LoadConfig.js index 7f946378a6..82659b96f2 100644 --- a/awx/ui/client/src/helpers/LoadConfig.js +++ b/awx/ui/client/src/helpers/LoadConfig.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name helpers.function:LoadConfig @@ -22,42 +22,52 @@ 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' }) + $rootScope.enteredPath = $location.path(); + // Load js/local_settings.json + $http({ method:'GET', url: $basePath + 'local_settings.json' }) .success(function(data) { - $log.info('loaded config.js'); - $AnsibleConfig = eval(data); - Store('AnsibleConfig', $AnsibleConfig); - $rootScope.$emit('ConfigReady'); + $log.info('loaded local_settings.json'); + if(angular.isObject(data)){ + $AnsibleConfig = _.extend($AnsibleConfig, data); + Store('AnsibleConfig', $AnsibleConfig); + $rootScope.$emit('ConfigReady'); + } + else { + $log.info('local_settings.json is not a valid object'); + $rootScope.$emit('ConfigReady'); + } + }) - .error(function(data, status) { - ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', - msg: 'Failed to load ' + $basePath + '/config.js. GET status: ' + status - }); + .error(function() { + //local_settings.json not found + $log.info('local_settings.json not found'); + $rootScope.$emit('ConfigReady'); }); }); - $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 + }); }); }; }]); diff --git a/awx/ui/client/src/login/loginModal.directive.js b/awx/ui/client/src/login/loginModal.directive.js index b0cbcc02b7..9c520bbb28 100644 --- a/awx/ui/client/src/login/loginModal.directive.js +++ b/awx/ui/client/src/login/loginModal.directive.js @@ -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, From 33a82222b9ccac6a678202cae397306f864ec238 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Mon, 21 Sep 2015 11:38:53 -0400 Subject: [PATCH 2/2] updated $http get request from deprecated syntax for angular 1.4 --- awx/ui/client/src/helpers/LoadConfig.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/awx/ui/client/src/helpers/LoadConfig.js b/awx/ui/client/src/helpers/LoadConfig.js index 82659b96f2..05c4a82233 100644 --- a/awx/ui/client/src/helpers/LoadConfig.js +++ b/awx/ui/client/src/helpers/LoadConfig.js @@ -34,10 +34,10 @@ angular.module('LoadConfigHelper', ['Utilities']) $rootScope.enteredPath = $location.path(); // Load js/local_settings.json $http({ method:'GET', url: $basePath + 'local_settings.json' }) - .success(function(data) { + .then(function(response) { $log.info('loaded local_settings.json'); - if(angular.isObject(data)){ - $AnsibleConfig = _.extend($AnsibleConfig, data); + if(angular.isObject(response.data)){ + $AnsibleConfig = _.extend($AnsibleConfig, response.data); Store('AnsibleConfig', $AnsibleConfig); $rootScope.$emit('ConfigReady'); } @@ -46,8 +46,7 @@ angular.module('LoadConfigHelper', ['Utilities']) $rootScope.$emit('ConfigReady'); } - }) - .error(function() { + }, function(response) { //local_settings.json not found $log.info('local_settings.json not found'); $rootScope.$emit('ConfigReady');