mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
Job detail page refactor
Latest iteration on event queue processing. Replaced setTimeout with an interval.
This commit is contained in:
@@ -470,6 +470,10 @@ angular.module('Tower', [
|
|||||||
HideStream();
|
HideStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($rootScope.jobDetailInterval) {
|
||||||
|
window.clearInterval($rootScope.jobDetailInterval);
|
||||||
|
}
|
||||||
|
|
||||||
// On each navigation request, check that the user is logged in
|
// On each navigation request, check that the user is logged in
|
||||||
if (!/^\/(login|logout)/.test($location.path())) {
|
if (!/^\/(login|logout)/.test($location.path())) {
|
||||||
// capture most recent URL, excluding login/logout
|
// capture most recent URL, excluding login/logout
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
scope.searchSummaryHostsEnabled = true;
|
scope.searchSummaryHostsEnabled = true;
|
||||||
scope.searchAllHostsEnabled = true;
|
scope.searchAllHostsEnabled = true;
|
||||||
scope.haltEventQueue = false;
|
scope.haltEventQueue = false;
|
||||||
|
scope.processing = false;
|
||||||
|
|
||||||
scope.host_summary = {};
|
scope.host_summary = {};
|
||||||
scope.host_summary.ok = 0;
|
scope.host_summary.ok = 0;
|
||||||
@@ -69,13 +70,14 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
event_socket.on("job_events-" + job_id, function(data) {
|
event_socket.on("job_events-" + job_id, function(data) {
|
||||||
data.event = data.event_name;
|
data.event = data.event_name;
|
||||||
if (api_complete && data.id > lastEventId) {
|
if (api_complete && data.id > lastEventId) {
|
||||||
if (queue.length < 20) {
|
if (queue.length < 25) {
|
||||||
|
$log.debug('received event: ' + data.id);
|
||||||
queue.unshift(data);
|
queue.unshift(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
api_complete = false; // stop more events from hitting the queue
|
api_complete = false; // stop more events from hitting the queue
|
||||||
window.clearInterval($rootScope.jobDetailInterval);
|
window.clearInterval($rootScope.jobDetailInterval);
|
||||||
$log.debug('queue halted. reloading...');
|
$log.debug('halting queue. reloading...');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$log.debug('reload');
|
$log.debug('reload');
|
||||||
scope.haltEventQueue = true;
|
scope.haltEventQueue = true;
|
||||||
@@ -99,6 +101,7 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
$log.debug('Job completed!');
|
$log.debug('Job completed!');
|
||||||
api_complete = false;
|
api_complete = false;
|
||||||
scope.haltEventQueue = true;
|
scope.haltEventQueue = true;
|
||||||
|
window.clearInterval($rootScope.jobDetailInterval);
|
||||||
queue = [];
|
queue = [];
|
||||||
scope.$emit('LoadJob');
|
scope.$emit('LoadJob');
|
||||||
}
|
}
|
||||||
@@ -124,7 +127,6 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
playId = (scope.plays.length > 0) ? scope.plays[scope.plays.length - 1].id : 0;
|
playId = (scope.plays.length > 0) ? scope.plays[scope.plays.length - 1].id : 0;
|
||||||
lastEventId = Math.max(hostId, taskId, playId);
|
lastEventId = Math.max(hostId, taskId, playId);
|
||||||
|
|
||||||
api_complete = true;
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|
||||||
// Draw the graph
|
// Draw the graph
|
||||||
@@ -147,16 +149,18 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
msg: 'Call to ' + url + '. GET returned: ' + status });
|
msg: 'Call to ' + url + '. GET returned: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (scope.host_summary.total > 0) {
|
else {
|
||||||
// Draw the graph based on summary values in memory
|
if (scope.host_summary.total > 0) {
|
||||||
DrawGraph({ scope: scope, resize: true });
|
// Draw the graph based on summary values in memory
|
||||||
|
DrawGraph({ scope: scope, resize: true });
|
||||||
|
}
|
||||||
|
api_complete = true;
|
||||||
|
scope.haltEventQueue = false;
|
||||||
|
ProcessEventQueue({
|
||||||
|
scope: scope,
|
||||||
|
eventQueue: queue
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessEventQueue({
|
|
||||||
scope: scope,
|
|
||||||
eventQueue: queue
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scope.removeInitialDataLoaded) {
|
if (scope.removeInitialDataLoaded) {
|
||||||
|
|||||||
@@ -42,25 +42,21 @@ angular.module('JobDetailHelper', ['Utilities', 'RestServices'])
|
|||||||
.factory('ProcessEventQueue', ['$log', '$rootScope', 'DigestEvent', 'JobIsFinished', function ($log, $rootScope, DigestEvent, JobIsFinished) {
|
.factory('ProcessEventQueue', ['$log', '$rootScope', 'DigestEvent', 'JobIsFinished', function ($log, $rootScope, DigestEvent, JobIsFinished) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
eventQueue = params.eventQueue,
|
eventQueue = params.eventQueue;
|
||||||
processing = false;
|
|
||||||
function runTheQ() {
|
function runTheQ() {
|
||||||
var event;
|
var event;
|
||||||
processing = true;
|
scope.processing = true;
|
||||||
while (!JobIsFinished(scope) && !scope.haltEventQueue && eventQueue.length > 0) {
|
while (!JobIsFinished(scope) && !scope.haltEventQueue && eventQueue.length > 0) {
|
||||||
event = eventQueue.pop();
|
event = eventQueue.pop();
|
||||||
$log.debug('processing event: ' + event.id);
|
$log.debug('processing event: ' + event.id);
|
||||||
DigestEvent({ scope: scope, event: event });
|
DigestEvent({ scope: scope, event: event });
|
||||||
}
|
}
|
||||||
processing = false;
|
$log.debug('processing halted');
|
||||||
//if (!JobIsFinished(scope) && !scope.haltEventQueue) {
|
scope.processing = false;
|
||||||
// setTimeout( function() {
|
|
||||||
// runTheQ();
|
|
||||||
// }, 1000);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
$rootScope.jobDetailInterval = window.setInterval(function() {
|
$rootScope.jobDetailInterval = window.setInterval(function() {
|
||||||
if (!processing && eventQueue.length > 0) {
|
$log.debug('checking... processing: ' + scope.processing + ' queue.length: ' + eventQueue.length);
|
||||||
|
if (!scope.processing && eventQueue.length > 0) {
|
||||||
runTheQ();
|
runTheQ();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user