* [pve-devel] [PATCH manager] ui: PBSEdit: cleanup iframe for paperkey
@ 2023-03-10 14:36 Aaron Lauterer
2023-03-11 16:49 ` Thomas Lamprecht
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Lauterer @ 2023-03-10 14:36 UTC (permalink / raw)
To: pve-devel
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@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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] [PATCH manager] ui: PBSEdit: cleanup iframe for paperkey
2023-03-10 14:36 [pve-devel] [PATCH manager] ui: PBSEdit: cleanup iframe for paperkey Aaron Lauterer
@ 2023-03-11 16:49 ` Thomas Lamprecht
2023-03-13 8:30 ` Aaron Lauterer
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Lamprecht @ 2023-03-11 16:49 UTC (permalink / raw)
To: Proxmox VE development discussion, Aaron Lauterer
Am 10/03/2023 um 15:36 schrieb Aaron Lauterer:
> Otherwise the iframe used to print the paperkey will remain even after
> the encryption key window is closed.
thanks for noticing!
> Additionally clean before creating a new one as otherwise we might end
> up with multiple iframes.
having to do both seems wrong. Why not add a on close or on destroy listener
on the window which handles that always correctly in a single place?
>
> Signed-off-by: Aaron Lauterer <a.lauterer@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;
You could replace the whole patch with adding the following line here:
me.on('destroy', () => document.body.removeChild(printFrame));
can also apply directly with a Reported-by tag if you see nothing off with this,
whatever you prefer?
> },
> });
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] [PATCH manager] ui: PBSEdit: cleanup iframe for paperkey
2023-03-11 16:49 ` Thomas Lamprecht
@ 2023-03-13 8:30 ` Aaron Lauterer
2023-03-13 9:50 ` Thomas Lamprecht
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Lauterer @ 2023-03-13 8:30 UTC (permalink / raw)
To: Thomas Lamprecht, Proxmox VE development discussion
On 3/11/23 17:49, Thomas Lamprecht wrote:
> Am 10/03/2023 um 15:36 schrieb Aaron Lauterer:
>> Otherwise the iframe used to print the paperkey will remain even after
>> the encryption key window is closed.
>
> thanks for noticing!
>
>> Additionally clean before creating a new one as otherwise we might end
>> up with multiple iframes.
>
> having to do both seems wrong. Why not add a on close or on destroy listener
> on the window which handles that always correctly in a single place?
>
>>
>> Signed-off-by: Aaron Lauterer <a.lauterer@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
[...]
>> @@ -181,6 +187,7 @@ ${prettifiedKey}
>>
>> printFrame.src = "data:text/html;base64," + btoa(html);
>> document.body.appendChild(printFrame);
>> + return printFrame;
>
> You could replace the whole patch with adding the following line here:
>
> me.on('destroy', () => document.body.removeChild(printFrame));
>
> can also apply directly with a Reported-by tag if you see nothing off with this,
> whatever you prefer?
Sure go ahead. Your approach is a lot cleaner. :)
>
>> },
>> });
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] [PATCH manager] ui: PBSEdit: cleanup iframe for paperkey
2023-03-13 8:30 ` Aaron Lauterer
@ 2023-03-13 9:50 ` Thomas Lamprecht
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2023-03-13 9:50 UTC (permalink / raw)
To: Proxmox VE development discussion, Aaron Lauterer
Am 13/03/2023 um 09:30 schrieb Aaron Lauterer:
> On 3/11/23 17:49, Thomas Lamprecht wrote:
>> Am 10/03/2023 um 15:36 schrieb Aaron Lauterer:
>>> @@ -181,6 +187,7 @@ ${prettifiedKey}
>>> printFrame.src = "data:text/html;base64," + btoa(html);
>>> document.body.appendChild(printFrame);
>>> + return printFrame;
>>
>> You could replace the whole patch with adding the following line here:
>>
>> me.on('destroy', () => document.body.removeChild(printFrame));
>>
>> can also apply directly with a Reported-by tag if you see nothing off with this,
>> whatever you prefer?
>
> Sure go ahead. Your approach is a lot cleaner. :)
>
Ack, pushed:
https://git.proxmox.com/?p=pve-manager.git;a=commitdiff;h=b380cb5814ec551588dfcbd6c5ed190f01d54029
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-13 9:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 14:36 [pve-devel] [PATCH manager] ui: PBSEdit: cleanup iframe for paperkey Aaron Lauterer
2023-03-11 16:49 ` Thomas Lamprecht
2023-03-13 8:30 ` Aaron Lauterer
2023-03-13 9:50 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox