Commit 47b80718 authored by Dietmar Maurer's avatar Dietmar Maurer

display VM name in console title window

parent 5e8c9a28
...@@ -695,10 +695,11 @@ Ext.define('PVE.Utils', { statics: { ...@@ -695,10 +695,11 @@ Ext.define('PVE.Utils', { statics: {
return PVE.Utils.format_task_description(type, id); return PVE.Utils.format_task_description(type, id);
}, },
openConoleWindow: function(vmtype, vmid, nodename) { openConoleWindow: function(vmtype, vmid, nodename, vmname) {
var url = Ext.urlEncode({ var url = Ext.urlEncode({
console: vmtype, // kvm or openvz console: vmtype, // kvm, openvz or shell
vmid: vmid, vmid: vmid,
vmname: vmname,
node: nodename node: nodename
}); });
var nw = window.open("?" + url, '_blank', var nw = window.open("?" + url, '_blank',
......
...@@ -320,7 +320,7 @@ Ext.define('PVE.KVMConsole', { ...@@ -320,7 +320,7 @@ Ext.define('PVE.KVMConsole', {
{ {
text: gettext('Console'), text: gettext('Console'),
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('kvm', me.vmid, me.nodename); PVE.Utils.openConoleWindow('kvm', me.vmid, me.nodename, me.vmname);
} }
} }
]; ];
...@@ -414,7 +414,7 @@ Ext.define('PVE.OpenVZConsole', { ...@@ -414,7 +414,7 @@ Ext.define('PVE.OpenVZConsole', {
{ {
text: gettext('Console'), text: gettext('Console'),
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('openvz', me.vmid, me.nodename); PVE.Utils.openConoleWindow('openvz', me.vmid, me.nodename, me.vmname);
} }
} }
]; ];
......
...@@ -119,22 +119,30 @@ Ext.define('PVE.ConsoleWorkspace', { ...@@ -119,22 +119,30 @@ Ext.define('PVE.ConsoleWorkspace', {
var content; var content;
if (consoleType === 'kvm') { if (consoleType === 'kvm') {
me.title = "VM " + param.vmid; me.title = "VM " + param.vmid;
if (param.vmname) {
me.title += " ('" + param.vmname + "')";
}
content = { content = {
xtype: 'pveKVMConsole', xtype: 'pveKVMConsole',
vmid: param.vmid, vmid: param.vmid,
nodename: param.node, nodename: param.node,
vmname: param.vmname,
toplevel: true toplevel: true
}; };
} else if (consoleType === 'openvz') { } else if (consoleType === 'openvz') {
me.title = "CT " + param.vmid; me.title = "CT " + param.vmid;
if (param.vmname) {
me.title += " ('" + param.vmname + "')";
}
content = { content = {
xtype: 'pveOpenVZConsole', xtype: 'pveOpenVZConsole',
vmid: param.vmid, vmid: param.vmid,
nodename: param.node, nodename: param.node,
vmname: param.vmname,
toplevel: true toplevel: true
}; };
} else if (consoleType === 'shell') { } else if (consoleType === 'shell') {
me.title = "node " + param.node + " - Proxmox Shell"; me.title = "node '" + param.node + "' - Proxmox Shell";
content = { content = {
xtype: 'pveShell', xtype: 'pveShell',
nodename: param.node, nodename: param.node,
......
...@@ -4,18 +4,22 @@ Ext.define('PVE.openvz.CmdMenu', { ...@@ -4,18 +4,22 @@ Ext.define('PVE.openvz.CmdMenu', {
initComponent: function() { initComponent: function() {
var me = this; var me = this;
if (!me.nodename) { var nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified"; throw "no node name specified";
} }
if (!me.vmid) { var vmid = me.pveSelNode.data.vmid;
if (!vmid) {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var vmname = me.pveSelNode.data.name;
var vm_command = function(cmd, params) { var vm_command = function(cmd, params) {
PVE.Utils.API2Request({ PVE.Utils.API2Request({
params: params, params: params,
url: '/nodes/' + me.nodename + '/openvz/' + me.vmid + "/status/" + cmd, url: '/nodes/' + nodename + '/openvz/' + vmid + "/status/" + cmd,
method: 'POST', method: 'POST',
failure: function(response, opts) { failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus); Ext.Msg.alert('Error', response.htmlStatus);
...@@ -23,7 +27,7 @@ Ext.define('PVE.openvz.CmdMenu', { ...@@ -23,7 +27,7 @@ Ext.define('PVE.openvz.CmdMenu', {
}); });
}; };
me.title = "CT " + me.vmid; me.title = "CT " + vmid;
me.items = [ me.items = [
{ {
...@@ -37,7 +41,7 @@ Ext.define('PVE.openvz.CmdMenu', { ...@@ -37,7 +41,7 @@ Ext.define('PVE.openvz.CmdMenu', {
text: gettext('Shutdown'), text: gettext('Shutdown'),
icon: '/pve2/images/stop.png', icon: '/pve2/images/stop.png',
handler: function() { handler: function() {
var msg = Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), me.vmid); var msg = Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
if (btn !== 'yes') { if (btn !== 'yes') {
return; return;
...@@ -51,7 +55,7 @@ Ext.define('PVE.openvz.CmdMenu', { ...@@ -51,7 +55,7 @@ Ext.define('PVE.openvz.CmdMenu', {
text: gettext('Console'), text: gettext('Console'),
icon: '/pve2/images/display.png', icon: '/pve2/images/display.png',
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('openvz', me.vmid, me.nodename); PVE.Utils.openConoleWindow('openvz', vmid, nodename, vmname);
} }
} }
]; ];
......
...@@ -82,14 +82,15 @@ Ext.define('PVE.openvz.Config', { ...@@ -82,14 +82,15 @@ Ext.define('PVE.openvz.Config', {
} }
}); });
var vmname = me.pveSelNode.data.name;
var consoleBtn = Ext.create('Ext.Button', { var consoleBtn = Ext.create('Ext.Button', {
text: gettext('Console'), text: gettext('Console'),
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('openvz', vmid, nodename); PVE.Utils.openConoleWindow('openvz', vmid, nodename, vmname);
} }
}); });
var vmname = me.pveSelNode.data.name;
var descr = vmid + " (" + (vmname ? "'" + vmname + "' " : "'CT " + vmid + "'") + ")"; var descr = vmid + " (" + (vmname ? "'" + vmname + "' " : "'CT " + vmid + "'") + ")";
Ext.apply(me, { Ext.apply(me, {
......
...@@ -4,18 +4,22 @@ Ext.define('PVE.qemu.CmdMenu', { ...@@ -4,18 +4,22 @@ Ext.define('PVE.qemu.CmdMenu', {
initComponent: function() { initComponent: function() {
var me = this; var me = this;
if (!me.nodename) { var nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified"; throw "no node name specified";
} }
if (!me.vmid) { var vmid = me.pveSelNode.data.vmid;
if (!vmid) {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var vmname = me.pveSelNode.data.name;
var vm_command = function(cmd, params) { var vm_command = function(cmd, params) {
PVE.Utils.API2Request({ PVE.Utils.API2Request({
params: params, params: params,
url: '/nodes/' + me.nodename + '/qemu/' + me.vmid + "/status/" + cmd, url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd,
method: 'POST', method: 'POST',
failure: function(response, opts) { failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus); Ext.Msg.alert('Error', response.htmlStatus);
...@@ -23,7 +27,7 @@ Ext.define('PVE.qemu.CmdMenu', { ...@@ -23,7 +27,7 @@ Ext.define('PVE.qemu.CmdMenu', {
}); });
}; };
me.title = "VM " + me.vmid; me.title = "VM " + vmid;
me.items = [ me.items = [
{ {
...@@ -37,7 +41,7 @@ Ext.define('PVE.qemu.CmdMenu', { ...@@ -37,7 +41,7 @@ Ext.define('PVE.qemu.CmdMenu', {
text: gettext('Shutdown'), text: gettext('Shutdown'),
icon: '/pve2/images/stop.png', icon: '/pve2/images/stop.png',
handler: function() { handler: function() {
var msg = Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), me.vmid); var msg = Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
if (btn !== 'yes') { if (btn !== 'yes') {
return; return;
...@@ -51,7 +55,7 @@ Ext.define('PVE.qemu.CmdMenu', { ...@@ -51,7 +55,7 @@ Ext.define('PVE.qemu.CmdMenu', {
text: gettext('Console'), text: gettext('Console'),
icon: '/pve2/images/display.png', icon: '/pve2/images/display.png',
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('kvm', me.vmid, me.nodename); PVE.Utils.openConoleWindow('kvm', vmid, nodename, vmname);
} }
} }
]; ];
......
...@@ -90,14 +90,15 @@ Ext.define('PVE.qemu.Config', { ...@@ -90,14 +90,15 @@ Ext.define('PVE.qemu.Config', {
} }
}); });
var vmname = me.pveSelNode.data.name;
var consoleBtn = Ext.create('Ext.Button', { var consoleBtn = Ext.create('Ext.Button', {
text: gettext('Console'), text: gettext('Console'),
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('kvm', vmid, nodename); PVE.Utils.openConoleWindow('kvm', vmid, nodename, vmname);
} }
}); });
var vmname = me.pveSelNode.data.name;
var descr = vmid + " (" + (vmname ? "'" + vmname + "' " : "'VM " + vmid + "'") + ")"; var descr = vmid + " (" + (vmname ? "'" + vmname + "' " : "'VM " + vmid + "'") + ")";
Ext.apply(me, { Ext.apply(me, {
......
...@@ -329,13 +329,11 @@ Ext.define('PVE.tree.ResourceTree', { ...@@ -329,13 +329,11 @@ Ext.define('PVE.tree.ResourceTree', {
if (record.data.type === 'qemu') { if (record.data.type === 'qemu') {
menu = Ext.create('PVE.qemu.CmdMenu', { menu = Ext.create('PVE.qemu.CmdMenu', {
vmid: record.data.vmid, pveSelNode: record
nodename: record.data.node
}); });
} else if (record.data.type === 'openvz') { } else if (record.data.type === 'openvz') {
menu = Ext.create('PVE.openvz.CmdMenu', { menu = Ext.create('PVE.openvz.CmdMenu', {
vmid: record.data.vmid, pveSelNode: record
nodename: record.data.node
}); });
} else { } else {
return; return;
......
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