mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-04 16:01:51 -05:00
Extract graph data retrieval to a service
This commit is contained in:
36
awx/ui/static/js/services/job-status-graph-data.js
Normal file
36
awx/ui/static/js/services/job-status-graph-data.js
Normal 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();
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user