mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
local_config
Fixed remaining fallout from delay of $AnsibleConfig object.
This commit is contained in:
parent
cc2e45b44e
commit
e7e52f3bf7
@ -575,8 +575,9 @@ angular.module('Tower', [
|
||||
setInterval(function() {
|
||||
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('socket status: ' + sock.checkStatus());
|
||||
$log.debug('attempting new socket connection');
|
||||
sock = null;
|
||||
openSocket();
|
||||
checkCount = 0;
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
angular.module('LoadConfigHelper', ['Utilities'])
|
||||
|
||||
.factory('LoadConfig', ['$log', '$rootScope', '$http', 'ProcessErrors', function($log, $rootScope, $http, ProcessErrors) {
|
||||
.factory('LoadConfig', ['$log', '$rootScope', '$http', 'ProcessErrors', 'Store', function($log, $rootScope, $http, ProcessErrors, Store) {
|
||||
return function() {
|
||||
|
||||
if ($rootScope.removeLoadConfig) {
|
||||
@ -27,6 +27,7 @@ angular.module('LoadConfigHelper', ['Utilities'])
|
||||
.success(function(data) {
|
||||
$log.info('loaded config.js');
|
||||
$AnsibleConfig = eval(data);
|
||||
Store('AnsibleConfig', $AnsibleConfig);
|
||||
$rootScope.$emit('ConfigReady');
|
||||
})
|
||||
.error(function(data, status) {
|
||||
@ -41,6 +42,7 @@ angular.module('LoadConfigHelper', ['Utilities'])
|
||||
.success(function(data) {
|
||||
$log.info('loaded local_config.js');
|
||||
$AnsibleConfig = eval(data);
|
||||
Store('AnsibleConfig', $AnsibleConfig);
|
||||
$rootScope.$emit('ConfigReady');
|
||||
})
|
||||
.error(function() {
|
||||
|
||||
@ -12,13 +12,26 @@
|
||||
|
||||
angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
|
||||
.factory('Socket', ['$rootScope', '$location', '$log', 'Authorization', function ($rootScope, $location, $log, Authorization) {
|
||||
.factory('Socket', ['$rootScope', '$location', '$log', 'Authorization', 'Store', function ($rootScope, $location, $log, Authorization, Store) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
host = $location.host(),
|
||||
endpoint = params.endpoint,
|
||||
protocol = $location.protocol(),
|
||||
url = protocol + '://' + host + ':' + $AnsibleConfig.websocket_port + '/socket.io/' + endpoint;
|
||||
config, socketPort, url;
|
||||
|
||||
// Since some pages are opened in a new tab, we might get here before AnsibleConfig is available.
|
||||
// In that case, load from local storage.
|
||||
if ($AnsibleConfig) {
|
||||
socketPort = $AnsibleConfig.websocket_port;
|
||||
}
|
||||
else {
|
||||
$log.debug('getting web socket port from local storage');
|
||||
config = Store('AnsibleConfig');
|
||||
socketPort = config.websocket_port;
|
||||
}
|
||||
url = protocol + '://' + host + ':' + socketPort + '/socket.io/' + endpoint;
|
||||
$log.debug('opening socket connection to: ' + url);
|
||||
|
||||
function getSocketTip(status) {
|
||||
var result = '';
|
||||
@ -43,7 +56,7 @@ angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
init: function() {
|
||||
var self = this,
|
||||
token = Authorization.getToken();
|
||||
if (!$rootScope.sessionTimer.isExpired()) {
|
||||
if (!$rootScope.sessionTimer || ($rootScope.sessionTimer && !$rootScope.sessionTimer.isExpired())) {
|
||||
// We have a valid session token, so attmempt socket connection
|
||||
$log.debug('Socket connecting to: ' + url);
|
||||
self.scope.socket_url = url;
|
||||
|
||||
@ -41,7 +41,9 @@ angular.module('TimerService', ['ngCookies', 'Utilities'])
|
||||
},
|
||||
|
||||
moveForward: function () {
|
||||
var t = new Date().getTime() + ($AnsibleConfig.session_timeout * 1000);
|
||||
var tm, t;
|
||||
tm = ($AnsibleConfig) ? $AnsibleConfig.session_timeout : 1800;
|
||||
t = new Date().getTime() + (tm * 1000);
|
||||
this.sessionTime = t;
|
||||
$cookieStore.put('sessionTime', t);
|
||||
$rootScope.sessionExpired = false;
|
||||
|
||||
@ -138,13 +138,11 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
||||
return function (scope, data, status, form, defaultMsg) {
|
||||
var field, fieldErrors, msg, keys;
|
||||
Wait('stop');
|
||||
if ($AnsibleConfig.debug_mode) {
|
||||
$log.debug('Debug status: ' + status);
|
||||
$log.debug('Debug data: ');
|
||||
$log.debug(data);
|
||||
if (defaultMsg.msg) {
|
||||
$log.debug('Debug: ' + defaultMsg.msg);
|
||||
}
|
||||
$log.debug('Debug status: ' + status);
|
||||
$log.debug('Debug data: ');
|
||||
$log.debug(data);
|
||||
if (defaultMsg.msg) {
|
||||
$log.debug('Debug: ' + defaultMsg.msg);
|
||||
}
|
||||
if (status === 403) {
|
||||
msg = 'The API responded with a 403 Access Denied error. ';
|
||||
@ -158,7 +156,9 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
||||
Alert('Deleted Object', 'The requested object was previously deleted and can no longer be accessed.');
|
||||
} else if ((status === 'Token is expired') || (status === 401 && data.detail && data.detail === 'Token is expired') ||
|
||||
(status === 401 && data.detail && data.detail === 'Invalid token')) {
|
||||
$rootScope.sessionTimer.expireSession();
|
||||
if ($rootScope.sessionTimer) {
|
||||
$rootScope.sessionTimer.expireSession();
|
||||
}
|
||||
$location.url('/login');
|
||||
} else if (data.non_field_errors) {
|
||||
Alert('Error!', data.non_field_errors);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user