]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: vm: allow to add socket backed serial devices
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 16 May 2018 13:30:59 +0000 (15:30 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 17 May 2018 07:25:34 +0000 (09:25 +0200)
We show and can remove serial devices but couldn't add new ones
through the WebUI.
Add a simple component to allow adding serial ports backed by a
socket, which can be especially useful now with xterm.js

Passing through serial devices from /dev isn't possible with this, as
it is normally a root only operation and not that often used.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/Makefile
www/manager6/qemu/HardwareView.js
www/manager6/qemu/SerialEdit.js [new file with mode: 0644]

index 7e9877b29c24b8e8d0112225d37bb69617351bba..a2bd4576c0c6952dfadd47c169355966b9fd2103 100644 (file)
@@ -129,6 +129,7 @@ JSSRC=                                                      \
        qemu/Config.js                                  \
        qemu/CreateWizard.js                            \
        qemu/USBEdit.js                                 \
+       qemu/SerialEdit.js                                      \
        qemu/AgentIPView.js                             \
        qemu/CloudInit.js                               \
        qemu/CIDriveEdit.js                             \
index 17e755a8cdfbd7d783310b22fb93cce41ff4e3be..a87a9df1f4725ace356c7af388f0c8d9cfa19ae0 100644 (file)
@@ -570,6 +570,19 @@ Ext.define('PVE.qemu.HardwareView', {
                                    win.show();
                                }
                            },
+                           {
+                               text: gettext('Serial Port'),
+                               itemId: 'addserial',
+                               iconCls: 'pve-itype-icon-serial',
+                               disabled: !caps.vms['VM.Config.Options'],
+                               handler: function() {
+                                   var win = Ext.create('PVE.qemu.SerialEdit', {
+                                       url: '/api2/extjs/' + baseurl
+                                   });
+                                   win.on('destroy', reload);
+                                   win.show();
+                               }
+                           },
                            {
                                text: gettext('CloudInit Drive'),
                                itemId: 'addci',
diff --git a/www/manager6/qemu/SerialEdit.js b/www/manager6/qemu/SerialEdit.js
new file mode 100644 (file)
index 0000000..794c7fa
--- /dev/null
@@ -0,0 +1,81 @@
+/*jslint confusion: true */
+Ext.define('PVE.qemu.SerialnputPanel', {
+    extend: 'Proxmox.panel.InputPanel',
+
+    autoComplete: false,
+
+    setVMConfig: function(vmconfig) {
+       var me = this, i;
+       me.vmconfig = vmconfig;
+
+       for (i = 0; i < 4; i++) {
+           var port = 'serial' +  i.toString();
+           if (!me.vmconfig[port]) {
+               me.down('field[name=serialid]').setValue(i);
+               break;
+           }
+       }
+
+    },
+
+    onGetValues: function(values) {
+       var me = this;
+
+       var id = 'serial' + values.serialid;
+       delete values.serialid;
+       values[id] = 'socket';
+       return values;
+    },
+
+    items: [
+       {
+           xtype: 'proxmoxintegerfield',
+           name: 'serialid',
+           fieldLabel: gettext('Serial Port'),
+           minValue: 0,
+           maxValue: 3,
+           allowBlank: false,
+           validator: function(id) {
+               if (!this.rendered) {
+                   return true;
+               }
+               var me = this.up('panel');
+               if (me.vmconfig !== undefined && Ext.isDefined(me.vmconfig['serial' + id])) {
+                       return "This device is already in use.";
+               }
+               return true;
+           }
+       }
+    ]
+});
+
+Ext.define('PVE.qemu.SerialEdit', {
+    extend: 'Proxmox.window.Edit',
+
+    vmconfig: undefined,
+
+    isAdd: true,
+
+    subject: gettext('Serial Port'),
+
+    initComponent : function() {
+       var me = this;
+
+       // for now create of (socket) serial port only
+       me.isCreate = true;
+
+       var ipanel = Ext.create('PVE.qemu.SerialnputPanel', {});
+
+       Ext.apply(me, {
+           items: [ ipanel ]
+       });
+
+       me.callParent();
+
+       me.load({
+           success: function(response, options) {
+               ipanel.setVMConfig(response.result.data);
+           }
+       });
+    }
+});