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:
@@ -233,6 +233,7 @@ router.post(
|
|||||||
enableFileManager,
|
enableFileManager,
|
||||||
defaultPath,
|
defaultPath,
|
||||||
tunnelConnections,
|
tunnelConnections,
|
||||||
|
statsConfig,
|
||||||
} = hostData;
|
} = hostData;
|
||||||
if (
|
if (
|
||||||
!isNonEmptyString(userId) ||
|
!isNonEmptyString(userId) ||
|
||||||
@@ -268,6 +269,7 @@ router.post(
|
|||||||
: null,
|
: null,
|
||||||
enableFileManager: enableFileManager ? 1 : 0,
|
enableFileManager: enableFileManager ? 1 : 0,
|
||||||
defaultPath: defaultPath || null,
|
defaultPath: defaultPath || null,
|
||||||
|
statsConfig: statsConfig || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (effectiveAuthType === "password") {
|
if (effectiveAuthType === "password") {
|
||||||
@@ -322,6 +324,7 @@ router.post(
|
|||||||
? JSON.parse(createdHost.tunnelConnections)
|
? JSON.parse(createdHost.tunnelConnections)
|
||||||
: [],
|
: [],
|
||||||
enableFileManager: !!createdHost.enableFileManager,
|
enableFileManager: !!createdHost.enableFileManager,
|
||||||
|
statsConfig: createdHost.statsConfig || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const resolvedHost = (await resolveHostCredentials(baseHost)) || baseHost;
|
const resolvedHost = (await resolveHostCredentials(baseHost)) || baseHost;
|
||||||
|
|||||||
@@ -210,16 +210,6 @@ export function HostManagerEditor({
|
|||||||
.default([]),
|
.default([]),
|
||||||
enableFileManager: z.boolean().default(true),
|
enableFileManager: z.boolean().default(true),
|
||||||
defaultPath: z.string().optional(),
|
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) => {
|
.superRefine((data, ctx) => {
|
||||||
if (data.authType === "password") {
|
if (data.authType === "password") {
|
||||||
@@ -302,14 +292,6 @@ export function HostManagerEditor({
|
|||||||
enableFileManager: true,
|
enableFileManager: true,
|
||||||
defaultPath: "/",
|
defaultPath: "/",
|
||||||
tunnelConnections: [],
|
tunnelConnections: [],
|
||||||
statsConfig: {
|
|
||||||
enabled: true,
|
|
||||||
displayItems: {
|
|
||||||
cpu: true,
|
|
||||||
memory: true,
|
|
||||||
disk: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -366,14 +348,6 @@ export function HostManagerEditor({
|
|||||||
enableFileManager: Boolean(cleanedHost.enableFileManager),
|
enableFileManager: Boolean(cleanedHost.enableFileManager),
|
||||||
defaultPath: cleanedHost.defaultPath || "/",
|
defaultPath: cleanedHost.defaultPath || "/",
|
||||||
tunnelConnections: cleanedHost.tunnelConnections || [],
|
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") {
|
if (defaultAuthType === "password") {
|
||||||
@@ -409,10 +383,6 @@ export function HostManagerEditor({
|
|||||||
enableFileManager: true,
|
enableFileManager: true,
|
||||||
defaultPath: "/",
|
defaultPath: "/",
|
||||||
tunnelConnections: [],
|
tunnelConnections: [],
|
||||||
statsConfig: {
|
|
||||||
enabled: true,
|
|
||||||
displayItems: { cpu: true, memory: true, disk: true },
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
form.reset(defaultFormData);
|
form.reset(defaultFormData);
|
||||||
@@ -451,12 +421,6 @@ export function HostManagerEditor({
|
|||||||
enableFileManager: Boolean(data.enableFileManager),
|
enableFileManager: Boolean(data.enableFileManager),
|
||||||
defaultPath: data.defaultPath || "/",
|
defaultPath: data.defaultPath || "/",
|
||||||
tunnelConnections: data.tunnelConnections || [],
|
tunnelConnections: data.tunnelConnections || [],
|
||||||
statsConfig: JSON.stringify(
|
|
||||||
data.statsConfig || {
|
|
||||||
enabled: true,
|
|
||||||
displayItems: { cpu: true, memory: true, disk: true },
|
|
||||||
},
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
submitData.credentialId = null;
|
submitData.credentialId = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user