mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-04 16:01:51 -05:00
Extract data loading for host count graph
This commit is contained in:
1
awx/ui/static/js/services/data-services.js
Normal file
1
awx/ui/static/js/services/data-services.js
Normal file
@@ -0,0 +1 @@
|
||||
angular.module('DataServices', []);
|
||||
44
awx/ui/static/js/services/host-count-graph-data.js
Normal file
44
awx/ui/static/js/services/host-count-graph-data.js
Normal file
@@ -0,0 +1,44 @@
|
||||
angular.module('DataServices')
|
||||
.service('hostCountGraphData',
|
||||
["Rest",
|
||||
"GetBasePath",
|
||||
"ProcessErrors",
|
||||
"$q",
|
||||
HostCountGraphData]);
|
||||
|
||||
function HostCountGraphData(Rest, getBasePath, processErrors, $q) {
|
||||
|
||||
function pluck(property, promise) {
|
||||
return promise.then(function(value) {
|
||||
return value[property];
|
||||
});
|
||||
}
|
||||
|
||||
function getLicenseData() {
|
||||
url = getBasePath('config');
|
||||
Rest.setUrl(url);
|
||||
return Rest.get()
|
||||
.then(function (data){
|
||||
license = data.data.license_info.instance_count;
|
||||
return license;
|
||||
})
|
||||
}
|
||||
|
||||
function getHostData() {
|
||||
url = getBasePath('dashboard')+'graphs/inventory/';
|
||||
Rest.setUrl(url);
|
||||
return pluck('data', Rest.get());
|
||||
}
|
||||
|
||||
return {
|
||||
get: function() {
|
||||
return $q.all({
|
||||
license: getLicenseData(),
|
||||
hosts: getHostData()
|
||||
}).catch(function (data, status) {
|
||||
processErrors(null, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Failed to get: ' + url + ' GET returned: ' + status });
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module('DataServices', [])
|
||||
angular.module('DataServices')
|
||||
.service('jobStatusGraphData',
|
||||
["Rest",
|
||||
"GetBasePath",
|
||||
|
||||
Reference in New Issue
Block a user