job results cleanup 1 of 2

This commit is contained in:
John Mitchell
2016-11-15 15:59:00 -05:00
committed by jaredevantabor
parent f3526ca86c
commit 53d7a822bd
5 changed files with 160 additions and 180 deletions

View File

@@ -7,8 +7,11 @@
export default ['jobResultsService', 'parseStdoutService', '$q', function(jobResultsService, parseStdoutService, $q){
var val = {};
val = {
populateDefers: {},
queue: {},
// Get the count of the last event
var getPreviousCount = function(counter, type) {
getPreviousCount: function(counter, type) {
var countAttr;
if (type === 'play') {
@@ -62,10 +65,9 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
}
return previousCount.promise;
};
},
// munge the raw event from the backend into the event_queue's format
var mungeEvent = function(event) {
munge: function(event) {
var mungedEventDefer = $q.defer();
// basic data needed in the munged event
@@ -98,34 +100,34 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
mungedEvent.changes.push('count');
mungedEvent.changes.push('startTime');
} else if (event.event_name === 'playbook_on_play_start') {
getPreviousCount(mungedEvent.counter, "play")
val.getPreviousCount(mungedEvent.counter, "play")
.then(count => {
mungedEvent.playCount = count + 1;
mungedEvent.changes.push('playCount');
});
} else if (event.event_name === 'playbook_on_task_start') {
getPreviousCount(mungedEvent.counter, "task")
val.getPreviousCount(mungedEvent.counter, "task")
.then(count => {
mungedEvent.taskCount = count + 1;
mungedEvent.changes.push('taskCount');
});
} else if (event.event_name === 'runner_on_ok' ||
event.event_name === 'runner_on_async_ok') {
getPreviousCount(mungedEvent.counter)
val.getPreviousCount(mungedEvent.counter)
.then(count => {
mungedEvent.count = count;
mungedEvent.count.ok++;
mungedEvent.changes.push('count');
});
} else if (event.event_name === 'runner_on_skipped') {
getPreviousCount(mungedEvent.counter)
val.getPreviousCount(mungedEvent.counter)
.then(count => {
mungedEvent.count = count;
mungedEvent.count.skipped++;
mungedEvent.changes.push('count');
});
} else if (event.event_name === 'runner_on_unreachable') {
getPreviousCount(mungedEvent.counter)
val.getPreviousCount(mungedEvent.counter)
.then(count => {
mungedEvent.count = count;
mungedEvent.count.unreachable++;
@@ -133,7 +135,7 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
});
} else if (event.event_name === 'runner_on_error' ||
event.event_name === 'runner_on_async_failed') {
getPreviousCount(mungedEvent.counter)
val.getPreviousCount(mungedEvent.counter)
.then(count => {
mungedEvent.count = count;
mungedEvent.count.failed++;
@@ -152,17 +154,8 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
mungedEventDefer.resolve(mungedEvent);
return mungedEventDefer.promise;
};
val = {
populateDefers: {},
queue: {},
},
// reinitializes the event queue value for the job results page
//
// TODO: implement some sort of local storage scheme
// to make viewing job details that the user has
// previous clicked on super quick, this would be where you grab
// from local storage
initialize: function() {
val.queue = {};
val.populateDefers = {};
@@ -175,6 +168,8 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
val.populateDefers[event.counter] = $q.defer();
}
// make sure not to send duplicate events over to the
// controller
if (val.queue[event.counter] &&
val.queue[event.counter].processed) {
val.populateDefers.reject("duplicate event: " +
@@ -185,11 +180,6 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
var resolvePopulation = function(event) {
// to resolve, put the event on the queue and
// then resolve the deferred value
//
// TODO: implement some sort of local storage scheme
// to make viewing job details that the user has
// previous clicked on super quick, this would be
// where you put in local storage
val.queue[event.counter] = event;
val.populateDefers[event.counter].resolve(event);
};
@@ -197,7 +187,7 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
if (event.counter === 1) {
// for the first event, go ahead and munge and
// resolve
mungeEvent(event).then(event => {
val.munge(event).then(event => {
resolvePopulation(event);
});
} else {
@@ -214,15 +204,11 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
}
// you can start the munging process...
mungeEvent(event).then(event => {
val.munge(event).then(event => {
// ...but wait until the previous event has
// been resolved before resolving this one and
// doing stuff in the ui (that's why we
// needed that previous conditional). this
// could be done in a more asynchronous nature
// if we need a performance boost. See the
// todo note in the markProcessed function
// for an idea
// needed that previous conditional).
val.populateDefers[event.counter - 1].promise
.then(() => {
resolvePopulation(event);
@@ -245,19 +231,6 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
// the event has now done it's work in the UI, record
// that!
val.queue[event.counter].processed = true;
// TODO: we can actually record what has been done in the
// UI and at what event too! (something like "resolved
// the count on event 63)".
//
// if we do something like this, we actually wouldn't
// have to wait until the previous events had completed
// before resolving and returning to the controller
// in populate()...
// in other words, we could send events out of order to
// the controller, but let the controller know that it's
// an older event that what is in the view so we don't
// need to do anything
};
if (!val.queue[event.counter]) {

View File

@@ -1,5 +1,7 @@
@import '../../shared/branding/colors.default.less';
@breakpoint-md: 1200px;
.JobResultsStdOut {
height: ~"calc(100% - 70px)";
}
@@ -204,7 +206,7 @@
color: @default-interface-txt;
}
@media (max-width: 1199px) {
@media (max-width: @breakpoint-md) {
.JobResultsStdOut-numberColumnPreload {
display: none;
}

View File

@@ -3,7 +3,6 @@
@import '../shared/layouts/one-plus-two.less';
@breakpoint-md: 1200px;
@breakpoint-sm: 623px;
.JobResults {
.OnePlusTwo-container(100%, @breakpoint-md);
@@ -115,7 +114,7 @@
margin-left: 20px;
}
@media (max-width: 1199px) {
@media (max-width: @breakpoint-md) {
.JobResults-detailsPanel {
overflow-y: auto;
}

View File

@@ -144,14 +144,19 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
}
if(change === 'stdout'){
// put stdout elements in stdout container
angular
.element(".JobResultsStdOut-stdoutContainer")
.append($compile(mungedEvent
.stdout)($scope));
// move the followAnchor to the bottom of the
// container
$(".JobResultsStdOut-followAnchor")
.appendTo(".JobResultsStdOut-stdoutContainer");
// if follow is engaged,
// scroll down to the followAnchor
if ($scope.followEngaged) {
$scope.followScroll();
}

View File

@@ -75,6 +75,7 @@ export default ['$q', 'Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErr
return count;
},
// rest call to grab previously complete job_events
getEvents: function(url) {
var val = $q.defer();