[pve-devel] [PATCH manager v2 3/4] make contextmenus status-sensitive
Dominik Csapak
d.csapak at proxmox.com
Tue Apr 5 11:31:47 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 53652a8..a21edfc 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 = PVE.Utils.format_task_description('vzsuspend', 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 = PVE.Utils.format_task_description('vzshutdown', 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 = PVE.Utils.format_task_description('vzstop', vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js
index 864060b..719d136 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 = PVE.Utils.format_task_description('qmsuspend', 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 = PVE.Utils.format_task_description('qmshutdown', 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 = PVE.Utils.format_task_description('qmstop', vmid);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
--
2.1.4
More information about the pve-devel
mailing list