feat: add export option for ssh hosts (#173) (#187)

* Update issue templates

* feat: add export JSON option for SSH hosts (#173)

---------

Co-authored-by: Karmaa <88517757+LukeGus@users.noreply.github.com>
Co-authored-by: LukeGus <bugattiguy527@gmail.com>
This commit was merged in pull request #187.
This commit is contained in:
Shivam Kumar
2025-09-08 10:30:46 +05:30
committed by GitHub
parent 5f6792dc0d
commit aa04597e16
3 changed files with 94 additions and 0 deletions

View File

@@ -110,6 +110,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);
@@ -787,6 +818,18 @@ export function HostManagerHostViewer({onEditHost}: SSHManagerHostViewerProps) {
>
<Trash2 className="h-3 w-3"/>
</Button>
<Button
size="sm"
variant="ghost"
onClick={(e) => {
e.stopPropagation();
handleExport(host);
}}
className="h-5 w-5 p-0 text-blue-500 hover:text-blue-700"
>
<Upload className="h-3 w-3"/>
</Button>
</div>
</div>