ui/vnc: reload IFrame-embedded noVNC on VM startup

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>
This commit is contained in:
Stefan Reiter 2019-12-18 13:19:50 +01:00 committed by Thomas Lamprecht
parent 78bfd48a92
commit c17ecca28d
2 changed files with 17 additions and 0 deletions

View File

@ -57,6 +57,12 @@ Ext.define('PVE.noVncConsole', {
me.on('afterrender', function() { me.on('afterrender', function() {
me.focus(); me.focus();
}); });
},
reloadConsole: function() {
// reload IFrame content to forcibly reconnect VNC/xterm.js to VM
var box = this.down();
box.getWin().location.reload();
} }
}); });

View File

@ -365,6 +365,7 @@ Ext.define('PVE.qemu.Config', {
me.callParent(); me.callParent();
var prevQmpstatus = 'unknown';
me.mon(me.statusStore, 'load', function(s, records, success) { me.mon(me.statusStore, 'load', function(s, records, success) {
var status; var status;
var qmpstatus; var qmpstatus;
@ -412,6 +413,16 @@ Ext.define('PVE.qemu.Config', {
shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running'); shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped'); me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
consoleBtn.setDisabled(template); 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() { me.on('afterrender', function() {