mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-05 13:10:27 +00:00
Add audio device to HardwareView
Adds the following: * Menu entry to create a new audio device only clickable if: * permissions are there * no audio device exists * listing in the hardwarew view Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
This commit is contained in:
parent
da97bd3d88
commit
171ca270a0
@ -277,6 +277,13 @@ Ext.define('PVE.qemu.HardwareView', {
|
||||
header: gettext('Serial Port') + ' (' + confid + ')'
|
||||
};
|
||||
}
|
||||
rows.audio0 = {
|
||||
group: 40,
|
||||
iconCls: 'volume-up',
|
||||
editor: caps.vms['VM.Config.HWType'] ? 'PVE.qemu.AudioEdit' : undefined,
|
||||
never_delete: caps.vms['VM.Config.HWType'] ? false : true,
|
||||
header: gettext('Audio Device')
|
||||
};
|
||||
for (i = 0; i < 256; i++) {
|
||||
rows["unused" + i.toString()] = {
|
||||
group: 99,
|
||||
@ -550,12 +557,15 @@ Ext.define('PVE.qemu.HardwareView', {
|
||||
// en/disable usb add button
|
||||
var usbcount = 0;
|
||||
var pcicount = 0;
|
||||
var audiocount = 0;
|
||||
var hasCloudInit = false;
|
||||
me.rstore.getData().items.forEach(function(item){
|
||||
if (/^usb\d+/.test(item.id)) {
|
||||
usbcount++;
|
||||
} else if (/^hostpci\d+/.test(item.id)) {
|
||||
pcicount++;
|
||||
} else if (/^audio\d+/.test(item.id)) {
|
||||
audiocount++;
|
||||
}
|
||||
if (!hasCloudInit && /vm-.*-cloudinit/.test(item.data.value)) {
|
||||
hasCloudInit = true;
|
||||
@ -564,9 +574,11 @@ Ext.define('PVE.qemu.HardwareView', {
|
||||
|
||||
// heuristic only for disabling some stuff, the backend has the final word.
|
||||
var noSysConsolePerm = !caps.nodes['Sys.Console'];
|
||||
var noVMConfigHWTypePerm = !caps.vms['VM.Config.HWType'];
|
||||
|
||||
me.down('#addusb').setDisabled(noSysConsolePerm || (usbcount >= 5));
|
||||
me.down('#addpci').setDisabled(noSysConsolePerm || (pcicount >= 4));
|
||||
me.down('#addaudio').setDisabled(noVMConfigHWTypePerm || (audiocount >= 1));
|
||||
me.down('#addci').setDisabled(noSysConsolePerm || hasCloudInit);
|
||||
|
||||
if (!rec) {
|
||||
@ -711,6 +723,21 @@ Ext.define('PVE.qemu.HardwareView', {
|
||||
win.on('destroy', reload);
|
||||
win.show();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: gettext('Audio Device'),
|
||||
itemId: 'addaudio',
|
||||
iconCls: 'fa fa-volume-up',
|
||||
disabled: !caps.vms['VM.Config.HWType'],
|
||||
handler: function() {
|
||||
var win = Ext.create('PVE.qemu.AudioEdit', {
|
||||
url: '/api2/extjs/' + baseurl,
|
||||
isCreate: true,
|
||||
isAdd: true
|
||||
});
|
||||
win.on('destroy', reload);
|
||||
win.show();
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user