mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 03:17:38 -02:30
local_config
Don't start the app until the config file is loaded and $AnsibleConfig is defined.
This commit is contained in:
@@ -416,11 +416,6 @@ angular.module('Tower', [
|
|||||||
var e, html, sock, checkCount;
|
var e, html, sock, checkCount;
|
||||||
|
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
LoadBasePaths();
|
|
||||||
|
|
||||||
$rootScope.breadcrumbs = [];
|
|
||||||
$rootScope.crumbCache = [];
|
|
||||||
$rootScope.sessionTimer = Timer.init();
|
|
||||||
|
|
||||||
function detectBrowser() {
|
function detectBrowser() {
|
||||||
var ua = window.navigator.userAgent,
|
var ua = window.navigator.userAgent,
|
||||||
@@ -513,76 +508,87 @@ angular.module('Tower', [
|
|||||||
activateTab();
|
activateTab();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Authorization.getToken()) {
|
if ($rootScope.removeConfigReady) {
|
||||||
// When the app first loads, redirect to login page
|
$rootScope.removeConfigReady();
|
||||||
$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');
|
|
||||||
}
|
}
|
||||||
|
$rootScope.removeConfigReady = $rootScope.$on('ConfigReady', function() {
|
||||||
|
LoadBasePaths();
|
||||||
|
|
||||||
activateTab();
|
$rootScope.breadcrumbs = [];
|
||||||
|
$rootScope.crumbCache = [];
|
||||||
|
$rootScope.sessionTimer = Timer.init();
|
||||||
|
|
||||||
$rootScope.viewCurrentUser = function () {
|
if (!Authorization.getToken()) {
|
||||||
$location.path('/users/' + $rootScope.current_user.id);
|
// When the app first loads, redirect to login page
|
||||||
};
|
$rootScope.sessionExpired = false;
|
||||||
|
$cookieStore.put('sessionExpired', false);
|
||||||
$rootScope.viewLicense = function () {
|
$location.path('/login');
|
||||||
ViewLicense();
|
} else {
|
||||||
};
|
// If browser refresh, set the user_is_superuser value
|
||||||
$rootScope.toggleTab = function(e, tab, tabs) {
|
$rootScope.user_is_superuser = Authorization.getUserInfo('is_superuser');
|
||||||
e.preventDefault();
|
|
||||||
$('#' + tabs + ' #' + tab).tab('show');
|
|
||||||
};
|
|
||||||
|
|
||||||
html = "<a href=\"\" aw-pop-over=\"{{ socketTip }}\" aw-pop-over-watch=\"socketTip\" data-placement=\"bottom\" data-trigger=\"hover\" " +
|
|
||||||
"data-popover-title=\"Live Updates\" data-container=\"body\" style=\"font-size: 10px;\"><i class=\"fa icon-socket-{{ socketStatus }}\"></i></a>";
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
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 = "<a href=\"\" aw-pop-over=\"{{ socketTip }}\" aw-pop-over-watch=\"socketTip\" data-placement=\"bottom\" data-trigger=\"hover\" " +
|
||||||
|
"data-popover-title=\"Live Updates\" data-container=\"body\" style=\"font-size: 10px;\"><i class=\"fa icon-socket-{{ socketStatus }}\"></i></a>";
|
||||||
|
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;
|
openSocket();
|
||||||
}
|
|
||||||
}, 3000);
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ angular.module('LoadConfigHelper', ['Utilities'])
|
|||||||
$http({ method:'GET', url: $basePath + 'js/config.js' })
|
$http({ method:'GET', url: $basePath + 'js/config.js' })
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
$AnsibleConfig = eval(data);
|
$AnsibleConfig = eval(data);
|
||||||
|
$rootScope.$emit('ConfigReady');
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
|
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
|
||||||
@@ -37,10 +38,11 @@ angular.module('LoadConfigHelper', ['Utilities'])
|
|||||||
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
|
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
$AnsibleConfig = eval(data);
|
$AnsibleConfig = eval(data);
|
||||||
|
$rootScope.$emit('ConfigReady');
|
||||||
})
|
})
|
||||||
.error(function() {
|
.error(function() {
|
||||||
//local_config.js not found
|
//local_config.js not found
|
||||||
$rootScope.$emit('LoadConfig');
|
$rootScope.$emit('LoadConfig');
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
}]);
|
}]);
|
||||||
Reference in New Issue
Block a user