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 2/3] ui: logpanel: catch up to very fast task logs with api calls
Date: Tue, 23 Nov 2021 08:49:34 +0100	[thread overview]
Message-ID: <20211123074935.736530-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211123074935.736530-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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





  parent reply	other threads:[~2021-11-23  7:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23  7:49 [pve-devel] [PATCH widget-toolkit 0/3] improve logpanel behaviour for fast tasks Dominik Csapak
2021-11-23  7:49 ` [pve-devel] [PATCH widget-toolkit 1/3] ui: logpanel: fix glitching on fast task logs Dominik Csapak
2021-11-23  7:49 ` Dominik Csapak [this message]
2021-11-23  7:49 ` [pve-devel] [PATCH widget-toolkit 3/3] ui: logpanel: work around browser 'setTimeout' quirks Dominik Csapak

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=20211123074935.736530-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