feat: Enhance gateway management and add Caddyfile generation support
This commit is contained in:
@@ -43,6 +43,14 @@ export function useGateway() {
|
||||
})
|
||||
}
|
||||
|
||||
export function useCaddyfile(enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: ["gateway", "caddyfile"],
|
||||
queryFn: () => apiClient.get<{ content: string }>("/gateway/caddyfile"),
|
||||
enabled,
|
||||
})
|
||||
}
|
||||
|
||||
async function waitForApi(attempts = 20, interval = 1000): Promise<void> {
|
||||
for (let i = 0; i < attempts; i++) {
|
||||
try {
|
||||
@@ -54,6 +62,14 @@ async function waitForApi(attempts = 20, interval = 1000): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export function useSystemdUnit(name: string, enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: ["services", name, "unit"],
|
||||
queryFn: () => apiClient.get<{ service: string; timer: string | null }>(`/services/${name}/unit`),
|
||||
enabled: enabled && !!name,
|
||||
})
|
||||
}
|
||||
|
||||
export function useServiceAction() {
|
||||
const qc = useQueryClient()
|
||||
return useMutation({
|
||||
|
||||
Reference in New Issue
Block a user