[pve-devel] [PATCH manager 4/4] use usbedit window to add/edit usb devices
Dominik Csapak
d.csapak at proxmox.com
Mon May 29 10:46:34 CEST 2017
the usb device button gets disabled when there are
already 5 usb devices
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/qemu/HardwareView.js | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
index a432d39e..e26f28b2 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -209,12 +209,13 @@ Ext.define('PVE.qemu.HardwareView', {
never_delete: caps.vms['VM.Config.Disk'] ? false : true,
header: gettext('EFI Disk')
};
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < 5; i++) {
confid = "usb" + i;
rows[confid] = {
group: 4,
tdCls: 'pve-itype-icon-usb',
- never_delete: true,
+ editor: caps.nodes['Sys.Console'] ? 'PVE.qemu.USBEdit' : undefined,
+ never_delete: caps.nodes['Sys.Console'] ? false : true,
header: gettext('USB Device') + ' (' + confid + ')'
};
}
@@ -472,6 +473,14 @@ Ext.define('PVE.qemu.HardwareView', {
// disable is ok in this case, because you can instantly
// see that there is already one
efidisk_menuitem.setDisabled(me.rstore.getData().map.efidisk0 !== undefined);
+ // en/disable usb add button
+ var count = 0;
+ me.rstore.getData().items.forEach(function(item){
+ if (/^usb\d+/.test(item.id)) {
+ count++;
+ }
+ });
+ me.down('#addusb').setDisabled((count >= 5));
if (!rec) {
remove_btn.disable();
@@ -556,7 +565,21 @@ Ext.define('PVE.qemu.HardwareView', {
win.show();
}
},
- efidisk_menuitem
+ efidisk_menuitem,
+ {
+ text: gettext('USB Device'),
+ itemId: 'addusb',
+ iconCls: 'pve-itype-icon-usb',
+ disabled: !caps.nodes['Sys.Console'],
+ handler: function() {
+ var win = Ext.create('PVE.qemu.USBEdit', {
+ url: '/api2/extjs/' + baseurl,
+ pveSelNode: me.pveSelNode
+ });
+ win.on('destroy', reload);
+ win.show();
+ }
+ }
]
})
},
--
2.11.0
More information about the pve-devel
mailing list