mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
make the event_queue actually work
This commit is contained in:
committed by
jaredevantabor
parent
9f5bec7767
commit
e31bfa2f1c
@@ -76,37 +76,60 @@ export default [function(){
|
|||||||
return count;
|
return count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get the count of the last event
|
||||||
|
var getPreviousCount = function(id) {
|
||||||
|
// get the ids of all the queue
|
||||||
|
var ids = Object.keys(val.queue).map(id => parseInt(id));
|
||||||
|
|
||||||
|
// iterate backwards to find the last count
|
||||||
|
while(ids.indexOf(id - 1) > -1) {
|
||||||
|
id = id - 1;
|
||||||
|
if (val.queue[id].count) {
|
||||||
|
// need to create a new copy of count when returning
|
||||||
|
// so that it is accurate for the particular event
|
||||||
|
return _.clone(val.queue[id].count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no count initialized
|
||||||
|
return {
|
||||||
|
ok: 0,
|
||||||
|
skipped: 0,
|
||||||
|
unreachable: 0,
|
||||||
|
failures: 0,
|
||||||
|
changed: 0
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// munge the raw event from the backend into the event_queue's format
|
// munge the raw event from the backend into the event_queue's format
|
||||||
var mungeEvent = function(event) {
|
var mungeEvent = function(event) {
|
||||||
var mungedEvent = {
|
var mungedEvent = {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
processed: false
|
processed: false,
|
||||||
|
name: event.event_name,
|
||||||
|
count: getPreviousCount(event.id)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (event.event_name === 'playbook_on_start') {
|
if (event.event_name === 'playbook_on_start') {
|
||||||
event.count = val.queue.count;
|
// sets count initially so this is a change
|
||||||
mungedEvent.changes = ['count'];
|
mungedEvent.changes = ['count'];
|
||||||
} else if (event.event_name === 'runner_on_ok' ||
|
} else if (event.event_name === 'runner_on_ok' ||
|
||||||
event.event_name === 'runner_on_async_ok') {
|
event.event_name === 'runner_on_async_ok') {
|
||||||
val.queue.count.ok++;
|
mungedEvent.count.ok++;
|
||||||
event.count = val.queue.count;
|
|
||||||
mungedEvent.changes = ['count'];
|
mungedEvent.changes = ['count'];
|
||||||
} else if (event.event_name === 'runner_on_skipped') {
|
} else if (event.event_name === 'runner_on_skipped') {
|
||||||
val.queue.count.skipped++;
|
mungedEvent.count.skipped++;
|
||||||
event.count = val.queue.count;
|
|
||||||
mungedEvent.changes = ['count'];
|
mungedEvent.changes = ['count'];
|
||||||
} else if (event.event_name === 'runner_on_unreachable') {
|
} else if (event.event_name === 'runner_on_unreachable') {
|
||||||
val.queue.count.unreachable++;
|
mungedEvent.count.unreachable++;
|
||||||
event.count = val.queue.count;
|
|
||||||
mungedEvent.changes = ['count'];
|
mungedEvent.changes = ['count'];
|
||||||
} else if (event.event_name === 'runner_on_error' ||
|
} else if (event.event_name === 'runner_on_error' ||
|
||||||
event.event_name === 'runner_on_async_failed') {
|
event.event_name === 'runner_on_async_failed') {
|
||||||
val.queue.count.failed++;
|
mungedEvent.count.failed++;
|
||||||
event.count = val.queue.count;
|
|
||||||
mungedEvent.changes = ['count'];
|
mungedEvent.changes = ['count'];
|
||||||
} else if (event.event_name === 'playbook_on_stats') {
|
} else if (event.event_name === 'playbook_on_stats') {
|
||||||
// get the data for populating the host status bar
|
// get the data for populating the host status bar
|
||||||
val.queue.count = getCountsFromStatsEvent(event.event_data);
|
mungedEvent.count = getCountsFromStatsEvent(event.event_data);
|
||||||
event.count = val.queue.count;
|
|
||||||
mungedEvent.changes = ['count'];
|
mungedEvent.changes = ['count'];
|
||||||
}
|
}
|
||||||
return mungedEvent;
|
return mungedEvent;
|
||||||
@@ -117,15 +140,6 @@ export default [function(){
|
|||||||
// reinitializes the event queue value for the job results page
|
// reinitializes the event queue value for the job results page
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
val.queue = {};
|
val.queue = {};
|
||||||
|
|
||||||
// initialize the host status counts
|
|
||||||
val.queue.count = {
|
|
||||||
ok: 0,
|
|
||||||
skipped: 0,
|
|
||||||
unreachable: 0,
|
|
||||||
failures: 0,
|
|
||||||
changed: 0
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
// populates the event queue
|
// populates the event queue
|
||||||
populate: function(event) {
|
populate: function(event) {
|
||||||
|
|||||||
@@ -16,23 +16,27 @@ export default [ 'templateUrl',
|
|||||||
// as count is changed by event data coming in,
|
// as count is changed by event data coming in,
|
||||||
// update the host status bar
|
// update the host status bar
|
||||||
scope.$watch('count', function(val) {
|
scope.$watch('count', function(val) {
|
||||||
Object.keys(val).forEach(key => {
|
if (val) {
|
||||||
// reposition the hosts status bar by setting the
|
Object.keys(val).forEach(key => {
|
||||||
// various flex values to the count of those hosts
|
// reposition the hosts status bar by setting
|
||||||
$(`.HostStatusBar-${key}`)
|
// the various flex values to the count of
|
||||||
.css('flex', `${val[key]} 0 auto`);
|
// those hosts
|
||||||
|
$(`.HostStatusBar-${key}`)
|
||||||
|
.css('flex', `${val[key]} 0 auto`);
|
||||||
|
|
||||||
// set the tooltip to give how many hosts of each
|
// set the tooltip to give how many hosts of
|
||||||
// type
|
// each type
|
||||||
if (val[key] > 0) {
|
if (val[key] > 0) {
|
||||||
scope[`${key}CountTip`] = `<span class='HostStatusBar-tooltipLabel'>${key}</span><span class='badge HostStatusBar-tooltipBadge HostStatusBar-tooltipBadge--${key}'>${val[key]}</span>`;
|
scope[`${key}CountTip`] = `<span class='HostStatusBar-tooltipLabel'>${key}</span><span class='badge HostStatusBar-tooltipBadge HostStatusBar-tooltipBadge--${key}'>${val[key]}</span>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// if there are any hosts that have finished, don't show
|
// if there are any hosts that have finished, don't
|
||||||
// default grey bar
|
// show default grey bar
|
||||||
scope.hostsFinished = (Object
|
scope.hostsFinished = (Object
|
||||||
.keys(val).filter(key => (val[key] > 0)).length > 0);
|
.keys(val)
|
||||||
|
.filter(key => (val[key] > 0)).length > 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,11 +77,13 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', '$scope', 'ParseTypeCh
|
|||||||
var mungedEvent = eventQueue.populate(event);
|
var mungedEvent = eventQueue.populate(event);
|
||||||
|
|
||||||
// make changes to ui based on the event returned from the queue
|
// make changes to ui based on the event returned from the queue
|
||||||
mungedEvent.changes.forEach(change => {
|
if (mungedEvent.changes) {
|
||||||
if (change === 'count') {
|
mungedEvent.changes.forEach(change => {
|
||||||
$scope.count = mungedEvent.count;
|
if (change === 'count') {
|
||||||
}
|
$scope.count = mungedEvent.count;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// the changes have been processed in the ui, mark it in the queue
|
// the changes have been processed in the ui, mark it in the queue
|
||||||
eventQueue.markProcessed(event);
|
eventQueue.markProcessed(event);
|
||||||
|
|||||||
Reference in New Issue
Block a user