mirror of
https://github.com/ansible/awx.git
synced 2026-07-28 00:19:54 -02:30
AC-715 make sure we load api resources immediately upon application start.
This commit is contained in:
@@ -11,12 +11,6 @@ angular.module('ApiLoader', ['ngCookies'])
|
|||||||
.factory('LoadBasePaths', ['$http', '$rootScope', '$cookieStore', 'ProcessErrors',
|
.factory('LoadBasePaths', ['$http', '$rootScope', '$cookieStore', 'ProcessErrors',
|
||||||
function($http, $rootScope, $cookieStore, ProcessErrors) {
|
function($http, $rootScope, $cookieStore, ProcessErrors) {
|
||||||
return function() {
|
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/')
|
$http.get('/api/')
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
var base = data.current_version;
|
var base = data.current_version;
|
||||||
@@ -40,10 +34,6 @@ angular.module('ApiLoader', ['ngCookies'])
|
|||||||
{ hdr: 'Error', msg: 'Failed to read /api. GET status: ' + status });
|
{ hdr: 'Error', msg: 'Failed to read /api. GET status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$rootScope['defaultUrls'] = $cookieStore.get('api');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('GetBasePath', ['$rootScope', '$cookieStore', 'LoadBasePaths',
|
.factory('GetBasePath', ['$rootScope', '$cookieStore', 'LoadBasePaths',
|
||||||
|
|||||||
Reference in New Issue
Block a user