From f72be0be7c71b96ebff7edbf782068342639e8ea Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Sat, 13 May 2023 06:36:31 -0400 Subject: [PATCH] feat(rsync-backup-ui): Add a Copy button to put public key on clipboard in rsync UI (#2227) --- management/templates/system-backup.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/management/templates/system-backup.html b/management/templates/system-backup.html index ad534f41..422b2a0e 100644 --- a/management/templates/system-backup.html +++ b/management/templates/system-backup.html @@ -73,6 +73,9 @@ passwordless authentication from your mail-in-a-box server and your backup server. +
+ +
@@ -374,4 +377,15 @@ const url_split = url => { } }; +// Hide Copy button if not in a modern clipboard-supporting environment. +// Using document API because jQuery is not necessarily available in this script scope. +if (!(navigator && navigator.clipboard && navigator.clipboard.writeText)) { + document.getElementById('copy_pub_key_div').hidden = true; +} + +function copy_pub_key_to_clipboard() { + const ssh_pub_key = $("#ssh-pub-key").val(); + navigator.clipboard.writeText(ssh_pub_key); +} +