Commit 0d278bac authored by Dietmar Maurer's avatar Dietmar Maurer

further console cleanups

parent 700f0740
......@@ -1090,17 +1090,44 @@ Ext.define('PVE.Utils', { statics: {
}
},
openConsoleWindow: function(vmtype, vmid, nodename, vmname, novnc) {
var url = Ext.urlEncode({
console: vmtype, // kvm, openvz or shell
novnc: novnc ? 1 : 0,
vmid: vmid,
vmname: vmname,
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) {
var dv = PVE.Utils.defaultViewer(allowSpice);
PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname);
},
openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname) {
// kvm, openvz, shell, upgrade
if (vmid == undefined && (vmtype === 'kvm' || vmtype === 'openvz')) {
throw "missing vmid";
}
if (!nodename) {
throw "no nodename specified";
}
if (viewer === 'applet' || viewer === 'html5') {
PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, viewer === 'html5');
} else if (viewer === 'vv') {
var url;
var params = { proxy: window.location.hostname };
if (vmtype === 'kvm') {
url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
PVE.Utils.openSpiceViewer(url, params);
} else if (vmtype === 'openvz') {
url = '/nodes/' + nodename + '/openvz/' + vmid.toString() + '/spiceproxy';
PVE.Utils.openSpiceViewer(url, params);
} else if (vmtype === 'shell') {
url = '/nodes/' + nodename + '/spiceshell';
PVE.Utils.openSpiceViewer(url, params);
} else if (vmtype === 'upgrade') {
url = '/nodes/' + nodename + '/spiceshell';
params.upgrade = 1;
PVE.Utils.openSpiceViewer(url, params);
}
} else {
throw "unknown viewer type";
}
},
defaultViewer: function(allowSpice) {
......@@ -1113,6 +1140,18 @@ Ext.define('PVE.Utils', { statics: {
return dv;
},
openVNCViewer: function(vmtype, vmid, nodename, vmname, novnc) {
var url = Ext.urlEncode({
console: vmtype, // kvm, openvz, upgrade or shell
novnc: novnc ? 1 : 0,
vmid: vmid,
vmname: vmname,
node: nodename
});
var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
nw.focus();
},
openSpiceViewer: function(url, params){
var downloadWithName = function(uri, name) {
......
......@@ -347,7 +347,7 @@ Ext.define('PVE.KVMConsole', {
{
text: gettext('Console'),
handler: function() {
PVE.Utils.openConsoleWindow('kvm', me.vmid, me.nodename, me.vmname, me.novnc);
PVE.Utils.openVNCViewer('kvm', me.vmid, me.nodename, me.vmname, me.novnc);
}
},
'->',
......@@ -506,7 +506,7 @@ Ext.define('PVE.Shell', {
{
text: gettext('Shell'),
handler: function() {
PVE.Utils.openConsoleWindow('shell', undefined, me.nodename, undefined, me.novnc);
PVE.Utils.openVNCViewer('shell', undefined, me.nodename, undefined, me.novnc);
}
}
]);
......
......@@ -26,83 +26,36 @@ Ext.define('PVE.button.ConsoleButton', {
throw "no node name specified";
}
if (!me.consoleName) {
if (me.consoleType === 'kvm') {
me.consoleName = "VM " + me.vmid.toString();
} else if (me.consoleType === 'openvz') {
me.consoleName = "CT " + me.vmid.toString();
} else {
me.consoleName = "Shell";
}
}
var create_spice_console = function() {
var url;
var params = { proxy: window.location.hostname };
if (me.consoleType === 'kvm') {
url = '/nodes/' + me.nodename + '/qemu/' +
me.vmid.toString() + '/spiceproxy';
PVE.Utils.openSpiceViewer(url, params);
} else if (me.consoleType === 'openvz') {
url = '/nodes/' + me.nodename + '/openvz/' +
me.vmid.toString() + '/spiceproxy';
PVE.Utils.openSpiceViewer(url, params);
} else if (me.consoleType === 'shell') {
url = '/nodes/' + me.nodename + '/spiceshell';
PVE.Utils.openSpiceViewer(url, params);
} else if (me.consoleType === 'upgrade') {
url = '/nodes/' + me.nodename + '/spiceshell';
params.upgrade = 1;
PVE.Utils.openSpiceViewer(url, params);
}
};
var create_vnc_console = function(novnc) {
if (me.consoleType === 'kvm') {
PVE.Utils.openConsoleWindow('kvm', me.vmid, me.nodename, me.consoleName, novnc);
} else if (me.consoleType === 'openvz') {
PVE.Utils.openConsoleWindow('openvz', me.vmid, me.nodename, me.consoleName, novnc);
} else if (me.consoleType === 'shell') {
PVE.Utils.openConsoleWindow('shell', undefined, me.nodename, undefined, novnc);
} else if (me.consoleType === 'upgrade') {
var url = Ext.urlEncode({ console: 'upgrade', node: me.nodename, novnc: novnc });
var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
nw.focus();
}
};
me.spiceMenu = Ext.create('Ext.menu.Item', {
text: 'SPICE',
iconCls: 'pve-itype-icon-virt-viewer',
handler: create_spice_console
handler: function() {
PVE.Utils.openConsoleWindow('vv', me.consoleType, me.vmid, me.nodename, me.consoleName);
}
});
var vncMenu = Ext.create('Ext.menu.Item', {
text: 'VNC',
iconCls: 'pve-itype-icon-tigervnc',
handler: function() { create_vnc_console(0); }
handler: function() {
PVE.Utils.openConsoleWindow('applet', me.consoleType, me.vmid, me.nodename, me.consoleName);
}
});
var noVncMenu = Ext.create('Ext.menu.Item', {
text: 'noVNC',
iconCls: 'pve-itype-icon-novnc',
handler: function() { create_vnc_console(1); }
handler: function() {
PVE.Utils.openConsoleWindow('html5', me.consoleType, me.vmid, me.nodename, me.consoleName);
}
});
Ext.applyIf(me, { text: gettext('Console') });
Ext.apply(me, {
handler: function() {
var dv = PVE.Utils.defaultViewer(me.enableSpice);
if (dv === 'vv') {
create_spice_console();
} else if (dv === 'applet') {
create_vnc_console(0);
} else if (dv === 'html5') {
create_vnc_console(1);
} else {
throw "unknown defaultViewer";
}
PVE.Utils.openDefaultConsoleWindow(me.enableSpice, me.consoleType, me.vmid,
me.nodename, me.consoleName);
},
menu: new Ext.menu.Menu({
items: [ noVncMenu, vncMenu, me.spiceMenu ]
......
......@@ -81,7 +81,7 @@ Ext.define('PVE.openvz.CmdMenu', {
text: gettext('Console'),
icon: '/pve2/images/display.png',
handler: function() {
PVE.Utils.openConsoleWindow('openvz', vmid, nodename, vmname);
PVE.Utils.openDefaultConsoleWindow(true, 'openvz', vmid, nodename, vmname);
}
}
];
......
......@@ -118,14 +118,8 @@ Ext.define('PVE.qemu.CmdMenu', {
Ext.Msg.alert('Error', response.htmlStatus);
},
success: function(response, opts) {
var spice = response.result.data.spice;
if (PVE.VersionInfo.console === 'applet' || !spice) {
PVE.Utils.openConsoleWindow('kvm', vmid, nodename, vmname);
} else {
var url = '/nodes/' + nodename + '/qemu/' + vmid + '/spiceproxy';
var params = { proxy: window.location.hostname };
PVE.Utils.openSpiceViewer(url, params);
}
var allowSpice = response.result.data.spice;
PVE.Utils.openDefaultConsoleWindow(allowSpice, 'kvm', vmid, nodename, vmname);
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment