mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Job detail page
Built new event viewer. Based on LogViewer.js that provides a common log viewing dialog. Event viewer dialog has the same look and feel.
This commit is contained in:
@@ -1168,124 +1168,4 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
||||
msg: 'Call to ' + url + '. GET returned: ' + status });
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('ViewHostResults', ['$log', 'CreateDialog', 'Rest', 'ProcessErrors', 'Wait', function($log, CreateDialog, Rest, ProcessErrors, Wait) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
my_scope = params.scope.$new(),
|
||||
id = params.id,
|
||||
url;
|
||||
|
||||
function parseJSON(obj) {
|
||||
var html="", keys;
|
||||
if (typeof obj === "object") {
|
||||
html += "<table class=\"object-list\">\n";
|
||||
html += "<tbody>\n";
|
||||
keys = Object.keys(obj).sort();
|
||||
keys.forEach(function(key) {
|
||||
if (typeof obj[key] === "boolean" || typeof obj[key] === "number" || typeof obj[key] === "string") {
|
||||
html += "<tr><td class=\"key\">" + key + ":</td><td class=\"value";
|
||||
html += (key === "results" || key === "stdout" || key === "stderr") ? " mono-space" : "";
|
||||
html += "\">";
|
||||
html += (key === "status") ? "<i class=\"fa icon-job-" + obj[key] + "\"></i> " + obj[key] : obj[key];
|
||||
html += "</td></tr>\n";
|
||||
}
|
||||
else if (obj[key] === null || obj[key] === undefined) {
|
||||
// html += "<tr><td class=\"key\">" + key + ":</td><td class=\"value\">null</td></tr>\n";
|
||||
}
|
||||
else if (typeof obj[key] === "object" && Array.isArray(obj[key])) {
|
||||
html += "<tr><td class=\"key\">" + key + ":</td><td class=\"value";
|
||||
html += (key === "results" || key === "stdout" || key === "stderr") ? " mono-space" : "";
|
||||
html += "\">";
|
||||
obj[key].forEach(function(row) {
|
||||
html += "<p>" + row + "</p>";
|
||||
});
|
||||
html += "</td></tr>\n";
|
||||
}
|
||||
else if (typeof obj[key] === "object") {
|
||||
html += "<tr><td class=\"key\">" + key + ":</td><td class=\"nested-table\">\n" + parseJSON(obj[key]) + "</td></tr>\n";
|
||||
}
|
||||
});
|
||||
html += "</tbody>\n";
|
||||
html += "</table>\n";
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
if (my_scope.removeDataReady) {
|
||||
my_scope.removeDataReady();
|
||||
}
|
||||
my_scope.removeDataReady = my_scope.$on('DataReady', function(e, event_data, host) {
|
||||
//var html = "<div class=\"title-section\">\n";
|
||||
//html += "<h4>" + host.name + "</h4>\n";
|
||||
//html += (host.description && host.description !== "imported") ? "<h5>" + host.description + "</h5>" : "";
|
||||
//html += "<p>Event " + id + " details:</p>\n";
|
||||
//html += "</div>\n";
|
||||
var html = "<div class=\"results\">\n";
|
||||
event_data.host = host.name;
|
||||
html += parseJSON(event_data);
|
||||
html += "<div class=\"spacer\"></div>\n";
|
||||
html += "</div>\n";
|
||||
|
||||
$('#event-viewer-dialog').empty().html(html);
|
||||
|
||||
CreateDialog({
|
||||
scope: my_scope,
|
||||
width: 600,
|
||||
height: 550,
|
||||
minWidth: 450,
|
||||
callback: 'ModalReady',
|
||||
id: 'event-viewer-dialog',
|
||||
title: 'Host Results',
|
||||
onOpen: function() {
|
||||
$('#dialog-ok-button').focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (my_scope.removeModalReady) {
|
||||
my_scope.removeModalReady();
|
||||
}
|
||||
my_scope.removeModalReady = my_scope.$on('ModalReady', function() {
|
||||
Wait('stop');
|
||||
$('#event-viewer-dialog').dialog('open');
|
||||
});
|
||||
|
||||
url = scope.job.related.job_events + "?id=" + id;
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success( function(data) {
|
||||
var key;
|
||||
Wait('stop');
|
||||
if (data.results.length > 0 && data.results[0].event_data.res) {
|
||||
for (key in data.results[0].event_data) {
|
||||
if (key !== "res") {
|
||||
data.results[0].event_data.res[key] = data.results[0].event_data[key];
|
||||
}
|
||||
}
|
||||
if (data.results[0].event_data.res.ansible_facts) {
|
||||
delete data.results[0].event_data.res.ansible_facts;
|
||||
}
|
||||
data.results[0].event_data.res.status = (data.results[0].event === "runner_on_skipped") ? 'skipped' : (data.results[0].failed) ? 'failed' :
|
||||
(data.results[0].changed) ? 'changed' : 'successful';
|
||||
my_scope.$emit('DataReady', data.results[0].event_data.res, data.results[0].summary_fields.host, data.results[0].id);
|
||||
}
|
||||
else {
|
||||
data.results[0].event_data.status = (data.results[0].event === "runner_on_skipped") ? 'skipped' : (data.results[0].failed) ? 'failed' :
|
||||
(data.results[0].changed) ? 'changed' : 'successful';
|
||||
my_scope.$emit('DataReady', data.results[0].event_data, data.results[0].summary_fields.host, data.results[0].id);
|
||||
}
|
||||
})
|
||||
.error(function(data, status) {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Call to ' + url + '. GET returned: ' + status });
|
||||
});
|
||||
|
||||
scope.modalOK = function() {
|
||||
$('#event-viewer-dialog').dialog('close');
|
||||
my_scope.$destroy();
|
||||
};
|
||||
};
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user