fix: complete statsConfig field support across all API routes

- Add statsConfig to POST /db/host (create) route
- Add statsConfig to all GET routes for consistent API responses
- Remove incorrect statsConfig schema from HostManagerEditor
- statsConfig is now only managed by Server page layout editor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ZacharyZcR
2025-10-09 09:25:36 +08:00
parent 8e022f0f1c
commit 8c20d41072
2 changed files with 3 additions and 36 deletions

View File

@@ -210,16 +210,6 @@ export function HostManagerEditor({
.default([]),
enableFileManager: z.boolean().default(true),
defaultPath: z.string().optional(),
statsConfig: z
.object({
enabled: z.boolean().default(true),
displayItems: z.object({
cpu: z.boolean().default(true),
memory: z.boolean().default(true),
disk: z.boolean().default(true),
}),
})
.optional(),
})
.superRefine((data, ctx) => {
if (data.authType === "password") {
@@ -302,14 +292,6 @@ export function HostManagerEditor({
enableFileManager: true,
defaultPath: "/",
tunnelConnections: [],
statsConfig: {
enabled: true,
displayItems: {
cpu: true,
memory: true,
disk: true,
},
},
},
});
@@ -366,14 +348,6 @@ export function HostManagerEditor({
enableFileManager: Boolean(cleanedHost.enableFileManager),
defaultPath: cleanedHost.defaultPath || "/",
tunnelConnections: cleanedHost.tunnelConnections || [],
statsConfig: cleanedHost.statsConfig
? typeof cleanedHost.statsConfig === "string"
? JSON.parse(cleanedHost.statsConfig)
: cleanedHost.statsConfig
: {
enabled: true,
displayItems: { cpu: true, memory: true, disk: true },
},
};
if (defaultAuthType === "password") {
@@ -409,10 +383,6 @@ export function HostManagerEditor({
enableFileManager: true,
defaultPath: "/",
tunnelConnections: [],
statsConfig: {
enabled: true,
displayItems: { cpu: true, memory: true, disk: true },
},
};
form.reset(defaultFormData);
@@ -451,12 +421,6 @@ export function HostManagerEditor({
enableFileManager: Boolean(data.enableFileManager),
defaultPath: data.defaultPath || "/",
tunnelConnections: data.tunnelConnections || [],
statsConfig: JSON.stringify(
data.statsConfig || {
enabled: true,
displayItems: { cpu: true, memory: true, disk: true },
},
),
};
submitData.credentialId = null;