mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
AC-715 make sure we load api resources immediately upon application start.
This commit is contained in:
parent
2f0615d8c1
commit
a1ff025488
@ -11,38 +11,28 @@ angular.module('ApiLoader', ['ngCookies'])
|
||||
.factory('LoadBasePaths', ['$http', '$rootScope', '$cookieStore', 'ProcessErrors',
|
||||
function($http, $rootScope, $cookieStore, ProcessErrors) {
|
||||
return function() {
|
||||
if (!$rootScope['defaultUrls'])
|
||||
// if 'defaultUrls', the data used by GetBasePath(), is not in $rootScope, then we need to
|
||||
// restore it from cookieStore or by querying the API. it goes missing from $rootScope
|
||||
// when user hits browser refresh
|
||||
if (!$cookieStore.get('api')) {
|
||||
// if it's not in cookieStore, then we need to retrieve it from the API
|
||||
$http.get('/api/')
|
||||
.success( function(data, status, headers, config) {
|
||||
var base = data.current_version;
|
||||
$http.get(base)
|
||||
.success( function(data, status, headers, config) {
|
||||
data['base'] = base;
|
||||
$rootScope['defaultUrls'] = data;
|
||||
$cookieStore.remove('api');
|
||||
$cookieStore.put('api',data); //Preserve in cookie to prevent against
|
||||
//loss during browser refresh
|
||||
})
|
||||
.error ( function(data, status, headers, config) {
|
||||
$rootScope['defaultUrls'] = { status: 'error' };
|
||||
ProcessErrors(null, data, status, null,
|
||||
{ hdr: 'Error', msg: 'Failed to read ' + base + '. GET status: ' + status });
|
||||
});
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
$rootScope['defaultUrls'] = { status: 'error' };
|
||||
ProcessErrors(null, data, status, null,
|
||||
{ hdr: 'Error', msg: 'Failed to read /api. GET status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
$rootScope['defaultUrls'] = $cookieStore.get('api');
|
||||
}
|
||||
$http.get('/api/')
|
||||
.success( function(data, status, headers, config) {
|
||||
var base = data.current_version;
|
||||
$http.get(base)
|
||||
.success( function(data, status, headers, config) {
|
||||
data['base'] = base;
|
||||
$rootScope['defaultUrls'] = data;
|
||||
$cookieStore.remove('api');
|
||||
$cookieStore.put('api',data); //Preserve in cookie to prevent against
|
||||
//loss during browser refresh
|
||||
})
|
||||
.error ( function(data, status, headers, config) {
|
||||
$rootScope['defaultUrls'] = { status: 'error' };
|
||||
ProcessErrors(null, data, status, null,
|
||||
{ hdr: 'Error', msg: 'Failed to read ' + base + '. GET status: ' + status });
|
||||
});
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
$rootScope['defaultUrls'] = { status: 'error' };
|
||||
ProcessErrors(null, data, status, null,
|
||||
{ hdr: 'Error', msg: 'Failed to read /api. GET status: ' + status });
|
||||
});
|
||||
}
|
||||
}])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user