From 0a66d1c3fc9a765df043e6fcab8ccc5a20f27c5d Mon Sep 17 00:00:00 2001 From: gconsidine Date: Mon, 4 Dec 2017 15:57:39 -0500 Subject: [PATCH] Add dynamic angular interaction after HTML insertion --- awx/ui/client/features/jobs/_index.less | 35 +++++++++------ .../features/output/index.controller.js | 45 ++++++++++--------- awx/ui/client/features/output/index.js | 2 +- awx/ui/client/features/output/index.view.html | 18 +------- 4 files changed, 48 insertions(+), 52 deletions(-) diff --git a/awx/ui/client/features/jobs/_index.less b/awx/ui/client/features/jobs/_index.less index 5b66ff8366..8c3a7195e1 100644 --- a/awx/ui/client/features/jobs/_index.less +++ b/awx/ui/client/features/jobs/_index.less @@ -20,6 +20,7 @@ font-size: 12px; padding: 0 20px 0 10px; + user-select: none; } &-line { @@ -30,30 +31,24 @@ padding-right: 5px; border-right: 1px solid @at-gray-dark; + user-select: none; } &-event { - padding-left: 2ch; - width: 83ch; + padding: 0 10px; } &-time { - padding-left: 20px; + padding-right: 2ch; font-size: 12px; text-align: right; + user-select: none; + width: 11ch; + border-left: 1px dashed @at-gray-dark; } &-container { - & > table { - table-layout: fixed; - - td { - vertical-align: top; - word-wrap: break-word; - white-space: pre-wrap; - } - } - + max-height: 80vh; font-size: 14px; border: 1px solid @at-gray-dark-2x; background-color: @at-gray-light-3x; @@ -61,5 +56,19 @@ margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; + + & > table { + table-layout: fixed; + + tr:hover > td { + background: white; + } + + td { + vertical-align: top; + word-wrap: break-word; + white-space: pre-wrap; + } + } } } diff --git a/awx/ui/client/features/output/index.controller.js b/awx/ui/client/features/output/index.controller.js index c571062641..d88d1e915f 100644 --- a/awx/ui/client/features/output/index.controller.js +++ b/awx/ui/client/features/output/index.controller.js @@ -2,6 +2,10 @@ import Ansi from 'ansi-to-html'; import hasAnsi from 'has-ansi'; let ansi; +let $timeout; +let $sce; +let $compile; +let $scope; const EVENT_START_TASK = 'playbook_on_task_start'; const EVENT_START_PLAY = 'playbook_on_play_start'; @@ -18,22 +22,30 @@ const TIME_EVENTS = [ EVENT_STATS_PLAY ]; -function JobsIndexController (job, $sce) { +function JobsIndexController (job, _$sce_, _$timeout_, _$scope_, _$compile_) { + ansi = new Ansi(); + $timeout = _$timeout_; + $sce = _$sce_; + $compile = _$compile_; + $scope = _$scope_; + const vm = this || {}; const events = job.get('related.job_events.results'); + const html = $sce.trustAsHtml(parseEvents(events)); - ansi = new Ansi(); - - const html = parseEvents(events); - - vm.html = $sce.trustAsHtml(html); vm.toggle = toggle; + + $timeout(() => { + const table = $('#result-table'); + + table.html($sce.getTrustedHtml(html)); + $compile(table.contents())($scope); + }); } function parseEvents (events) { events.sort(orderByLineNumber); - console.log(events); return events.reduce((html, event) => `${html}${parseLine(event)}`, ''); } @@ -90,12 +102,12 @@ function createRow (ln, content, time, group) { let expand = ''; if (group.parent) { - expand = ''; + expand = ''; } return ` - ${expand} + ${expand} ${ln} ${content} ${time} @@ -108,6 +120,7 @@ function getGroup (event, i) { if (EVENT_GROUPS.includes(event.event) && i === 1) { group.parent = true; group.classList = `parent parent-${event.event_level}`; + group.id = i; } else { group.classList = ''; } @@ -130,17 +143,7 @@ function getTime (event, i) { function toggle (id) { console.log(id); } -/* - * - *function getTruncatedEvent () { - * - *} - * - *function addDynamic (start) { - * document.getElementsByClassName('parent') - *} - * - */ -JobsIndexController.$inject = ['job', '$sce']; + +JobsIndexController.$inject = ['job', '$sce', '$timeout', '$scope', '$compile']; module.exports = JobsIndexController; diff --git a/awx/ui/client/features/output/index.js b/awx/ui/client/features/output/index.js index abe9a5edec..aa98a2359a 100644 --- a/awx/ui/client/features/output/index.js +++ b/awx/ui/client/features/output/index.js @@ -30,7 +30,7 @@ function JobsRun ($stateExtender, strings) { return new Jobs('get', id) .then(job => job.extend('job_events', { params: { - page_size: 200, + page_size: 10000, order_by: 'start_line' } })); diff --git a/awx/ui/client/features/output/index.view.html b/awx/ui/client/features/output/index.view.html index 5a585c7321..34fd7dc368 100644 --- a/awx/ui/client/features/output/index.view.html +++ b/awx/ui/client/features/output/index.view.html @@ -12,23 +12,7 @@
-

-                
-                    
-                        
-                        
-                        
-                    
-                
-                
-                
-                    
-                        
-                        
-                        
-                        
-                    
-                
 
  Back to Top
+