luci-proto-wireguard: add download link for peer config

Ease download of the generated config.

Closes #8389

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald
2026-03-05 16:09:23 +01:00
parent 0d5a250bcc
commit ec799109e5

View File

@@ -808,7 +808,30 @@ return network.registerProtocol('wireguard', {
}, [ peer_config ])
]);
const linkdiv = E('div', {
'style': 'width:100%;text-align:center'
}, [
E('button', {
'class': 'btn',
'click'(ev) {
ev.preventDefault();
const blob = new Blob([peer_config], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'wireguard-peer.conf';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
}, [ _('Download peer configuration file') ])
]);
buildSVGQRCode(peer_config, node.firstChild);
node.appendChild(linkdiv);
return node;
};