[pve-devel] [PATCH manager 2/2] ui: group storages in folder view

Dominik Csapak d.csapak at proxmox.com
Wed Jun 14 11:50:47 CEST 2023


so if there are many storages and/or nodes, it makes the list of
storages a bit clearer

to do that we have to add a virtual field to group by that is not the
same as the 'type' of the individual entries (otherwise the grouping
logic does insert them wrong)

to not pollute the column list in the search grids, we only include the
ones with 'header' or 'text' property (without those, the columsn would
show up with an empty string)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/data/ResourceStore.js | 10 +++++++++-
 www/manager6/form/ViewSelector.js  |  2 +-
 www/manager6/tree/ResourceTree.js  |  3 +++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/www/manager6/data/ResourceStore.js b/www/manager6/data/ResourceStore.js
index 871d5145..a4f16b87 100644
--- a/www/manager6/data/ResourceStore.js
+++ b/www/manager6/data/ResourceStore.js
@@ -256,6 +256,12 @@ Ext.define('PVE.data.ResourceStore', {
 		sortable: true,
 		width: 110,
 	    },
+	    // to group them, we need a field that is not named like the type
+	    storageGroup: {
+		type: 'string',
+		hidden: true,
+		calculate: (data) => data.storage,
+	    },
 	    pool: {
 		header: gettext('Pool'),
 		type: 'string',
@@ -354,7 +360,9 @@ Ext.define('PVE.data.ResourceStore', {
 		let res = [];
 		Ext.Object.each(field_defaults, function(field, info) {
 		    let fieldInfo = Ext.apply({ dataIndex: field }, info);
-		    res.push(fieldInfo);
+		    if (fieldInfo.header || fieldInfo.text) {
+			res.push(fieldInfo);
+		    }
 		});
 		return res;
 	    },
diff --git a/www/manager6/form/ViewSelector.js b/www/manager6/form/ViewSelector.js
index e25547c4..222d80e7 100644
--- a/www/manager6/form/ViewSelector.js
+++ b/www/manager6/form/ViewSelector.js
@@ -24,7 +24,7 @@ Ext.define('PVE.form.ViewSelector', {
 	    },
 	    folder: {
 		text: gettext('Folder View'),
-		groups: ['type'],
+		groups: ['type', 'storageGroup'],
 	    },
 	    pool: {
 		text: gettext('Pool View'),
diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index 54c6403d..d9f17be3 100644
--- a/www/manager6/tree/ResourceTree.js
+++ b/www/manager6/tree/ResourceTree.js
@@ -21,6 +21,9 @@ Ext.define('PVE.tree.ResourceTree', {
 		iconCls: 'fa fa-database',
 		text: gettext('Storage'),
 	    },
+	    storageGroup: {
+		iconCls: 'fa fa-database',
+	    },
 	    sdn: {
 		iconCls: 'fa fa-th',
 		text: gettext('SDN'),
-- 
2.30.2






More information about the pve-devel mailing list