]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/VNCConsole.js
add cmd parameter & rework query string creation
[pve-manager.git] / www / manager6 / VNCConsole.js
1 Ext.define('PVE.noVncConsole', {
2 extend: 'Ext.panel.Panel',
3 alias: 'widget.pveNoVncConsole',
4
5 nodename: undefined,
6
7 vmid: undefined,
8
9 cmd: undefined,
10
11 consoleType: undefined, // lxc, kvm, shell, cmd
12
13 layout: 'fit',
14
15 xtermjs: false,
16
17 border: false,
18
19
20 initComponent : function() {
21 var me = this;
22
23 if (!me.nodename) {
24 throw "no node name specified";
25 }
26
27 if (!me.consoleType) {
28 throw "no console type specified";
29 }
30
31 if (!me.vmid && me.consoleType !== 'shell' && me.consoleType !== 'cmd') {
32 throw "no VM ID specified";
33 }
34
35 // always use same iframe, to avoid running several noVnc clients
36 // at same time (to avoid performance problems)
37 var box = Ext.create('Ext.ux.IFrame', { itemid : "vncconsole" });
38
39 var type = me.xtermjs ? 'xtermjs' : 'novnc';
40 Ext.apply(me, {
41 items: box,
42 listeners: {
43 activate: function() {
44 var queryDict = {
45 console: me.consoleType, // kvm, lxc, upgrade or shell
46 vmid: me.vmid,
47 node: me.nodename,
48 cmd: me.cmd,
49 resize: 'scale'
50 };
51 queryDict[type] = 1;
52 PVE.Utils.cleanEmptyObjectKeys(queryDict);
53 var url = '/?' + Ext.Object.toQueryString(queryDict);
54 box.load(url);
55 }
56 }
57 });
58
59 me.callParent();
60
61 me.on('afterrender', function() {
62 me.focus();
63 });
64 }
65 });
66