]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/form/ControllerSelector.js
1 Ext
.define('PVE.form.ControllerSelector', {
2 extend
: 'Ext.form.FieldContainer',
3 alias
: 'widget.pveControllerSelector',
7 vmconfig
: {}, // used to check for existing devices
9 setToFree: function(controllers
, busField
, deviceIDField
) {
11 let freeId
= PVE
.Utils
.nextFreeDisk(controllers
, me
.vmconfig
);
13 if (freeId
!== undefined) {
14 busField
.setValue(freeId
.controller
);
15 deviceIDField
.setValue(freeId
.id
);
20 setVMConfig: function(vmconfig
, autoSelect
) {
23 me
.vmconfig
= Ext
.apply({}, vmconfig
);
25 let bussel
= me
.down('field[name=controller]');
26 let deviceid
= me
.down('field[name=deviceid]');
29 if (autoSelect
=== 'cdrom') {
30 if (!Ext
.isDefined(me
.vmconfig
.ide2
)) {
31 bussel
.setValue('ide');
35 clist
= ['ide', 'scsi', 'sata'];
37 // in most cases we want to add a disk to the same controller we previously used
38 clist
= PVE
.Utils
.sortByPreviousUsage(me
.vmconfig
);
41 me
.setToFree(clist
, bussel
, deviceid
);
46 initComponent: function() {
50 fieldLabel
: gettext('Bus/Device'),
57 xtype
: 'pveBusSelector',
59 value
: PVE
.qemu
.OSDefaults
.generic
.busType
,
60 noVirtIO
: me
.noVirtIO
,
64 change: function(t
, value
) {
68 let field
= me
.down('field[name=deviceid]');
69 field
.setMaxValue(PVE
.Utils
.diskControllerMaxIDs
[value
] - 1);
75 xtype
: 'proxmoxintegerfield',
78 maxValue
: PVE
.Utils
.diskControllerMaxIDs
.ide
- 1,
82 validator: function(value
) {
86 let controller
= me
.down('field[name=controller]').getValue();
87 let confid
= controller
+ value
;
88 if (Ext
.isDefined(me
.vmconfig
[confid
])) {
89 return "This device is already in use.";