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