]> git.proxmox.com Git - pve-manager.git/commitdiff
ui/vnc: reload IFrame-embedded noVNC on VM startup
authorStefan Reiter <s.reiter@proxmox.com>
Wed, 18 Dec 2019 12:19:50 +0000 (13:19 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 18 Dec 2019 16:55:57 +0000 (17:55 +0100)
Avoids having to do the 'Console' -> 'Summary' -> 'Console' dance
everytime the VM is started and the Console window is currently open.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
www/manager6/VNCConsole.js
www/manager6/qemu/Config.js

index 758b683936e0e8ac50a774108c69c416e3603cee..039c9687ee7f90f22275f97c5352958473885f3a 100644 (file)
@@ -57,6 +57,12 @@ Ext.define('PVE.noVncConsole', {
        me.on('afterrender', function() {
            me.focus();
        });
+    },
+
+    reloadConsole: function() {
+       // reload IFrame content to forcibly reconnect VNC/xterm.js to VM
+       var box = this.down();
+       box.getWin().location.reload();
     }
 });
 
index 58a1568c96fc2438660438b35f32f9103dcbb3a4..8c15dadb071de6081f3c42c45826c7a7b61f370a 100644 (file)
@@ -365,6 +365,7 @@ Ext.define('PVE.qemu.Config', {
 
        me.callParent();
 
+       var prevQmpstatus = 'unknown';
         me.mon(me.statusStore, 'load', function(s, records, success) {
            var status;
            var qmpstatus;
@@ -412,6 +413,16 @@ Ext.define('PVE.qemu.Config', {
            shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
            me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
            consoleBtn.setDisabled(template);
+
+           if (['prelaunch', 'stopped', 'suspended'].indexOf(prevQmpstatus) !== -1
+               && qmpstatus === 'running') {
+               var con = me.down('#console');
+               if (con) {
+                   con.reloadConsole();
+               }
+           }
+
+           prevQmpstatus = qmpstatus;
        });
 
        me.on('afterrender', function() {