add cmd parameter & rework query string creation

Signed-off-by: Tim Marx <t.marx@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Tim Marx 2019-03-06 12:29:39 +01:00 committed by Thomas Lamprecht
parent 8eccc68f6c
commit b945c7c1be
2 changed files with 26 additions and 7 deletions

View File

@ -1091,6 +1091,17 @@ Ext.define('PVE.Utils', { utilities: {
return;
}
}
},
cleanEmptyObjectKeys: function (obj) {
var propName;
for (propName in obj) {
if (obj.hasOwnProperty(propName)) {
if (obj[propName] === null || obj[propName] === undefined) {
delete obj[propName];
}
}
}
}
},

View File

@ -6,7 +6,9 @@ Ext.define('PVE.noVncConsole', {
vmid: undefined,
consoleType: undefined, // lxc or kvm
cmd: undefined,
consoleType: undefined, // lxc, kvm, shell, cmd
layout: 'fit',
@ -14,6 +16,7 @@ Ext.define('PVE.noVncConsole', {
border: false,
initComponent : function() {
var me = this;
@ -25,7 +28,7 @@ Ext.define('PVE.noVncConsole', {
throw "no console type specified";
}
if (!me.vmid && me.consoleType !== 'shell') {
if (!me.vmid && me.consoleType !== 'shell' && me.consoleType !== 'cmd') {
throw "no VM ID specified";
}
@ -34,15 +37,20 @@ Ext.define('PVE.noVncConsole', {
var box = Ext.create('Ext.ux.IFrame', { itemid : "vncconsole" });
var type = me.xtermjs ? 'xtermjs' : 'novnc';
Ext.apply(me, {
items: box,
listeners: {
activate: function() {
var url = '/?console=' + me.consoleType + '&' + type + '=1&node=' + me.nodename + '&resize=scale';
if (me.vmid) {
url += '&vmid='+ me.vmid;
}
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);
}
}