🐛 fix: Increase pagination size limit for server and node lists to improve data retrieval
This commit is contained in:
parent
10250d9e34
commit
7c0a312163
@ -92,7 +92,7 @@ export default function NodeForm(props: {
|
|||||||
const { data } = useQuery({
|
const { data } = useQuery({
|
||||||
queryKey: ['filterServerListAll'],
|
queryKey: ['filterServerListAll'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await filterServerList({ page: 1, size: 1000 });
|
const { data } = await filterServerList({ page: 1, size: 999999999 });
|
||||||
return data?.data?.list || [];
|
return data?.data?.list || [];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -130,17 +130,32 @@ export default function NodeForm(props: {
|
|||||||
|
|
||||||
const sel = servers.find((s) => s.id === id);
|
const sel = servers.find((s) => s.id === id);
|
||||||
const dirty = form.formState.dirtyFields as Record<string, any>;
|
const dirty = form.formState.dirtyFields as Record<string, any>;
|
||||||
|
const currentValues = form.getValues();
|
||||||
|
|
||||||
if (!dirty.name) {
|
if (!dirty.name) {
|
||||||
form.setValue('name', (sel?.name as string) || '', { shouldDirty: false });
|
form.setValue('name', (sel?.name as string) || '', { shouldDirty: false });
|
||||||
}
|
}
|
||||||
if (!dirty.address) {
|
|
||||||
|
if (
|
||||||
|
!dirty.address &&
|
||||||
|
(!currentValues.address || currentValues.address === (sel?.address as string))
|
||||||
|
) {
|
||||||
form.setValue('address', (sel?.address as string) || '', { shouldDirty: false });
|
form.setValue('address', (sel?.address as string) || '', { shouldDirty: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
const allowed = (sel?.protocols || [])
|
const allowed = (sel?.protocols || [])
|
||||||
.map((p) => (p as any).type as ProtocolName)
|
.map((p) => (p as any).type as ProtocolName)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
if (!allowed.includes(form.getValues('protocol') as ProtocolName)) {
|
|
||||||
form.setValue('protocol', '' as any);
|
const currentProtocol = form.getValues('protocol') as ProtocolName;
|
||||||
|
|
||||||
|
if (!allowed.includes(currentProtocol)) {
|
||||||
|
const firstProtocol = allowed[0] || '';
|
||||||
|
form.setValue('protocol', firstProtocol as any);
|
||||||
|
|
||||||
|
if (firstProtocol) {
|
||||||
|
handleProtocolChange(firstProtocol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,13 +163,18 @@ export default function NodeForm(props: {
|
|||||||
const p = (nextProto || '') as ProtocolName | '';
|
const p = (nextProto || '') as ProtocolName | '';
|
||||||
form.setValue('protocol', p);
|
form.setValue('protocol', p);
|
||||||
if (!p || !currentServer) return;
|
if (!p || !currentServer) return;
|
||||||
|
|
||||||
const dirty = form.formState.dirtyFields as Record<string, any>;
|
const dirty = form.formState.dirtyFields as Record<string, any>;
|
||||||
|
const currentValues = form.getValues();
|
||||||
|
|
||||||
if (!dirty.port) {
|
if (!dirty.port) {
|
||||||
const hit = (currentServer.protocols as any[]).find((x) => (x as any).type === p);
|
const hit = (currentServer.protocols as any[]).find((x) => (x as any).type === p);
|
||||||
const port = (hit as any)?.port as number | undefined;
|
const port = (hit as any)?.port as number | undefined;
|
||||||
form.setValue('port', typeof port === 'number' && port > 0 ? port : 0, {
|
const newPort = typeof port === 'number' && port > 0 ? port : 0;
|
||||||
shouldDirty: false,
|
|
||||||
});
|
if (!currentValues.port || currentValues.port === 0 || currentValues.port === newPort) {
|
||||||
|
form.setValue('port', newPort, { shouldDirty: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ export default function NodesPage() {
|
|||||||
const { data: servers = [] } = useQuery({
|
const { data: servers = [] } = useQuery({
|
||||||
queryKey: ['filterServerListAll'],
|
queryKey: ['filterServerListAll'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await filterServerList({ page: 1, size: 1000 });
|
const { data } = await filterServerList({ page: 1, size: 999999999 });
|
||||||
return data?.data?.list || [];
|
return data?.data?.list || [];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,7 +37,7 @@ export default function Page() {
|
|||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getSubscribeList({
|
const { data } = await getSubscribeList({
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 9999,
|
size: 999999999,
|
||||||
});
|
});
|
||||||
return data.data?.list as API.SubscribeGroup[];
|
return data.data?.list as API.SubscribeGroup[];
|
||||||
},
|
},
|
||||||
|
|||||||
@ -241,7 +241,7 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
|||||||
const { data: nodes } = useQuery({
|
const { data: nodes } = useQuery({
|
||||||
queryKey: ['filterNodeListAll'],
|
queryKey: ['filterNodeListAll'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await filterNodeList({ page: 1, size: 9999 });
|
const { data } = await filterNodeList({ page: 1, size: 999999999 });
|
||||||
return (data.data?.list || []) as API.Node[];
|
return (data.data?.list || []) as API.Node[];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user