mirror of
https://github.com/ansible/awx.git
synced 2026-05-21 15:57:52 -02:30
loca_config
Fixed lingering issues where $AnsibleConfig is referenced when it is not yet defined.
This commit is contained in:
@@ -400,7 +400,7 @@ angular.module('Tower', [
|
|||||||
var _debug = $delegate.debug;
|
var _debug = $delegate.debug;
|
||||||
$delegate.debug = function(msg) {
|
$delegate.debug = function(msg) {
|
||||||
// only show debug messages when debug_mode set to true in config
|
// only show debug messages when debug_mode set to true in config
|
||||||
if ($AnsibleConfig.debug_mode) {
|
if ($AnsibleConfig && $AnsibleConfig.debug_mode) {
|
||||||
_debug(msg);
|
_debug(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -415,8 +415,6 @@ angular.module('Tower', [
|
|||||||
|
|
||||||
var e, html, sock, checkCount;
|
var e, html, sock, checkCount;
|
||||||
|
|
||||||
LoadConfig();
|
|
||||||
|
|
||||||
function detectBrowser() {
|
function detectBrowser() {
|
||||||
var ua = window.navigator.userAgent,
|
var ua = window.navigator.userAgent,
|
||||||
browser;
|
browser;
|
||||||
@@ -462,6 +460,16 @@ angular.module('Tower', [
|
|||||||
$('#ansible-mobile-menu a[href="#' + base + '"]').addClass('active');
|
$('#ansible-mobile-menu a[href="#' + base + '"]').addClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($rootScope.removeConfigReady) {
|
||||||
|
$rootScope.removeConfigReady();
|
||||||
|
}
|
||||||
|
$rootScope.removeConfigReady = $rootScope.$on('ConfigReady', function() {
|
||||||
|
LoadBasePaths();
|
||||||
|
|
||||||
|
$rootScope.breadcrumbs = [];
|
||||||
|
$rootScope.crumbCache = [];
|
||||||
|
$rootScope.sessionTimer = Timer.init();
|
||||||
|
|
||||||
$rootScope.browser = detectBrowser();
|
$rootScope.browser = detectBrowser();
|
||||||
|
|
||||||
$rootScope.$on("$routeChangeStart", function (event, next) {
|
$rootScope.$on("$routeChangeStart", function (event, next) {
|
||||||
@@ -508,16 +516,6 @@ angular.module('Tower', [
|
|||||||
activateTab();
|
activateTab();
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($rootScope.removeConfigReady) {
|
|
||||||
$rootScope.removeConfigReady();
|
|
||||||
}
|
|
||||||
$rootScope.removeConfigReady = $rootScope.$on('ConfigReady', function() {
|
|
||||||
LoadBasePaths();
|
|
||||||
|
|
||||||
$rootScope.breadcrumbs = [];
|
|
||||||
$rootScope.crumbCache = [];
|
|
||||||
$rootScope.sessionTimer = Timer.init();
|
|
||||||
|
|
||||||
if (!Authorization.getToken()) {
|
if (!Authorization.getToken()) {
|
||||||
// When the app first loads, redirect to login page
|
// When the app first loads, redirect to login page
|
||||||
$rootScope.sessionExpired = false;
|
$rootScope.sessionExpired = false;
|
||||||
@@ -575,7 +573,7 @@ angular.module('Tower', [
|
|||||||
// monitor socket status
|
// monitor socket status
|
||||||
checkCount = 0;
|
checkCount = 0;
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
if (sock.checkStatus() === 'error' || checkCount > 2) {
|
if (sock.checkStatus() === 'error' || checkCount > 3) {
|
||||||
// there's an error or we're stuck in a 'connecting' state. attempt to reconnect
|
// there's an error or we're stuck in a 'connecting' state. attempt to reconnect
|
||||||
sock = null;
|
sock = null;
|
||||||
$log.debug('attempting new socket connection');
|
$log.debug('attempting new socket connection');
|
||||||
@@ -590,5 +588,7 @@ angular.module('Tower', [
|
|||||||
}
|
}
|
||||||
}, 3000);
|
}, 3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
LoadConfig();
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,11 +8,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* globals console:false */
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function Authenticate($cookieStore, $compile, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
|
function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
|
||||||
Timer, Empty) {
|
Timer, Empty) {
|
||||||
|
|
||||||
var setLoginFocus, lastPath, sessionExpired,
|
var setLoginFocus, lastPath, sessionExpired,
|
||||||
@@ -28,10 +26,8 @@ function Authenticate($cookieStore, $compile, $window, $scope, $rootScope, $loca
|
|||||||
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
|
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($AnsibleConfig.debug_mode && console) {
|
$log.debug('User session expired: ' + sessionExpired);
|
||||||
console.log('User session expired: ' + sessionExpired);
|
$log.debug('Last URL: ' + lastPath());
|
||||||
console.log('Last URL: ' + lastPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide any lingering modal dialogs
|
// Hide any lingering modal dialogs
|
||||||
$('.modal[aria-hidden=false]').each(function () {
|
$('.modal[aria-hidden=false]').each(function () {
|
||||||
@@ -166,6 +162,6 @@ function Authenticate($cookieStore, $compile, $window, $scope, $rootScope, $loca
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Authenticate.$inject = ['$cookieStore', '$compile', '$window', '$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait',
|
Authenticate.$inject = ['$log', '$cookieStore', '$compile', '$window', '$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait',
|
||||||
'Timer', 'Empty'
|
'Timer', 'Empty'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
angular.module('LoadConfigHelper', ['Utilities'])
|
angular.module('LoadConfigHelper', ['Utilities'])
|
||||||
|
|
||||||
.factory('LoadConfig', ['$rootScope', '$http', 'ProcessErrors', function($rootScope, $http, ProcessErrors) {
|
.factory('LoadConfig', ['$log', '$rootScope', '$http', 'ProcessErrors', function($log, $rootScope, $http, ProcessErrors) {
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
if ($rootScope.removeLoadConfig) {
|
if ($rootScope.removeLoadConfig) {
|
||||||
@@ -22,8 +22,10 @@ angular.module('LoadConfigHelper', ['Utilities'])
|
|||||||
}
|
}
|
||||||
$rootScope.removeLoadConfig = $rootScope.$on('LoadConfig', function() {
|
$rootScope.removeLoadConfig = $rootScope.$on('LoadConfig', function() {
|
||||||
// local_config.js not found, so we'll load config.js
|
// local_config.js not found, so we'll load config.js
|
||||||
|
$log.info('attempting to load config.js');
|
||||||
$http({ method:'GET', url: $basePath + 'js/config.js' })
|
$http({ method:'GET', url: $basePath + 'js/config.js' })
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
|
$log.info('loaded config.js');
|
||||||
$AnsibleConfig = eval(data);
|
$AnsibleConfig = eval(data);
|
||||||
$rootScope.$emit('ConfigReady');
|
$rootScope.$emit('ConfigReady');
|
||||||
})
|
})
|
||||||
@@ -37,11 +39,13 @@ angular.module('LoadConfigHelper', ['Utilities'])
|
|||||||
// Load js/local_config.js
|
// Load js/local_config.js
|
||||||
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
|
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
|
$log.info('loaded local_config.js');
|
||||||
$AnsibleConfig = eval(data);
|
$AnsibleConfig = eval(data);
|
||||||
$rootScope.$emit('ConfigReady');
|
$rootScope.$emit('ConfigReady');
|
||||||
})
|
})
|
||||||
.error(function() {
|
.error(function() {
|
||||||
//local_config.js not found
|
//local_config.js not found
|
||||||
|
$log.info('local_config.js not found');
|
||||||
$rootScope.$emit('LoadConfig');
|
$rootScope.$emit('LoadConfig');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user