fix(frontend): query schemes by type

This commit is contained in:
2026-07-30 11:01:45 +08:00
parent 4596af7c12
commit 7745333a58
7 changed files with 62 additions and 30 deletions
@@ -127,12 +127,15 @@ const SchemeQuery: React.FC<Props> = ({
const handleQuery = async () => {
setLoading(true);
try {
const params: Record<string, string> = { network: NETWORK_NAME };
const params: Record<string, string> = {
network: NETWORK_NAME,
scheme_type: "burst_detection",
};
if (!queryAll && queryDate) {
params.query_date = queryDate.startOf("day").toISOString();
}
const response = await api.get("/api/v1/burst-detection/schemes/", { params });
const response = await api.get("/api/v1/schemes", { params });
const nextSchemes = response.data as BurstDetectionSchemeRecord[];
setSchemes(nextSchemes);
open?.({
@@ -154,8 +157,8 @@ const SchemeQuery: React.FC<Props> = ({
const handleViewSchemeResult = async (schemeName: string) => {
try {
const response = await api.get(
`/api/v1/burst-detection/schemes/${encodeURIComponent(schemeName)}`,
{ params: { network: NETWORK_NAME } },
`/api/v1/schemes/${encodeURIComponent(schemeName)}`,
{ params: { network: NETWORK_NAME, scheme_type: "burst_detection" } },
);
const schemeRecord = response.data as BurstDetectionSchemeRecord & {
result_payload?: BurstDetectionResult;
@@ -125,7 +125,7 @@ const AnalysisParameters: React.FC<Props> = ({
setSchemeLoading(true);
try {
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params: { network: NETWORK_NAME },
params: { network: NETWORK_NAME, scheme_type: "burst_analysis" },
});
const burstSchemes = (response.data as SchemeItem[]).filter(
(scheme) => scheme.scheme_type === "burst_analysis",
@@ -222,18 +222,18 @@ const SchemeQuery: React.FC<Props> = ({
const handleQuery = async () => {
setLoading(true);
try {
// API call to fetch schemes
// Adjust URL as needed
let url = `${config.BACKEND_URL}/api/v1/burst-location/schemes/`;
const params: Record<string, string> = { network: NETWORK_NAME };
const params: Record<string, string> = {
network: NETWORK_NAME,
scheme_type: "burst_location",
};
if (!queryAll && queryDate) {
params.query_date = queryDate.startOf("day").toISOString();
}
const [response, simulationResponse] = await Promise.all([
api.get(url, { params }),
api.get(`${config.BACKEND_URL}/api/v1/schemes`, { params }),
api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params: { network: NETWORK_NAME },
params: { network: NETWORK_NAME, scheme_type: "burst_analysis" },
}),
]);
const nextSchemes = response.data as BurstSchemeRecord[];
@@ -274,8 +274,8 @@ const SchemeQuery: React.FC<Props> = ({
const handleViewSchemeResult = async (schemeName: string) => {
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/burst-location/schemes/${encodeURIComponent(schemeName)}`,
{ params: { network: NETWORK_NAME } },
`${config.BACKEND_URL}/api/v1/schemes/${encodeURIComponent(schemeName)}`,
{ params: { network: NETWORK_NAME, scheme_type: "burst_location" } },
);
const schemeRecord = response.data as BurstSchemeRecord & {
result_payload?: BurstLocationResult;
@@ -152,9 +152,16 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
setLoading(true);
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/schemes?network=${network}`,
);
const params: Record<string, string> = {
network,
scheme_type: SCHEME_TYPE,
};
if (!queryAll && queryDate) {
params.query_date = queryDate.startOf("day").toISOString();
}
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params,
});
let filteredResults = response.data;
if (!queryAll) {
@@ -178,7 +185,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
if (filteredResults.length === 0) {
open?.({
type: "error",
type: "success",
message: "查询结果",
description: queryAll
? "没有找到任何方案"
@@ -216,9 +216,16 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
if (!queryAll && !queryDate) return;
setLoading(true);
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/schemes?network=${network}`,
);
const params: Record<string, string> = {
network,
scheme_type: SCHEME_TYPE,
};
if (!queryAll && queryDate) {
params.query_date = queryDate.startOf("day").toISOString();
}
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params,
});
let filteredResults = response.data;
if (!queryAll) {
@@ -244,7 +251,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
if (filteredResults.length === 0) {
open?.({
type: "error",
type: "success",
message: "查询结果",
description: queryAll
? "没有找到任何方案"
@@ -79,18 +79,21 @@ const SchemeQuery: React.FC<Props> = ({
const handleQuery = async () => {
setLoading(true);
try {
const params: Record<string, string> = { network: NETWORK_NAME };
const params: Record<string, string> = {
network: NETWORK_NAME,
scheme_type: "dma_leak_identification",
};
if (!queryAll && queryDate) {
params.query_date = queryDate.startOf("day").toISOString();
}
const response = await api.get(`${config.BACKEND_URL}/api/v1/leakage/schemes/`, {
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params,
});
const nextSchemes = response.data as LeakageSchemeRecord[];
setSchemes(nextSchemes);
if (nextSchemes.length === 0) {
open?.({
type: "error",
type: "success",
message: "查询结果",
description: queryAll
? "没有找到任何方案"
@@ -117,8 +120,13 @@ const SchemeQuery: React.FC<Props> = ({
const handleViewSchemeResult = async (schemeName: string) => {
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/leakage/schemes/${encodeURIComponent(schemeName)}`,
{ params: { network: NETWORK_NAME } },
`${config.BACKEND_URL}/api/v1/schemes/${encodeURIComponent(schemeName)}`,
{
params: {
network: NETWORK_NAME,
scheme_type: "dma_leak_identification",
},
},
);
onViewResult(response.data as LeakageResultDetail);
} catch (error: any) {
@@ -262,9 +262,16 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
setLoading(true);
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/schemes?network=${network}`,
);
const params: Record<string, string> = {
network,
scheme_type: SCHEME_TYPE,
};
if (!queryAll && queryDate) {
params.query_date = queryDate.startOf("day").toISOString();
}
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params,
});
let filteredResults = response.data;
@@ -292,7 +299,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
if (filteredResults.length === 0) {
open?.({
type: "error",
type: "success",
message: "未找到相关方案",
description: "请尝试更改查询条件",
});