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