From cfbab84ed7a082efff075ee7e290a04ab09c5e01 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 1 Jul 2016 13:28:20 -0700 Subject: [PATCH 1/2] removing unnecessary "jobs" websocket init --- .../host-summary/host-summary.controller.js | 40 +++++++++++-------- .../client/src/job-detail/job-detail.route.js | 8 ---- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js b/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js index 496e7d76d7..903554617f 100644 --- a/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js +++ b/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js @@ -48,22 +48,28 @@ $scope.status = res.results[0].status; }); }; - var socketListener = function(){ - // emitted by the API in the same function used to persist host summary data - // JobEvent.update_host_summary_from_stats() from /awx/main.models.jobs.py - jobSocket.on('summary_complete', function(data) { - // 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; - } - }); - }; + if ($rootScope.removeJobStatusChange) { + $rootScope.removeJobStatusChange(); + } + // emitted by the API in the same function used to persist host summary data + // JobEvent.update_host_summary_from_stats() from /awx/main.models.jobs.py + $rootScope.removeJobStatusChange = $rootScope.$on('JobSummaryComplete', function(e, data) { + // 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 + 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){ var grammar = function(n, status){ @@ -136,7 +142,7 @@ }; $scope.get = filter === 'all' ? getAll() : getFailed(); }; - socketListener(); + init(); // 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 diff --git a/awx/ui/client/src/job-detail/job-detail.route.js b/awx/ui/client/src/job-detail/job-detail.route.js index 926b8f7306..dda2722511 100644 --- a/awx/ui/client/src/job-detail/job-detail.route.js +++ b/awx/ui/client/src/job-detail/job-detail.route.js @@ -27,14 +27,6 @@ export default { } else { 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'), From 826392b2a80ed77ebf4f2ee421febf5b405d4ecd Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 1 Jul 2016 13:42:52 -0700 Subject: [PATCH 2/2] removing jobSocket module --- .../src/job-detail/host-summary/host-summary.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js b/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js index 903554617f..89d5572e8a 100644 --- a/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js +++ b/awx/ui/client/src/job-detail/host-summary/host-summary.controller.js @@ -5,7 +5,7 @@ *************************************************/ 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; $scope.loading = $scope.hosts.length > 0 ? false : true;