From 04dbc2fcc41a36b3c7d59f9864420c0c8ca5b49b Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 23 Aug 2018 13:55:47 -0400 Subject: [PATCH] add basic click handler for fetching and showing missing events --- .../features/output/index.controller.js | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/awx/ui/client/features/output/index.controller.js b/awx/ui/client/features/output/index.controller.js index f314a28afc..abb08b907e 100644 --- a/awx/ui/client/features/output/index.controller.js +++ b/awx/ui/client/features/output/index.controller.js @@ -555,7 +555,41 @@ function showHostDetails (id, uuid) { } function showMissingEvents (uuid) { - console.log(`expandMissingEvents: ${uuid}`); + const { counters } = render.records[uuid]; + + const min = Math.min(...counters); + const max = Math.min(Math.max(...counters), min + OUTPUT_PAGE_SIZE); + + const selector = `#${uuid}`; + const clicked = $(selector); + + return resource.events.getRange([min, max]) + .then(results => { + let lines = 0; + let untrusted = ''; + + for (let i = 0; i <= results.length - 1; i++) { + const { html, count } = render.transformEvent(results[i]); + + lines += count; + untrusted += html; + render.records[uuid].counters.shift(); + } + + const trusted = render.trustHtml(untrusted); + const elements = angular.element(trusted); + + return render + .requestAnimationFrame(() => { + elements.insertBefore(clicked); + + if (render.records[uuid].counters.length === 0) { + clicked.remove(); + } + }) + .then(() => render.compile(elements)) + .then(() => lines); + }); } //