mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-09-19 17:50:13 +00:00
feat: batch set server config (#114)
* feat: batch set server config * make every field optional * chore: auto-fix linting and formatting issues * update * [WIP] improve batch edit ux * chore: auto-fix linting and formatting issues
This commit is contained in:
+17
-12
@@ -99,12 +99,6 @@ export interface GithubComNezhahqNezhaModelCommonResponseGithubComNezhahqNezhaMo
|
||||
success: boolean
|
||||
}
|
||||
|
||||
export interface GithubComNezhahqNezhaModelCommonResponseModelForceUpdateResponse {
|
||||
data: ModelForceUpdateResponse
|
||||
error: string
|
||||
success: boolean
|
||||
}
|
||||
|
||||
export interface GithubComNezhahqNezhaModelCommonResponseModelLoginResponse {
|
||||
data: ModelLoginResponse
|
||||
error: string
|
||||
@@ -117,6 +111,12 @@ export interface GithubComNezhahqNezhaModelCommonResponseModelProfile {
|
||||
success: boolean
|
||||
}
|
||||
|
||||
export interface GithubComNezhahqNezhaModelCommonResponseModelServerTaskResponse {
|
||||
data: ModelServerTaskResponse
|
||||
error: string
|
||||
success: boolean
|
||||
}
|
||||
|
||||
export interface GithubComNezhahqNezhaModelCommonResponseModelServiceResponse {
|
||||
data: ModelServiceResponse
|
||||
error: string
|
||||
@@ -336,12 +336,6 @@ export interface ModelDDNSProfile {
|
||||
webhook_url: string
|
||||
}
|
||||
|
||||
export interface ModelForceUpdateResponse {
|
||||
failure?: number[]
|
||||
offline?: number[]
|
||||
success?: number[]
|
||||
}
|
||||
|
||||
export interface ModelFrontendTemplate {
|
||||
author: string
|
||||
is_admin: boolean
|
||||
@@ -577,6 +571,11 @@ export interface ModelServer {
|
||||
uuid: string
|
||||
}
|
||||
|
||||
export interface ModelServerConfigForm {
|
||||
config: string
|
||||
servers: number[]
|
||||
}
|
||||
|
||||
export interface ModelServerForm {
|
||||
/** DDNS配置 */
|
||||
ddns_profiles?: number[]
|
||||
@@ -615,6 +614,12 @@ export interface ModelServerGroupResponseItem {
|
||||
servers: number[]
|
||||
}
|
||||
|
||||
export interface ModelServerTaskResponse {
|
||||
failure?: number[]
|
||||
offline?: number[]
|
||||
success?: number[]
|
||||
}
|
||||
|
||||
export interface ModelService {
|
||||
cover: number
|
||||
created_at: string
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { asOptionalField } from "@/lib/utils"
|
||||
import { z } from "zod"
|
||||
|
||||
export const AgentConfigSchema = z.object({
|
||||
debug: asOptionalField(z.boolean()),
|
||||
disable_auto_update: asOptionalField(z.boolean()),
|
||||
disable_command_execute: asOptionalField(z.boolean()),
|
||||
disable_force_update: asOptionalField(z.boolean()),
|
||||
disable_nat: asOptionalField(z.boolean()),
|
||||
disable_send_query: asOptionalField(z.boolean()),
|
||||
gpu: asOptionalField(z.boolean()),
|
||||
hard_drive_partition_allowlist: asOptionalField(z.array(z.string())),
|
||||
hard_drive_partition_allowlist_raw: asOptionalField(
|
||||
z.string().refine(
|
||||
(val) => {
|
||||
try {
|
||||
JSON.parse(val)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
{
|
||||
message: "Invalid JSON string",
|
||||
},
|
||||
),
|
||||
),
|
||||
ip_report_period: asOptionalField(z.coerce.number().int().min(30)),
|
||||
nic_allowlist: asOptionalField(z.record(z.boolean())),
|
||||
nic_allowlist_raw: asOptionalField(
|
||||
z.string().refine(
|
||||
(val) => {
|
||||
try {
|
||||
JSON.parse(val)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
{
|
||||
message: "Invalid JSON string",
|
||||
},
|
||||
),
|
||||
),
|
||||
report_delay: asOptionalField(z.coerce.number().int().min(1).max(4)),
|
||||
skip_connection_count: asOptionalField(z.boolean()),
|
||||
skip_procs_count: asOptionalField(z.boolean()),
|
||||
temperature: asOptionalField(z.boolean()),
|
||||
})
|
||||
|
||||
type AgentConfig = z.infer<typeof AgentConfigSchema>
|
||||
|
||||
const boolFields: (keyof AgentConfig)[] = [
|
||||
"disable_auto_update",
|
||||
"disable_command_execute",
|
||||
"disable_force_update",
|
||||
"disable_nat",
|
||||
"disable_send_query",
|
||||
"gpu",
|
||||
"temperature",
|
||||
"skip_connection_count",
|
||||
"skip_procs_count",
|
||||
"debug",
|
||||
]
|
||||
|
||||
export const GroupedBoolFields: (keyof AgentConfig)[][] = []
|
||||
for (let i = 0; i < boolFields.length; i += 2) {
|
||||
GroupedBoolFields.push(boolFields.slice(i, i + 2))
|
||||
}
|
||||
Reference in New Issue
Block a user