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 D7C357676B
 for <pbs-devel@lists.proxmox.com>; Fri, 23 Apr 2021 12:52:46 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id CBD6F2827A
 for <pbs-devel@lists.proxmox.com>; Fri, 23 Apr 2021 12:52:46 +0200 (CEST)
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 42C0A28272
 for <pbs-devel@lists.proxmox.com>; Fri, 23 Apr 2021 12:52:46 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0FD73434CA
 for <pbs-devel@lists.proxmox.com>; Fri, 23 Apr 2021 12:52:46 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Fri, 23 Apr 2021 12:52:45 +0200
Message-Id: <20210423105245.23151-1-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.000 Adjusted score from AWL reputation of From: address
 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: [pbs-devel] [PATCH proxmox-backup] ui: tape: reload drive status on
 user actions
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 23 Apr 2021 10:52:46 -0000

when the user start an action where we know that it locks the drive,
reload the tape store, so that the state is refreshed

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

diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index acc77680..2c55fc97 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -33,6 +33,10 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
     controller: {
 	xclass: 'Ext.app.ViewController',
 
+	reloadTapeStore: function() {
+	    Ext.ComponentQuery.query('navigationtree')[0].reloadTapeStore();
+	},
+
 	reload: function() {
 	    let me = this;
 	    me.lookup('statusgrid').rstore.load();
@@ -46,6 +50,7 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	    vm.set('online', online);
 	    let title = online ? gettext('Status') : gettext('Status (No Tape loaded)');
 	    statusgrid.setTitle(title);
+	    Ext.ComponentQuery.query('navigationtree')[0].reloadTapeStore();
 	},
 
 	onStateLoad: function(store) {
@@ -79,6 +84,11 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	    let me = this;
 	    Ext.create('PBS.TapeManagement.LabelMediaWindow', {
 		driveid: me.getView().drive,
+		apiCallDone: function(success) {
+		    if (success) {
+			me.reloadTapeStore();
+		    }
+		},
 	    }).show();
 	},
 
@@ -90,6 +100,7 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 		waitMsgTarget: view,
 		method: 'POST',
 		success: function(response) {
+		    me.reloadTapeStore();
 		    Ext.create('Proxmox.window.TaskProgress', {
 			upid: response.result.data,
 			taskDone: function() {
@@ -108,6 +119,7 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 		waitMsgTarget: view,
 		method: 'POST',
 		success: function(response) {
+		    me.reloadTapeStore();
 		    Ext.create('Proxmox.window.TaskProgress', {
 			upid: response.result.data,
 			taskDone: function() {
@@ -126,6 +138,7 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 		waitMsgTarget: view,
 		method: 'POST',
 		success: function(response) {
+		    me.reloadTapeStore();
 		    Ext.create('Proxmox.window.TaskViewer', {
 			upid: response.result.data,
 			taskDone: function() {
@@ -143,7 +156,10 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 
 	    PBS.Utils.driveCommand(drive, 'read-label', {
 		waitMsgTarget: view,
-		success: PBS.Utils.showMediaLabelWindow,
+		success: function(response) {
+		    me.reloadTapeStore();
+		    PBS.Utils.showMediaLabelWindow(response);
+		},
 	    });
 	},
 
@@ -153,7 +169,10 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	    let drive = view.drive;
 	    PBS.Utils.driveCommand(drive, 'volume-statistics', {
 		waitMsgTarget: view,
-		success: PBS.Utils.showVolumeStatisticsWindow,
+		success: function(response) {
+		    me.reloadTapeStore();
+		    PBS.Utils.showVolumeStatisticsWindow(response);
+		},
 	    });
 	},
 
@@ -163,7 +182,10 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	    let drive = view.drive;
 	    PBS.Utils.driveCommand(drive, 'cartridge-memory', {
 		waitMsgTarget: me.getView(),
-		success: PBS.Utils.showCartridgeMemoryWindow,
+		success: function(response) {
+		    me.reloadTapeStore();
+		    PBS.Utils.showCartridgeMemoryWindow(response);
+		},
 	    });
 	},
 
-- 
2.20.1