mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 22:49:32 -02:30
job results cleanup 1.5 of 2
parse standard out service is commented
This commit is contained in:
committed by
jaredevantabor
parent
53d7a822bd
commit
86cf09ec71
@@ -4,12 +4,15 @@
|
|||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default [function(){
|
export default ['$log', function($log){
|
||||||
var val = {
|
var val = {
|
||||||
|
// parses stdout string from api and formats various codes to the
|
||||||
|
// correct dom structure
|
||||||
prettify: function(line){
|
prettify: function(line){
|
||||||
|
|
||||||
|
// TODO: remove once Chris's fixes to the [K lines comes in
|
||||||
if (line.indexOf("[K") > -1) {
|
if (line.indexOf("[K") > -1) {
|
||||||
console.log(line);
|
$log.error(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line.replace(/u001b/g, '');
|
line = line.replace(/u001b/g, '');
|
||||||
@@ -30,45 +33,60 @@ export default [function(){
|
|||||||
line = line.replace(/\[0m/g, '</span>');
|
line = line.replace(/\[0m/g, '</span>');
|
||||||
return line;
|
return line;
|
||||||
},
|
},
|
||||||
|
// adds anchor tags and tooltips to host status lines
|
||||||
getAnchorTags: function(event, line){
|
getAnchorTags: function(event, line){
|
||||||
if(event.event.indexOf("runner_") === -1){
|
if(event.event.indexOf("runner_") === -1){
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
var str = `<a ui-sref="jobDetail.host-event.details({eventId: ${event.parent}, taskId: ${event.id} })" aw-tool-tip="Event ID: ${event.id} <br> Status: ${event.event_display}. <br> Click for details" data-tip-watch="result.tip" data-placement="top">`,
|
return `<a ui-sref="jobDetail.host-event.details({eventId: ${event.parent}, taskId: ${event.id} })" aw-tool-tip="Event ID: ${event.id} <br>Status: ${event.event_display}. <br>Click for details" data-tip-watch="result.tip" data-placement="top">${line}</a>`;
|
||||||
str2 = '</a>';
|
|
||||||
return str.concat(line).concat(str2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
getCollapseClasses: function(event, line, lineNum) {
|
// this adds classes based on event data to the
|
||||||
|
// .JobResultsStdOut-aLineOfStdOut element
|
||||||
|
getLineClasses: function(event, line, lineNum) {
|
||||||
var string = "";
|
var string = "";
|
||||||
if (event.event_name === "playbook_on_play_start") {
|
if (event.event_name === "playbook_on_play_start") {
|
||||||
|
// play header classes
|
||||||
string += " header_play";
|
string += " header_play";
|
||||||
string += " header_play_" + event.event_data.play_uuid;
|
string += " header_play_" + event.event_data.play_uuid;
|
||||||
if (line) {
|
if (line) {
|
||||||
string += " actual_header";
|
string += " actual_header";
|
||||||
}
|
}
|
||||||
} else if (event.event_name === "playbook_on_task_start") {
|
} else if (event.event_name === "playbook_on_task_start") {
|
||||||
|
// task header classes
|
||||||
string += " header_task";
|
string += " header_task";
|
||||||
string += " header_task_" + event.event_data.task_uuid;
|
string += " header_task_" + event.event_data.task_uuid;
|
||||||
if (event.event_data.play_uuid) {
|
|
||||||
string += " play_" + event.event_data.play_uuid;
|
|
||||||
}
|
|
||||||
if (line) {
|
if (line) {
|
||||||
string += " actual_header";
|
string += " actual_header";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
// task headers also get classed by their parent play
|
||||||
|
// if applicable
|
||||||
if (event.event_data.play_uuid) {
|
if (event.event_data.play_uuid) {
|
||||||
string += " play_" + event.event_data.play_uuid;
|
string += " play_" + event.event_data.play_uuid;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// host status or debug line
|
||||||
|
|
||||||
|
// these get classed by their parent play if applicable
|
||||||
|
if (event.event_data.play_uuid) {
|
||||||
|
string += " play_" + event.event_data.play_uuid;
|
||||||
|
}
|
||||||
|
// as well as their parent task if applicable
|
||||||
if (event.event_data.task_uuid) {
|
if (event.event_data.task_uuid) {
|
||||||
string += " task_" + event.event_data.task_uuid;
|
string += " task_" + event.event_data.task_uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: adding this line_num_XX class is hacky because the
|
||||||
|
// line number is availabe in children of this dom element
|
||||||
string += " line_num_" + lineNum;
|
string += " line_num_" + lineNum;
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
},
|
},
|
||||||
|
// used to add expand/collapse icon next to line numbers of headers
|
||||||
getCollapseIcon: function(event, line) {
|
getCollapseIcon: function(event, line) {
|
||||||
var clickClass,
|
var clickClass,
|
||||||
expanderizerSpecifier;
|
expanderizerSpecifier;
|
||||||
@@ -81,19 +99,26 @@ export default [function(){
|
|||||||
line !== "") {
|
line !== "") {
|
||||||
if (event.event_name === "playbook_on_play_start" &&
|
if (event.event_name === "playbook_on_play_start" &&
|
||||||
line.indexOf("PLAY") > -1) {
|
line.indexOf("PLAY") > -1) {
|
||||||
|
// play header specific attrs
|
||||||
expanderizerSpecifier = "play";
|
expanderizerSpecifier = "play";
|
||||||
clickClass = "play_" +
|
clickClass = "play_" +
|
||||||
event.event_data.play_uuid;
|
event.event_data.play_uuid;
|
||||||
} else if (line.indexOf("TASK") > -1 ||
|
} else if (line.indexOf("TASK") > -1 ||
|
||||||
line.indexOf("RUNNING HANDLER") > -1) {
|
line.indexOf("RUNNING HANDLER") > -1) {
|
||||||
|
// task header specific attrs
|
||||||
expanderizerSpecifier = "task";
|
expanderizerSpecifier = "task";
|
||||||
clickClass = "task_" +
|
clickClass = "task_" +
|
||||||
event.event_data.task_uuid;
|
event.event_data.task_uuid;
|
||||||
} else {
|
} else {
|
||||||
|
// header lines that don't have PLAY, TASK,
|
||||||
|
// or RUNNING HANDLER in them don't get
|
||||||
|
// expand icon.
|
||||||
|
// This provides cowsay support.
|
||||||
return emptySpan;
|
return emptySpan;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `
|
|
||||||
|
var expandDom = `
|
||||||
<span class="JobResultsStdOut-lineExpander">
|
<span class="JobResultsStdOut-lineExpander">
|
||||||
<i class="JobResultsStdOut-lineExpanderIcon fa fa-caret-down expanderizer
|
<i class="JobResultsStdOut-lineExpanderIcon fa fa-caret-down expanderizer
|
||||||
expanderizer--${expanderizerSpecifier} expanded"
|
expanderizer--${expanderizerSpecifier} expanded"
|
||||||
@@ -101,22 +126,42 @@ export default [function(){
|
|||||||
data-uuid="${clickClass}">
|
data-uuid="${clickClass}">
|
||||||
</i>
|
</i>
|
||||||
</span>`;
|
</span>`;
|
||||||
|
console.log(expandDom);
|
||||||
|
return expandDom;
|
||||||
} else {
|
} else {
|
||||||
|
// non-header lines don't get an expander
|
||||||
return emptySpan;
|
return emptySpan;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// public function that provides the parsed stdout line, given a
|
||||||
|
// job_event
|
||||||
parseStdout: function(event){
|
parseStdout: function(event){
|
||||||
return _
|
// this utilizes the start/end lines and stdout blob
|
||||||
|
// to create an array in the format:
|
||||||
|
// [
|
||||||
|
// [lineNum: lineText],
|
||||||
|
// [lineNum: lineText],
|
||||||
|
// ]
|
||||||
|
var lineArr = _
|
||||||
.zip(_.range(event.start_line + 1,
|
.zip(_.range(event.start_line + 1,
|
||||||
event.end_line + 1),
|
event.end_line + 1),
|
||||||
event.stdout.replace("\t", " ").split("\r\n").slice(0, -1))
|
event.stdout.replace("\t", " ").split("\r\n").slice(0, -1));
|
||||||
|
|
||||||
|
// this takes each `[lineNum: lineText]` element and calls the
|
||||||
|
// relevant helper functions in this service to build the
|
||||||
|
// parsed line of standard out
|
||||||
|
lineArr = lineArr
|
||||||
.map(lineArr => {
|
.map(lineArr => {
|
||||||
return `
|
return `
|
||||||
<div class="JobResultsStdOut-aLineOfStdOut${this.getCollapseClasses(event, lineArr[1], lineArr[0])}">
|
<div class="JobResultsStdOut-aLineOfStdOut${this.getLineClasses(event, lineArr[1], lineArr[0])}">
|
||||||
<div class="JobResultsStdOut-lineNumberColumn">${this.getCollapseIcon(event, lineArr[1])}${lineArr[0]}</div>
|
<div class="JobResultsStdOut-lineNumberColumn">${this.getCollapseIcon(event, lineArr[1])}${lineArr[0]}</div>
|
||||||
<div class="JobResultsStdOut-stdoutColumn">${this.getAnchorTags(event, this.prettify(lineArr[1]))}</div>
|
<div class="JobResultsStdOut-stdoutColumn">${this.getAnchorTags(event, this.prettify(lineArr[1]))}</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}).join("");
|
});
|
||||||
|
|
||||||
|
// this joins all the lines for this job_event together and
|
||||||
|
// returns to the mungeEvent function
|
||||||
|
return lineArr.join("");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return val;
|
return val;
|
||||||
|
|||||||
Reference in New Issue
Block a user