public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 pve-manager 2/2] ui: add bulk hibernate action
Date: Tue,  9 Feb 2021 11:31:24 +0100	[thread overview]
Message-ID: <20210209103124.1949709-3-h.laimer@proxmox.com> (raw)
In-Reply-To: <20210209103124.1949709-1-h.laimer@proxmox.com>

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---

The bulk action name usually matches the endpoint it will call, here,
however, the corresponding endpoint is responsible for hibernate and pause,
therefore in order to distinguish both actions the name does not match
the endpoint here. This also allows to possible add another bulk action
for pausing VMs later.

 www/manager6/Utils.js             |  2 ++
 www/manager6/form/VMSelector.js   | 34 ++++++++++++++++++++++---------
 www/manager6/node/CmdMenu.js      | 15 ++++++++++++++
 www/manager6/node/Config.js       | 13 ++++++++++++
 www/manager6/window/BulkAction.js |  7 +++++++
 5 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index ab4988b0..d3a44fa9 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1807,6 +1807,8 @@ Ext.define('PVE.Utils', {
 	    spiceshell: ['', gettext('Shell') + ' (Spice)'],
 	    startall: ['', gettext('Start all VMs and Containers')],
 	    stopall: ['', gettext('Stop all VMs and Containers')],
+	    hibernateall: ['', gettext('Hibernate all VMs')],
+	    suspendall: ['', gettext('Suspend all VMs')],
 	    unknownimgdel: ['', gettext('Destroy image from unknown guest')],
 	    vncproxy: ['VM/CT', gettext('Console')],
 	    vncshell: ['', gettext('Shell')],
diff --git a/www/manager6/form/VMSelector.js b/www/manager6/form/VMSelector.js
index 6a51a73d..b5cc0781 100644
--- a/www/manager6/form/VMSelector.js
+++ b/www/manager6/form/VMSelector.js
@@ -180,6 +180,7 @@ Ext.define('PVE.form.VMSelector', {
 	// only show the relevant guests by default
 	if (me.action) {
 	    var statusfilter = '';
+	    var typefilter = '';
 	    switch (me.action) {
 		case 'startall':
 		    statusfilter = 'stopped';
@@ -187,17 +188,30 @@ Ext.define('PVE.form.VMSelector', {
 		case 'stopall':
 		    statusfilter = 'running';
 		    break;
+		case 'suspendall':
+		    statusfilter = 'running';
+		    typefilter = 'qemu';
+		    break;
 	    }
-	    if (statusfilter !== '') {
-		me.store.filters.add({
-		    property: 'template',
-		    value: 0,
-		}, {
-		    id: 'x-gridfilter-status',
-		    operator: 'in',
-		    property: 'status',
-		    value: [statusfilter],
-		});
+	    if (statusfilter !== '' || typefilter !== '') {
+
+		if (statusfilter !== '') {
+		    me.store.filters.add({
+			id: 'x-gridfilter-status',
+			operator: 'in',
+			property: 'status',
+			value: [statusfilter],
+		    });
+		}
+
+		if (typefilter !== '') {
+		    me.store.filters.add({
+			id: 'x-gridfilter-type',
+			operator: 'in',
+			property: 'type',
+			value: [typefilter],
+		    });
+		}
 	    }
 	}
 
diff --git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js
index b650bfa0..b91c2efe 100644
--- a/www/manager6/node/CmdMenu.js
+++ b/www/manager6/node/CmdMenu.js
@@ -60,6 +60,21 @@ Ext.define('PVE.node.CmdMenu', {
 		win.show();
 	    },
 	},
+	{
+	    text: gettext('Bulk Hibernate'),
+	    itemId: 'bulksuspend',
+	    iconCls: 'fa fa-fw fa-download',
+	    handler: function() {
+		var me = this.up('menu');
+		var win = Ext.create('PVE.window.BulkAction', {
+		    nodename: me.nodename,
+		    title: gettext('Bulk Hibernate'),
+		    btnText: gettext('Hibernate'),
+		    action: 'hibernateall',
+		});
+		win.show();
+	    },
+	},
 	{
 	    text: gettext('Bulk Migrate'),
 	    itemId: 'bulkmigrate',
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index ef3ac32c..db3f0c2e 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -63,6 +63,19 @@ Ext.define('PVE.node.Config', {
 			    win.show();
 			},
 		    },
+		    {
+			text: gettext('Bulk Hibernate'),
+			iconCls: 'fa fa-fw fa-download',
+			handler: function() {
+			    var win = Ext.create('PVE.window.BulkAction', {
+				nodename: nodename,
+				title: gettext('Bulk Hibernate'),
+				btnText: gettext('Hibernate'),
+				action: 'hibernateall',
+			    });
+			    win.show();
+			},
+		    },
 		    {
 			text: gettext('Bulk Migrate'),
 			iconCls: 'fa fa-fw fa-send-o',
diff --git a/www/manager6/window/BulkAction.js b/www/manager6/window/BulkAction.js
index 135f570f..488b82ff 100644
--- a/www/manager6/window/BulkAction.js
+++ b/www/manager6/window/BulkAction.js
@@ -117,6 +117,13 @@ Ext.define('PVE.window.BulkAction', {
 		name: 'force',
 		value: 1,
 	    });
+	} else if (me.action === 'hibernateall') {
+	    me.action = 'suspendall';
+	    items.push({
+		xtype: 'hiddenfield',
+		name: 'todisk',
+		value: 1,
+	    });
 	}
 
 	items.push({
-- 
2.20.1





      parent reply	other threads:[~2021-02-09 10:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 10:31 [pve-devel] [PATCH v2 pve-manager 0/2] add bulk hibernation action Hannes Laimer
2021-02-09 10:31 ` [pve-devel] [PATCH v2 pve-manager 1/2] api2: add suspendall endpoint Hannes Laimer
2021-02-19 16:41   ` Thomas Lamprecht
2021-02-09 10:31 ` Hannes Laimer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210209103124.1949709-3-h.laimer@proxmox.com \
    --to=h.laimer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal