From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 00AB78143F for ; Tue, 23 Nov 2021 13:03:01 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EAC2CAF77 for ; Tue, 23 Nov 2021 13:02:30 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 26160AF62 for ; Tue, 23 Nov 2021 13:02:30 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F131643A0C for ; Tue, 23 Nov 2021 13:02:29 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 23 Nov 2021 13:02:29 +0100 Message-Id: <20211123120229.3606307-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211123120229.3606307-1-d.csapak@proxmox.com> References: <20211123120229.3606307-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.204 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH widget-toolkit v2 2/2] ui: logpanel: catch up to very fast task logs with api calls X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2021 12:03:01 -0000 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 --- 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('
')); 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