修复查询探针列表代码不正确的问题
This commit is contained in:
1 parent
01a8ddcfbf
commit
8d0e784d64
4 files changed
+23
-21
No files matched your search
@@ -8,8 +8,8 @@ import type {AlertRecord} from '@/types';
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import {getErrorMessage} from '@/lib/utils';
|
import {getErrorMessage} from '@/lib/utils';
|
||||||
import {PageHeader} from '@admin/components';
|
import {PageHeader} from '@admin/components';
|
||||||
import {getAgentPaging} from '@/api/agent.ts';
|
|
||||||
import {useQuery, useQueryClient} from '@tanstack/react-query';
|
import {useQuery, useQueryClient} from '@tanstack/react-query';
|
||||||
|
import {listAgentsByAdmin} from "@/api/agent.ts";
|
||||||
|
|
||||||
const AlertRecordList = () => {
|
const AlertRecordList = () => {
|
||||||
const {message: messageApi, modal} = App.useApp();
|
const {message: messageApi, modal} = App.useApp();
|
||||||
@@ -24,7 +24,7 @@ const AlertRecordList = () => {
|
|||||||
const {data: agentsData} = useQuery({
|
const {data: agentsData} = useQuery({
|
||||||
queryKey: ['agents-for-alert-filter'],
|
queryKey: ['agents-for-alert-filter'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const response = await getAgentPaging(1, 1000);
|
const response = await listAgentsByAdmin();
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -90,7 +90,7 @@ const AlertRecordList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 计算探针选项
|
// 计算探针选项
|
||||||
const agentOptions = agentsData?.items?.map((agent) => ({
|
const agentOptions = agentsData?.map((agent) => ({
|
||||||
label: agent.name || agent.id,
|
label: agent.name || agent.id,
|
||||||
value: agent.id,
|
value: agent.id,
|
||||||
})) || [];
|
})) || [];
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {App, Form, Input, Modal, Select, Switch} from 'antd';
|
|||||||
import {createDDNSConfig, getDDNSConfig, updateDDNSConfig} from '@/api/ddns.ts';
|
import {createDDNSConfig, getDDNSConfig, updateDDNSConfig} from '@/api/ddns.ts';
|
||||||
import {getDNSProviders} from '@/api/dnsProvider.ts';
|
import {getDNSProviders} from '@/api/dnsProvider.ts';
|
||||||
import type {CreateDDNSConfigRequest, UpdateDDNSConfigRequest} from '@/types/ddns.ts';
|
import type {CreateDDNSConfigRequest, UpdateDDNSConfigRequest} from '@/types/ddns.ts';
|
||||||
import {getAgentPaging} from '@/api/agent.ts';
|
import {listAgentsByAdmin} from '@/api/agent.ts';
|
||||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
||||||
|
|
||||||
interface DDNSModalProps {
|
interface DDNSModalProps {
|
||||||
@@ -41,8 +41,8 @@ const DDNSModal = ({open, id, onCancel, onSuccess}: DDNSModalProps) => {
|
|||||||
const {data: agentsData} = useQuery({
|
const {data: agentsData} = useQuery({
|
||||||
queryKey: ['agents', 'paging'],
|
queryKey: ['agents', 'paging'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const data = await getAgentPaging(1, 1000);
|
const data = await listAgentsByAdmin();
|
||||||
return data.data.items || [];
|
return data.data || [];
|
||||||
},
|
},
|
||||||
enabled: open && !isEditMode,
|
enabled: open && !isEditMode,
|
||||||
});
|
});
|
||||||
@@ -218,7 +218,8 @@ const DDNSModal = ({open, id, onCancel, onSuccess}: DDNSModalProps) => {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form.Item noStyle shouldUpdate={(prevValues, currentValues) => prevValues.enableIpv4 !== currentValues.enableIpv4}>
|
<Form.Item noStyle
|
||||||
|
shouldUpdate={(prevValues, currentValues) => prevValues.enableIpv4 !== currentValues.enableIpv4}>
|
||||||
{() => {
|
{() => {
|
||||||
const enableIpv4 = form.getFieldValue('enableIpv4');
|
const enableIpv4 = form.getFieldValue('enableIpv4');
|
||||||
if (!enableIpv4) {
|
if (!enableIpv4) {
|
||||||
@@ -279,7 +280,8 @@ const DDNSModal = ({open, id, onCancel, onSuccess}: DDNSModalProps) => {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form.Item noStyle shouldUpdate={(prevValues, currentValues) => prevValues.enableIpv6 !== currentValues.enableIpv6}>
|
<Form.Item noStyle
|
||||||
|
shouldUpdate={(prevValues, currentValues) => prevValues.enableIpv6 !== currentValues.enableIpv6}>
|
||||||
{() => {
|
{() => {
|
||||||
const enableIpv6 = form.getFieldValue('enableIpv6');
|
const enableIpv6 = form.getFieldValue('enableIpv6');
|
||||||
if (!enableIpv6) {
|
if (!enableIpv6) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {useEffect, useMemo} from 'react';
|
|||||||
import {App, Button, Form, Input, InputNumber, Modal, Select, Space, Switch} from 'antd';
|
import {App, Button, Form, Input, InputNumber, Modal, Select, Space, Switch} from 'antd';
|
||||||
import {MinusCircle, PlusCircle} from 'lucide-react';
|
import {MinusCircle, PlusCircle} from 'lucide-react';
|
||||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
||||||
import {getAgentPaging} from '@/api/agent.ts';
|
import {listAgentsByAdmin} from '@/api/agent.ts';
|
||||||
import {createMonitor, getMonitor, updateMonitor} from '@/api/monitor.ts';
|
import {createMonitor, getMonitor, updateMonitor} from '@/api/monitor.ts';
|
||||||
import type {Agent, MonitorTaskRequest} from '@/types';
|
import type {Agent, MonitorTaskRequest} from '@/types';
|
||||||
import {getErrorMessage} from '@/lib/utils';
|
import {getErrorMessage} from '@/lib/utils';
|
||||||
@@ -31,8 +31,8 @@ const MonitorModal = ({open, monitorId, onCancel, onSuccess}: MonitorModalProps)
|
|||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ['agents', 'paging'],
|
queryKey: ['agents', 'paging'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const response = await getAgentPaging(1, 1000);
|
const response = await listAgentsByAdmin();
|
||||||
return response.data.items || [];
|
return response.data || [];
|
||||||
},
|
},
|
||||||
enabled: open,
|
enabled: open,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {App, Button, Card, Form, Input, InputNumber, Radio, Select, Space, Spin,
|
|||||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
||||||
import type {PublicIPConfig} from '@/api/property';
|
import type {PublicIPConfig} from '@/api/property';
|
||||||
import {getPublicIPConfig, savePublicIPConfig} from '@/api/property';
|
import {getPublicIPConfig, savePublicIPConfig} from '@/api/property';
|
||||||
import {getAgentPaging} from '@/api/agent.ts';
|
import {listAgentsByAdmin} from '@/api/agent.ts';
|
||||||
import {getErrorMessage} from '@/lib/utils';
|
import {getErrorMessage} from '@/lib/utils';
|
||||||
import type {Agent} from '@/types';
|
import type {Agent} from '@/types';
|
||||||
|
|
||||||
@@ -44,10 +44,10 @@ const PublicIPConfigComponent = ({defaultIPv4APIs, defaultIPv6APIs}: PublicIPCon
|
|||||||
|
|
||||||
const {data: agentsResponse} = useQuery({
|
const {data: agentsResponse} = useQuery({
|
||||||
queryKey: ['admin', 'agents', 'public-ip'],
|
queryKey: ['admin', 'agents', 'public-ip'],
|
||||||
queryFn: () => getAgentPaging(1, 1000),
|
queryFn: () => listAgentsByAdmin(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const agentOptions = (agentsResponse?.data?.items || []).map((agent) => ({
|
const agentOptions = (agentsResponse?.data || []).map((agent) => ({
|
||||||
label: formatAgentLabel(agent),
|
label: formatAgentLabel(agent),
|
||||||
value: agent.id,
|
value: agent.id,
|
||||||
}));
|
}));
|
||||||
@@ -128,7 +128,7 @@ const PublicIPConfigComponent = ({defaultIPv4APIs, defaultIPv6APIs}: PublicIPCon
|
|||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center py-20">
|
<div className="flex justify-center items-center py-20">
|
||||||
<Spin />
|
<Spin/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -145,21 +145,21 @@ const PublicIPConfigComponent = ({defaultIPv4APIs, defaultIPv6APIs}: PublicIPCon
|
|||||||
<Card title="采集设置" type="inner" className="mb-4">
|
<Card title="采集设置" type="inner" className="mb-4">
|
||||||
<div className="flex flex-wrap items-center gap-6">
|
<div className="flex flex-wrap items-center gap-6">
|
||||||
<Form.Item label="启用采集" name="enabled" valuePropName="checked">
|
<Form.Item label="启用采集" name="enabled" valuePropName="checked">
|
||||||
<Switch />
|
<Switch/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="采集间隔(秒)"
|
label="采集间隔(秒)"
|
||||||
name="intervalSeconds"
|
name="intervalSeconds"
|
||||||
rules={[{type: 'number', min: 30, message: '采集间隔不能小于 30 秒'}]}
|
rules={[{type: 'number', min: 30, message: '采集间隔不能小于 30 秒'}]}
|
||||||
>
|
>
|
||||||
<InputNumber min={30} max={86400} />
|
<InputNumber min={30} max={86400}/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="IPv4 配置" type="inner" className="mb-4">
|
<Card title="IPv4 配置" type="inner" className="mb-4">
|
||||||
<Form.Item label="启用 IPv4" name="ipv4Enabled" valuePropName="checked">
|
<Form.Item label="启用 IPv4" name="ipv4Enabled" valuePropName="checked">
|
||||||
<Switch />
|
<Switch/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="IPv4 采集范围" name="ipv4Scope">
|
<Form.Item label="IPv4 采集范围" name="ipv4Scope">
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
@@ -196,13 +196,13 @@ const PublicIPConfigComponent = ({defaultIPv4APIs, defaultIPv6APIs}: PublicIPCon
|
|||||||
name="ipv4ApisText"
|
name="ipv4ApisText"
|
||||||
tooltip="每行一个 HTTP/HTTPS API 地址"
|
tooltip="每行一个 HTTP/HTTPS API 地址"
|
||||||
>
|
>
|
||||||
<Input.TextArea rows={6} placeholder="每行一个 IPv4 API" />
|
<Input.TextArea rows={6} placeholder="每行一个 IPv4 API"/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="IPv6 配置" type="inner" className="mb-4">
|
<Card title="IPv6 配置" type="inner" className="mb-4">
|
||||||
<Form.Item label="启用 IPv6" name="ipv6Enabled" valuePropName="checked">
|
<Form.Item label="启用 IPv6" name="ipv6Enabled" valuePropName="checked">
|
||||||
<Switch />
|
<Switch/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="IPv6 采集范围" name="ipv6Scope">
|
<Form.Item label="IPv6 采集范围" name="ipv6Scope">
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
@@ -239,7 +239,7 @@ const PublicIPConfigComponent = ({defaultIPv4APIs, defaultIPv6APIs}: PublicIPCon
|
|||||||
name="ipv6ApisText"
|
name="ipv6ApisText"
|
||||||
tooltip="每行一个 HTTP/HTTPS API 地址"
|
tooltip="每行一个 HTTP/HTTPS API 地址"
|
||||||
>
|
>
|
||||||
<Input.TextArea rows={6} placeholder="每行一个 IPv6 API" />
|
<Input.TextArea rows={6} placeholder="每行一个 IPv6 API"/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user