refactor(frontend): align TJWater Next integrations
This commit is contained in:
@@ -21,7 +21,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import "dayjs/locale/zh-cn";
|
||||
import { useNotification } from "@refinedev/core";
|
||||
import { api } from "@/lib/api";
|
||||
import { getAnalysisScheme, listAnalysisSchemes } from "@/lib/analysisRuns";
|
||||
import { NETWORK_NAME } from "@config/config";
|
||||
import { useControllableObjectState } from "@components/olmap/core/useControllableState";
|
||||
import { SchemeQueryEmptyState } from "@components/olmap/common/PanelEmptyState";
|
||||
@@ -42,7 +42,7 @@ interface Props {
|
||||
export interface BurstDetectionSchemeQueryState {
|
||||
queryAll: boolean;
|
||||
queryDate: Dayjs | null;
|
||||
expandedId: number | null;
|
||||
expandedId: string | null;
|
||||
hasQueried: boolean;
|
||||
}
|
||||
|
||||
@@ -130,15 +130,12 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
const handleQuery = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const params: Record<string, string> = {
|
||||
scheme_type: "burst_detection",
|
||||
};
|
||||
if (!queryAll && queryDate) {
|
||||
params.query_date = queryDate.startOf("day").toISOString();
|
||||
}
|
||||
|
||||
const response = await api.get("/api/v1/schemes", { params });
|
||||
const nextSchemes = response.data as BurstDetectionSchemeRecord[];
|
||||
const nextSchemes = (await listAnalysisSchemes({
|
||||
runType: "burst_detection",
|
||||
queryDate: !queryAll && queryDate
|
||||
? queryDate.format("YYYY-MM-DD")
|
||||
: undefined,
|
||||
})) as BurstDetectionSchemeRecord[];
|
||||
setSchemes(nextSchemes);
|
||||
setQueryField("hasQueried", true);
|
||||
open?.({
|
||||
@@ -157,13 +154,9 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
}
|
||||
};
|
||||
|
||||
const handleViewSchemeResult = async (schemeName: string) => {
|
||||
const handleViewSchemeResult = async (runId: string) => {
|
||||
try {
|
||||
const response = await api.get(
|
||||
`/api/v1/schemes/${encodeURIComponent(schemeName)}`,
|
||||
{ params: { scheme_type: "burst_detection" } },
|
||||
);
|
||||
const schemeRecord = response.data as BurstDetectionSchemeRecord & {
|
||||
const schemeRecord = (await getAnalysisScheme(runId)) as BurstDetectionSchemeRecord & {
|
||||
result_payload?: BurstDetectionResult;
|
||||
};
|
||||
const normalizedResult =
|
||||
@@ -185,7 +178,7 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
open?.({
|
||||
type: "success",
|
||||
message: "方案加载成功",
|
||||
description: `已加载方案:${schemeName}`,
|
||||
description: `已加载方案:${schemeRecord.scheme_name}`,
|
||||
});
|
||||
} catch (error: any) {
|
||||
open?.({
|
||||
@@ -398,7 +391,7 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
size="small"
|
||||
className="bg-blue-600 hover:bg-blue-700"
|
||||
sx={{ textTransform: "none", fontWeight: 500 }}
|
||||
onClick={() => handleViewSchemeResult(scheme.scheme_name)}
|
||||
onClick={() => handleViewSchemeResult(scheme.scheme_id)}
|
||||
>
|
||||
查看侦测结果
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user