From e1b7e7f6ce8194ccd7f7064d27d3738c190d8e1a Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 9 Aug 2018 22:36:51 -0400 Subject: [PATCH 1/2] add event replay mode --- awx/ui/client/features/output/_index.less | 10 +++++++ .../features/output/index.controller.js | 30 ++++++++++++++++--- awx/ui/client/features/output/index.js | 4 +-- awx/ui/client/features/output/index.view.html | 3 ++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/awx/ui/client/features/output/_index.less b/awx/ui/client/features/output/_index.less index bd2c18c14d..2fb6239c7e 100644 --- a/awx/ui/client/features/output/_index.less +++ b/awx/ui/client/features/output/_index.less @@ -38,6 +38,16 @@ } } + &-menuIcon--md { + font-size: 14px; + padding: 10px; + cursor: pointer; + + &:hover { + color: @at-blue; + } + } + &-menuIcon--lg { font-size: 22px; line-height: 12px; diff --git a/awx/ui/client/features/output/index.controller.js b/awx/ui/client/features/output/index.controller.js index 88d86ca91b..b0dae231ec 100644 --- a/awx/ui/client/features/output/index.controller.js +++ b/awx/ui/client/features/output/index.controller.js @@ -412,6 +412,22 @@ function reloadState (params) { return $state.transitionTo($state.current, params, { inherit: false, location: 'replace' }); } +function clear () { + stopListening(); + render.clear(); + + followOnce = true; + lockFollow = false; + lockFrames = false; + + bufferInit(); + status.init(resource); + slide.init(render, resource.events, scroll); + status.subscribe(data => { vm.status = data.status; }); + + startListening(); +} + function OutputIndexController ( _$compile_, _$q_, @@ -428,7 +444,8 @@ function OutputIndexController ( strings, $stateParams, ) { - const { isPanelExpanded } = $stateParams; + const { isPanelExpanded, _debug } = $stateParams; + const isProcessingFinished = !_debug && _resource_.model.get('event_processing_finished'); $compile = _$compile_; $q = _$q_; @@ -440,7 +457,7 @@ function OutputIndexController ( render = _render_; status = _status_; stream = _stream_; - slide = resource.model.get('event_processing_finished') ? _page_ : _slide_; + slide = isProcessingFinished ? _page_ : _slide_; vm = this || {}; @@ -454,7 +471,7 @@ function OutputIndexController ( vm.togglePanelExpand = togglePanelExpand; // Stdout Navigation - vm.menu = { last: menuLast, first, down, up }; + vm.menu = { last: menuLast, first, down, up, clear }; vm.isMenuExpanded = true; vm.isFollowing = false; vm.toggleMenuExpand = toggleMenuExpand; @@ -462,6 +479,7 @@ function OutputIndexController ( vm.showHostDetails = showHostDetails; vm.toggleLineEnabled = resource.model.get('type') === 'job'; vm.followTooltip = vm.strings.get('tooltips.MENU_LAST'); + vm.debug = _debug; render.requestAnimationFrame(() => { bufferInit(); @@ -497,7 +515,7 @@ function OutputIndexController ( } }); - if (resource.model.get('event_processing_finished')) { + if (isProcessingFinished) { followOnce = false; lockFollow = true; lockFrames = true; @@ -511,6 +529,10 @@ function OutputIndexController ( startListening(); } + if (_debug) { + return render.clear(); + } + return last(); }); } diff --git a/awx/ui/client/features/output/index.js b/awx/ui/client/features/output/index.js index ce016c1f19..0109877d9b 100644 --- a/awx/ui/client/features/output/index.js +++ b/awx/ui/client/features/output/index.js @@ -82,7 +82,7 @@ function resolveResource ( order_by: OUTPUT_ORDER_BY, }; - if (job_event_search) { // eslint-disable-line camelcase + if (job_event_search) { const query = qs.encodeQuerysetObject(qs.decodeArr(job_event_search)); Object.assign(params, query); } @@ -173,7 +173,7 @@ function JobsRun ($stateRegistry, $filter, strings) { const sanitize = $filter('sanitize'); const state = { - url: '/:type/:id?job_event_search', + url: '/:type/:id?job_event_search?_debug', name: 'output', parent, ncyBreadcrumb, diff --git a/awx/ui/client/features/output/index.view.html b/awx/ui/client/features/output/index.view.html index 08df5f714a..a7f4dafe66 100644 --- a/awx/ui/client/features/output/index.view.html +++ b/awx/ui/client/features/output/index.view.html @@ -46,6 +46,9 @@ +
+ +
From 0c3d6e7c3301bad875981a1e2eed2c1ae2e75d16 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 9 Aug 2018 23:38:03 -0400 Subject: [PATCH 2/2] add testing section for job events --- docs/job_events.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/job_events.md b/docs/job_events.md index 60f5ad7afd..2f4c35ae72 100644 --- a/docs/job_events.md +++ b/docs/job_events.md @@ -95,6 +95,9 @@ playbook_on_play_start-install runner_on_ok_hostA (install_tower) ``` +## Testing +A management command for event replay exists for replaying jobs at varying speeds and other parameters. Run `awx-manage replay_job_events --help` for additional usage information. To prepare the UI for event replay, load the page for a finished job and then append `_debug` as a parameter to the url. + ## Code References * More comprehensive list of Job Events and the hierarchy they form https://github.com/ansible/awx/blob/devel/awx/main/models/jobs.py#L870 * Exhaustive list of Job Events in Tower https://github.com/ansible/awx/blob/devel/awx/main/models/jobs.py#L900