Compare commits
6 Commits
ba907f5403
...
b06bb76c20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b06bb76c20 | ||
|
|
661c810cde | ||
|
|
dc8841b407 | ||
|
|
1913a69bb5 | ||
|
|
5476e84bb8 | ||
|
|
dd3e001312 |
@@ -60,7 +60,7 @@ import (
|
||||
usersvc "git.netcell-it.de/projekte/edgeguard-native/internal/services/users"
|
||||
)
|
||||
|
||||
var version = "1.1.74"
|
||||
var version = "1.1.75"
|
||||
|
||||
func main() {
|
||||
addr := os.Getenv("EDGEGUARD_API_ADDR")
|
||||
|
||||
@@ -129,6 +129,13 @@ export default function AlertsPage() {
|
||||
},
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const quickToggle = useMutation({
|
||||
mutationFn: async ({ id, row, checked }: { id: number; row: Channel; checked: boolean }) => {
|
||||
await apiClient.put(`/alerts/channels/${id}`, buildPayload({ ...row, active: checked } as ChannelFormValues))
|
||||
},
|
||||
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['alerts', 'channels'] }) },
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const del = useMutation({
|
||||
mutationFn: async (id: number) => { await apiClient.delete(`/alerts/channels/${id}`) },
|
||||
onSuccess: () => { qc.invalidateQueries({ queryKey: ['alerts', 'channels'] }) },
|
||||
@@ -161,8 +168,14 @@ export default function AlertsPage() {
|
||||
},
|
||||
{
|
||||
title: t('alerts.col.active'), dataIndex: 'active', width: 80,
|
||||
render: (v: boolean) =>
|
||||
v ? <Tag color="green">an</Tag> : <Tag>aus</Tag>,
|
||||
render: (v: boolean, r: Channel) => (
|
||||
<Switch
|
||||
size="small"
|
||||
checked={v}
|
||||
loading={quickToggle.isPending && quickToggle.variables?.id === r.id}
|
||||
onChange={(checked) => quickToggle.mutate({ id: r.id, row: r, checked })}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('common.actions'), key: 'a', width: 180,
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
Select, Space, Switch, Table, Tag, Tooltip, Typography, message,
|
||||
} from 'antd'
|
||||
import type { ColumnsType } from 'antd/es/table'
|
||||
import { DatabaseOutlined, PlusOutlined } from '@ant-design/icons'
|
||||
import { CheckCircleOutlined, CloseCircleOutlined, DatabaseOutlined, PlusOutlined } from '@ant-design/icons'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import DataTable from '../../components/DataTable'
|
||||
@@ -122,6 +122,15 @@ export default function BackendsPage() {
|
||||
|
||||
const { data, isLoading } = useQuery({ queryKey: ['backends'], queryFn: listBackends })
|
||||
const { data: domains } = useQuery({ queryKey: ['domains'], queryFn: listDomains })
|
||||
const { data: services } = useQuery({
|
||||
queryKey: ['system', 'services'],
|
||||
queryFn: async () => {
|
||||
const r = await apiClient.get('/system/services')
|
||||
return isEnvelope(r.data) ? (r.data.data as Array<{ unit: string; active: boolean; state: string }>).filter(Boolean) : []
|
||||
},
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
const haproxyService = services?.find(s => s.unit === 'haproxy.service' || s.unit === 'haproxy')
|
||||
const { data: haproxyStats } = useQuery({
|
||||
queryKey: ['haproxy', 'stats'],
|
||||
queryFn: listHAProxyStats,
|
||||
@@ -303,6 +312,17 @@ export default function BackendsPage() {
|
||||
icon={<DatabaseOutlined />}
|
||||
title={t('backends.title')}
|
||||
subtitle={t('backends.intro')}
|
||||
extra={haproxyService && (
|
||||
<Tag
|
||||
icon={haproxyService.active ? <CheckCircleOutlined /> : <CloseCircleOutlined />}
|
||||
color={haproxyService.active ? 'green' : 'red'}
|
||||
>
|
||||
<Space size={4}>
|
||||
<span>haproxy</span>
|
||||
<span style={{ fontWeight: 400, opacity: 0.85 }}>{haproxyService.state}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
/>
|
||||
<DataTable
|
||||
rowKey="id"
|
||||
|
||||
@@ -116,6 +116,16 @@ export default function RemoteTargetsTab() {
|
||||
},
|
||||
onError: (e: Error) => msg.error(e.message),
|
||||
})
|
||||
const quickToggle = useMutation({
|
||||
mutationFn: async ({ id, row, checked }: { id: number; row: RemoteTarget; checked: boolean }) => {
|
||||
await apiClient.put(`/backup-remotes/${id}`, {
|
||||
name: row.name, kind: row.kind, target_url: row.target_url,
|
||||
settings: row.settings, active: checked,
|
||||
})
|
||||
},
|
||||
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['backup-remotes'] }) },
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const del = useMutation({
|
||||
mutationFn: async (id: number) => { await apiClient.delete(`/backup-remotes/${id}`) },
|
||||
onSuccess: () => { qc.invalidateQueries({ queryKey: ['backup-remotes'] }) },
|
||||
@@ -156,7 +166,14 @@ export default function RemoteTargetsTab() {
|
||||
},
|
||||
{
|
||||
title: t('remotes.col.active'), dataIndex: 'active', width: 80,
|
||||
render: (v: boolean) => v ? <Tag color="green">an</Tag> : <Tag>aus</Tag>,
|
||||
render: (v: boolean, r: RemoteTarget) => (
|
||||
<Switch
|
||||
size="small"
|
||||
checked={v}
|
||||
loading={quickToggle.isPending && quickToggle.variables?.id === r.id}
|
||||
onChange={(checked) => quickToggle.mutate({ id: r.id, row: r, checked })}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('common.actions'), key: 'a', width: 240,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from 'react'
|
||||
import { Alert, Button, Drawer, Form, Input, InputNumber, Modal, Select, Space, Switch, Tabs, Tag, Typography, message } from 'antd'
|
||||
import type { ColumnsType } from 'antd/es/table'
|
||||
import { GlobalOutlined, NodeIndexOutlined, PlusOutlined, SettingOutlined } from '@ant-design/icons'
|
||||
import { CheckCircleOutlined, CloseCircleOutlined, GlobalOutlined, NodeIndexOutlined, PlusOutlined, SettingOutlined } from '@ant-design/icons'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
@@ -71,8 +71,21 @@ async function listSystemInterfaces(): Promise<SystemIface[]> {
|
||||
return (r.data.data as { interfaces?: SystemIface[] }).interfaces ?? []
|
||||
}
|
||||
|
||||
interface ServiceStatus { label: string; unit: string; active: boolean; state: string }
|
||||
|
||||
export default function DNSPage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { data: services } = useQuery({
|
||||
queryKey: ['system', 'services'],
|
||||
queryFn: async () => {
|
||||
const r = await apiClient.get('/system/services')
|
||||
return isEnvelope(r.data) ? (r.data.data as { services: ServiceStatus[] }).services : []
|
||||
},
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
const unbound = services?.find(s => s.unit === 'unbound.service' || s.unit === 'unbound')
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageHeader
|
||||
@@ -82,6 +95,17 @@ export default function DNSPage() {
|
||||
/>
|
||||
<Tabs
|
||||
defaultActiveKey="zones"
|
||||
tabBarExtraContent={unbound && (
|
||||
<Tag
|
||||
icon={unbound.active ? <CheckCircleOutlined /> : <CloseCircleOutlined />}
|
||||
color={unbound.active ? 'green' : 'red'}
|
||||
>
|
||||
<Space size={4}>
|
||||
<span>unbound</span>
|
||||
<span style={{ fontWeight: 400, opacity: 0.85 }}>{unbound.state}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
items={[
|
||||
{ key: 'zones', label: <span><NodeIndexOutlined /> {t('dns.tabs.zones')}</span>, children: <ZonesTab /> },
|
||||
{ key: 'settings', label: <span><SettingOutlined /> {t('dns.tabs.settings')}</span>, children: <SettingsTab /> },
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Tabs } from 'antd'
|
||||
import { FireOutlined } from '@ant-design/icons'
|
||||
import { Space, Tag, Tabs } from 'antd'
|
||||
import { CheckCircleOutlined, CloseCircleOutlined, FireOutlined } from '@ant-design/icons'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
|
||||
import apiClient, { isEnvelope } from '../../api/client'
|
||||
import PageHeader from '../../components/PageHeader'
|
||||
import AddressObjectsTab from './AddressObjects'
|
||||
import AddressGroupsTab from './AddressGroups'
|
||||
@@ -12,9 +14,21 @@ import NATRulesTab from './NATRules'
|
||||
import SystemRulesCard from './SystemRules'
|
||||
import ZonesTab from './Zones'
|
||||
|
||||
interface ServiceStatus { label: string; unit: string; active: boolean; state: string }
|
||||
|
||||
export default function FirewallPage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { data: services } = useQuery({
|
||||
queryKey: ['system', 'services'],
|
||||
queryFn: async () => {
|
||||
const r = await apiClient.get('/system/services')
|
||||
return isEnvelope(r.data) ? (r.data.data as { services: ServiceStatus[] }).services : []
|
||||
},
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
const nftables = services?.find(s => s.unit === 'nftables.service' || s.unit === 'nftables')
|
||||
|
||||
const tabs = [
|
||||
{ key: 'rules', label: t('fw.tabs.rules'), children: <RulesTab /> },
|
||||
{ key: 'nat', label: t('fw.tabs.nat'), children: <NATRulesTab /> },
|
||||
@@ -33,7 +47,21 @@ export default function FirewallPage() {
|
||||
title={t('fw.title')}
|
||||
subtitle={t('fw.intro')}
|
||||
/>
|
||||
<Tabs items={tabs} defaultActiveKey="rules" />
|
||||
<Tabs
|
||||
items={tabs}
|
||||
defaultActiveKey="rules"
|
||||
tabBarExtraContent={nftables && (
|
||||
<Tag
|
||||
icon={nftables.active ? <CheckCircleOutlined /> : <CloseCircleOutlined />}
|
||||
color={nftables.active ? 'green' : 'red'}
|
||||
>
|
||||
<Space size={4}>
|
||||
<span>nftables</span>
|
||||
<span style={{ fontWeight: 400, opacity: 0.85 }}>{nftables.state}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
Alert, Button, Card, Col, Form, Input, InputNumber, Modal, Row, Select, Space, Statistic, Switch, Tabs, Tag, Tooltip, Typography, message,
|
||||
} from 'antd'
|
||||
import type { ColumnsType } from 'antd/es/table'
|
||||
import { ClockCircleOutlined, DatabaseOutlined, PlusOutlined, ReloadOutlined, SettingOutlined } from '@ant-design/icons'
|
||||
import { CheckCircleOutlined, ClockCircleOutlined, CloseCircleOutlined, DatabaseOutlined, PlusOutlined, ReloadOutlined, SettingOutlined } from '@ant-design/icons'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
@@ -86,6 +86,15 @@ export default function NTPPage() {
|
||||
queryFn: fetchNTPStatus,
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
const { data: services } = useQuery({
|
||||
queryKey: ['system', 'services'],
|
||||
queryFn: async () => {
|
||||
const r = await apiClient.get('/system/services')
|
||||
return isEnvelope(r.data) ? (r.data.data as Array<{ unit: string; active: boolean; state: string }>) : []
|
||||
},
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
const chrony = services?.find(s => s.unit === 'chrony' || s.unit === 'chronyd')
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -93,6 +102,17 @@ export default function NTPPage() {
|
||||
icon={<ClockCircleOutlined />}
|
||||
title={t('ntp.title')}
|
||||
subtitle={t('ntp.intro')}
|
||||
extra={chrony && (
|
||||
<Tag
|
||||
icon={chrony.active ? <CheckCircleOutlined /> : <CloseCircleOutlined />}
|
||||
color={chrony.active ? 'green' : 'red'}
|
||||
>
|
||||
<Space size={4}>
|
||||
<span>chrony</span>
|
||||
<span style={{ fontWeight: 400, opacity: 0.85 }}>{chrony.state}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Card
|
||||
|
||||
@@ -99,6 +99,14 @@ export default function RoutesTab() {
|
||||
onSuccess: () => { qc.invalidateQueries({ queryKey: ['routes'] }) },
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const quickToggle = useMutation({
|
||||
mutationFn: async ({ id, row, checked }: { id: number; row: ManagedRoute; checked: boolean }) => {
|
||||
const { id: _id, ...body } = row
|
||||
await apiClient.put(`/routes/${id}`, { ...body, active: checked })
|
||||
},
|
||||
onSuccess: () => { qc.invalidateQueries({ queryKey: ['routes'] }) },
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
|
||||
const managedColumns: ColumnsType<ManagedRoute> = [
|
||||
{
|
||||
@@ -115,8 +123,17 @@ export default function RoutesTab() {
|
||||
render: (v?: string) => v ? <Tag>{v}</Tag> : '—' },
|
||||
{ title: t('routes.col.metric'), dataIndex: 'metric', width: 80 },
|
||||
{ title: t('routes.col.table'), dataIndex: 'table_name', width: 90 },
|
||||
{ title: t('routes.col.active'), dataIndex: 'active', width: 80,
|
||||
render: (v: boolean) => v ? <Tag color="green">on</Tag> : <Tag>off</Tag> },
|
||||
{
|
||||
title: t('routes.col.active'), dataIndex: 'active', width: 80,
|
||||
render: (v: boolean, row: ManagedRoute) => (
|
||||
<Switch
|
||||
size="small"
|
||||
checked={v}
|
||||
loading={quickToggle.isPending && quickToggle.variables?.id === row.id}
|
||||
onChange={(checked) => quickToggle.mutate({ id: row.id, row, checked })}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{ title: t('routes.col.comment'), dataIndex: 'comment',
|
||||
render: (v?: string) => v || <Text type="secondary">—</Text> },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user