[pbs-devel] [PATCH proxmox-backup 19/26] ui: form: add PartitionSelector

Hannes Laimer h.laimer at proxmox.com
Tue Jul 5 15:08:27 CEST 2022


... used by the removable device edit window, only shows partitions
that have a filesystem and gives their uuid as value

Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
 www/Makefile                  |  1 +
 www/form/PartitionSelector.js | 61 +++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 www/form/PartitionSelector.js

diff --git a/www/Makefile b/www/Makefile
index 12be1ce5..b916ecc8 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -44,6 +44,7 @@ JSSRC=							\
 	form/DataStoreSelector.js			\
 	form/NamespaceSelector.js			\
 	form/NamespaceMaxDepth.js			\
+	form/PartitionSelector.js			\
 	form/CalendarEvent.js				\
 	form/PermissionPathSelector.js			\
 	form/GroupSelector.js				\
diff --git a/www/form/PartitionSelector.js b/www/form/PartitionSelector.js
new file mode 100644
index 00000000..53c0560a
--- /dev/null
+++ b/www/form/PartitionSelector.js
@@ -0,0 +1,61 @@
+Ext.define('pbs-partition-list', {
+    extend: 'Ext.data.Model',
+    fields: ['name', 'uuid', 'filesystem', 'devpath', 'size'],
+    proxy: {
+        type: 'proxmox',
+        url: "/api2/json/nodes/localhost/disks/list?include-partitions=1",
+	reader: {
+	    transform: (rawData) => {
+		let partitions = [];
+		for (let disk of rawData.data) {
+		    const p = (disk.partitions ?? []).filter((i) => i.used === 'filesystem');
+		    partitions.push(...p);
+		}
+		return { data: partitions };
+	    },
+	},
+    },
+    idProperty: 'devpath',
+
+});
+
+Ext.define('PBS.form.PartitionSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    alias: 'widget.pbsPartitionSelector',
+
+    allowBlank: false,
+    autoSelect: false,
+    valueField: 'uuid',
+    displayField: 'uuid',
+
+    store: {
+	model: 'pbs-partition-list',
+	autoLoad: true,
+	sorters: 'devpath',
+    },
+
+    listConfig: {
+	columns: [
+	    {
+		header: gettext('Path'),
+		sortable: true,
+		dataIndex: 'devpath',
+		renderer: (v, metaData, rec) => Ext.String.htmlEncode(v),
+		flex: 1,
+	    },
+	    {
+		header: gettext('Filesystem'),
+		sortable: true,
+		dataIndex: 'filesystem',
+		flex: 1,
+	    },
+	    {
+		header: gettext('Size'),
+		sortable: true,
+		dataIndex: 'size',
+		renderer: Proxmox.Utils.format_size,
+		flex: 1,
+	    },
+	],
+    },
+});
-- 
2.30.2






More information about the pbs-devel mailing list