From 3b5ea6f6923ea2da1d6fdd037fb4ba835d448200 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Date: Sat, 6 Sep 2025 11:38:59 +0530 Subject: [PATCH] feat: add export JSON option for SSH hosts (#173) --- .../Host Manager/HostManagerHostViewer.tsx | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/ui/Apps/Host Manager/HostManagerHostViewer.tsx b/src/ui/Apps/Host Manager/HostManagerHostViewer.tsx index 33574649..16d6012a 100644 --- a/src/ui/Apps/Host Manager/HostManagerHostViewer.tsx +++ b/src/ui/Apps/Host Manager/HostManagerHostViewer.tsx @@ -86,6 +86,37 @@ export function HostManagerHostViewer({onEditHost}: SSHManagerHostViewerProps) { } }; + const handleExport = (host: SSHHost) => { + const exportData = { + name: host.name, + ip: host.ip, + port: host.port, + username: host.username, + authType: host.authType, + folder: host.folder, + tags: host.tags, + pin: host.pin, + enableTerminal: host.enableTerminal, + enableTunnel: host.enableTunnel, + enableFileManager: host.enableFileManager, + defaultPath: host.defaultPath, + tunnelConnections: host.tunnelConnections, + }; + + const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = `${host.name || host.username + '@' + host.ip}-credentials.json`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + + toast.success(`Exported credentials for ${host.name || host.username}@${host.ip}`); +}; + + const handleEdit = (host: SSHHost) => { if (onEditHost) { onEditHost(host); @@ -427,6 +458,18 @@ export function HostManagerHostViewer({onEditHost}: SSHManagerHostViewerProps) { > + +