mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 04:47:44 -02:30
working on stdout view line population
This commit is contained in:
committed by
jaredevantabor
parent
51bfc0525a
commit
3c261b8904
@@ -73,9 +73,18 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
|
|||||||
counter: event.counter,
|
counter: event.counter,
|
||||||
id: event.id,
|
id: event.id,
|
||||||
processed: false,
|
processed: false,
|
||||||
name: event.event_name
|
name: event.event_name,
|
||||||
|
changes: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// the interface for grabbing standard out is generalized and
|
||||||
|
// present across many types of events, so go ahead and check for
|
||||||
|
// updates to it
|
||||||
|
if (event.stdout) {
|
||||||
|
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
||||||
|
mungedEvent.changes.push('stdout');
|
||||||
|
}
|
||||||
|
|
||||||
// for different types of events, you need different types of data
|
// for different types of events, you need different types of data
|
||||||
if (event.event_name === 'playbook_on_start') {
|
if (event.event_name === 'playbook_on_start') {
|
||||||
mungedEvent.count = {
|
mungedEvent.count = {
|
||||||
@@ -86,20 +95,19 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
|
|||||||
changed: 0
|
changed: 0
|
||||||
};
|
};
|
||||||
mungedEvent.startTime = event.modified;
|
mungedEvent.startTime = event.modified;
|
||||||
mungedEvent.changes = ['count', 'startTime'];
|
mungedEvent.changes.push('count');
|
||||||
|
mungedEvent.changes.push('startTime');
|
||||||
} else if (event.event_name === 'playbook_on_play_start') {
|
} else if (event.event_name === 'playbook_on_play_start') {
|
||||||
getPreviousCount(mungedEvent.counter, "play")
|
getPreviousCount(mungedEvent.counter, "play")
|
||||||
.then(count => {
|
.then(count => {
|
||||||
mungedEvent.playCount = count + 1;
|
mungedEvent.playCount = count + 1;
|
||||||
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
mungedEvent.changes.push('playCount');
|
||||||
mungedEvent.changes = ['playCount', 'stdout'];
|
|
||||||
});
|
});
|
||||||
} else if (event.event_name === 'playbook_on_task_start') {
|
} else if (event.event_name === 'playbook_on_task_start') {
|
||||||
getPreviousCount(mungedEvent.counter, "task")
|
getPreviousCount(mungedEvent.counter, "task")
|
||||||
.then(count => {
|
.then(count => {
|
||||||
mungedEvent.taskCount = count + 1;
|
mungedEvent.taskCount = count + 1;
|
||||||
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
mungedEvent.changes.push('taskCount');
|
||||||
mungedEvent.changes = ['taskCount', 'stdout'];
|
|
||||||
});
|
});
|
||||||
} 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') {
|
||||||
@@ -107,24 +115,21 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
|
|||||||
.then(count => {
|
.then(count => {
|
||||||
mungedEvent.count = count;
|
mungedEvent.count = count;
|
||||||
mungedEvent.count.ok++;
|
mungedEvent.count.ok++;
|
||||||
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
mungedEvent.changes.push('count');
|
||||||
mungedEvent.changes = ['count', 'stdout'];
|
|
||||||
});
|
});
|
||||||
} else if (event.event_name === 'runner_on_skipped') {
|
} else if (event.event_name === 'runner_on_skipped') {
|
||||||
getPreviousCount(mungedEvent.counter)
|
getPreviousCount(mungedEvent.counter)
|
||||||
.then(count => {
|
.then(count => {
|
||||||
mungedEvent.count = count;
|
mungedEvent.count = count;
|
||||||
mungedEvent.count.skipped++;
|
mungedEvent.count.skipped++;
|
||||||
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
mungedEvent.changes.push('count');
|
||||||
mungedEvent.changes = ['count', 'stdout'];
|
|
||||||
});
|
});
|
||||||
} else if (event.event_name === 'runner_on_unreachable') {
|
} else if (event.event_name === 'runner_on_unreachable') {
|
||||||
getPreviousCount(mungedEvent.counter)
|
getPreviousCount(mungedEvent.counter)
|
||||||
.then(count => {
|
.then(count => {
|
||||||
mungedEvent.count = count;
|
mungedEvent.count = count;
|
||||||
mungedEvent.count.unreachable++;
|
mungedEvent.count.unreachable++;
|
||||||
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
mungedEvent.changes.push('count');
|
||||||
mungedEvent.changes = ['count', 'stdout'];
|
|
||||||
});
|
});
|
||||||
} 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') {
|
||||||
@@ -132,18 +137,16 @@ export default ['jobResultsService', 'parseStdoutService', '$q', function(jobRes
|
|||||||
.then(count => {
|
.then(count => {
|
||||||
mungedEvent.count = count;
|
mungedEvent.count = count;
|
||||||
mungedEvent.count.failed++;
|
mungedEvent.count.failed++;
|
||||||
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
mungedEvent.changes.push('count');
|
||||||
mungedEvent.changes = ['count', 'stdout'];
|
|
||||||
});
|
});
|
||||||
} else if (event.event_name === 'playbook_on_stats') {
|
} else if (event.event_name === 'playbook_on_stats') {
|
||||||
console.log(event.modified);
|
|
||||||
// get the data for populating the host status bar
|
// get the data for populating the host status bar
|
||||||
mungedEvent.count = jobResultsService
|
mungedEvent.count = jobResultsService
|
||||||
.getCountsFromStatsEvent(event.event_data);
|
.getCountsFromStatsEvent(event.event_data);
|
||||||
mungedEvent.stdout = parseStdoutService.parseStdout(event);
|
|
||||||
mungedEvent.finishedTime = event.modified;
|
mungedEvent.finishedTime = event.modified;
|
||||||
mungedEvent.changes = ['count', 'countFinished', 'finishedTime', 'stdout'];
|
mungedEvent.changes.push('count');
|
||||||
} else {
|
mungedEvent.changes.push('countFinished');
|
||||||
|
mungedEvent.changes.push('finishedTime');
|
||||||
}
|
}
|
||||||
|
|
||||||
mungedEventDefer.resolve(mungedEvent);
|
mungedEventDefer.resolve(mungedEvent);
|
||||||
|
|||||||
@@ -4,28 +4,45 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
background-color: @default-no-items-bord;
|
background-color: @default-no-items-bord;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.JobResultsStdOut-aLineOfStdOut{
|
.JobResultsStdOut-aLineOfStdOut,
|
||||||
|
.JobResultsStdOut-expandLine {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.JobResultsStdOut-lineNumberColumn{
|
.JobResultsStdOut-lineNumberColumn{
|
||||||
|
display: flex;
|
||||||
background-color: @default-list-header-bg;
|
background-color: @default-list-header-bg;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding: 10px 10px 10px;
|
padding-right: 10px;
|
||||||
|
padding-top: 2px;
|
||||||
|
padding-bottom: 2px;
|
||||||
color: @b7grey;
|
color: @b7grey;
|
||||||
width: 75px;
|
width: 75px;
|
||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.JobResultsStdOut-lineExpander {
|
||||||
|
text-align: left;
|
||||||
|
padding-left: 10px;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.JobResultsStdOut-lineNumberColumn--first{
|
.JobResultsStdOut-lineNumberColumn--first{
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
padding-left: 11px;
|
||||||
|
padding-top: 10px;
|
||||||
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.JobResultsStdOut-stdoutColumn{
|
.JobResultsStdOut-stdoutColumn{
|
||||||
padding: 10px 20px 10px 20px;
|
padding-left: 20px;
|
||||||
|
padding-top: 2px;
|
||||||
|
padding-bottom: 2px;
|
||||||
color: @default-interface-txt;
|
color: @default-interface-txt;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="JobResultsStdOut">
|
<div class="JobResultsStdOut">
|
||||||
<div class="JobResultsStdOut-aLineOfStdOut">
|
<div class="JobResultsStdOut-expandLine">
|
||||||
<div class="JobResultsStdOut-lineNumberColumn
|
<div class="JobResultsStdOut-lineNumberColumn
|
||||||
JobResultsStdOut-lineNumberColumn--first">
|
JobResultsStdOut-lineNumberColumn--first">
|
||||||
<i class="fa fa-plus"></i>
|
<i class="fa fa-plus"></i>
|
||||||
@@ -8,14 +8,4 @@
|
|||||||
JobResultsStdOut-stdoutColumn--first">
|
JobResultsStdOut-stdoutColumn--first">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-repeat="line in stdoutArr">
|
|
||||||
<div class="JobResultsStdOut-aLineOfStdOut">
|
|
||||||
<div class="JobResultsStdOut-lineNumberColumn">
|
|
||||||
{{line.end_line}}
|
|
||||||
</div>
|
|
||||||
<div class="JobResultsStdOut-stdoutColumn" ng-bind-html="line.stdout">
|
|
||||||
<!-- {{line.stdout}} -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(change === 'stdout'){
|
if(change === 'stdout'){
|
||||||
$scope.stdoutArr.push(mungedEvent.stdout);
|
$(".JobResultsStdOut").append(mungedEvent.stdout);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
export default [function(){
|
export default [function(){
|
||||||
var val = {
|
var val = {
|
||||||
prettify: function(line){
|
prettify: function(line){
|
||||||
|
|
||||||
// this function right now just removes the 'rn' strings
|
// this function right now just removes the 'rn' strings
|
||||||
// that i'm currently seeing on this branch on the beginning
|
// that i'm currently seeing on this branch on the beginning
|
||||||
// and end of each event string. In the future it could be
|
// and end of each event string. In the future it could be
|
||||||
// used to add styling classes to the actual lines of stdout
|
// used to add styling classes to the actual lines of stdout
|
||||||
line = line.replace(/rn/g, '\n');
|
// line = line.replace(/rn/g, '\n');
|
||||||
line = line.replace(/u001b/g, '');
|
line = line.replace(/u001b/g, '');
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
@@ -23,20 +24,55 @@ export default [function(){
|
|||||||
|
|
||||||
line = line.replace(/\[0;32m=/g, '<span class="ansi32">');
|
line = line.replace(/\[0;32m=/g, '<span class="ansi32">');
|
||||||
line = line.replace(/\[0;32m1/g, '<span class="ansi36">');
|
line = line.replace(/\[0;32m1/g, '<span class="ansi36">');
|
||||||
|
line = line.replace(/\[0;33m/g, '<span class="ansi33">');
|
||||||
|
line = line.replace(/\[0;36m/g, '<span class="ansi36">');
|
||||||
|
|
||||||
//end span
|
//end span
|
||||||
line = line.replace(/\[0m/g, '</span>');
|
line = line.replace(/\[0m/g, '</span>');
|
||||||
return line;
|
return line;
|
||||||
},
|
},
|
||||||
|
getCollapseClasses: function(event) {
|
||||||
|
var string = "";
|
||||||
|
if (event.event_name === "playbook_on_play_start") {
|
||||||
|
return string;
|
||||||
|
} else if (event.event_name === "playbook_on_task_start") {
|
||||||
|
if (event.event_data.play_uuid) {
|
||||||
|
string += " play_" + event.event_data.play_uuid;
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
} else {
|
||||||
|
if (event.event_data.play_uuid) {
|
||||||
|
string += " play_" + event.event_data.play_uuid;
|
||||||
|
}
|
||||||
|
if (event.event_data.task_uuid) {
|
||||||
|
string += " task_" + event.event_data.task_uuid;
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getCollapseIcon: function(event, line) {
|
||||||
|
if ((event.event_name === "playbook_on_play_start" || event.event_name === "playbook_on_task_start") && line !== "") {
|
||||||
|
return `<span class="JobResultsStdOut-lineExpander"><i class="fa fa-caret-down"></i></span>`;
|
||||||
|
} else {
|
||||||
|
return `<span class="JobResultsStdOut-lineExpander"></span>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
parseStdout: function(event){
|
parseStdout: function(event){
|
||||||
|
var stdoutStrings = _
|
||||||
|
.zip(_.range(event.start_line + 1,
|
||||||
|
event.end_line + 1),
|
||||||
|
event.stdout.split("\r\n").slice(0, -1))
|
||||||
|
.map(lineArr => {
|
||||||
|
return `
|
||||||
|
<div class="JobResultsStdOut-aLineOfStdOut${this.getCollapseClasses(event)}">
|
||||||
|
<div class="JobResultsStdOut-lineNumberColumn">${this.getCollapseIcon(event, lineArr[1])}${lineArr[0]}</div>
|
||||||
|
<div class="JobResultsStdOut-stdoutColumn">${this.prettify(lineArr[1])}</div>
|
||||||
|
</div>`;
|
||||||
|
}).join("");
|
||||||
// this object will be used by the ng-repeat in the
|
// this object will be used by the ng-repeat in the
|
||||||
// job-results-stdout.partial.html. probably need to add the
|
// job-results-stdout.partial.html. probably need to add the
|
||||||
// elapsed time in here too
|
// elapsed time in here too
|
||||||
return {
|
return stdoutStrings;
|
||||||
start_line: event.start_line,
|
|
||||||
end_line: event.end_line,
|
|
||||||
stdout: this.prettify(event.stdout)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return val;
|
return val;
|
||||||
|
|||||||
Reference in New Issue
Block a user