mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-15 07:48:38 -05:00
Job stdout refactor
Switching to new stdout endpoint and restyling.
This commit is contained in:
@@ -33,52 +33,16 @@ function JobStdoutController ($rootScope, $scope, $compile, $routeParams, ClearS
|
||||
$scope.removeLoadStdout();
|
||||
}
|
||||
$scope.removeLoadStdout = $scope.$on('LoadStdout', function() {
|
||||
Rest.setUrl(stdout_url + '?format=html');
|
||||
Rest.setUrl(stdout_url + '?format=json&start_line=-1000');
|
||||
Rest.get()
|
||||
.success(function(data) {
|
||||
var lines, styles=[], html=[], found=false, doc, style, pre, parser;
|
||||
api_complete = true;
|
||||
Wait('stop');
|
||||
if ($rootScope.browser === "SAFARI") {
|
||||
// Safari's DOMParser will not parse HTML, so we have to do our best to extract the
|
||||
// parts we want.
|
||||
|
||||
lines = data.split("\n");
|
||||
// Get the style sheet
|
||||
lines.forEach(function(line) {
|
||||
if (/<style.*/.test(line)) {
|
||||
found = true;
|
||||
}
|
||||
if (found) {
|
||||
styles.push(line);
|
||||
}
|
||||
if (/<\/style>/.test(line)) {
|
||||
found = false;
|
||||
}
|
||||
});
|
||||
found = false;
|
||||
// Get all the bits between <pre> and </pre>
|
||||
lines.forEach(function(line) {
|
||||
if (/<pre>/.test(line)) {
|
||||
found = true;
|
||||
}
|
||||
else if (/<\/pre>/.test(line)) {
|
||||
found = false;
|
||||
}
|
||||
else if (found) {
|
||||
html.push(line);
|
||||
}
|
||||
});
|
||||
$('#style-sheet-container').empty().html(styles.join("\n"));
|
||||
$('#pre-container-content').empty().html(html.join("\n"));
|
||||
if (data.content) {
|
||||
$('#pre-container-content').empty().html(data.content);
|
||||
}
|
||||
else {
|
||||
parser = new DOMParser();
|
||||
doc = parser.parseFromString(data, "text/html");
|
||||
pre = doc.getElementsByTagName('pre');
|
||||
style = doc.getElementsByTagName('style');
|
||||
$('#style-sheet-container').empty().html(style[0]);
|
||||
$('#pre-container-content').empty().html($(pre[0]).html());
|
||||
$('#pre-container-content').empty();
|
||||
}
|
||||
setTimeout(function() { $('#pre-container').mCustomScrollbar("scrollTo", 'bottom'); }, 1000);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user