public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] ui: tape/DriveStatus: fix updating pointer+click handler on info widget
Date: Wed, 17 Mar 2021 11:47:32 +0100	[thread overview]
Message-ID: <20210317104732.29276-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210317104732.29276-1-d.csapak@proxmox.com>

we can only do this after it is rendered, the element does not exist
before

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/DriveStatus.js | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index b529a9af..38cddaaf 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -469,17 +469,38 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 
 	let vm = me.getViewModel();
 	vm.set('drive', record.data);
+	vm.notify();
+	me.updatePointer();
+    },
+
+    updatePointer: function() {
+	let me = this;
 	let stateWidget = me.down('pmxInfoWidget[reference=statewidget]');
 	let stateEl = stateWidget.getEl();
-	stateEl.removeListener('click', me.clickState);
-	if (record.data.state) {
-	    stateEl.on('click', me.clickState, me);
+	if (!stateEl) {
+	    setTimeout(function() {
+		me.updatePointer();
+	    }, 100);
+	    return;
+	}
+
+	let vm = me.getViewModel();
+	let drive = vm.get('drive');
+
+	if (drive.state) {
 	    stateEl.addCls('info-pointer');
 	} else {
 	    stateEl.removeCls('info-pointer');
 	}
+    },
 
-	vm.notify();
+    listeners: {
+	afterrender: function() {
+	    let me = this;
+	    let stateWidget = me.down('pmxInfoWidget[reference=statewidget]');
+	    let stateEl = stateWidget.getEl();
+	    stateEl.on('click', me.clickState, me);
+	},
     },
 
     initComponent: function() {
@@ -488,12 +509,12 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 	    throw "no drive given";
 	}
 
+	me.callParent();
+
 	let tapeStore = Ext.ComponentQuery.query('navigationtree')[0].tapestore;
 	me.mon(tapeStore, 'load', me.updateData, me);
 	if (tapeStore.isLoaded()) {
 	    me.updateData(tapeStore);
 	}
-
-	me.callParent();
     },
 });
-- 
2.20.1





  reply	other threads:[~2021-03-17 10:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 10:47 [pbs-devel] [PATCH proxmox-backup 1/2] ui: tape/DriveStatus: add erase button Dominik Csapak
2021-03-17 10:47 ` Dominik Csapak [this message]
2021-03-17 12:38 ` [pbs-devel] applied: " Dietmar Maurer

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=20210317104732.29276-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-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