diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js
index ae6255a3e0..a272f80485 100644
--- a/awx/ui/static/js/app.js
+++ b/awx/ui/static/js/app.js
@@ -416,11 +416,6 @@ angular.module('Tower', [
var e, html, sock, checkCount;
LoadConfig();
- LoadBasePaths();
-
- $rootScope.breadcrumbs = [];
- $rootScope.crumbCache = [];
- $rootScope.sessionTimer = Timer.init();
function detectBrowser() {
var ua = window.navigator.userAgent,
@@ -513,76 +508,87 @@ angular.module('Tower', [
activateTab();
});
- if (!Authorization.getToken()) {
- // When the app first loads, redirect to login page
- $rootScope.sessionExpired = false;
- $cookieStore.put('sessionExpired', false);
- $location.path('/login');
- } else {
- // If browser refresh, set the user_is_superuser value
- $rootScope.user_is_superuser = Authorization.getUserInfo('is_superuser');
+ if ($rootScope.removeConfigReady) {
+ $rootScope.removeConfigReady();
}
+ $rootScope.removeConfigReady = $rootScope.$on('ConfigReady', function() {
+ LoadBasePaths();
- activateTab();
+ $rootScope.breadcrumbs = [];
+ $rootScope.crumbCache = [];
+ $rootScope.sessionTimer = Timer.init();
- $rootScope.viewCurrentUser = function () {
- $location.path('/users/' + $rootScope.current_user.id);
- };
-
- $rootScope.viewLicense = function () {
- ViewLicense();
- };
- $rootScope.toggleTab = function(e, tab, tabs) {
- e.preventDefault();
- $('#' + tabs + ' #' + tab).tab('show');
- };
-
- html = "";
- e = angular.element(document.getElementById('socket-beacon-div'));
- e.empty().append(html);
- $compile(e)($rootScope);
-
- e = angular.element(document.getElementById('socket-beacon-li'));
- e.empty().append(html);
- $compile(e)($rootScope);
-
- // Listen for job changes and issue callbacks to initiate
- // DOM updates
- function openSocket() {
- sock = Socket({ scope: $rootScope, endpoint: "jobs" });
- sock.init();
- sock.on("status_changed", function(data) {
- $log.debug('Job ' + data.unified_job_id + ' status changed to ' + data.status);
- $rootScope.$emit('JobStatusChange', data);
- });
- }
-
- openSocket();
-
- setTimeout(function() {
- $rootScope.$apply(function() {
- sock.checkStatus();
- $log.debug('socket status: ' + $rootScope.socketStatus);
- });
- },2000);
-
- // monitor socket status
- checkCount = 0;
- setInterval(function() {
- if (sock.checkStatus() === 'error' || checkCount > 2) {
- // there's an error or we're stuck in a 'connecting' state. attempt to reconnect
- sock = null;
- $log.debug('attempting new socket connection');
- openSocket();
- checkCount = 0;
+ if (!Authorization.getToken()) {
+ // When the app first loads, redirect to login page
+ $rootScope.sessionExpired = false;
+ $cookieStore.put('sessionExpired', false);
+ $location.path('/login');
+ } else {
+ // If browser refresh, set the user_is_superuser value
+ $rootScope.user_is_superuser = Authorization.getUserInfo('is_superuser');
}
- else if (sock.checkStatus() === 'connecting') {
- checkCount++;
+
+ activateTab();
+
+ $rootScope.viewCurrentUser = function () {
+ $location.path('/users/' + $rootScope.current_user.id);
+ };
+
+ $rootScope.viewLicense = function () {
+ ViewLicense();
+ };
+ $rootScope.toggleTab = function(e, tab, tabs) {
+ e.preventDefault();
+ $('#' + tabs + ' #' + tab).tab('show');
+ };
+
+ html = "";
+ e = angular.element(document.getElementById('socket-beacon-div'));
+ e.empty().append(html);
+ $compile(e)($rootScope);
+
+ e = angular.element(document.getElementById('socket-beacon-li'));
+ e.empty().append(html);
+ $compile(e)($rootScope);
+
+ // Listen for job changes and issue callbacks to initiate
+ // DOM updates
+ function openSocket() {
+ sock = Socket({ scope: $rootScope, endpoint: "jobs" });
+ sock.init();
+ sock.on("status_changed", function(data) {
+ $log.debug('Job ' + data.unified_job_id + ' status changed to ' + data.status);
+ $rootScope.$emit('JobStatusChange', data);
+ });
}
- else {
- checkCount = 0;
- }
- }, 3000);
+
+ openSocket();
+
+ setTimeout(function() {
+ $rootScope.$apply(function() {
+ sock.checkStatus();
+ $log.debug('socket status: ' + $rootScope.socketStatus);
+ });
+ },2000);
+
+ // monitor socket status
+ checkCount = 0;
+ setInterval(function() {
+ if (sock.checkStatus() === 'error' || checkCount > 2) {
+ // there's an error or we're stuck in a 'connecting' state. attempt to reconnect
+ sock = null;
+ $log.debug('attempting new socket connection');
+ openSocket();
+ checkCount = 0;
+ }
+ else if (sock.checkStatus() === 'connecting') {
+ checkCount++;
+ }
+ else {
+ checkCount = 0;
+ }
+ }, 3000);
+ });
}
]);
diff --git a/awx/ui/static/js/helpers/LoadConfig.js b/awx/ui/static/js/helpers/LoadConfig.js
index 13ad0a08e1..e40d0f6f5b 100644
--- a/awx/ui/static/js/helpers/LoadConfig.js
+++ b/awx/ui/static/js/helpers/LoadConfig.js
@@ -25,6 +25,7 @@ angular.module('LoadConfigHelper', ['Utilities'])
$http({ method:'GET', url: $basePath + 'js/config.js' })
.success(function(data) {
$AnsibleConfig = eval(data);
+ $rootScope.$emit('ConfigReady');
})
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
@@ -37,10 +38,11 @@ angular.module('LoadConfigHelper', ['Utilities'])
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
.success(function(data) {
$AnsibleConfig = eval(data);
+ $rootScope.$emit('ConfigReady');
})
.error(function() {
//local_config.js not found
$rootScope.$emit('LoadConfig');
});
- };
+ }
}]);
\ No newline at end of file