mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Rebase of devel (w/ channels) + socket rework for new job details
Replacing old socket.io receiver w/ new websocket receivers
This commit is contained in:
parent
648bd3d1a0
commit
3ade961e92
@ -1,3 +1,4 @@
|
||||
<<<<<<< 4cf6a946a1aa14b7d64a8e1e8dabecfd3d056f27
|
||||
//<<<<<<< bc59236851902d7c768aa26abdb7dc9c9dc27a5a
|
||||
/*************************************************
|
||||
* Copyright (c) 2016 Ansible, Inc.
|
||||
@ -46,6 +47,8 @@
|
||||
// controller: 'JobDetailController'
|
||||
// };
|
||||
//=======
|
||||
=======
|
||||
>>>>>>> Rebase of devel (w/ channels) + socket rework for new job details
|
||||
// /*************************************************
|
||||
// * Copyright (c) 2016 Ansible, Inc.
|
||||
// *
|
||||
@ -61,6 +64,12 @@
|
||||
// parent: 'jobs',
|
||||
// label: "{{ job.id }} - {{ job.name }}"
|
||||
// },
|
||||
// socket: {
|
||||
// "groups":{
|
||||
// "jobs": ["status_changed", "summary"],
|
||||
// "job_events": []
|
||||
// }
|
||||
// },
|
||||
// resolve: {
|
||||
// jobEventsSocket: ['Socket', '$rootScope', function(Socket, $rootScope) {
|
||||
// if (!$rootScope.event_socket) {
|
||||
|
||||
@ -76,13 +76,6 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa
|
||||
$scope.hostCount = getTotalHostCount(count.val);
|
||||
$scope.countFinished = count.countFinished;
|
||||
|
||||
// Process incoming job status changes
|
||||
$rootScope.$on('JobStatusChange-jobDetails', function(e, data) {
|
||||
if (parseInt(data.unified_job_id, 10) === parseInt($scope.job.id,10)) {
|
||||
$scope.job.status = data.status;
|
||||
}
|
||||
});
|
||||
|
||||
// EVENT STUFF BELOW
|
||||
|
||||
// just putting the event queue on scope so it can be inspected in the
|
||||
@ -150,14 +143,26 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa
|
||||
};
|
||||
getEvents($scope.job.related.job_events);
|
||||
|
||||
// PUSH! process incoming job events
|
||||
$rootScope.event_socket.on("job_events-" + $scope.job.id, function(data) {
|
||||
// Processing of job_events messages from the websocket
|
||||
$scope.$on(`ws-job_events-${$scope.job.id}`, function(e, data) {
|
||||
processEvent(data);
|
||||
});
|
||||
|
||||
// STOP! stop listening to job events
|
||||
$scope.$on('$destroy', function() {
|
||||
$rootScope.event_socket.removeAllListeners("job_events-" +
|
||||
$scope.job.id);
|
||||
// Processing of job-status messages from the websocket
|
||||
$scope.$on(`ws-jobs`, function(e, data) {
|
||||
if (parseInt(data.unified_job_id, 10) === parseInt($scope.job.id,10)) {
|
||||
$scope.job.status = data.status;
|
||||
}
|
||||
});
|
||||
|
||||
// The code below was used in the old job detail controller,
|
||||
// and is for processing the 'Job Summary' event that is delivered
|
||||
// for a completed job. Not sure if we have an equivalent function
|
||||
// at this point. TODO: write function to handle Job Summary
|
||||
// scope.$on('ws-jobs-summary', function() {
|
||||
// // the job host summary should now be available from the API
|
||||
// $log.debug('Trigging reload of job_host_summaries');
|
||||
// scope.$emit('InitialLoadComplete');
|
||||
// });
|
||||
|
||||
}];
|
||||
|
||||
@ -15,6 +15,12 @@ export default {
|
||||
parent: 'jobs',
|
||||
label: '{{ job.id }} - {{ job.name }}'
|
||||
},
|
||||
socket: {
|
||||
"groups":{
|
||||
"jobs": ["status_changed", "summary"],
|
||||
"job_events": []
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
// the GET for the particular job
|
||||
jobData: ['Rest', 'GetBasePath', '$stateParams', '$q', '$state', 'Alert', function(Rest, GetBasePath, $stateParams, $q, $state, Alert) {
|
||||
@ -122,25 +128,6 @@ export default {
|
||||
});
|
||||
return val.promise;
|
||||
}],
|
||||
// This gives us access to the job events socket so we can start
|
||||
// listening for updates we need to make for the ui as data comes in
|
||||
//
|
||||
// TODO: we could probably make this better by not initing
|
||||
// job_events for completed jobs
|
||||
jobEventsSocket: ['Socket', '$rootScope', function(Socket, $rootScope) {
|
||||
if (!$rootScope.event_socket) {
|
||||
$rootScope.event_socket = Socket({
|
||||
scope: $rootScope,
|
||||
endpoint: "job_events"
|
||||
});
|
||||
$rootScope.event_socket.init();
|
||||
// returns should really be providing $rootScope.event_socket
|
||||
// otherwise, we have to inject the entire $rootScope into the controller
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}],
|
||||
// This clears out the event queue, otherwise it'd be full of events
|
||||
// for previous job results the user had navigated to
|
||||
eventQueueInit: ['eventQueue', function(eventQueue) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user