feat: complete Loki query, insights, settings and deployment workflows

Add the Loki query UI, access policies, ingress insights, alert and registry settings, and their backend APIs. Include the related Kubernetes deployment and collector updates required by the integrated application.

Validated with go test ./..., npm run build, and npm run lint.
This commit is contained in:
logan committed 2026-10-25 21:28:32 +08:00
1 parent f9c6c1d826
commit 2d73661dd1
127 files changed
+8117 -2876

No files matched your search

@@ -43,6 +43,7 @@ const hostFormSchema = z
labels: z.string().optional(),
})
.superRefine((data, ctx) => {
if (EDITING_REF.current) return
if (data.authType === 'password' && !data.password?.trim()) {
ctx.addIssue({
code: 'custom',
@@ -77,15 +78,19 @@ interface HostFormDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
/** 创建成功回调(父级刷新列表并关闭弹窗) */
onCreated: () => void
onCreated: () => void /** 编辑目标(编辑模式:凭证留空=保留) */
editing?: import('@/types').Host | null
}
/** 添加 SSH 主机弹窗 — react-hook-form + zod,自包含表单逻辑,页面只传开关与回调 */
const EDITING_REF = { current: false as boolean | null }
export const HostFormDialog = memo(function HostFormDialog({
open,
onOpenChange,
onCreated,
}: HostFormDialogProps) {
editing,
}: HostFormDialogProps) {
const [submitting, setSubmitting] = useState(false)
const form = useForm<HostFormValues>({
@@ -95,26 +100,35 @@ export const HostFormDialog = memo(function HostFormDialog({
const authType = form.watch('authType')
// 打开时重置(默认值),关闭/重开时机明确
EDITING_REF.current = !!editing
useEffect(() => {
if (open) {
form.reset(DEFAULT_VALUES)
form.reset(editing ? {
name: editing.name, hostIP: editing.hostIP, port: String(editing.port),
user: editing.user, authType: editing.authType,
password: '', privateKey: '', keyPhrase: '', labels: editing.labels || '',
} as never : DEFAULT_VALUES)
}
}, [open, form])
}, [open, form, editing])
const onSubmit = form.handleSubmit(async (values) => {
setSubmitting(true)
try {
await hostApi.create({
name: values.name,
hostIP: values.hostIP,
port: Number(values.port),
user: values.user,
authType: values.authType,
password: values.authType === 'password' ? values.password : undefined,
privateKey: values.authType === 'key' ? values.privateKey : undefined,
keyPhrase: values.authType === 'key' ? values.keyPhrase : undefined,
labels: values.labels,
})
await (editing
? hostApi.update(editing.id, {
name: values.name, hostIP: values.hostIP, port: Number(values.port),
user: values.user, authType: values.authType,
password: values.password || undefined,
privateKey: values.privateKey || undefined,
keyPhrase: values.keyPhrase || undefined,
labels: values.labels,
})
: hostApi.create({
name: values.name, hostIP: values.hostIP, port: Number(values.port),
user: values.user, authType: values.authType,
password: values.password, privateKey: values.privateKey,
keyPhrase: values.keyPhrase, labels: values.labels,
}))
onOpenChange(false)
onCreated()
} catch (err) {
@@ -128,7 +142,7 @@ export const HostFormDialog = memo(function HostFormDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
<DialogHeader>
<DialogTitle>添加 SSH 主机</DialogTitle>
<DialogTitle>{editing ? `编辑主机${editing.name ? ` · ${editing.name}` : ''}` : '添加 SSH 主机'}</DialogTitle>
</DialogHeader>
<Form {...form}>
<form onSubmit={onSubmit} className="space-y-4">
@@ -232,7 +246,7 @@ export const HostFormDialog = memo(function HostFormDialog({
name="password"
render={({ field }) => (
<FormItem>
<FormLabel>密码 *</FormLabel>
<FormLabel>密码{editing ? '(留空保持不变)' : ' *'}</FormLabel>
<FormControl>
<PasswordInput placeholder="SSH 登录密码" {...field} />
</FormControl>
@@ -247,7 +261,7 @@ export const HostFormDialog = memo(function HostFormDialog({
name="privateKey"
render={({ field }) => (
<FormItem>
<FormLabel>私钥 *</FormLabel>
<FormLabel>私钥{editing ? '(留空保持不变)' : ' *'}</FormLabel>
<FormControl>
<Textarea
placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
@@ -294,7 +308,7 @@ export const HostFormDialog = memo(function HostFormDialog({
className="w-full bg-primary hover:bg-primary/90"
disabled={submitting}
>
{submitting ? '添加中...' : '添加主机'}
{submitting ? (editing ? '保存中...' : '添加中...') : editing ? '保存修改' : '添加主机'}
</Button>
</form>
</Form>