[pbs-devel] [PATCH proxmox-backup 2/2] ui: refactor reloadTapeStore

Dominik Csapak d.csapak at proxmox.com
Fri Mar 12 13:29:13 CET 2021


by making use of the Ext.StoreManager and moving the code to PBS.Utils.
This is ok since the store exists for the whole time of the UI (if it does at
all).

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/NavigationTree.js     | 10 +---------
 www/Utils.js              |  4 ++++
 www/tape/ChangerConfig.js |  7 +------
 www/tape/DriveConfig.js   |  7 +------
 4 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/www/NavigationTree.js b/www/NavigationTree.js
index c609d9a4..35edacc5 100644
--- a/www/NavigationTree.js
+++ b/www/NavigationTree.js
@@ -121,6 +121,7 @@ Ext.define('PBS.view.main.NavigationTree', {
 		if (view.tapestore === undefined) {
 		    view.tapestore = Ext.create('Proxmox.data.UpdateStore', {
 			autoStart: true,
+			storeId: 'pbs-tape-drive-list',
 			interval: 60 * 1000,
 			model: 'pbs-tape-drive-list',
 		    });
@@ -267,15 +268,6 @@ Ext.define('PBS.view.main.NavigationTree', {
 	},
     },
 
-    reloadTapeStore: function() {
-	let me = this;
-	if (!PBS.enableTapeUI) {
-	    return;
-	}
-
-	me.tapestore.load();
-    },
-
     select: function(path, silent) {
 	var me = this;
 	if (me.rstore.isLoaded() && (!PBS.enableTapeUI || me.tapestore.isLoaded())) {
diff --git a/www/Utils.js b/www/Utils.js
index 6c8ca5cb..7c54ca41 100644
--- a/www/Utils.js
+++ b/www/Utils.js
@@ -620,6 +620,10 @@ Ext.define('PBS.Utils', {
 	return `${icon} ${value}`;
     },
 
+    reloadTapeStore() {
+	Ext.StoreManager.get('pbs-tape-drive-list').load();
+    },
+
 });
 
 Ext.define('PBS.Async', {
diff --git a/www/tape/ChangerConfig.js b/www/tape/ChangerConfig.js
index 0d9f6db6..8de61ff0 100644
--- a/www/tape/ChangerConfig.js
+++ b/www/tape/ChangerConfig.js
@@ -11,11 +11,6 @@ Ext.define('PBS.TapeManagement.ChangerPanel', {
     controller: {
 	xclass: 'Ext.app.ViewController',
 
-	reloadTapeStore: function() {
-	    let navtree = Ext.ComponentQuery.query('navigationtree')[0];
-	    navtree.reloadTapeStore();
-	},
-
 	onAdd: function() {
 	    let me = this;
 	    Ext.create('PBS.TapeManagement.ChangerEditWindow', {
@@ -45,7 +40,7 @@ Ext.define('PBS.TapeManagement.ChangerPanel', {
 
 	reload: function() {
 	    this.getView().getStore().rstore.load();
-	    this.reloadTapeStore();
+	    PBS.Utils.reloadTapeStore();
 	},
 
 	stopStore: function() {
diff --git a/www/tape/DriveConfig.js b/www/tape/DriveConfig.js
index a65de63a..ed73d028 100644
--- a/www/tape/DriveConfig.js
+++ b/www/tape/DriveConfig.js
@@ -19,11 +19,6 @@ Ext.define('PBS.TapeManagement.DrivePanel', {
     controller: {
 	xclass: 'Ext.app.ViewController',
 
-	reloadTapeStore: function() {
-	    let navtree = Ext.ComponentQuery.query('navigationtree')[0];
-	    navtree.reloadTapeStore();
-	},
-
 	onAdd: function() {
 	    let me = this;
 	    Ext.create('PBS.TapeManagement.DriveEditWindow', {
@@ -62,7 +57,7 @@ Ext.define('PBS.TapeManagement.DrivePanel', {
 
 	reload: function() {
 	    this.getView().getStore().rstore.load();
-	    this.reloadTapeStore();
+	    PBS.Utils.reloadTapeStore();
 	},
 
 	stopStore: function() {
-- 
2.20.1






More information about the pbs-devel mailing list