[pve-devel] [PATCH widget-toolkit v2 2/2] ui: logpanel: catch up to very fast task logs with api calls

Dominik Csapak d.csapak at proxmox.com
Tue Nov 23 13:02:29 CET 2021


by updating the start to 'total-limit' if we follow the task log live.
to do that, we decouple the 'scroll' event from updating the 'start'
parameter and call that directly after we scrolled down.

to not trigger the scroll event multiple times, suspend the scroll event
while doing that.

while we're touching those lines, remove the 'setTimeout' workaround
for touchscreens, since it seems to work fine since extjs 7.0

this also fixes the issue that the scroll event is not called sometimes

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/panel/LogView.js | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/panel/LogView.js b/src/panel/LogView.js
index 51335fa..0ce48f5 100644
--- a/src/panel/LogView.js
+++ b/src/panel/LogView.js
@@ -72,8 +72,11 @@ Ext.define('Proxmox.panel.LogView', {
 	    content.update(lines.join('<br>'));
 
 	    if (scrollToBottom) {
-		// we use setTimeout to work around scroll handling on touchscreens
-		setTimeout(function() { view.scrollTo(0, Infinity); }, 10);
+		let scroller = view.getScrollable();
+		scroller.suspendEvent('scroll');
+		view.scrollTo(0, Infinity);
+		me.updateStart(true);
+		scroller.resumeEvent('scroll');
 	    }
 	},
 
@@ -126,6 +129,25 @@ Ext.define('Proxmox.panel.LogView', {
 	    });
 	},
 
+	updateStart: function(scrolledToBottom, targetLine) {
+	    let me = this;
+	    let view = me.getView();
+	    let viewModel = me.getViewModel();
+
+	    let limit = viewModel.get('params.limit');
+
+	    if (scrolledToBottom) {
+		let total = viewModel.get('data.total');
+		viewModel.set('params.start',
+		    Math.max(parseInt(total - limit, 10), 0));
+	    } else {
+		viewModel.set('params.start',
+		    Math.max(parseInt(targetLine - (limit / 2) + 10, 10), 0));
+	    }
+
+	    view.loadTask.delay(200);
+	},
+
 	onScroll: function(x, y) {
 	    let me = this;
 	    let view = me.getView();
@@ -141,9 +163,7 @@ Ext.define('Proxmox.panel.LogView', {
 	    let viewEnd = parseInt(line + viewLines + 1 + view.viewBuffer, 10);
 
 	    if (viewStart < start || viewEnd > start+limit) {
-		viewModel.set('params.start',
-		    Math.max(parseInt(line - (limit / 2) + 10, 10), 0));
-		view.loadTask.delay(200);
+		me.updateStart(false, line);
 	    }
 	},
 
-- 
2.30.2






More information about the pve-devel mailing list