mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Job detail page
Fixed https://trello.com/c/bfSOKm8x/281-on-job-details-page-when-one-task-completely-fails-the-next-task-shows-up-with-a-green-light-beside-it
This commit is contained in:
@@ -222,87 +222,92 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
|
|||||||
}
|
}
|
||||||
scope.removeLoadHosts = scope.$on('LoadHosts', function() {
|
scope.removeLoadHosts = scope.$on('LoadHosts', function() {
|
||||||
if (scope.activeTask) {
|
if (scope.activeTask) {
|
||||||
|
|
||||||
var play = scope.jobData.plays[scope.activePlay],
|
var play = scope.jobData.plays[scope.activePlay],
|
||||||
task = play.tasks[scope.activeTask],
|
task = play.tasks[scope.activeTask],
|
||||||
url;
|
url;
|
||||||
|
|
||||||
url = scope.job.related.job_events + '?parent=' + task.id + '&';
|
if (play && task) {
|
||||||
url += 'event__startswith=runner&page_size=' + scope.hostResultsMaxRows + '&order_by=-host__name';
|
url = scope.job.related.job_events + '?parent=' + task.id + '&';
|
||||||
|
url += 'event__startswith=runner&page_size=' + scope.hostResultsMaxRows + '&order_by=-host__name';
|
||||||
|
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
var idx, event, status, status_text, item, msg;
|
var idx, event, status, status_text, item, msg;
|
||||||
if (data.results.length > 0) {
|
if (data.results.length > 0) {
|
||||||
lastEventId = data.results[0].id;
|
lastEventId = data.results[0].id;
|
||||||
}
|
|
||||||
scope.next_host_results = data.next;
|
|
||||||
for (idx=data.results.length - 1; idx >= 0; idx--) {
|
|
||||||
event = data.results[idx];
|
|
||||||
if (event.event === "runner_on_skipped") {
|
|
||||||
status = 'skipped';
|
|
||||||
}
|
|
||||||
else if (event.event === "runner_on_unreachable") {
|
|
||||||
status = 'unreachable';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
|
|
||||||
}
|
|
||||||
switch(status) {
|
|
||||||
case "successful":
|
|
||||||
status_text = 'OK';
|
|
||||||
break;
|
|
||||||
case "changed":
|
|
||||||
status_text = "Changed";
|
|
||||||
break;
|
|
||||||
case "failed":
|
|
||||||
status_text = "Failed";
|
|
||||||
break;
|
|
||||||
case "unreachable":
|
|
||||||
status_text = "Unreachable";
|
|
||||||
break;
|
|
||||||
case "skipped":
|
|
||||||
status_text = "Skipped";
|
|
||||||
}
|
}
|
||||||
|
scope.next_host_results = data.next;
|
||||||
|
for (idx=data.results.length - 1; idx >= 0; idx--) {
|
||||||
|
event = data.results[idx];
|
||||||
|
if (event.event === "runner_on_skipped") {
|
||||||
|
status = 'skipped';
|
||||||
|
}
|
||||||
|
else if (event.event === "runner_on_unreachable") {
|
||||||
|
status = 'unreachable';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
|
||||||
|
}
|
||||||
|
switch(status) {
|
||||||
|
case "successful":
|
||||||
|
status_text = 'OK';
|
||||||
|
break;
|
||||||
|
case "changed":
|
||||||
|
status_text = "Changed";
|
||||||
|
break;
|
||||||
|
case "failed":
|
||||||
|
status_text = "Failed";
|
||||||
|
break;
|
||||||
|
case "unreachable":
|
||||||
|
status_text = "Unreachable";
|
||||||
|
break;
|
||||||
|
case "skipped":
|
||||||
|
status_text = "Skipped";
|
||||||
|
}
|
||||||
|
|
||||||
if (event.event_data && event.event_data.res) {
|
if (event.event_data && event.event_data.res) {
|
||||||
item = event.event_data.res.item;
|
item = event.event_data.res.item;
|
||||||
if (typeof item === "object") {
|
if (typeof item === "object") {
|
||||||
item = JSON.stringify(item);
|
item = JSON.stringify(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = '';
|
||||||
|
if (event.event_data && event.event_data.res) {
|
||||||
|
if (typeof event.event_data.res === 'object') {
|
||||||
|
msg = event.event_data.res.msg;
|
||||||
|
} else {
|
||||||
|
msg = event.event_data.res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.event !== "runner_on_no_hosts") {
|
||||||
|
task.hostResults[event.id] = {
|
||||||
|
id: event.id,
|
||||||
|
status: status,
|
||||||
|
status_text: status_text,
|
||||||
|
host_id: event.host,
|
||||||
|
task_id: event.parent,
|
||||||
|
name: event.event_data.host,
|
||||||
|
created: event.created,
|
||||||
|
msg: msg,
|
||||||
|
item: item
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scope.$emit('LoadHostSummaries');
|
||||||
msg = '';
|
})
|
||||||
if (event.event_data && event.event_data.res) {
|
.error(function(data, status) {
|
||||||
if (typeof event.event_data.res === 'object') {
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
msg = event.event_data.res.msg;
|
msg: 'Call to ' + url + '. GET returned: ' + status });
|
||||||
} else {
|
});
|
||||||
msg = event.event_data.res;
|
} else {
|
||||||
}
|
console.log('no tasks loaded!');
|
||||||
}
|
scope.$emit('LoadHostSummaries');
|
||||||
|
}
|
||||||
if (event.event !== "runner_on_no_hosts") {
|
} else {
|
||||||
task.hostResults[event.id] = {
|
|
||||||
id: event.id,
|
|
||||||
status: status,
|
|
||||||
status_text: status_text,
|
|
||||||
host_id: event.host,
|
|
||||||
task_id: event.parent,
|
|
||||||
name: event.event_data.host,
|
|
||||||
created: event.created,
|
|
||||||
msg: msg,
|
|
||||||
item: item
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scope.$emit('LoadHostSummaries');
|
|
||||||
})
|
|
||||||
.error(function(data, status) {
|
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Call to ' + url + '. GET returned: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope.$emit('LoadHostSummaries');
|
scope.$emit('LoadHostSummaries');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -314,98 +319,104 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
|
|||||||
if (scope.activePlay) {
|
if (scope.activePlay) {
|
||||||
var play = scope.jobData.plays[scope.activePlay], url;
|
var play = scope.jobData.plays[scope.activePlay], url;
|
||||||
|
|
||||||
url = scope.job.url + 'job_tasks/?event_id=' + play.id;
|
if (play) {
|
||||||
url += '&page_size=' + scope.tasksMaxRows + '&order_by=id';
|
url = scope.job.url + 'job_tasks/?event_id=' + play.id;
|
||||||
|
url += '&page_size=' + scope.tasksMaxRows + '&order_by=id';
|
||||||
|
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
scope.next_tasks = data.next;
|
scope.next_tasks = data.next;
|
||||||
if (data.results.length > 0) {
|
if (data.results.length > 0) {
|
||||||
lastEventId = data.results[data.results.length - 1].id;
|
lastEventId = data.results[data.results.length - 1].id;
|
||||||
if (scope.liveEventProcessing) {
|
if (scope.liveEventProcessing) {
|
||||||
scope.activeTask = data.results[data.results.length - 1].id;
|
scope.activeTask = data.results[data.results.length - 1].id;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.activeTask = data.results[0].id;
|
||||||
|
}
|
||||||
|
scope.selectedTask = scope.activeTask;
|
||||||
}
|
}
|
||||||
else {
|
data.results.forEach(function(event, idx) {
|
||||||
scope.activeTask = data.results[0].id;
|
var end, elapsed, status, status_text;
|
||||||
}
|
|
||||||
scope.selectedTask = scope.activeTask;
|
|
||||||
}
|
|
||||||
data.results.forEach(function(event, idx) {
|
|
||||||
var end, elapsed, status, status_text;
|
|
||||||
|
|
||||||
if (play.firstTask === undefined || play.firstTask === null) {
|
if (play.firstTask === undefined || play.firstTask === null) {
|
||||||
play.firstTask = event.id;
|
play.firstTask = event.id;
|
||||||
play.hostCount = (event.host_count) ? event.host_count : 0;
|
play.hostCount = (event.host_count) ? event.host_count : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx < data.length - 1) {
|
if (idx < data.length - 1) {
|
||||||
// end date = starting date of the next event
|
// end date = starting date of the next event
|
||||||
end = data[idx + 1].created;
|
end = data[idx + 1].created;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// no next event (task), get the end time of the play
|
// no next event (task), get the end time of the play
|
||||||
end = scope.jobData.plays[scope.activePlay].finished;
|
end = scope.jobData.plays[scope.activePlay].finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end) {
|
if (end) {
|
||||||
elapsed = GetElapsed({
|
elapsed = GetElapsed({
|
||||||
start: event.created,
|
start: event.created,
|
||||||
end: end
|
end: end
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elapsed = '00:00:00';
|
||||||
|
}
|
||||||
|
|
||||||
|
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
|
||||||
|
status_text = (event.failed) ? 'Failed' : (event.changed) ? 'Changed' : 'OK';
|
||||||
|
|
||||||
|
play.tasks[event.id] = {
|
||||||
|
id: event.id,
|
||||||
|
play_id: scope.activePlay,
|
||||||
|
name: event.name,
|
||||||
|
status: status,
|
||||||
|
status_text: status_text,
|
||||||
|
status_tip: "Event ID: " + event.id + "<br />Status: " + status_text,
|
||||||
|
created: event.created,
|
||||||
|
modified: event.modified,
|
||||||
|
finished: end,
|
||||||
|
elapsed: elapsed,
|
||||||
|
hostCount: (event.host_count) ? event.host_count : 0,
|
||||||
|
reportedHosts: (event.reported_hosts) ? event.reported_hosts : 0,
|
||||||
|
successfulCount: (event.successful_count) ? event.successful_count : 0,
|
||||||
|
failedCount: (event.failed_count) ? event.failed_count : 0,
|
||||||
|
changedCount: (event.changed_count) ? event.changed_count : 0,
|
||||||
|
skippedCount: (event.skipped_count) ? event.skipped_count : 0,
|
||||||
|
unreachableCount: (event.unreachable_count) ? event.unreachable_count : 0,
|
||||||
|
taskActiveClass: '',
|
||||||
|
hostResults: {}
|
||||||
|
};
|
||||||
|
if (play.firstTask !== event.id) {
|
||||||
|
// this is not the first task
|
||||||
|
play.tasks[event.id].hostCount = play.tasks[play.firstTask].hostCount;
|
||||||
|
}
|
||||||
|
if (play.tasks[event.id].reportedHosts === 0 && play.tasks[event.id].successfulCount === 0 &&
|
||||||
|
play.tasks[event.id].failedCount === 0 && play.tasks[event.id].changedCount === 0 &&
|
||||||
|
play.tasks[event.id].skippedCount === 0 && play.tasks[event.id].unreachableCount === 0) {
|
||||||
|
play.tasks[event.id].status = 'no-matching-hosts';
|
||||||
|
play.tasks[event.id].status_text = 'No matching hosts';
|
||||||
|
play.tasks[event.id].status_tip = "Event ID: " + event.id + "<br />Status: No matching hosts";
|
||||||
|
}
|
||||||
|
play.taskCount++;
|
||||||
|
SetTaskStyles({
|
||||||
|
task: play.tasks[event.id]
|
||||||
});
|
});
|
||||||
}
|
|
||||||
else {
|
|
||||||
elapsed = '00:00:00';
|
|
||||||
}
|
|
||||||
|
|
||||||
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
|
|
||||||
status_text = (event.failed) ? 'Failed' : (event.changed) ? 'Changed' : 'OK';
|
|
||||||
|
|
||||||
play.tasks[event.id] = {
|
|
||||||
id: event.id,
|
|
||||||
play_id: scope.activePlay,
|
|
||||||
name: event.name,
|
|
||||||
status: status,
|
|
||||||
status_text: status_text,
|
|
||||||
status_tip: "Event ID: " + event.id + "<br />Status: " + status_text,
|
|
||||||
created: event.created,
|
|
||||||
modified: event.modified,
|
|
||||||
finished: end,
|
|
||||||
elapsed: elapsed,
|
|
||||||
hostCount: (event.host_count) ? event.host_count : 0,
|
|
||||||
reportedHosts: (event.reported_hosts) ? event.reported_hosts : 0,
|
|
||||||
successfulCount: (event.successful_count) ? event.successful_count : 0,
|
|
||||||
failedCount: (event.failed_count) ? event.failed_count : 0,
|
|
||||||
changedCount: (event.changed_count) ? event.changed_count : 0,
|
|
||||||
skippedCount: (event.skipped_count) ? event.skipped_count : 0,
|
|
||||||
unreachableCount: (event.unreachable_count) ? event.unreachable_count : 0,
|
|
||||||
taskActiveClass: '',
|
|
||||||
hostResults: {}
|
|
||||||
};
|
|
||||||
if (play.firstTask !== event.id) {
|
|
||||||
// this is not the first task
|
|
||||||
play.tasks[event.id].hostCount = play.tasks[play.firstTask].hostCount;
|
|
||||||
}
|
|
||||||
if (play.tasks[event.id].hostCount === 0) {
|
|
||||||
play.tasks[event.id].status_text = 'No matching hosts';
|
|
||||||
play.tasks[event.id].status_tip = "Event ID: " + event.id + "<br />Status: No matching hosts";
|
|
||||||
}
|
|
||||||
play.taskCount++;
|
|
||||||
SetTaskStyles({
|
|
||||||
task: play.tasks[event.id]
|
|
||||||
});
|
});
|
||||||
|
if (scope.activeTask && scope.jobData.plays[scope.activePlay] && scope.jobData.plays[scope.activePlay].tasks[scope.activeTask]) {
|
||||||
|
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active';
|
||||||
|
}
|
||||||
|
scope.$emit('LoadHosts');
|
||||||
|
})
|
||||||
|
.error(function(data) {
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + '. GET returned: ' + status });
|
||||||
});
|
});
|
||||||
if (scope.activeTask && scope.jobData.plays[scope.activePlay] && scope.jobData.plays[scope.activePlay].tasks[scope.activeTask]) {
|
} else {
|
||||||
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active';
|
scope.$emit('LoadHostSummaries');
|
||||||
}
|
}
|
||||||
scope.$emit('LoadHosts');
|
} else {
|
||||||
})
|
|
||||||
.error(function(data) {
|
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Call to ' + url + '. GET returned: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope.$emit('LoadHostSummaries');
|
scope.$emit('LoadHostSummaries');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -502,6 +513,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scope.jobData.plays[event.id].hostCount === 0 && event.unreachable_count === 0) {
|
if (scope.jobData.plays[event.id].hostCount === 0 && event.unreachable_count === 0) {
|
||||||
|
scope.jobData.plays[event.id].status = 'no-matching-hosts';
|
||||||
scope.jobData.plays[event.id].status_text = 'No matching hosts';
|
scope.jobData.plays[event.id].status_text = 'No matching hosts';
|
||||||
scope.jobData.plays[event.id].status_tip = "Event ID: " + event.id + "<br />Status: No matching hosts";
|
scope.jobData.plays[event.id].status_tip = "Event ID: " + event.id + "<br />Status: No matching hosts";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -391,10 +391,11 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
|||||||
}
|
}
|
||||||
else if (play.status !== 'changed' && play.status !== 'failed') {
|
else if (play.status !== 'changed' && play.status !== 'failed') {
|
||||||
// once the status becomes 'changed' or 'failed' don't modify it
|
// once the status becomes 'changed' or 'failed' don't modify it
|
||||||
play.status = (changed) ? 'changed' : (failed) ? 'failed' : 'successful';
|
|
||||||
if (no_hosts) {
|
if (no_hosts) {
|
||||||
|
play.status = 'no-matching-hosts';
|
||||||
play.status_text = 'No matching hosts';
|
play.status_text = 'No matching hosts';
|
||||||
} else {
|
} else {
|
||||||
|
play.status = (changed) ? 'changed' : (failed) ? 'failed' : 'successful';
|
||||||
play.status_text = (changed) ? 'Changed' : (failed) ? 'Failed' : 'OK';
|
play.status_text = (changed) ? 'Changed' : (failed) ? 'Failed' : 'OK';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1259,7 +1260,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
|||||||
filteredListX = [],
|
filteredListX = [],
|
||||||
filteredListA = [],
|
filteredListA = [],
|
||||||
filteredListB = [],
|
filteredListB = [],
|
||||||
idx, key, keys, newKeys, tasks;
|
idx, key, keys, newKeys, tasks, t;
|
||||||
|
|
||||||
function listSort(a,b) {
|
function listSort(a,b) {
|
||||||
if (parseInt(a,10) < parseInt(b,10))
|
if (parseInt(a,10) < parseInt(b,10))
|
||||||
@@ -1275,7 +1276,9 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
|||||||
|
|
||||||
// Only draw tasks that are in the 'active' list
|
// Only draw tasks that are in the 'active' list
|
||||||
for (key in tasks) {
|
for (key in tasks) {
|
||||||
if (tasks[key].reportedHosts > 0 || tasks[key].status === 'no-matching-hosts') {
|
t = tasks[key];
|
||||||
|
if (t.reportedHosts > 0 || t.hostCount > 0 || t.successfulCount >0 || t.failedCount > 0 ||
|
||||||
|
t.changedCount > 0 || t.skippedCount > 0 || t.unreachableCount > 0) {
|
||||||
filteredListX[key] = tasks[key];
|
filteredListX[key] = tasks[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user