]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/USBEdit.js
b25f45e69f5ccbc696040e717b052a4ffaf1d3be
1 Ext
.define('PVE.qemu.USBInputPanel', {
2 extend
: 'Proxmox.panel.InputPanel',
3 mixins
: ['Proxmox.Mixin.CBind' ],
6 onlineHelp
: 'qm_usb_passthrough',
13 xclass
: 'Ext.app.ViewController',
17 change: function(field
, newValue
, oldValue
) {
18 var usb3field
= this.lookupReference('usb3');
19 var usbval
= field
.getUSBValue();
20 var dev_is_usb3
= /usb3=1/.test(usbval
);
23 usb3field
.savedVal
= usb3field
.getValue();
24 usb3field
.setValue(true);
26 if (usb3field
.savedVal
!== undefined) {
27 usb3field
.setValue(usb3field
.savedVal
);
29 usb3field
.setValue(usb3field
.originalValue
);
31 usb3field
.setDisabled(false);
38 setVMConfig: function(vmconfig
) {
40 me
.vmconfig
= vmconfig
;
43 onGetValues: function(values
) {
46 for (let i
= 0; i
< 6; i
++) {
47 let id
= 'usb' + i
.toString();
48 if (!me
.vmconfig
[id
]) {
55 var type
= me
.down('radiofield').getGroupValue();
61 val
= me
.down('pveUSBSelector[name=' + type
+ ']').getUSBValue();
64 throw "invalid type selected";
71 values
[me
.confid
] = val
;
77 xtype
: 'fieldcontainer',
78 defaultType
: 'radiofield',
83 boxLabel
: gettext('Spice Port'),
89 inputValue
: 'hostdevice',
90 boxLabel
: gettext('Use USB Vendor/Device ID'),
91 reference
: 'hostdevice',
95 xtype
: 'pveUSBSelector',
99 cbind
: { pveSelNode
: '{pveSelNode}' },
100 bind
: { disabled
: '{!hostdevice.checked}' },
103 fieldLabel
: 'Choose Device',
110 boxLabel
: gettext('Use USB Port'),
115 xtype
: 'pveUSBSelector',
118 cbind
: { pveSelNode
: '{pveSelNode}' },
119 bind
: { disabled
: '{!port.checked}' },
123 fieldLabel
: gettext('Choose Port'),
132 fieldLabel
: gettext('Use USB3')
139 Ext
.define('PVE.qemu.USBEdit', {
140 extend
: 'Proxmox.window.Edit',
145 subject
: gettext('USB Device'),
147 initComponent : function() {
150 me
.isCreate
= !me
.confid
;
152 var ipanel
= Ext
.create('PVE.qemu.USBInputPanel', {
154 pveSelNode
: me
.pveSelNode
164 success: function(response
, options
) {
165 ipanel
.setVMConfig(response
.result
.data
);
170 var data
= response
.result
.data
[me
.confid
].split(',');
171 var port
, hostdevice
, usb3
= false;
174 for (let i
= 0; i
< data
.length
; i
++) {
175 if (/^(host=)?(0x)?[a-zA-Z0-9]{4}\:(0x)?[a-zA-Z0-9]{4}$/.test(data
[i
])) {
176 hostdevice
= data
[i
];
177 hostdevice
= hostdevice
.replace('host=', '').replace('0x','');
179 } else if (/^(host=)?(\d+)\-(\d+(\.\d+)*)$/.test(data
[i
])) {
181 port
= port
.replace('host=', '');
185 if (/^usb3=(1|on|true)$/.test(data
[i
])) {
191 hostdevice
: hostdevice
,
196 ipanel
.setValues(values
);