Extract data loading for host count graph

This commit is contained in:
Joe Fiorini
2015-01-27 14:05:36 -05:00
parent 50d9c11419
commit d3a6fac5f9
8 changed files with 191 additions and 40 deletions

View File

@@ -0,0 +1 @@
angular.module('DataServices', []);

View 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 });
});
}
};
}

View File

@@ -1,4 +1,4 @@
angular.module('DataServices', [])
angular.module('DataServices')
.service('jobStatusGraphData',
["Rest",
"GetBasePath",