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:
Michael Abashian
2016-06-03 11:38:21 -04:00
3 changed files with 31 additions and 9 deletions

View File

@@ -207,6 +207,11 @@ export default
} }
UpdateDOM({ scope: scope }); 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(); openSocket();

View File

@@ -211,7 +211,15 @@ angular.module('SocketIO', ['Utilities'])
}, },
getUrl: function() { getUrl: function() {
return url; return url;
},
removeAllListeners: function (eventName) {
var self = this;
if(self){
if(self.socket){
self.socket.removeAllListeners(eventName);
} }
}
},
}; };
}; };
}]); }]);

View File

@@ -28,6 +28,11 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
event_queue++; 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') { if ($state.current.name === 'adHocJobStdout') {
$log.debug("socket watching on ad_hoc_command_events-" + job_id); $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++; 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(); openSockets();