[pve-devel] [PATCH manager v7 10/11] ui: form: add DIRMapSelector

Markus Frank m.frank at proxmox.com
Wed Aug 9 10:37:38 CEST 2023


Signed-off-by: Markus Frank <m.frank at proxmox.com>
---
 www/manager6/Makefile               |  1 +
 www/manager6/form/DIRMapSelector.js | 63 +++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 www/manager6/form/DIRMapSelector.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 4c1fcdbb..69627ae0 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -34,6 +34,7 @@ JSSRC= 							\
 	form/ContentTypeSelector.js			\
 	form/ControllerSelector.js			\
 	form/DayOfWeekSelector.js			\
+	form/DIRMapSelector.js                          \
 	form/DiskFormatSelector.js			\
 	form/DiskStorageSelector.js			\
 	form/EmailNotificationSelector.js		\
diff --git a/www/manager6/form/DIRMapSelector.js b/www/manager6/form/DIRMapSelector.js
new file mode 100644
index 00000000..6cfb89cf
--- /dev/null
+++ b/www/manager6/form/DIRMapSelector.js
@@ -0,0 +1,63 @@
+Ext.define('PVE.form.DIRMapSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    alias: 'widget.pveDIRMapSelector',
+
+    store: {
+	fields: ['name', 'path'],
+	filterOnLoad: true,
+	sorters: [
+	    {
+		property: 'name',
+		direction: 'ASC',
+	    },
+	],
+    },
+
+    allowBlank: false,
+    autoSelect: false,
+    displayField: 'id',
+    valueField: 'id',
+
+    listConfig: {
+	columns: [
+	    {
+		header: gettext('Directory ID'),
+		dataIndex: 'id',
+		flex: 1,
+	    },
+	    {
+		header: gettext('Comment'),
+		dataIndex: 'description',
+		flex: 1,
+	    },
+	],
+    },
+
+    setNodename: function(nodename) {
+	var me = this;
+
+	if (!nodename || me.nodename === nodename) {
+	    return;
+	}
+
+	me.nodename = nodename;
+
+	me.store.setProxy({
+	    type: 'proxmox',
+	    url: `/api2/json/cluster/mapping/dir?check-node=${nodename}`,
+	});
+
+	me.store.load();
+    },
+
+    initComponent: function() {
+	var me = this;
+
+	var nodename = me.nodename;
+	me.nodename = undefined;
+
+        me.callParent();
+
+	me.setNodename(nodename);
+    },
+});
-- 
2.39.2






More information about the pve-devel mailing list