1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

Merge pull request #2771 from jaredevantabor/socket-removal

removing unnecessary "jobs" websocket init
This commit is contained in:
Jared Tabor 2016-07-05 09:53:46 -07:00 committed by GitHub
commit a2f0f7a6dc
2 changed files with 24 additions and 26 deletions

View File

@ -5,7 +5,7 @@
*************************************************/ *************************************************/
export default export default
['$scope', '$rootScope', '$stateParams', 'Wait', 'JobDetailService', 'jobSocket', 'DrawGraph', function($scope, $rootScope, $stateParams, Wait, JobDetailService, jobSocket, DrawGraph){ ['$scope', '$rootScope', '$stateParams', 'Wait', 'JobDetailService', 'DrawGraph', function($scope, $rootScope, $stateParams, Wait, JobDetailService, DrawGraph){
var page_size = 200; var page_size = 200;
$scope.loading = $scope.hosts.length > 0 ? false : true; $scope.loading = $scope.hosts.length > 0 ? false : true;
@ -48,22 +48,28 @@
$scope.status = res.results[0].status; $scope.status = res.results[0].status;
}); });
}; };
var socketListener = function(){ if ($rootScope.removeJobStatusChange) {
// emitted by the API in the same function used to persist host summary data $rootScope.removeJobStatusChange();
// JobEvent.update_host_summary_from_stats() from /awx/main.models.jobs.py }
jobSocket.on('summary_complete', function(data) { // emitted by the API in the same function used to persist host summary data
// discard socket msgs we don't care about in this context // JobEvent.update_host_summary_from_stats() from /awx/main.models.jobs.py
if (parseInt($stateParams.id) === data.unified_job_id){ $rootScope.removeJobStatusChange = $rootScope.$on('JobSummaryComplete', function(e, data) {
init(); // discard socket msgs we don't care about in this context
} if (parseInt($stateParams.id) === data.unified_job_id){
}); init();
// UnifiedJob.def socketio_emit_status() from /awx/main.models.unified_jobs.py }
jobSocket.on('status_changed', function(data) { });
if (parseInt($stateParams.id) === data.unified_job_id){
$scope.status = data.status; // UnifiedJob.def socketio_emit_status() from /awx/main.models.unified_jobs.py
} if ($rootScope.removeJobSummaryComplete) {
}); $rootScope.removeJobSummaryComplete();
}; }
$rootScope.removeJobSummaryComplete = $rootScope.$on('JobStatusChange-jobDetails', function(e, data) {
if (parseInt($stateParams.id) === data.unified_job_id){
$scope.status = data.status;
}
});
$scope.buildTooltip = function(n, status){ $scope.buildTooltip = function(n, status){
var grammar = function(n, status){ var grammar = function(n, status){
@ -136,7 +142,7 @@
}; };
$scope.get = filter === 'all' ? getAll() : getFailed(); $scope.get = filter === 'all' ? getAll() : getFailed();
}; };
socketListener();
init(); init();
// calling the init routine twice will size the d3 chart correctly - no idea why // calling the init routine twice will size the d3 chart correctly - no idea why
// instantiating the graph inside a setTimeout() SHOULD have the same effect, but it doesn't // instantiating the graph inside a setTimeout() SHOULD have the same effect, but it doesn't

View File

@ -27,14 +27,6 @@ export default {
} else { } else {
return true; return true;
} }
}],
jobSocket: ['Socket', '$rootScope', function(Socket, $rootScope) {
var job_socket = Socket({
scope: $rootScope,
endpoint: "jobs"
});
job_socket.init();
return job_socket;
}] }]
}, },
templateUrl: templateUrl('job-detail/job-detail'), templateUrl: templateUrl('job-detail/job-detail'),