mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 13:11:19 -03:30
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
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() {
|
|
var url = getBasePath('config');
|
|
Rest.setUrl(url);
|
|
return Rest.get()
|
|
.then(function (data){
|
|
var license = data.data.license_info.instance_count;
|
|
return license;
|
|
});
|
|
}
|
|
|
|
function getHostData() {
|
|
var 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 (response) {
|
|
var errorMessage = 'Failed to get: ' + response.url + ' GET returned: ' + response.status;
|
|
processErrors(null, response.data, response.status, null, { hdr: 'Error!',
|
|
msg: errorMessage
|
|
});
|
|
throw response;
|
|
});
|
|
}
|
|
};
|
|
}
|