pve-manager/www/manager6/VNCConsole.js
Tim Marx b945c7c1be add cmd parameter & rework query string creation
Signed-off-by: Tim Marx <t.marx@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
2019-03-08 12:30:11 +01:00

67 lines
1.3 KiB
JavaScript

Ext.define('PVE.noVncConsole', {
extend: 'Ext.panel.Panel',
alias: 'widget.pveNoVncConsole',
nodename: undefined,
vmid: undefined,
cmd: undefined,
consoleType: undefined, // lxc, kvm, shell, cmd
layout: 'fit',
xtermjs: false,
border: false,
initComponent : function() {
var me = this;
if (!me.nodename) {
throw "no node name specified";
}
if (!me.consoleType) {
throw "no console type specified";
}
if (!me.vmid && me.consoleType !== 'shell' && me.consoleType !== 'cmd') {
throw "no VM ID specified";
}
// always use same iframe, to avoid running several noVnc clients
// at same time (to avoid performance problems)
var box = Ext.create('Ext.ux.IFrame', { itemid : "vncconsole" });
var type = me.xtermjs ? 'xtermjs' : 'novnc';
Ext.apply(me, {
items: box,
listeners: {
activate: function() {
var queryDict = {
console: me.consoleType, // kvm, lxc, upgrade or shell
vmid: me.vmid,
node: me.nodename,
cmd: me.cmd,
resize: 'scale'
};
queryDict[type] = 1;
PVE.Utils.cleanEmptyObjectKeys(queryDict);
var url = '/?' + Ext.Object.toQueryString(queryDict);
box.load(url);
}
}
});
me.callParent();
me.on('afterrender', function() {
me.focus();
});
}
});