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 E67CD81333 for ; Tue, 23 Nov 2021 08:49:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E454626DB8 for ; Tue, 23 Nov 2021 08:49:42 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3B3C226D8C for ; Tue, 23 Nov 2021 08:49:41 +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 E010443E55 for ; Tue, 23 Nov 2021 08:49:35 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 23 Nov 2021 08:49:34 +0100 Message-Id: <20211123074935.736530-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211123074935.736530-1-d.csapak@proxmox.com> References: <20211123074935.736530-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.205 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 2/3] 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 07:49:42 -0000 if we have a task log that produces more lines than we ask for (start+limit), set the start to the (current) total-limit. otherwise, keep the logic to set the start so that our current line is about in the middle of the requested data (to have a buffer in both directions) Signed-off-by: Dominik Csapak --- src/panel/LogView.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/panel/LogView.js b/src/panel/LogView.js index bbf38ee..4a273a1 100644 --- a/src/panel/LogView.js +++ b/src/panel/LogView.js @@ -132,14 +132,20 @@ Ext.define('Proxmox.panel.LogView', { let line = view.getScrollY()/lineHeight; let start = viewModel.get('params.start'); let limit = viewModel.get('params.limit'); + let total = viewModel.get('data.total'); let viewLines = view.getHeight()/lineHeight; let viewStart = Math.max(parseInt(line - 1 - view.viewBuffer, 10), 0); 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)); + if (view.scrollToEnd && total) { + viewModel.set('params.start', + Math.max(parseInt(total - limit, 10), 0)); + } else { + viewModel.set('params.start', + Math.max(parseInt(line - (limit / 2) + 10, 10), 0)); + } view.loadTask.delay(200); } }, -- 2.30.2