// Auto-extracted from backup-page.js (verbatim) — augments BackupPage.prototype. Loaded after the base.
Object.assign(BackupPage.prototype, {
renderBackupSshKeyCard(l) {
const idx = l.idx;
const hasKey = l.ssh_key_exists === true;
const pub = l.ssh_public_key || '';
const body = hasKey ? `
Add this public key to the remote server's ~/.ssh/authorized_keys:
` : `
Paste an existing private key, or generate one and we'll show the public key to add on the remote.
`;
return `
SSH key
${hasKey ? '✓ Key configured' : 'No key yet'}
${body}
`;
},
async saveBackupSshKey(idx) {
const card = document.querySelector(`.backup-ssh-key-card[data-loc="${idx}"]`);
const key = (card?.querySelector('.backup-ssh-keyinput')?.value || '').trim();
if (!key) { this.notify('Paste a private key first', 'error'); return; }
const b64 = btoa(unescape(encodeURIComponent(key + '\n')));
await this.runTask(`libreportal backup location ssh-key-set ${idx} ${b64}`, 'backup', null);
},
async generateBackupSshKey(idx) {
await this.runTask(`libreportal backup location ssh-key-generate ${idx}`, 'backup', null);
},
async deleteBackupSshKey(idx) {
if (!confirm("Delete this location's SSH key? Backups here will fail until a new key is set and added on the remote.")) return;
await this.runTask(`libreportal backup location ssh-key-delete ${idx}`, 'backup', null);
},
async copyBackupSshKey(idx) {
const loc = (this.locations?.locations || []).find(l => l.idx === idx);
const pub = loc?.ssh_public_key || '';
try { await navigator.clipboard.writeText(pub); this.notify('Public key copied', 'success'); }
catch { this.notify('Copy failed — select the text and copy manually', 'error'); }
},
});