Backend: - Audit-Log: Search-Endpoint mit ILIKE-Filter (actor/action/subject/date) - NTP: /ntp/status via chronyc tracking (Stratum, Offset, Quelle) - System: /service-restart mit Allowlist (haproxy/squid/unbound/chrony/scheduler) - Domain-Response-Headers + Rate-Limit (Migration 0024) - Join-Tokens (Migration 0025), Cluster-mTLS, Aggregator-Fan-Out - apt-Service für Update-Banner (apt-get update + Versionsprüfung) - Backup-Retry mit exponential backoff (retry_apt 3×) - publish.sh fail-fast + cleanup-old.sh (max 10 Versionen) Frontend: - Audit-Log-Page (/audit) mit Filter + Pagination - ErrorBoundary an React-Root + Vite build-target festgenagelt (iOS 15+) - Storage-Schema-Stamp: auto-wipe bei Versions-Mismatch (blank-page-Fix) - EmptyState-Komponente überall ausgerollt - SSL: Aggregate-Karte (total/expiring/expired/errors) - Backups: Aggregate-Karte (letzter Backup/Größe/Fehlschläge 24h) + Backup-Now - NTP: Sync-Status-Karte (chronyc tracking live) - Domains: Backend-UP/DOWN-Chip aus HAProxy-Stats - Backends: HAProxy-Status-Spalte (UP/DEGRADED/DOWN) - Settings: Service-Neustart-Karte (haproxy/squid/unbound/chrony/scheduler) - Settings: Upgrade-Status-Card, Wartungsmodus, Auto-Update, Retention - Dashboard: Recent-Alerts, Cluster-Health, License-Chip, Onboarding-Hint - System-Regeln im Firewall als eigener Tab Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
146 lines
5.4 KiB
TypeScript
146 lines
5.4 KiB
TypeScript
import { useState } from 'react'
|
|
import { Button, Form, Input, Modal, Popconfirm, Select, Space, Tag, message } from 'antd'
|
|
import type { ColumnsType } from 'antd/es/table'
|
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { GroupOutlined } from '@ant-design/icons'
|
|
|
|
import DataTable from '../../components/DataTable'
|
|
import EmptyState from '../../components/EmptyState'
|
|
|
|
import apiClient, { isEnvelope } from '../../api/client'
|
|
import type { AddressGroup, AddressObject } from './types'
|
|
|
|
interface FormValues {
|
|
name: string
|
|
description?: string
|
|
member_ids?: number[]
|
|
}
|
|
|
|
async function listGroups(): Promise<AddressGroup[]> {
|
|
const r = await apiClient.get('/firewall/address-groups')
|
|
if (!isEnvelope(r.data)) return []
|
|
return (r.data.data as { address_groups?: AddressGroup[] }).address_groups ?? []
|
|
}
|
|
async function listObjects(): Promise<AddressObject[]> {
|
|
const r = await apiClient.get('/firewall/address-objects')
|
|
if (!isEnvelope(r.data)) return []
|
|
return (r.data.data as { address_objects?: AddressObject[] }).address_objects ?? []
|
|
}
|
|
|
|
export default function AddressGroupsTab() {
|
|
const { t } = useTranslation()
|
|
const qc = useQueryClient()
|
|
const { data: groups, isLoading } = useQuery({ queryKey: ['fw', 'addr-grp'], queryFn: listGroups })
|
|
const { data: objects } = useQuery({ queryKey: ['fw', 'addr-obj'], queryFn: listObjects })
|
|
|
|
const objLabel = (id: number) => objects?.find(o => o.id === id)?.name ?? `#${id}`
|
|
|
|
const [editing, setEditing] = useState<AddressGroup | null>(null)
|
|
const [creating, setCreating] = useState(false)
|
|
const [form] = Form.useForm<FormValues>()
|
|
|
|
const create = useMutation({
|
|
mutationFn: async (v: FormValues) => { await apiClient.post('/firewall/address-groups', v) },
|
|
onSuccess: () => {
|
|
message.success(t('common.save')); setCreating(false); form.resetFields()
|
|
void qc.invalidateQueries({ queryKey: ['fw', 'addr-grp'] })
|
|
},
|
|
})
|
|
const update = useMutation({
|
|
mutationFn: async ({ id, v }: { id: number; v: FormValues }) => { await apiClient.put(`/firewall/address-groups/${id}`, v) },
|
|
onSuccess: () => {
|
|
message.success(t('common.save')); setEditing(null); form.resetFields()
|
|
void qc.invalidateQueries({ queryKey: ['fw', 'addr-grp'] })
|
|
},
|
|
})
|
|
const del = useMutation({
|
|
mutationFn: async (id: number) => { await apiClient.delete(`/firewall/address-groups/${id}`) },
|
|
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['fw', 'addr-grp'] }) },
|
|
})
|
|
|
|
const columns: ColumnsType<AddressGroup> = [
|
|
{ title: t('fw.ag.name'), dataIndex: 'name', key: 'name' },
|
|
{
|
|
title: t('fw.ag.members'), key: 'members',
|
|
render: (_, row) => (
|
|
<Space wrap>
|
|
{(row.member_ids ?? []).map((id) => <Tag key={id}>{objLabel(id)}</Tag>)}
|
|
{(row.member_ids?.length ?? 0) === 0 && <span>—</span>}
|
|
</Space>
|
|
),
|
|
},
|
|
{ title: t('fw.ag.description'), dataIndex: 'description', key: 'desc', render: (v?: string) => v ?? '—' },
|
|
{
|
|
title: t('common.edit'), key: 'actions',
|
|
render: (_, row) => (
|
|
<Space>
|
|
<Button size="small" onClick={() => {
|
|
setEditing(row)
|
|
form.setFieldsValue({ name: row.name, description: row.description ?? undefined, member_ids: row.member_ids ?? [] })
|
|
}}>{t('common.edit')}</Button>
|
|
<Popconfirm title={t('fw.ag.deleteConfirm', { name: row.name })} onConfirm={() => del.mutate(row.id)}>
|
|
<Button size="small" danger>{t('common.delete')}</Button>
|
|
</Popconfirm>
|
|
</Space>
|
|
),
|
|
},
|
|
]
|
|
|
|
const openCreate = () => {
|
|
setCreating(true); form.resetFields()
|
|
form.setFieldsValue({ member_ids: [] })
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Button type="primary" className="mb-16" onClick={openCreate}>
|
|
{t('fw.ag.add')}
|
|
</Button>
|
|
<DataTable
|
|
rowKey="id"
|
|
loading={isLoading}
|
|
dataSource={groups ?? []}
|
|
columns={columns}
|
|
emptyContent={
|
|
<EmptyState
|
|
icon={<GroupOutlined />}
|
|
title={t('fw.ag.emptyTitle')}
|
|
description={t('fw.ag.emptyDesc')}
|
|
action={<Button type="primary" onClick={openCreate}>{t('fw.ag.add')}</Button>}
|
|
/>
|
|
}
|
|
/>
|
|
<Modal
|
|
title={editing ? t('fw.ag.edit') : t('fw.ag.add')}
|
|
open={editing !== null || creating}
|
|
onCancel={() => { setEditing(null); setCreating(false) }}
|
|
onOk={() => { void form.submit() }}
|
|
confirmLoading={create.isPending || update.isPending}
|
|
>
|
|
<Form
|
|
form={form}
|
|
layout="vertical"
|
|
onFinish={(v) => { if (editing) update.mutate({ id: editing.id, v }); else create.mutate(v) }}
|
|
>
|
|
<Form.Item label={t('fw.ag.name')} name="name" rules={[{ required: true }]}>
|
|
<Input placeholder="OfficeNetwork" />
|
|
</Form.Item>
|
|
<Form.Item label={t('fw.ag.members')} name="member_ids">
|
|
<Select
|
|
mode="multiple"
|
|
showSearch
|
|
optionFilterProp="label"
|
|
placeholder={t('fw.ag.selectMembers')}
|
|
options={(objects ?? []).map(o => ({ value: o.id, label: `${o.name} (${o.kind}: ${o.value})` }))}
|
|
/>
|
|
</Form.Item>
|
|
<Form.Item label={t('fw.ag.description')} name="description">
|
|
<Input />
|
|
</Form.Item>
|
|
</Form>
|
|
</Modal>
|
|
</>
|
|
)
|
|
}
|