From 374f781d0d988f3041ae00cf578b3df0bd705f79 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Tue, 26 Jun 2018 10:15:25 -0400 Subject: [PATCH] make nav controls move up or down by viewable content height --- .../features/output/index.controller.js | 33 ++++++++++++++----- awx/ui/client/features/output/index.view.html | 7 ++-- .../client/features/output/scroll.service.js | 24 ++++++++------ 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/awx/ui/client/features/output/index.controller.js b/awx/ui/client/features/output/index.controller.js index ae249b1210..d8a7088d58 100644 --- a/awx/ui/client/features/output/index.controller.js +++ b/awx/ui/client/features/output/index.controller.js @@ -21,6 +21,7 @@ const listeners = []; const rx = []; let following = false; +let attach = true; function bufferInit () { rx.length = 0; @@ -65,6 +66,10 @@ function onFrames (events) { return $q.resolve(); } + if (!attach) { + return $q.resolve(); + } + follow(); } @@ -117,23 +122,39 @@ function last () { stream.setMissingCounterThreshold(slide.getTailCounter() + 1); scroll.setScrollPosition(scroll.getScrollHeight()); + attach = true; scroll.resume(); return $q.resolve(); }); } +function down () { + scroll.moveDown(); +} + +function up () { + if (following) { + unfollow(); + } else { + scroll.moveUp(); + } +} + function follow () { scroll.pause(); - // scroll.hide(); + scroll.hide(); following = true; + vm.isFollowing = following; } function unfollow () { + attach = false; following = false; + vm.isFollowing = following; - // scroll.unhide(); + scroll.unhide(); scroll.resume(); } @@ -288,13 +309,9 @@ function OutputIndexController ( vm.togglePanelExpand = togglePanelExpand; // Stdout Navigation - vm.menu = { - end: last, - home: first, - up: previous, - down: next, - }; + vm.menu = { last, first, down, up }; vm.isMenuExpanded = true; + vm.isFollowing = following; vm.toggleMenuExpand = toggleMenuExpand; vm.toggleLineExpand = toggleLineExpand; vm.showHostDetails = showHostDetails; diff --git a/awx/ui/client/features/output/index.view.html b/awx/ui/client/features/output/index.view.html index f81a715a42..d56730b14b 100644 --- a/awx/ui/client/features/output/index.view.html +++ b/awx/ui/client/features/output/index.view.html @@ -22,18 +22,19 @@ ng-class="{ 'fa-minus': vm.isMenuExpanded, 'fa-plus': !vm.isMenuExpanded }"> -
+
-
+
- +
diff --git a/awx/ui/client/features/output/scroll.service.js b/awx/ui/client/features/output/scroll.service.js index 6ebafe09e4..1cd5887f25 100644 --- a/awx/ui/client/features/output/scroll.service.js +++ b/awx/ui/client/features/output/scroll.service.js @@ -86,22 +86,20 @@ function JobScrollService ($q, $timeout) { return false; }; - this.pageUp = () => { - if (this.isPaused()) { - return; - } - + /** + * Move scroll position up by one page of visible content. + */ + this.moveUp = () => { const top = this.getScrollPosition(); const height = this.getViewableHeight(); this.setScrollPosition(top - height); }; - this.pageDown = () => { - if (this.isPaused()) { - return; - } - + /** + * Move scroll position down by one page of visible content. + */ + this.moveDown = () => { const top = this.getScrollPosition(); const height = this.getViewableHeight(); @@ -110,6 +108,12 @@ function JobScrollService ($q, $timeout) { this.getScrollHeight = () => this.el[0].scrollHeight; this.getViewableHeight = () => this.el[0].offsetHeight; + + /** + * Get the vertical scroll position. + * + * @returns {Number} - The number of pixels that are hidden from view above the scrollable area. + */ this.getScrollPosition = () => this.el[0].scrollTop; this.setScrollPosition = position => {