mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
job results cleanup 1.5 of 2
parse standard out service is commented
This commit is contained in:
parent
53d7a822bd
commit
86cf09ec71
@ -4,12 +4,15 @@
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
export default [function(){
|
||||
export default ['$log', function($log){
|
||||
var val = {
|
||||
// parses stdout string from api and formats various codes to the
|
||||
// correct dom structure
|
||||
prettify: function(line){
|
||||
|
||||
// TODO: remove once Chris's fixes to the [K lines comes in
|
||||
if (line.indexOf("[K") > -1) {
|
||||
console.log(line);
|
||||
$log.error(line);
|
||||
}
|
||||
|
||||
line = line.replace(/u001b/g, '');
|
||||
@ -30,45 +33,60 @@ export default [function(){
|
||||
line = line.replace(/\[0m/g, '</span>');
|
||||
return line;
|
||||
},
|
||||
// adds anchor tags and tooltips to host status lines
|
||||
getAnchorTags: function(event, line){
|
||||
if(event.event.indexOf("runner_") === -1){
|
||||
return line;
|
||||
}
|
||||
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">`,
|
||||
str2 = '</a>';
|
||||
return str.concat(line).concat(str2);
|
||||
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>`;
|
||||
}
|
||||
|
||||
},
|
||||
getCollapseClasses: function(event, line, lineNum) {
|
||||
// this adds classes based on event data to the
|
||||
// .JobResultsStdOut-aLineOfStdOut element
|
||||
getLineClasses: function(event, line, lineNum) {
|
||||
var string = "";
|
||||
if (event.event_name === "playbook_on_play_start") {
|
||||
// play header classes
|
||||
string += " header_play";
|
||||
string += " header_play_" + event.event_data.play_uuid;
|
||||
if (line) {
|
||||
string += " actual_header";
|
||||
}
|
||||
} else if (event.event_name === "playbook_on_task_start") {
|
||||
// task header classes
|
||||
string += " header_task";
|
||||
string += " header_task_" + event.event_data.task_uuid;
|
||||
if (event.event_data.play_uuid) {
|
||||
string += " play_" + event.event_data.play_uuid;
|
||||
}
|
||||
if (line) {
|
||||
string += " actual_header";
|
||||
}
|
||||
} else {
|
||||
|
||||
// task headers also get classed by their parent play
|
||||
// if applicable
|
||||
if (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) {
|
||||
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;
|
||||
|
||||
return string;
|
||||
},
|
||||
// used to add expand/collapse icon next to line numbers of headers
|
||||
getCollapseIcon: function(event, line) {
|
||||
var clickClass,
|
||||
expanderizerSpecifier;
|
||||
@ -81,19 +99,26 @@ export default [function(){
|
||||
line !== "") {
|
||||
if (event.event_name === "playbook_on_play_start" &&
|
||||
line.indexOf("PLAY") > -1) {
|
||||
// play header specific attrs
|
||||
expanderizerSpecifier = "play";
|
||||
clickClass = "play_" +
|
||||
event.event_data.play_uuid;
|
||||
} else if (line.indexOf("TASK") > -1 ||
|
||||
line.indexOf("RUNNING HANDLER") > -1) {
|
||||
// task header specific attrs
|
||||
expanderizerSpecifier = "task";
|
||||
clickClass = "task_" +
|
||||
event.event_data.task_uuid;
|
||||
} 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 `
|
||||
|
||||
var expandDom = `
|
||||
<span class="JobResultsStdOut-lineExpander">
|
||||
<i class="JobResultsStdOut-lineExpanderIcon fa fa-caret-down expanderizer
|
||||
expanderizer--${expanderizerSpecifier} expanded"
|
||||
@ -101,22 +126,42 @@ export default [function(){
|
||||
data-uuid="${clickClass}">
|
||||
</i>
|
||||
</span>`;
|
||||
console.log(expandDom);
|
||||
return expandDom;
|
||||
} else {
|
||||
// non-header lines don't get an expander
|
||||
return emptySpan;
|
||||
}
|
||||
},
|
||||
// public function that provides the parsed stdout line, given a
|
||||
// job_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,
|
||||
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 => {
|
||||
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-stdoutColumn">${this.getAnchorTags(event, this.prettify(lineArr[1]))}</div>
|
||||
</div>`;
|
||||
}).join("");
|
||||
});
|
||||
|
||||
// this joins all the lines for this job_event together and
|
||||
// returns to the mungeEvent function
|
||||
return lineArr.join("");
|
||||
}
|
||||
};
|
||||
return val;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user