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