fix(api): align frontend with REST contracts
This commit is contained in:
@@ -108,13 +108,13 @@ const fetchFromBackend = async (
|
||||
.join(",");
|
||||
|
||||
// 监测值数据接口(use_cleaned=false)
|
||||
const rawDataUrl = `${config.BACKEND_URL}/api/v1/composite/element-scada?element_id=${feature_ids}&start_time=${start_time}&end_time=${end_time}&use_cleaned=false`;
|
||||
const rawDataUrl = `${config.BACKEND_URL}/api/v1/timeseries/views/element-scada-readings?element_id=${feature_ids}&start_time=${start_time}&end_time=${end_time}&use_cleaned=false`;
|
||||
// 清洗数据接口(use_cleaned=true)
|
||||
const cleanedDataUrl = `${config.BACKEND_URL}/api/v1/composite/element-scada?element_id=${feature_ids}&start_time=${start_time}&end_time=${end_time}&use_cleaned=true`;
|
||||
const cleanedDataUrl = `${config.BACKEND_URL}/api/v1/timeseries/views/element-scada-readings?element_id=${feature_ids}&start_time=${start_time}&end_time=${end_time}&use_cleaned=true`;
|
||||
// 模拟数据接口
|
||||
const simulationDataUrl = `${config.BACKEND_URL}/api/v1/composite/element-simulation?feature_infos=${feature_infos}&start_time=${start_time}&end_time=${end_time}`;
|
||||
const simulationDataUrl = `${config.BACKEND_URL}/api/v1/timeseries/views/element-simulations?feature_infos=${feature_infos}&start_time=${start_time}&end_time=${end_time}`;
|
||||
// 策略模拟数据接口
|
||||
const schemeSimulationDataUrl = `${config.BACKEND_URL}/api/v1/composite/element-simulation?feature_infos=${feature_infos}&start_time=${start_time}&end_time=${end_time}&scheme_type=${scheme_type}&scheme_name=${scheme_name}`;
|
||||
const schemeSimulationDataUrl = `${config.BACKEND_URL}/api/v1/timeseries/views/element-simulations?feature_infos=${feature_infos}&start_time=${start_time}&end_time=${end_time}&scheme_type=${scheme_type}&scheme_name=${scheme_name}`;
|
||||
|
||||
try {
|
||||
if (type === "none") {
|
||||
|
||||
@@ -241,11 +241,11 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
nodePromise =
|
||||
sourceType === "scheme" && schemeName
|
||||
? apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/scheme/query/by-scheme-time-property?scheme_type=${schemeType}&scheme_name=${schemeName}&query_time=${query_time}&type=node&property=${junctionProperties}`,
|
||||
`${config.BACKEND_URL}/api/v1/timeseries/schemes/records?scheme_type=${schemeType}&scheme_name=${schemeName}&query_time=${query_time}&type=node&property=${junctionProperties}`,
|
||||
{ signal },
|
||||
)
|
||||
: apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/realtime/query/by-time-property?query_time=${query_time}&type=node&property=${junctionProperties}`,
|
||||
`${config.BACKEND_URL}/api/v1/timeseries/realtime/records?query_time=${query_time}&type=node&property=${junctionProperties}`,
|
||||
{ signal },
|
||||
);
|
||||
requests.push(nodePromise);
|
||||
@@ -270,11 +270,11 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
linkPromise =
|
||||
sourceType === "scheme" && schemeName
|
||||
? apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/scheme/query/by-scheme-time-property?scheme_type=${schemeType}&scheme_name=${schemeName}&query_time=${query_time}&type=link&property=${normalizedPipeProperties}`,
|
||||
`${config.BACKEND_URL}/api/v1/timeseries/schemes/records?scheme_type=${schemeType}&scheme_name=${schemeName}&query_time=${query_time}&type=link&property=${normalizedPipeProperties}`,
|
||||
{ signal },
|
||||
)
|
||||
: apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/realtime/query/by-time-property?query_time=${query_time}&type=link&property=${normalizedPipeProperties}`,
|
||||
`${config.BACKEND_URL}/api/v1/timeseries/realtime/records?query_time=${query_time}&type=link&property=${normalizedPipeProperties}`,
|
||||
{ signal },
|
||||
);
|
||||
requests.push(linkPromise);
|
||||
@@ -717,13 +717,12 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
});
|
||||
try {
|
||||
const body = {
|
||||
name: NETWORK_NAME,
|
||||
start_time: dayjs(calculationDateTime).format("YYYY-MM-DDTHH:mm:ssZ"),
|
||||
duration: calculatedInterval,
|
||||
};
|
||||
|
||||
const response = await apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/simulations/run-by-date`,
|
||||
`${config.BACKEND_URL}/api/v1/simulation-runs`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
||||
@@ -431,11 +431,10 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
network: networkName,
|
||||
link: selectedValveId,
|
||||
});
|
||||
const response = await apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/getstatus/?${params.toString()}`,
|
||||
`${config.BACKEND_URL}/api/v1/status?${params.toString()}`,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -484,11 +483,10 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
network: networkName,
|
||||
valve: selectedValveId,
|
||||
});
|
||||
const response = await apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/getvalveproperties/?${params.toString()}`,
|
||||
`${config.BACKEND_URL}/api/v1/valves/properties?${params.toString()}`,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -534,13 +532,12 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
setIsValveStatusSaving(true);
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
network: networkName,
|
||||
link: selectedValveId,
|
||||
});
|
||||
const response = await apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/setstatus/?${params.toString()}`,
|
||||
`${config.BACKEND_URL}/api/v1/status-properties?${params.toString()}`,
|
||||
{
|
||||
method: "POST",
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
@@ -567,7 +564,7 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
setIsValveStatusSaving(false);
|
||||
}
|
||||
},
|
||||
[networkName, open, selectedValveId],
|
||||
[open, selectedValveId],
|
||||
);
|
||||
|
||||
const handleValveSettingSave = useCallback(
|
||||
@@ -600,13 +597,12 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
setIsValveSettingSaving(true);
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
network: networkName,
|
||||
valve: selectedValveId,
|
||||
});
|
||||
const response = await apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/setvalveproperties/?${params.toString()}`,
|
||||
`${config.BACKEND_URL}/api/v1/valves/properties?${params.toString()}`,
|
||||
{
|
||||
method: "POST",
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
@@ -637,7 +633,6 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
}
|
||||
},
|
||||
[
|
||||
networkName,
|
||||
open,
|
||||
selectedValveId,
|
||||
selectedValveType,
|
||||
@@ -679,12 +674,12 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
if (queryType === "scheme") {
|
||||
response = await apiFetch(
|
||||
// `${config.BACKEND_URL}/queryschemesimulationrecordsbyidtime/?scheme_name=${schemeName}&id=${id}&querytime=${querytime}&type=${type}`
|
||||
`${config.BACKEND_URL}/api/v1/scheme/query/by-id-time?scheme_type=${schemeType}&scheme_name=${schemeName}&id=${id}&type=${type}&query_time=${querytime}`,
|
||||
`${config.BACKEND_URL}/api/v1/timeseries/schemes/simulation-results?scheme_type=${schemeType}&scheme_name=${schemeName}&id=${id}&type=${type}&query_time=${querytime}`,
|
||||
);
|
||||
} else {
|
||||
response = await apiFetch(
|
||||
// `${config.BACKEND_URL}/querysimulationrecordsbyidtime/?id=${id}&querytime=${querytime}&type=${type}`
|
||||
`${config.BACKEND_URL}/api/v1/realtime/query/by-id-time?id=${id}&type=${type}&query_time=${querytime}`,
|
||||
`${config.BACKEND_URL}/api/v1/timeseries/realtime/simulation-results?id=${id}&type=${type}&query_time=${querytime}`,
|
||||
);
|
||||
}
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("useTimelineTimeConfig", () => {
|
||||
});
|
||||
expect(result.current.durationMinutes).toBe(1440);
|
||||
expect(String(apiFetch.mock.calls[0][0])).toContain(
|
||||
"/api/v1/gettimeproperties/?network=test-network",
|
||||
"/api/v1/network-options/time",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -68,9 +68,7 @@ export const useTimelineTimeConfig = (): TimelineTimeConfig => {
|
||||
const fetchTimeProperties = async () => {
|
||||
try {
|
||||
const response = await apiFetch(
|
||||
`${config.BACKEND_URL}/api/v1/gettimeproperties/?network=${encodeURIComponent(
|
||||
networkName,
|
||||
)}`,
|
||||
`${config.BACKEND_URL}/api/v1/network-options/time`,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch time properties: ${response.status}`);
|
||||
|
||||
@@ -164,7 +164,7 @@ export const useToolbarChatActions = ({
|
||||
? `?session_id=${encodeURIComponent(action.sessionId)}`
|
||||
: "";
|
||||
const response = await apiFetch(
|
||||
`${config.AGENT_URL}/api/v1/agent/chat/render-ref/${encodeURIComponent(action.renderRef)}${query}`,
|
||||
`${config.AGENT_URL}/api/v1/agent/render-references/${encodeURIComponent(action.renderRef)}${query}`,
|
||||
{
|
||||
method: "GET",
|
||||
projectHeaderMode: "include",
|
||||
|
||||
Reference in New Issue
Block a user