Extract graph data retrieval to a service

This commit is contained in:
Joe Fiorini
2015-01-21 11:31:36 -05:00
parent 1697aff309
commit d7a150befe
4 changed files with 132 additions and 3 deletions

View File

@@ -0,0 +1,36 @@
angular.module('DataServices', [])
.service('jobStatusGraphData',
["RestServices",
"GetBasePath",
"ProcessErrors",
"$rootScope",
"$q",
JobStatusGraphData]);
function JobStatusGraphData(Rest, getBasePath, processErrors, $rootScope, $q) {
var callbacks = {};
var currentCallbackId = 0;
function getData() {
return Rest.get();
}
return {
setupWatcher: function() {
$rootScope.$on('JobStatusChange', function() {
getData().then(function(result) {
$rootScope.
$broadcast('DataReceived:JobStatusGraph',
result);
});
});
},
get: function(period, jobType) {
this.setupWatcher();
return getData();
}
};
}