From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 1CFA38142D
 for <pve-devel@lists.proxmox.com>; Tue, 23 Nov 2021 13:02:31 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 1AE12AF78
 for <pve-devel@lists.proxmox.com>; Tue, 23 Nov 2021 13:02:31 +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 37586AF6D
 for <pve-devel@lists.proxmox.com>; 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 1025A45C6A
 for <pve-devel@lists.proxmox.com>; Tue, 23 Nov 2021 13:02:30 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Tue, 23 Nov 2021 13:02:28 +0100
Message-Id: <20211123120229.3606307-2-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
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [data.total]
Subject: [pve-devel] [PATCH widget-toolkit v2 1/2] ui: logpanel: fix
 glitching fast task logs
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 23 Nov 2021 12:02:31 -0000

if the total we got was bigger than the last line number, we appended
empty lines at the end of the panel, to which we scrolled

the only time we need to do that is when we do not follow the task log
'live' but when we are elsewhere (to keep the scroll position/size)

so give the lines directly to 'updateView' and let it decide
if we append the empty lines at the end

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/panel/LogView.js | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/panel/LogView.js b/src/panel/LogView.js
index 1772737..51335fa 100644
--- a/src/panel/LogView.js
+++ b/src/panel/LogView.js
@@ -45,27 +45,33 @@ Ext.define('Proxmox.panel.LogView', {
 	    return maxPos - pos;
 	},
 
-	updateView: function(text, first, total) {
+	updateView: function(lines, first, total) {
 	    let me = this;
 	    let view = me.getView();
 	    let viewModel = me.getViewModel();
 	    let content = me.lookup('content');
 	    let data = viewModel.get('data');
 
-	    if (first === data.first && total === data.total && text.length === data.textlen) {
+	    if (first === data.first && total === data.total && lines.length === data.lines) {
 		return; // same content, skip setting and scrolling
 	    }
 	    viewModel.set('data', {
 		first: first,
 		total: total,
-		textlen: text.length,
+		lines: lines.length,
 	    });
 
 	    let scrollPos = me.scrollPosBottom();
+	    let scrollToBottom = view.scrollToEnd && scrollPos <= 5;
 
-	    content.update(text);
+	    if (!scrollToBottom) {
+		// so that we have the 'correct' height for the text
+		lines.length = total;
+	    }
+
+	    content.update(lines.join('<br>'));
 
-	    if (view.scrollToEnd && scrollPos <= 5) {
+	    if (scrollToBottom) {
 		// we use setTimeout to work around scroll handling on touchscreens
 		setTimeout(function() { view.scrollTo(0, Infinity); }, 10);
 	    }
@@ -97,8 +103,7 @@ Ext.define('Proxmox.panel.LogView', {
 			lines[line.n - 1] = Ext.htmlEncode(line.t);
 		    });
 
-		    lines.length = total;
-		    me.updateView(lines.join('<br>'), first - 1, total);
+		    me.updateView(lines, first - 1, total);
 		    me.running = false;
 		    if (me.requested) {
 			me.requested = false;
-- 
2.30.2