loca_config

Fixed lingering issues where $AnsibleConfig is referenced when it is not yet defined.
This commit is contained in:
Chris Houseknecht
2014-07-25 13:59:34 -04:00
parent de953ec3ed
commit 7139b5b25a
3 changed files with 59 additions and 59 deletions

View File

@@ -400,7 +400,7 @@ angular.module('Tower', [
var _debug = $delegate.debug;
$delegate.debug = function(msg) {
// only show debug messages when debug_mode set to true in config
if ($AnsibleConfig.debug_mode) {
if ($AnsibleConfig && $AnsibleConfig.debug_mode) {
_debug(msg);
}
};
@@ -415,8 +415,6 @@ angular.module('Tower', [
var e, html, sock, checkCount;
LoadConfig();
function detectBrowser() {
var ua = window.navigator.userAgent,
browser;
@@ -462,6 +460,16 @@ angular.module('Tower', [
$('#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.$on("$routeChangeStart", function (event, next) {
@@ -508,16 +516,6 @@ angular.module('Tower', [
activateTab();
});
if ($rootScope.removeConfigReady) {
$rootScope.removeConfigReady();
}
$rootScope.removeConfigReady = $rootScope.$on('ConfigReady', function() {
LoadBasePaths();
$rootScope.breadcrumbs = [];
$rootScope.crumbCache = [];
$rootScope.sessionTimer = Timer.init();
if (!Authorization.getToken()) {
// When the app first loads, redirect to login page
$rootScope.sessionExpired = false;
@@ -575,7 +573,7 @@ angular.module('Tower', [
// monitor socket status
checkCount = 0;
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
sock = null;
$log.debug('attempting new socket connection');
@@ -590,5 +588,7 @@ angular.module('Tower', [
}
}, 3000);
});
LoadConfig();
}
]);

View File

@@ -8,11 +8,9 @@
*
*/
/* globals console:false */
'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) {
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;
};
if ($AnsibleConfig.debug_mode && console) {
console.log('User session expired: ' + sessionExpired);
console.log('Last URL: ' + lastPath());
}
$log.debug('User session expired: ' + sessionExpired);
$log.debug('Last URL: ' + lastPath());
// Hide any lingering modal dialogs
$('.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'
];

View File

@@ -14,7 +14,7 @@
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() {
if ($rootScope.removeLoadConfig) {
@@ -22,8 +22,10 @@ angular.module('LoadConfigHelper', ['Utilities'])
}
$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 + 'js/config.js' })
.success(function(data) {
$log.info('loaded config.js');
$AnsibleConfig = eval(data);
$rootScope.$emit('ConfigReady');
})
@@ -37,11 +39,13 @@ angular.module('LoadConfigHelper', ['Utilities'])
// Load js/local_config.js
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
.success(function(data) {
$log.info('loaded local_config.js');
$AnsibleConfig = eval(data);
$rootScope.$emit('ConfigReady');
})
.error(function() {
//local_config.js not found
$log.info('local_config.js not found');
$rootScope.$emit('LoadConfig');
});
};