[pve-devel] [PATCH manager] ui: PBSEdit: cleanup iframe for paperkey

Aaron Lauterer a.lauterer at proxmox.com
Fri Mar 10 15:36:57 CET 2023


Otherwise the iframe used to print the paperkey will remain even after
the encryption key window is closed.
Additionally clean before creating a new one as otherwise we might end
up with multiple iframes.

Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---
 www/manager6/storage/PBSEdit.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/www/manager6/storage/PBSEdit.js b/www/manager6/storage/PBSEdit.js
index 5b6b6bb8..dbc88668 100644
--- a/www/manager6/storage/PBSEdit.js
+++ b/www/manager6/storage/PBSEdit.js
@@ -112,7 +112,10 @@ Ext.define('PVE.Storage.PBSKeyShow', {
 			    width: 110,
 			    handler: function(b) {
 				let win = this.up('window');
-				win.paperkey(win.key);
+				if (win.printFrame) {
+				    document.body.removeChild(win.printFrame);
+				}
+				win.printFrame = win.paperkey(win.key, win.printFrame);
 			    },
 			},
 		    ],
@@ -132,6 +135,9 @@ Ext.define('PVE.Storage.PBSKeyShow', {
 	    text: gettext('Close'),
 	    handler: function(b) {
 		let win = this.up('window');
+		if (win.printFrame) {
+		    document.body.removeChild(win.printFrame);
+		}
 		win.close();
 	    },
 	},
@@ -181,6 +187,7 @@ ${prettifiedKey}
 
 	printFrame.src = "data:text/html;base64," + btoa(html);
 	document.body.appendChild(printFrame);
+	return printFrame;
     },
 });
 
-- 
2.30.2






More information about the pve-devel mailing list