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

Dominik Csapak d.csapak at proxmox.com
Tue Nov 23 08:49:34 CET 2021


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






More information about the pve-devel mailing list