From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3777A9B496 for ; Mon, 20 Nov 2023 15:19:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 140CF1A84F for ; Mon, 20 Nov 2023 15:18:54 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 20 Nov 2023 15:18:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4B466434AB for ; Mon, 20 Nov 2023 15:18:53 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Mon, 20 Nov 2023 15:18:52 +0100 Message-Id: <20231120141852.1105425-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.017 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH manager] fix #4873: use last used backup storage for the storage selector X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Nov 2023 14:19:24 -0000 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 --- 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