[pve-devel] [PATCH widget-toolkit 1/2] (multi) disk selector: allow requesting partitions too

Fabian Ebner f.ebner at proxmox.com
Tue Sep 28 13:39:51 CEST 2021


No functional change for existing users is intended.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/form/DiskSelector.js      |  7 +++++++
 src/form/MultiDiskSelector.js | 22 +++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/form/DiskSelector.js b/src/form/DiskSelector.js
index 4552beb..3292661 100644
--- a/src/form/DiskSelector.js
+++ b/src/form/DiskSelector.js
@@ -8,6 +8,9 @@ Ext.define('Proxmox.form.DiskSelector', {
     // journal_disk: all disks with gpt
     diskType: undefined,
 
+    // use include-partitions=1 as a parameter
+    includePartitions: false,
+
     // the property the backend wnats for the type ('type' by default)
     typeProperty: 'type',
 
@@ -53,6 +56,10 @@ Ext.define('Proxmox.form.DiskSelector', {
 	    extraParams[me.typeProperty] = me.diskType;
 	}
 
+	if (me.includePartitions) {
+	    extraParams['include-partitions'] = 1;
+	}
+
 	var store = Ext.create('Ext.data.Store', {
 	    filterOnLoad: true,
 	    model: 'pmx-disk-list',
diff --git a/src/form/MultiDiskSelector.js b/src/form/MultiDiskSelector.js
index 9e989a4..88cdc80 100644
--- a/src/form/MultiDiskSelector.js
+++ b/src/form/MultiDiskSelector.js
@@ -24,6 +24,9 @@ Ext.define('Proxmox.form.MultiDiskSelector', {
     // the type of disks to show
     diskType: 'unused',
 
+    // add include-partitions=1 as a request parameter
+    includePartitions: false,
+
     disks: [],
 
     allowBlank: false,
@@ -141,22 +144,31 @@ Ext.define('Proxmox.form.MultiDiskSelector', {
     initComponent: function() {
 	let me = this;
 
+	let extraParams = {};
+
 	if (!me.url) {
 	    if (!me.nodename) {
 		throw "no url or nodename given";
 	    }
 
-	    let node = me.nodename;
-	    let param = me.typeParameter;
-	    let type = me.diskType;
-	    me.url = `/api2/json/nodes/${node}/disks/list?${param}=${type}`;
+	    me.url = `/api2/json/nodes/${me.nodename}/disks/list`;
+
+	    extraParams[me.typeParameter] = me.diskType;
+
+	    if (me.includePartitions) {
+		extraParams['include-partitions'] = 1;
+	    }
 	}
 
 	me.disks = [];
 
 	me.callParent();
 	let store = me.getStore();
-	store.getProxy().setUrl(me.url);
+	store.setProxy({
+	    type: 'proxmox',
+	    url: me.url,
+	    extraParams,
+	});
 	store.load();
 	store.sort({ property: me.valueField });
     },
-- 
2.30.2






More information about the pve-devel mailing list