mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
Merge pull request #2145 from mabashian/standard-out-log
Remove job details/stdout event socket listeners when $scope is destroyed
This commit is contained in:
commit
e4d08e7cb1
@ -207,6 +207,11 @@ export default
|
||||
}
|
||||
UpdateDOM({ scope: scope });
|
||||
});
|
||||
// Unbind $rootScope socket event binding(s) so that they don't get triggered
|
||||
// in another instance of this controller
|
||||
scope.$on('$destroy', function() {
|
||||
$rootScope.event_socket.removeAllListeners("job_events-" + job_id);
|
||||
});
|
||||
}
|
||||
openSocket();
|
||||
|
||||
|
||||
@ -211,7 +211,15 @@ angular.module('SocketIO', ['Utilities'])
|
||||
},
|
||||
getUrl: function() {
|
||||
return url;
|
||||
}
|
||||
},
|
||||
removeAllListeners: function (eventName) {
|
||||
var self = this;
|
||||
if(self){
|
||||
if(self.socket){
|
||||
self.socket.removeAllListeners(eventName);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
}]);
|
||||
|
||||
@ -21,13 +21,18 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
|
||||
// Open up a socket for events depending on the type of job
|
||||
function openSockets() {
|
||||
if ($state.current.name === 'jobDetail') {
|
||||
$log.debug("socket watching on job_events-" + job_id);
|
||||
$rootScope.event_socket.on("job_events-" + job_id, function() {
|
||||
$log.debug("socket fired on job_events-" + job_id);
|
||||
if (api_complete) {
|
||||
event_queue++;
|
||||
}
|
||||
});
|
||||
$log.debug("socket watching on job_events-" + job_id);
|
||||
$rootScope.event_socket.on("job_events-" + job_id, function() {
|
||||
$log.debug("socket fired on job_events-" + job_id);
|
||||
if (api_complete) {
|
||||
event_queue++;
|
||||
}
|
||||
});
|
||||
// Unbind $rootScope socket event binding(s) so that they don't get triggered
|
||||
// in another instance of this controller
|
||||
$scope.$on('$destroy', function() {
|
||||
$rootScope.event_socket.removeAllListeners("job_events-" + job_id);
|
||||
});
|
||||
}
|
||||
if ($state.current.name === 'adHocJobStdout') {
|
||||
$log.debug("socket watching on ad_hoc_command_events-" + job_id);
|
||||
@ -37,8 +42,12 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
|
||||
event_queue++;
|
||||
}
|
||||
});
|
||||
// Unbind $rootScope socket event binding(s) so that they don't get triggered
|
||||
// in another instance of this controller
|
||||
$scope.$on('$destroy', function() {
|
||||
$rootScope.adhoc_event_socket.removeAllListeners("ad_hoc_command_events-" + job_id);
|
||||
});
|
||||
}
|
||||
// TODO: do we need to add socket listeners for scmUpdateStdout, inventorySyncStdout, managementJobStdout?
|
||||
}
|
||||
|
||||
openSockets();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user