public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] fix #4873: use last used backup storage for the storage selector
Date: Mon, 20 Nov 2023 15:18:52 +0100	[thread overview]
Message-ID: <20231120141852.1105425-1-d.csapak@proxmox.com> (raw)

for this, we invent the 'storageStateId' parameter that is undeifned by
default, but if set, the storage selector saves it's value on every
change there and on initial load (when no value is set from outside)
loads it from there and uses that as its value.

for now only use it for the selection of backup storages namely in:
* backup grid
* "backup now" edit window
* backup job edit window

in the future we could use that to have a 'last used disk image' or
'last used iso' storage too if this approach fits

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---

the backup job edit is a bit weird and probably warrants a bit of
discussion, since the interaction when editing an existing job is imho
unexpected:

 1. select backup storage X in backup grid
 2. edit a backup job where storage Y is selected (that happens
    correctly) but don't touch the storage field
 3. now storage Y is the last used and selected on the grids

 www/manager6/dc/Backup.js            |  1 +
 www/manager6/form/StorageSelector.js | 14 ++++++++++++++
 www/manager6/grid/BackupView.js      |  1 +
 www/manager6/window/Backup.js        |  1 +
 4 files changed, 17 insertions(+)

diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index 9aae4090..28b41b2b 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -250,6 +250,7 @@ Ext.define('PVE.dc.BackupEdit', {
 				{
 				    xtype: 'pveStorageSelector',
 				    reference: 'storageSelector',
+				    storageStateId: 'pve-last-backup-storage',
 				    fieldLabel: gettext('Storage'),
 				    clusterView: true,
 				    storageContent: 'backup',
diff --git a/www/manager6/form/StorageSelector.js b/www/manager6/form/StorageSelector.js
index 872bc1ab..0a43712f 100644
--- a/www/manager6/form/StorageSelector.js
+++ b/www/manager6/form/StorageSelector.js
@@ -147,6 +147,15 @@ Ext.define('PVE.form.StorageSelector', {
 	me.reloadStorageList();
     },
 
+    listeners: {
+	change: function(selector, storage) {
+	    if (selector.storageStateId){
+		let sp = Ext.state.Manager.getProvider();
+		sp.set(selector.storageStateId, storage);
+	    }
+	},
+    },
+
     initComponent: function() {
 	var me = this;
 
@@ -168,6 +177,11 @@ Ext.define('PVE.form.StorageSelector', {
 	me.callParent();
 
 	me.setNodename(nodename);
+
+	if ((!me.value || !me.value.length) && me.storageStateId) {
+	    let sp = Ext.state.Manager.getProvider();
+	    me.setValue(sp.get(me.storageStateId));
+	}
     },
 }, function() {
     Ext.define('pve-storage-status', {
diff --git a/www/manager6/grid/BackupView.js b/www/manager6/grid/BackupView.js
index 65340dcb..8af51b34 100644
--- a/www/manager6/grid/BackupView.js
+++ b/www/manager6/grid/BackupView.js
@@ -104,6 +104,7 @@ Ext.define('PVE.grid.BackupView', {
 
 	var storagesel = Ext.create('PVE.form.StorageSelector', {
 	    nodename: nodename,
+	    storageStateId: 'pve-last-backup-storage',
 	    fieldLabel: gettext('Storage'),
 	    labelAlign: 'right',
 	    storageContent: 'backup',
diff --git a/www/manager6/window/Backup.js b/www/manager6/window/Backup.js
index 8d8c9ff0..2b263a9a 100644
--- a/www/manager6/window/Backup.js
+++ b/www/manager6/window/Backup.js
@@ -73,6 +73,7 @@ Ext.define('PVE.window.Backup', {
 
 	var storagesel = Ext.create('PVE.form.StorageSelector', {
 	    nodename: me.nodename,
+	    storageStateId: 'pve-last-backup-storage',
 	    name: 'storage',
 	    fieldLabel: gettext('Storage'),
 	    storageContent: 'backup',
-- 
2.30.2





             reply	other threads:[~2023-11-20 14:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 14:18 Dominik Csapak [this message]
2024-01-26 13:27 ` Fiona Ebner

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=20231120141852.1105425-1-d.csapak@proxmox.com \
    --to=d.csapak@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