[pve-devel] [PATCH manager 4/8] ui: form: add USBMapSelector
Dominik Csapak
d.csapak at proxmox.com
Mon Jun 21 15:55:30 CEST 2021
similar to PCIMapSelector
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/form/USBMapSelector.js | 73 +++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
create mode 100644 www/manager6/form/USBMapSelector.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 4168bc4e..b4e48d33 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -65,6 +65,7 @@ JSSRC= \
form/TFASelector.js \
form/TokenSelector.js \
form/USBSelector.js \
+ form/USBMapSelector.js \
form/UserSelector.js \
form/VLanField.js \
form/VMCPUFlagSelector.js \
diff --git a/www/manager6/form/USBMapSelector.js b/www/manager6/form/USBMapSelector.js
new file mode 100644
index 00000000..6a96dad6
--- /dev/null
+++ b/www/manager6/form/USBMapSelector.js
@@ -0,0 +1,73 @@
+Ext.define('PVE.form.USBMapSelector', {
+ extend: 'Proxmox.form.ComboGrid',
+ alias: 'widget.pveUSBMapSelector',
+
+ store: {
+ fields: ['name', 'vendor', 'device', 'usbpath'],
+ filterOnLoad: true,
+ sorters: [
+ {
+ property: 'name',
+ direction: 'ASC',
+ },
+ ],
+ },
+
+ allowBlank: false,
+ autoSelect: false,
+ displayField: 'name',
+ valueField: 'name',
+
+ listConfig: {
+ columns: [
+ {
+ header: gettext('Name'),
+ dataIndex: 'name',
+ flex: 2,
+ },
+ {
+ header: gettext('Path'),
+ dataIndex: 'usbpath',
+ flex: 1,
+ },
+ {
+ header: gettext('Vendor'),
+ dataIndex: 'vendor',
+ flex: 1,
+ },
+ {
+ header: gettext('Device'),
+ dataIndex: 'device',
+ 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/nodes/${me.nodename}/hardware/mapping?type=usb`,
+ });
+
+ me.store.load();
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ var nodename = me.nodename;
+ me.nodename = undefined;
+
+ me.callParent();
+
+ me.setNodename(nodename);
+ },
+});
--
2.20.1
More information about the pve-devel
mailing list