fix: wrap ssh host json export in hosts array

This commit is contained in:
LukeGus
2025-12-22 02:09:45 -06:00
parent 28729e3de2
commit a73f767072
4 changed files with 76 additions and 53 deletions

View File

@@ -1,5 +1,6 @@
import type { Client } from "ssh2"; import type { Client } from "ssh2";
import { execCommand } from "./common-utils.js"; import { execCommand } from "./common-utils.js";
import { statsLogger } from "../../utils/logger.js";
export interface LoginRecord { export interface LoginRecord {
user: string; user: string;

View File

@@ -8,8 +8,8 @@ export async function collectProcessesMetrics(client: Client): Promise<{
top: Array<{ top: Array<{
pid: string; pid: string;
user: string; user: string;
cpu: number; cpu: string;
mem: number; mem: string;
command: string; command: string;
}>; }>;
}> { }> {
@@ -18,8 +18,8 @@ export async function collectProcessesMetrics(client: Client): Promise<{
const topProcesses: Array<{ const topProcesses: Array<{
pid: string; pid: string;
user: string; user: string;
cpu: number; cpu: string;
mem: number; mem: string;
command: string; command: string;
}> = []; }> = [];
@@ -38,8 +38,8 @@ export async function collectProcessesMetrics(client: Client): Promise<{
topProcesses.push({ topProcesses.push({
pid: parts[1], pid: parts[1],
user: parts[0], user: parts[0],
cpu: Number.isFinite(cpuVal) ? cpuVal : 0, cpu: Number.isFinite(cpuVal) ? cpuVal.toString() : "0",
mem: Number.isFinite(memVal) ? memVal : 0, mem: Number.isFinite(memVal) ? memVal.toString() : "0",
command: parts.slice(10).join(" ").substring(0, 50), command: parts.slice(10).join(" ").substring(0, 50),
}); });
} }

View File

@@ -363,7 +363,12 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) {
), ),
); );
const blob = new Blob([JSON.stringify(cleanExportData, null, 2)], { // Wrap in hosts array for valid import format
const exportFormat = {
hosts: [cleanExportData],
};
const blob = new Blob([JSON.stringify(exportFormat, null, 2)], {
type: "application/json", type: "application/json",
}); });
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);

View File

@@ -798,6 +798,20 @@ export function Auth({
if (dbConnectionFailed) { if (dbConnectionFailed) {
return ( return (
<div
className={`fixed inset-0 flex items-center justify-center ${className || ""}`}
style={{
background: "#0e0e10",
backgroundImage: `repeating-linear-gradient(
45deg,
transparent,
transparent 35px,
rgba(255, 255, 255, 0.03) 35px,
rgba(255, 255, 255, 0.03) 37px
)`,
}}
{...props}
>
<div <div
className={`w-[420px] max-w-full p-6 flex flex-col bg-dark-bg border-2 border-dark-border rounded-md overflow-y-auto my-2 animate-in fade-in zoom-in-95 duration-300 ${className || ""}`} className={`w-[420px] max-w-full p-6 flex flex-col bg-dark-bg border-2 border-dark-border rounded-md overflow-y-auto my-2 animate-in fade-in zoom-in-95 duration-300 ${className || ""}`}
style={{ maxHeight: "calc(100vh - 1rem)" }} style={{ maxHeight: "calc(100vh - 1rem)" }}
@@ -836,7 +850,9 @@ export function Auth({
{isElectron() && currentServerUrl && ( {isElectron() && currentServerUrl && (
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div> <div>
<Label className="text-sm text-muted-foreground">Server</Label> <Label className="text-sm text-muted-foreground">
Server
</Label>
<div className="text-xs text-muted-foreground truncate max-w-[200px]"> <div className="text-xs text-muted-foreground truncate max-w-[200px]">
{currentServerUrl} {currentServerUrl}
</div> </div>
@@ -854,6 +870,7 @@ export function Auth({
)} )}
</div> </div>
</div> </div>
</div>
); );
} }