]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/USBEdit.js
1 Ext
.define('PVE.qemu.USBInputPanel', {
2 extend
: 'Proxmox.panel.InputPanel',
3 mixins
: ['Proxmox.Mixin.CBind'],
6 onlineHelp
: 'qm_usb_passthrough',
8 cbindData: function(initialConfig
) {
11 throw "no pveSelNode given";
14 return { nodename
: me
.pveSelNode
.data
.node
};
21 setVMConfig: function(vmconfig
) {
23 me
.vmconfig
= vmconfig
;
24 let max_usb
= PVE
.Utils
.get_max_usb_count(me
.vmconfig
.ostype
, me
.vmconfig
.machine
);
25 if (max_usb
> PVE
.Utils
.hardware_counts
.usb_old
) {
26 me
.down('field[name=usb3]').setDisabled(true);
30 onGetValues: function(values
) {
33 let max_usb
= PVE
.Utils
.get_max_usb_count(me
.vmconfig
.ostype
, me
.vmconfig
.machine
);
34 for (let i
= 0; i
< max_usb
; i
++) {
35 let id
= 'usb' + i
.toString();
36 if (!me
.vmconfig
[id
]) {
43 var type
= me
.down('radiofield').getGroupValue();
49 val
= `mapping=${values[type]}`;
54 val
= 'host=' + values
[type
];
58 throw "invalid type selected";
65 values
[me
.confid
] = val
;
71 xtype
: 'fieldcontainer',
72 defaultType
: 'radiofield',
78 boxLabel
: gettext('Spice Port'),
85 boxLabel
: gettext('Use mapped Device'),
90 xtype
: 'pveUSBMapSelector',
93 cbind
: { nodename
: '{nodename}' },
94 bind
: { disabled
: '{!mapped.checked}' },
96 fieldLabel
: gettext('Choose Device'),
101 inputValue
: 'hostdevice',
102 boxLabel
: gettext('Use USB Vendor/Device ID'),
103 reference
: 'hostdevice',
107 xtype
: 'pveUSBSelector',
111 cbind
: { pveSelNode
: '{pveSelNode}' },
112 bind
: { disabled
: '{!hostdevice.checked}' },
115 fieldLabel
: gettext('Choose Device'),
121 boxLabel
: gettext('Use USB Port'),
126 xtype
: 'pveUSBSelector',
129 cbind
: { pveSelNode
: '{pveSelNode}' },
130 bind
: { disabled
: '{!port.checked}' },
134 fieldLabel
: gettext('Choose Port'),
143 fieldLabel
: gettext('Use USB3'),
150 Ext
.define('PVE.qemu.USBEdit', {
151 extend
: 'Proxmox.window.Edit',
157 subject
: gettext('USB Device'),
159 initComponent: function() {
162 me
.isCreate
= !me
.confid
;
164 var ipanel
= Ext
.create('PVE.qemu.USBInputPanel', {
166 pveSelNode
: me
.pveSelNode
,
176 success: function(response
, options
) {
177 ipanel
.setVMConfig(response
.result
.data
);
182 let data
= PVE
.Parser
.parsePropertyString(response
.result
.data
[me
.confid
], 'host');
183 let port
, hostdevice
, mapped
, usb3
= false;
187 if (/^(0x)?[a-zA-Z0-9]{4}:(0x)?[a-zA-Z0-9]{4}$/.test(data
.host
)) {
188 hostdevice
= data
.host
.replace('0x', '');
190 } else if (/^(\d+)-(\d+(\.\d+)*)$/.test(data
.host
)) {
193 } else if (/^spice$/i.test(data
.host
)) {
196 } else if (data
.mapping
) {
197 mapped
= data
.mapping
;
201 usb3
= data
.usb3
?? false;
211 ipanel
.setValues(values
);