[pve-devel] [PATCH v2 manager 17/20] group backups by backup groups in backup view

Fabian Ebner f.ebner at proxmox.com
Wed Sep 16 14:50:38 CEST 2020


It was necessary to make the component not stateful, because of an ExtJS bug
where groupFn is not being preserved when the state is restored, see:
https://forum.sencha.com/forum/showthread.php?469145-Uncaught-TypeError-me-_groupFn-is-not-a-function

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

new in v2

Couldn't find a way to make this work with stateful: true...
Not using Ext.create and only passing along the Object with the properties
for the grouper doesn't seem to help either.

 www/manager6/storage/BackupView.js  | 24 ++++++++++++++++++++++--
 www/manager6/storage/ContentView.js |  1 +
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/www/manager6/storage/BackupView.js b/www/manager6/storage/BackupView.js
index 2669d2ca..ad377de6 100644
--- a/www/manager6/storage/BackupView.js
+++ b/www/manager6/storage/BackupView.js
@@ -3,8 +3,12 @@ Ext.define('PVE.storage.BackupView', {
 
     alias: 'widget.pveStorageBackupView',
 
-    stateful: true,
-    stateId: 'grid-storage-content-backup',
+    features: [
+	{
+	    ftype: 'grouping',
+	    groupHeaderTpl: '{name} ({rows.length} Backup{[values.rows.length > 1 ? "s" : ""]})',
+	},
+    ],
 
     initComponent: function() {
 	var me = this;
@@ -69,6 +73,22 @@ Ext.define('PVE.storage.BackupView', {
 	    },
 	];
 
+	me.grouper = Ext.create('Ext.util.Grouper', {
+	    groupFn: function(val) {
+		let name = val.data.text;
+		let vmid = val.data.vmid;
+		if (!vmid) {
+		    return 'other';
+		}
+		if (name.startsWith('vzdump-lxc-')) {
+		    return 'CT/' + vmid;
+		} else if (name.startsWith('vzdump-qemu-')) {
+		    return 'VM/' + vmid;
+		}
+		return 'other';
+	    },
+	});
+
 	me.callParent();
     },
 });
diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
index 0f1bbc0c..e563d3a3 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -232,6 +232,7 @@ Ext.define('PVE.storage.ContentView', {
 	var baseurl = "/nodes/" + nodename + "/storage/" + storage + "/content";
 	var store = me.store = Ext.create('Ext.data.Store', {
 	    model: 'pve-storage-content',
+	    grouper: me.grouper,
 	    proxy: {
                 type: 'proxmox',
 		url: '/api2/json' + baseurl,
-- 
2.20.1






More information about the pve-devel mailing list