* [pve-devel] [PATCH manager] fix #4873: use last used backup storage for the storage selector
@ 2023-11-20 14:18 Dominik Csapak
2024-01-26 13:27 ` Fiona Ebner
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2023-11-20 14:18 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pve-devel] [PATCH manager] fix #4873: use last used backup storage for the storage selector
2023-11-20 14:18 [pve-devel] [PATCH manager] fix #4873: use last used backup storage for the storage selector Dominik Csapak
@ 2024-01-26 13:27 ` Fiona Ebner
0 siblings, 0 replies; 2+ messages in thread
From: Fiona Ebner @ 2024-01-26 13:27 UTC (permalink / raw)
To: Proxmox VE development discussion, Dominik Csapak
Am 20.11.23 um 15:18 schrieb Dominik Csapak:
> 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>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@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
>
Agreed, but it's still more convenient with the patch than without.
Could we maybe only enable the state update from the second change event
onward? AFAIU, there will always be one change event to set the initial
value and for that we could simply not update the state.
> 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){
eslint complains here because of missing space
> + let sp = Ext.state.Manager.getProvider();
> + sp.set(selector.storageStateId, storage);
Is this state fully global? If yes, is limiting it to instances of the
'PVE.form.StorageSelector' xtype possible/feasible?
> + }
> + },
> + },
> +
> initComponent: function() {
> var me = this;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-26 13:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 14:18 [pve-devel] [PATCH manager] fix #4873: use last used backup storage for the storage selector Dominik Csapak
2024-01-26 13:27 ` Fiona Ebner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox