mirror of
https://github.com/ansible/awx.git
synced 2026-05-18 06:47:41 -02:30
Merge pull request #197 from gconsidine/ui/fix/stdout-chars
Ui/fix/stdout chars
This commit is contained in:
@@ -9,7 +9,6 @@ export default ['$log', 'moment', 'i18n', function($log, moment, i18n){
|
|||||||
// parses stdout string from api and formats various codes to the
|
// parses stdout string from api and formats various codes to the
|
||||||
// correct dom structure
|
// correct dom structure
|
||||||
prettify: function(line, unstyled){
|
prettify: function(line, unstyled){
|
||||||
|
|
||||||
line = line
|
line = line
|
||||||
.replace(/&/g, "&")
|
.replace(/&/g, "&")
|
||||||
.replace(/</g, "<")
|
.replace(/</g, "<")
|
||||||
@@ -27,46 +26,35 @@ export default ['$log', 'moment', 'i18n', function($log, moment, i18n){
|
|||||||
line = line.replace(/u001b/g, '');
|
line = line.replace(/u001b/g, '');
|
||||||
|
|
||||||
// ansi classes
|
// ansi classes
|
||||||
line = line.replace(/\[1;im/g, '<span class="JobResultsStdOut-cappedLine">');
|
/* jshint ignore:start */
|
||||||
line = line.replace(/\[0;30m/g, '<span class="ansi30">');
|
line = line.replace(/(|)\[1;im/g, '<span class="JobResultsStdOut-cappedLine">');
|
||||||
line = line.replace(/\[1;30m/g, '<span class="ansi1 ansi30">');
|
line = line.replace(/(|)\[0;30m/g, '<span class="ansi30">');
|
||||||
line = line.replace(/\[1;31m/g, '<span class="ansi1 ansi31">');
|
line = line.replace(/(|)\[1;30m/g, '<span class="ansi1 ansi30">');
|
||||||
line = line.replace(/\[0;31m/g, '<span class="ansi1 ansi31">');
|
line = line.replace(/(|)\[[0,1];31m/g, '<span class="ansi1 ansi31">');
|
||||||
line = line.replace(/\[1;31m/g, '<span class="ansi1 ansi31">');
|
line = line.replace(/(|)\[0;32m(=|)/g, '<span class="ansi32">');
|
||||||
line = line.replace(/\[0;31m/g, '<span class="ansi1 ansi31">');
|
line = line.replace(/(|)\[0;32m1/g, '<span class="ansi36">');
|
||||||
line = line.replace(/\[0;32m/g, '<span class="ansi32">');
|
line = line.replace(/(|)\[0;33m/g, '<span class="ansi33">');
|
||||||
line = line.replace(/\[0;32m=/g, '<span class="ansi32">');
|
line = line.replace(/(|)\[0;34m/g, '<span class="ansi34">');
|
||||||
line = line.replace(/\[0;32m1/g, '<span class="ansi36">');
|
line = line.replace(/(|)\[[0,1];35m/g, '<span class="ansi35">');
|
||||||
line = line.replace(/\[0;33m/g, '<span class="ansi33">');
|
line = line.replace(/(|)\[0;36m/g, '<span class="ansi36">');
|
||||||
line = line.replace(/\[0;34m/g, '<span class="ansi34">');
|
|
||||||
line = line.replace(/\[0;35m/g, '<span class="ansi35">');
|
|
||||||
line = line.replace(/\[1;35m/g, '<span class="ansi35">');
|
|
||||||
line = line.replace(/\[0;36m/g, '<span class="ansi36">');
|
|
||||||
line = line.replace(/(<host.*?>)\s/g, '$1');
|
line = line.replace(/(<host.*?>)\s/g, '$1');
|
||||||
|
|
||||||
//end span
|
//end span
|
||||||
line = line.replace(/\[0m/g, '</span>');
|
line = line.replace(/(|)\[0m/g, '</span>');
|
||||||
|
/* jshint ignore:end */
|
||||||
} else {
|
} else {
|
||||||
// For the host event modal in the standard out tab,
|
// For the host event modal in the standard out tab,
|
||||||
// the styling isn't necessary
|
// the styling isn't necessary
|
||||||
line = line.replace(/u001b/g, '');
|
line = line.replace(/u001b/g, '');
|
||||||
|
|
||||||
// ansi classes
|
// ansi classes
|
||||||
line = line.replace(/\[0;30m/g, '');
|
/* jshint ignore:start */
|
||||||
line = line.replace(/\[1;30m/g, '');
|
line = line.replace(/(|)\[[0,1];3[0-9]m(1|=|)/g, '');
|
||||||
line = line.replace(/\[1;31m/g, '');
|
|
||||||
line = line.replace(/\[0;31m/g, '');
|
|
||||||
line = line.replace(/\[0;32m/g, '');
|
|
||||||
line = line.replace(/\[0;32m=/g, '');
|
|
||||||
line = line.replace(/\[0;32m1/g, '');
|
|
||||||
line = line.replace(/\[0;33m/g, '');
|
|
||||||
line = line.replace(/\[0;34m/g, '');
|
|
||||||
line = line.replace(/\[0;35m/g, '');
|
|
||||||
line = line.replace(/\[0;36m/g, '');
|
|
||||||
line = line.replace(/(<host.*?>)\s/g, '$1');
|
line = line.replace(/(<host.*?>)\s/g, '$1');
|
||||||
|
|
||||||
//end span
|
//end span
|
||||||
line = line.replace(/\[0m/g, '');
|
line = line.replace(/(|)\[0m/g, '');
|
||||||
|
/* jshint ignore:end */
|
||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ describe('parseStdoutService', () => {
|
|||||||
describe('prettify()', () => {
|
describe('prettify()', () => {
|
||||||
it('returns lines of stdout with styling classes', () => {
|
it('returns lines of stdout with styling classes', () => {
|
||||||
let line = "[0;32mok: [host-00][0m",
|
let line = "[0;32mok: [host-00][0m",
|
||||||
styledLine = '<span class="ansi32">ok: [host-00]</span>';
|
styledLine = '<span class="ansi32">ok: [host-00]</span>';
|
||||||
expect(parseStdoutService.prettify(line)).toBe(styledLine);
|
expect(parseStdoutService.prettify(line)).toBe(styledLine);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can return lines of stdout without styling classes', () => {
|
it('can return lines of stdout without styling classes', () => {
|
||||||
let line = "[0;32mok: [host-00][0m",
|
let line = "[0;32mok: [host-00][0m",
|
||||||
unstyled = "unstyled",
|
unstyled = "unstyled",
|
||||||
unstyledLine = 'ok: [host-00]';
|
unstyledLine = 'ok: [host-00]';
|
||||||
expect(parseStdoutService.prettify(line, unstyled)).toBe(unstyledLine);
|
expect(parseStdoutService.prettify(line, unstyled)).toBe(unstyledLine);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user