From 946f3b5c9217bc709322f3a2eb6a53ffad0ad2ef Mon Sep 17 00:00:00 2001 From: gconsidine Date: Wed, 8 Nov 2017 16:08:37 -0500 Subject: [PATCH] Add ansi parsing libs --- awx/ui/client/features/_index.less | 1 + awx/ui/client/features/jobs/_index.less | 12 ++++++ .../features/output/index.controller.js | 39 ++++++++++++++++++- awx/ui/client/features/output/index.js | 10 ++--- awx/ui/client/features/output/index.view.html | 7 +++- 5 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 awx/ui/client/features/jobs/_index.less diff --git a/awx/ui/client/features/_index.less b/awx/ui/client/features/_index.less index e2339dc9e4..4a69120ed9 100644 --- a/awx/ui/client/features/_index.less +++ b/awx/ui/client/features/_index.less @@ -1,2 +1,3 @@ @import 'credentials/_index'; +@import 'jobs/_index'; @import 'users/tokens/_index'; diff --git a/awx/ui/client/features/jobs/_index.less b/awx/ui/client/features/jobs/_index.less new file mode 100644 index 0000000000..9144f3c93c --- /dev/null +++ b/awx/ui/client/features/jobs/_index.less @@ -0,0 +1,12 @@ +.at-Stdout { + tr { + & > td:first-child { + padding-right: 5px; + border-right: 1px solid gray; + } + + & > td:last-child { + padding-left: 5px; + } + } +} diff --git a/awx/ui/client/features/output/index.controller.js b/awx/ui/client/features/output/index.controller.js index 358750aefb..71c4bcf408 100644 --- a/awx/ui/client/features/output/index.controller.js +++ b/awx/ui/client/features/output/index.controller.js @@ -1,5 +1,40 @@ -function JobsIndexController (resolved) { - console.log('test', resolved); +import Ansi from 'ansi-to-html'; +import hasAnsi from 'has-ansi'; + +function JobsIndexController (job, $sce) { + const vm = this || {}; + const results = job.get('related.job_events.results'); + const ansi = new Ansi({}); + + /* + * const colors = []; + * + * for (let i = 0; i < 255; i++) { + * colors.push('#ababab'); + * } + * + */ + + let html = ''; + results.forEach((line, i) => { + if (!line.stdout) { + return; + } + + let output; + + if (hasAnsi(line.stdout)) { + output = ansi.toHtml(line.stdout); + } else { + output = line.stdout; // .replace(/(\n|\r)/g, ''); + } + + html += `${i}${output}`; + }); + + vm.html = $sce.trustAsHtml(html); } +JobsIndexController.$inject = ['job', '$sce']; + module.exports = JobsIndexController; diff --git a/awx/ui/client/features/output/index.js b/awx/ui/client/features/output/index.js index f7f0e9c768..c5899b7964 100644 --- a/awx/ui/client/features/output/index.js +++ b/awx/ui/client/features/output/index.js @@ -24,13 +24,9 @@ function JobsRun ($stateExtender, strings) { } }, resolve: { - resolved: ['JobsModel', Jobs => { - const jobs = new Jobs(); - - return { - models: { jobs } - }; - }] + job: ['JobsModel', Jobs => new Jobs('get', 1002) + .then(job => job.extend('job_events')) + ] } }); } diff --git a/awx/ui/client/features/output/index.view.html b/awx/ui/client/features/output/index.view.html index de0177058e..92d2594851 100644 --- a/awx/ui/client/features/output/index.view.html +++ b/awx/ui/client/features/output/index.view.html @@ -6,7 +6,12 @@
-

right

+
+                
+                  
+                  
+                
+