]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
Add audio device to HardwareView
authorAaron Lauterer <a.lauterer@proxmox.com>
Fri, 19 Jul 2019 13:32:21 +0000 (15:32 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Jul 2019 16:29:05 +0000 (18:29 +0200)
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>
www/manager6/qemu/HardwareView.js

index 3dfbd016fc1580ed60550309b50a50f06001ce5c..bb6feedf0a3abba51e63717ea5e032ca4c559565 100644 (file)
@@ -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();
+                               }
                            }
                        ]
                    })