mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Job detail page refactor
Reverting attempt to use _.throttle and _.defer. They assume we actually want to process every event. We need to stop all processing if the job has finished.
This commit is contained in:
committed by
Luke Sneeringer
parent
cb44949a1d
commit
3a6fe9ee4a
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest,
|
function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest,
|
||||||
ProcessErrors, ProcessEventQueue, SelectPlay, SelectTask, Socket, GetElapsed, FilterAllByHostName, DrawGraph, LoadHostSummary, ReloadHostSummaryList,
|
ProcessErrors, ProcessEventQueue, SelectPlay, SelectTask, Socket, GetElapsed, FilterAllByHostName, DrawGraph, LoadHostSummary, ReloadHostSummaryList,
|
||||||
JobIsFinished, SetTaskStyles, DigestEvent) {
|
JobIsFinished, SetTaskStyles) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -19,8 +19,7 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
api_complete = false,
|
api_complete = false,
|
||||||
refresh_count = 0,
|
refresh_count = 0,
|
||||||
lastEventId = 0,
|
lastEventId = 0,
|
||||||
queue = [],
|
queue = [];
|
||||||
processEvent;
|
|
||||||
|
|
||||||
scope.plays = [];
|
scope.plays = [];
|
||||||
scope.playsMap = {};
|
scope.playsMap = {};
|
||||||
@@ -67,42 +66,27 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
|
|
||||||
event_socket.init();
|
event_socket.init();
|
||||||
|
|
||||||
|
|
||||||
processEvent = _.throttle(function() {
|
|
||||||
var event;
|
|
||||||
if (queue.length > 0) {
|
|
||||||
event = queue.pop();
|
|
||||||
$log.debug('processing event: ' + event.id);
|
|
||||||
DigestEvent({
|
|
||||||
scope: scope,
|
|
||||||
event: event
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 200);
|
|
||||||
|
|
||||||
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) {
|
||||||
$log.debug('received event: ' + data.id);
|
if (queue.length < 20) {
|
||||||
queue.unshift(data);
|
queue.unshift(data);
|
||||||
processEvent();
|
}
|
||||||
|
else {
|
||||||
|
api_complete = false; // stop more events from hitting the queue
|
||||||
|
window.clearInterval($rootScope.jobDetailInterval);
|
||||||
|
$log.debug('queue halted. reloading...');
|
||||||
|
setTimeout(function() {
|
||||||
|
$log.debug('reload');
|
||||||
|
scope.haltEventQueue = true;
|
||||||
|
queue = [];
|
||||||
|
scope.$emit('LoadJob');
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//if (queue.length < 20) {
|
|
||||||
// queue.unshift(data);
|
|
||||||
//}
|
|
||||||
//*else {
|
|
||||||
// api_complete = false; // stop more events from hitting the queue
|
|
||||||
// $log.debug('queue halted. reloading in 1.');
|
|
||||||
// setTimeout(function() {
|
|
||||||
// $log.debug('reloading');
|
|
||||||
// scope.haltEventQueue = true;
|
|
||||||
// queue = [];
|
|
||||||
// scope.$emit('LoadJob');
|
|
||||||
// }, 1000);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if ($rootScope.removeJobStatusChange) {
|
if ($rootScope.removeJobStatusChange) {
|
||||||
$rootScope.removeJobStatusChange();
|
$rootScope.removeJobStatusChange();
|
||||||
}
|
}
|
||||||
@@ -121,6 +105,7 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (scope.removeAPIComplete) {
|
if (scope.removeAPIComplete) {
|
||||||
scope.removeAPIComplete();
|
scope.removeAPIComplete();
|
||||||
}
|
}
|
||||||
@@ -167,10 +152,10 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
DrawGraph({ scope: scope, resize: true });
|
DrawGraph({ scope: scope, resize: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
//ProcessEventQueue({
|
ProcessEventQueue({
|
||||||
// scope: scope,
|
scope: scope,
|
||||||
// eventQueue: queue
|
eventQueue: queue
|
||||||
//});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -984,5 +969,5 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
|
|
||||||
JobDetailController.$inject = [ '$rootScope', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath',
|
JobDetailController.$inject = [ '$rootScope', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath',
|
||||||
'Wait', 'Rest', 'ProcessErrors', 'ProcessEventQueue', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'FilterAllByHostName', 'DrawGraph',
|
'Wait', 'Rest', 'ProcessErrors', 'ProcessEventQueue', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'FilterAllByHostName', 'DrawGraph',
|
||||||
'LoadHostSummary', 'ReloadHostSummaryList', 'JobIsFinished', 'SetTaskStyles', 'DigestEvent'
|
'LoadHostSummary', 'ReloadHostSummaryList', 'JobIsFinished', 'SetTaskStyles'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -39,24 +39,31 @@
|
|||||||
|
|
||||||
angular.module('JobDetailHelper', ['Utilities', 'RestServices'])
|
angular.module('JobDetailHelper', ['Utilities', 'RestServices'])
|
||||||
|
|
||||||
.factory('ProcessEventQueue', ['$log', 'DigestEvent', 'JobIsFinished', function ($log, 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,
|
||||||
event;
|
processing = false;
|
||||||
function runTheQ() {
|
function runTheQ() {
|
||||||
while (eventQueue.length > 0) {
|
var event;
|
||||||
|
processing = true;
|
||||||
|
while (!JobIsFinished(scope) && !scope.haltEventQueue && eventQueue.length > 0) {
|
||||||
event = eventQueue.pop();
|
event = eventQueue.pop();
|
||||||
$log.debug('read event: ' + event.id);
|
$log.debug('processing event: ' + event.id);
|
||||||
DigestEvent({ scope: scope, event: event });
|
DigestEvent({ scope: scope, event: event });
|
||||||
}
|
}
|
||||||
if (!JobIsFinished(scope) && !scope.haltEventQueue) {
|
processing = false;
|
||||||
setTimeout( function() {
|
//if (!JobIsFinished(scope) && !scope.haltEventQueue) {
|
||||||
runTheQ();
|
// setTimeout( function() {
|
||||||
}, 300);
|
// runTheQ();
|
||||||
}
|
// }, 1000);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
runTheQ();
|
$rootScope.jobDetailInterval = window.setInterval(function() {
|
||||||
|
if (!processing && eventQueue.length > 0) {
|
||||||
|
runTheQ();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user