[pve-devel] [PATCH manager 3/4] make contextmenus status-sensitive
Dominik Csapak
d.csapak at proxmox.com
Mon Apr 4 14:07:41 CEST 2016
for example, allow starting from contextmenu
only if vm/ct is stopped, etc.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/lxc/CmdMenu.js | 21 +++++++++++++++++++++
www/manager6/qemu/CmdMenu.js | 21 +++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/www/manager6/lxc/CmdMenu.js b/www/manager6/lxc/CmdMenu.js
index 5046269..5f0c428 100644
--- a/www/manager6/lxc/CmdMenu.js
+++ b/www/manager6/lxc/CmdMenu.js
@@ -27,12 +27,29 @@ Ext.define('PVE.lxc.CmdMenu', {
});
};
+ var running = false;
+ var stopped = true;
+ var suspended = false;
+
+ switch (me.pveSelNode.data.status) {
+ case 'running':
+ running = true;
+ stopped = false;
+ break;
+ case 'paused':
+ stopped = false;
+ suspended = true;
+ break;
+ default: break;
+ }
+
me.title = 'CT ' + vmid;
me.items = [
{
text: gettext('Start'),
iconCls: 'fa fa-fw fa-play',
+ disabled: running,
handler: function() {
vm_command('start');
}
@@ -52,6 +69,7 @@ Ext.define('PVE.lxc.CmdMenu', {
{
text: gettext('Suspend'),
iconCls: 'fa fa-fw fa-pause',
+ disabled: stopped || suspended,
handler: function() {
var msg = Ext.String.format(gettext("Do you really want to suspend {0}?"), 'CT ' + vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
@@ -66,6 +84,7 @@ Ext.define('PVE.lxc.CmdMenu', {
{
text: gettext('Resume'),
iconCls: 'fa fa-fw fa-play',
+ disabled: !suspended,
handler: function() {
vm_command('resume');
}
@@ -73,6 +92,7 @@ Ext.define('PVE.lxc.CmdMenu', {
{
text: gettext('Shutdown'),
iconCls: 'fa fa-fw fa-power-off',
+ disabled: stopped || suspended,
handler: function() {
var msg = Ext.String.format(gettext("Do you really want to shutdown {0}?"), 'CT ' + vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
@@ -87,6 +107,7 @@ Ext.define('PVE.lxc.CmdMenu', {
{
text: gettext('Stop'),
iconCls: 'fa fa-fw fa-stop',
+ disabled: stopped,
handler: function() {
var msg = Ext.String.format(gettext("Do you really want to stop {0}?"), 'CT ' + vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js
index a5261c3..79bfe38 100644
--- a/www/manager6/qemu/CmdMenu.js
+++ b/www/manager6/qemu/CmdMenu.js
@@ -27,12 +27,29 @@ Ext.define('PVE.qemu.CmdMenu', {
});
};
+ var running = false;
+ var stopped = true;
+ var suspended = false;
+
+ switch (me.pveSelNode.data.status) {
+ case 'running':
+ running = true;
+ stopped = false;
+ break;
+ case 'paused':
+ stopped = false;
+ suspended = true;
+ break;
+ default: break;
+ }
+
me.title = "VM " + vmid;
me.items = [
{
text: gettext('Start'),
iconCls: 'fa fa-fw fa-play',
+ disabled: running,
handler: function() {
vm_command('start');
}
@@ -52,6 +69,7 @@ Ext.define('PVE.qemu.CmdMenu', {
{
text: gettext('Suspend'),
iconCls: 'fa fa-fw fa-pause',
+ disabled: stopped || suspended,
handler: function() {
var msg = Ext.String.format(gettext("Do you really want to suspend {0}?"), 'VM ' + vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
@@ -65,6 +83,7 @@ Ext.define('PVE.qemu.CmdMenu', {
{
text: gettext('Resume'),
iconCls: 'fa fa-fw fa-play',
+ disabled: !suspended,
handler: function() {
vm_command('resume');
}
@@ -72,6 +91,7 @@ Ext.define('PVE.qemu.CmdMenu', {
{
text: gettext('Shutdown'),
iconCls: 'fa fa-fw fa-power-off',
+ disabled: stopped || suspended,
handler: function() {
var msg = Ext.String.format(gettext("Do you really want to shutdown {0}?"), 'VM ' + vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
@@ -86,6 +106,7 @@ Ext.define('PVE.qemu.CmdMenu', {
{
text: gettext('Stop'),
iconCls: 'fa fa-fw fa-stop',
+ disabled: stopped,
handler: function() {
var msg = Ext.String.format(gettext("Do you really want to stop {0}?"), 'VM ' + vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
--
2.1.4
More information about the pve-devel
mailing list