public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit v2 2/2] ui: logpanel: catch up to very fast task logs with api calls
Date: Tue, 23 Nov 2021 13:02:29 +0100	[thread overview]
Message-ID: <20211123120229.3606307-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211123120229.3606307-1-d.csapak@proxmox.com>

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@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





  parent reply	other threads:[~2021-11-23 12:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 12:02 [pve-devel] [PATCH widget-toolkit v2 0/2] improve logpanel behaviour for fast tasks Dominik Csapak
2021-11-23 12:02 ` [pve-devel] [PATCH widget-toolkit v2 1/2] ui: logpanel: fix glitching fast task logs Dominik Csapak
2021-11-23 12:02 ` Dominik Csapak [this message]
2021-11-24 10:43 ` [pve-devel] applied-series: [PATCH widget-toolkit v2 0/2] improve logpanel behaviour for fast tasks Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211123120229.3606307-3-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal