diff --git a/awx/ui/client/features/output/index.controller.js b/awx/ui/client/features/output/index.controller.js index 64d53b4faa..4af5247e5b 100644 --- a/awx/ui/client/features/output/index.controller.js +++ b/awx/ui/client/features/output/index.controller.js @@ -67,14 +67,6 @@ function onFrames (events) { const capacity = slide.getCapacity(); - if (capacity >= events.length) { - return slide.pushFront(events); - } - - delete render.record; - - render.record = {}; - return slide.popBack(events.length - capacity) .then(() => slide.pushFront(events)) .then(() => { @@ -131,10 +123,6 @@ function last () { }); } -function compile (html) { - return $compile(html)($scope); -} - function follow () { scroll.pause(); // scroll.hide(); @@ -149,6 +137,69 @@ function unfollow () { scroll.resume(); } +function togglePanelExpand () { + vm.isPanelExpanded = !vm.isPanelExpanded; +} + +function toggleMenuExpand () { + if (scroll.isPaused()) return; + + const recordList = Object.keys(render.record).map(key => render.record[key]); + const minLevel = Math.min(...recordList.map(({ level }) => level)); + + const toggled = recordList + .filter(({ level }) => level === minLevel) + .map(({ uuid }) => getToggleElements(uuid)) + .filter(({ icon }) => icon.length > 0) + .map(({ icon, lines }) => setExpanded(icon, lines, !vm.isMenuExpanded)); + + if (toggled.length > 0) { + vm.isMenuExpanded = !vm.isMenuExpanded; + } +} + +function toggleLineExpand (uuid) { + if (scroll.isPaused()) return; + + const { icon, lines } = getToggleElements(uuid); + const isExpanded = icon.hasClass('fa-angle-down'); + + setExpanded(icon, lines, !isExpanded); + + vm.isMenuExpanded = !isExpanded; +} + +function getToggleElements (uuid) { + const record = render.record[uuid]; + const lines = $(`.child-of-${uuid}`); + + const iconSelector = '.at-Stdout-toggle > i'; + const additionalSelector = `#${(record.children || []).join(', #')}`; + + let icon = $(`#${uuid} ${iconSelector}`); + if (additionalSelector) { + icon = icon.add($(additionalSelector).find(iconSelector)); + } + + return { icon, lines }; +} + +function setExpanded (icon, lines, expanded) { + if (expanded) { + icon.removeClass('fa-angle-right'); + icon.addClass('fa-angle-down'); + lines.removeClass('hidden'); + } else { + icon.removeClass('fa-angle-down'); + icon.addClass('fa-angle-right'); + lines.addClass('hidden'); + } +} + +function compile (html) { + return $compile(html)($scope); +} + function showHostDetails (id, uuid) { $state.go('output.host-event.json', { eventId: id, taskUuid: uuid }); } @@ -203,13 +254,11 @@ function OutputIndexController ( vm = this || {}; // Panel + vm.title = $filter('sanitize')(resource.model.get('name')); vm.strings = strings; vm.resource = resource; - vm.title = $filter('sanitize')(resource.model.get('name')); - - vm.expanded = false; - vm.showHostDetails = showHostDetails; - vm.toggleExpanded = () => { vm.expanded = !vm.expanded; }; + vm.isPanelExpanded = false; + vm.togglePanelExpand = togglePanelExpand; // Stdout Navigation vm.menu = { @@ -218,6 +267,11 @@ function OutputIndexController ( up: previous, down: next, }; + vm.isMenuExpanded = true; + vm.toggleMenuExpand = toggleMenuExpand; + vm.toggleLineExpand = toggleLineExpand; + vm.showHostDetails = showHostDetails; + vm.toggleLineEnabled = resource.model.get('type') === 'job'; render.requestAnimationFrame(() => { bufferInit(); @@ -225,7 +279,7 @@ function OutputIndexController ( status.init(resource); slide.init(render, resource.events); - render.init({ compile }); + render.init({ compile, toggles: vm.toggleLineEnabled }); scroll.init({ previous, next }); stream.init({ diff --git a/awx/ui/client/features/output/index.view.html b/awx/ui/client/features/output/index.view.html index 441879b21f..fa973ec40d 100644 --- a/awx/ui/client/features/output/index.view.html +++ b/awx/ui/client/features/output/index.view.html @@ -1,25 +1,25 @@