]>
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',
12 setVMConfig: function(vmconfig
) {
14 me
.vmconfig
= vmconfig
;
15 let max_usb
= PVE
.Utils
.get_max_usb_count(me
.vmconfig
.ostype
, me
.vmconfig
.machine
);
16 if (max_usb
> PVE
.Utils
.hardware_counts
.usb_old
) {
17 me
.down('field[name=usb3]').setDisabled(true);
21 onGetValues: function(values
) {
24 let max_usb
= PVE
.Utils
.get_max_usb_count(me
.vmconfig
.ostype
, me
.vmconfig
.machine
);
25 for (let i
= 0; i
< max_usb
; i
++) {
26 let id
= 'usb' + i
.toString();
27 if (!me
.vmconfig
[id
]) {
34 var type
= me
.down('radiofield').getGroupValue();
41 val
= 'host=' + values
[type
];
45 throw "invalid type selected";
52 values
[me
.confid
] = val
;
58 xtype
: 'fieldcontainer',
59 defaultType
: 'radiofield',
65 boxLabel
: gettext('Spice Port'),
71 inputValue
: 'hostdevice',
72 boxLabel
: gettext('Use USB Vendor/Device ID'),
73 reference
: 'hostdevice',
77 xtype
: 'pveUSBSelector',
81 cbind
: { pveSelNode
: '{pveSelNode}' },
82 bind
: { disabled
: '{!hostdevice.checked}' },
85 fieldLabel
: gettext('Choose Device'),
91 boxLabel
: gettext('Use USB Port'),
96 xtype
: 'pveUSBSelector',
99 cbind
: { pveSelNode
: '{pveSelNode}' },
100 bind
: { disabled
: '{!port.checked}' },
104 fieldLabel
: gettext('Choose Port'),
113 fieldLabel
: gettext('Use USB3'),
120 Ext
.define('PVE.qemu.USBEdit', {
121 extend
: 'Proxmox.window.Edit',
127 subject
: gettext('USB Device'),
129 initComponent: function() {
132 me
.isCreate
= !me
.confid
;
134 var ipanel
= Ext
.create('PVE.qemu.USBInputPanel', {
136 pveSelNode
: me
.pveSelNode
,
146 success: function(response
, options
) {
147 ipanel
.setVMConfig(response
.result
.data
);
152 var data
= response
.result
.data
[me
.confid
].split(',');
153 var port
, hostdevice
, usb3
= false;
156 for (let i
= 0; i
< data
.length
; i
++) {
157 if (/^(host=)?(0x)?[a-zA-Z0-9]{4}:(0x)?[a-zA-Z0-9]{4}$/.test(data
[i
])) {
158 hostdevice
= data
[i
];
159 hostdevice
= hostdevice
.replace('host=', '').replace('0x', '');
161 } else if (/^(host=)?(\d+)-(\d+(\.\d+)*)$/.test(data
[i
])) {
163 port
= port
.replace('host=', '');
167 if (/^usb3=(1|on|true)$/.test(data
[i
])) {
173 hostdevice
: hostdevice
,
178 ipanel
.setValues(values
);