Refactor 3D Widget Input Handling and Cleanup
- Removed commented-out code related to adding 3D widgets from BarChartInput, LineGrapInput, PieChartInput, Progress1Input, Progress2Input components. - Updated widget input fetching logic in Widget2InputCard3D, Widget3InputCard3D, and Widget4InputCard3D to include projectId and versionId. - Enhanced error handling and logging in add3dWidget and get3dWidgetInput services. - Cleaned up console logs and unnecessary comments across various components for better readability. - Ensured consistent handling of widget data structure in ProductionCapacity, ReturnOfInvestment, StateWorking, and Throughput components.
This commit is contained in:
@@ -91,16 +91,7 @@ const BarChartInput = (props: Props) => {
|
|||||||
duration: inputDuration,
|
duration: inputDuration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// const adding3dWidget = {
|
|
||||||
// organization: organization,
|
|
||||||
// widget: newWidget,
|
|
||||||
// zoneUuid: selectedZone.zoneUuid,
|
|
||||||
// projectId, userId
|
|
||||||
// };
|
|
||||||
// if (visualizationSocket) {
|
|
||||||
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
|
||||||
|
|
||||||
// }
|
|
||||||
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -210,15 +210,7 @@ const LineGrapInput = (props: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const adding3dWidget = {
|
|
||||||
// organization: organization,
|
|
||||||
// widget: newWidget,
|
|
||||||
// zoneUuid: selectedZone.zoneUuid,
|
|
||||||
// projectId, userId
|
|
||||||
// };
|
|
||||||
// if (visualizationSocket) {
|
|
||||||
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
|
||||||
// }
|
|
||||||
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
||||||
|
|
||||||
if (response.message === "Widget updated successfully") {
|
if (response.message === "Widget updated successfully") {
|
||||||
|
|||||||
@@ -94,15 +94,7 @@ const PieChartInput = (props: Props) => {
|
|||||||
duration: inputDuration,
|
duration: inputDuration,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// const adding3dWidget = {
|
|
||||||
// organization: organization,
|
|
||||||
// widget: newWidget,
|
|
||||||
// zoneUuid: selectedZone.zoneUuid,
|
|
||||||
// projectId, userId
|
|
||||||
// };
|
|
||||||
// if (visualizationSocket) {
|
|
||||||
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
|
||||||
// }
|
|
||||||
|
|
||||||
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
||||||
|
|
||||||
|
|||||||
@@ -93,15 +93,7 @@ const Progress1Input = (props: Props) => {
|
|||||||
duration: inputDuration,
|
duration: inputDuration,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// const adding3dWidget = {
|
|
||||||
// organization: organization,
|
|
||||||
// widget: newWidget,
|
|
||||||
// zoneUuid: selectedZone.zoneUuid,
|
|
||||||
// projectId, userId
|
|
||||||
// };
|
|
||||||
// if (visualizationSocket) {
|
|
||||||
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
|
||||||
// }
|
|
||||||
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
||||||
|
|
||||||
if (response.message === "Widget updated successfully") {
|
if (response.message === "Widget updated successfully") {
|
||||||
|
|||||||
@@ -94,16 +94,6 @@ const Progress2Input = (props: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const adding3dWidget = {
|
|
||||||
// organization: organization,
|
|
||||||
// widget: newWidget,
|
|
||||||
// zoneUuid: selectedZone.zoneUuid,
|
|
||||||
// projectId, userId
|
|
||||||
// };
|
|
||||||
// if (visualizationSocket) {
|
|
||||||
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
|
||||||
// }
|
|
||||||
|
|
||||||
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
||||||
|
|
||||||
if (response.message === "Widget updated successfully") {
|
if (response.message === "Widget updated successfully") {
|
||||||
|
|||||||
@@ -38,15 +38,15 @@ const Widget2InputCard3D = (props: Props) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
|
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// console.log("dropdown data:", response.data);
|
//
|
||||||
setDropDownData(response.data);
|
setDropDownData(response.data);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} else {
|
} else {
|
||||||
// console.log("Unexpected response:", response);
|
//
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
echo.error("Failed to fetch zone data");
|
echo.error("Failed to fetch zone data");
|
||||||
console.error("There was an error!", error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchZoneData();
|
fetchZoneData();
|
||||||
@@ -55,14 +55,14 @@ const Widget2InputCard3D = (props: Props) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchSavedInputes = async () => {
|
const fetchSavedInputes = async () => {
|
||||||
if (selectedChartId.id !== "") {
|
if (selectedChartId.id !== "") {
|
||||||
let response = await get3dWidgetInput(selectedChartId.id, organization)
|
let response = await get3dWidgetInput(selectedChartId.id, organization, projectId, selectedVersion?.versionId || "")
|
||||||
console.log('response: ', response);
|
|
||||||
if (response) {
|
if (response) {
|
||||||
setSelections(response.data.Data.measurements);
|
setSelections(response.Datastructure.measurements);
|
||||||
setDuration(response.data.Data.duration);
|
setDuration(response.Datastructure.duration);
|
||||||
setWidgetName(response.data.widgetName);
|
setWidgetName(response.widgetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -81,44 +81,61 @@ const Widget2InputCard3D = (props: Props) => {
|
|||||||
inputDuration: any,
|
inputDuration: any,
|
||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
// let newWidget = {
|
let newWidget = {
|
||||||
// id: selectedChartId.id,
|
id: selectedChartId.id,
|
||||||
// widgetName: inputName,
|
widgetName: inputName,
|
||||||
// Data: {
|
Data: {
|
||||||
// measurements: inputMeasurement,
|
measurements: inputMeasurement,
|
||||||
// duration: inputDuration,
|
duration: inputDuration,
|
||||||
// },
|
},
|
||||||
// }
|
|
||||||
|
|
||||||
// let response = await adding3dWidgets(selectedZone.zoneUuid, organization, newWidget,projectId, selectedVersion?.versionId || "")
|
|
||||||
// console.log('response: ', response);
|
|
||||||
try {
|
|
||||||
const response = await axios.post(
|
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`,
|
|
||||||
{
|
|
||||||
organization,
|
|
||||||
zoneUuid: selectedZone.zoneUuid,
|
|
||||||
widget: {
|
|
||||||
id: selectedChartId.id,
|
|
||||||
widgetName: inputName,
|
|
||||||
Data: {
|
|
||||||
measurements: inputMeasurement,
|
|
||||||
duration: inputDuration,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as any
|
|
||||||
);
|
|
||||||
if (response.status === 200) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// console.log("Unexpected response:", response);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
echo.error("Failed to send input");
|
|
||||||
console.error("There was an error!", error);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let response = await adding3dWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
|
||||||
|
|
||||||
|
if (response.message === "widget update successfully") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// try {
|
||||||
|
// const response = await axios.post(
|
||||||
|
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`,
|
||||||
|
// {
|
||||||
|
// headers: {
|
||||||
|
// Authorization: "Bearer <access_token>",
|
||||||
|
// "Content-Type": "application/json",
|
||||||
|
// token: localStorage.getItem("token") || "",
|
||||||
|
// refresh_token: localStorage.getItem("refreshToken") || "",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// organization,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// widget: {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// projectId: projectId,
|
||||||
|
// versionId: selectedVersion?.versionId || ""
|
||||||
|
// } as any,
|
||||||
|
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (response.status === 200) {
|
||||||
|
// return true;
|
||||||
|
// } else {
|
||||||
|
// //
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// echo.error("Failed to send input");
|
||||||
|
//
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelect = async (
|
const handleSelect = async (
|
||||||
@@ -133,7 +150,7 @@ const Widget2InputCard3D = (props: Props) => {
|
|||||||
newSelections[inputKey] = selectedData;
|
newSelections[inputKey] = selectedData;
|
||||||
}
|
}
|
||||||
// setMeasurements(newSelections); // Update Zustand store
|
// setMeasurements(newSelections); // Update Zustand store
|
||||||
// console.log(newSelections);
|
//
|
||||||
if (await sendInputes(newSelections, duration, widgetName)) {
|
if (await sendInputes(newSelections, duration, widgetName)) {
|
||||||
setSelections(newSelections);
|
setSelections(newSelections);
|
||||||
}
|
}
|
||||||
@@ -150,7 +167,7 @@ const Widget2InputCard3D = (props: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleNameChange = async (name: any) => {
|
const handleNameChange = async (name: any) => {
|
||||||
// console.log("name change requested", name);
|
//
|
||||||
|
|
||||||
if (await sendInputes(selections, duration, name)) {
|
if (await sendInputes(selections, duration, name)) {
|
||||||
setWidgetName(name);
|
setWidgetName(name);
|
||||||
|
|||||||
@@ -36,15 +36,15 @@ const Widget3InputCard3D = () => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await axios.get(`http://${iotApiUrl}/getinput`);
|
const response = await axios.get(`http://${iotApiUrl}/getinput`);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// console.log("dropdown data:", response.data);
|
//
|
||||||
setDropDownData(response.data);
|
setDropDownData(response.data);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} else {
|
} else {
|
||||||
// console.log("Unexpected response:", response);
|
//
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
echo.error("Failed to fetch zone data");
|
echo.error("Failed to fetch zone data");
|
||||||
console.error("There was an error!", error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchZoneData();
|
fetchZoneData();
|
||||||
@@ -53,12 +53,12 @@ const Widget3InputCard3D = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchSavedInputes = async () => {
|
const fetchSavedInputes = async () => {
|
||||||
if (selectedChartId.id !== "") {
|
if (selectedChartId.id !== "") {
|
||||||
let response = await get3dWidgetInput(selectedChartId.id, organization)
|
let response = await get3dWidgetInput(selectedChartId.id, organization, projectId, selectedVersion?.versionId || "")
|
||||||
console.log('response: ', response);
|
|
||||||
if (response) {
|
if (response) {
|
||||||
setSelections(response.data.Data.measurements);
|
setSelections(response.Datastructure.measurements);
|
||||||
setDuration(response.data.Data.duration);
|
setDuration(response.Datastructure.duration);
|
||||||
setWidgetName(response.data.widgetName);
|
setWidgetName(response.widgetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -79,45 +79,61 @@ const Widget3InputCard3D = () => {
|
|||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
// let newWidget = {
|
let newWidget = {
|
||||||
// id: selectedChartId.id,
|
id: selectedChartId.id,
|
||||||
// widgetName: inputName,
|
widgetName: inputName,
|
||||||
// Data: {
|
Data: {
|
||||||
// measurements: inputMeasurement,
|
measurements: inputMeasurement,
|
||||||
// duration: inputDuration,
|
duration: inputDuration,
|
||||||
// },
|
},
|
||||||
// }
|
|
||||||
|
|
||||||
// let response = await adding3dWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
|
|
||||||
// console.log('response: ', response);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await axios.post(
|
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`,
|
|
||||||
{
|
|
||||||
organization,
|
|
||||||
zoneUuid: selectedZone.zoneUuid,
|
|
||||||
widget: {
|
|
||||||
id: selectedChartId.id,
|
|
||||||
widgetName: inputName,
|
|
||||||
Data: {
|
|
||||||
measurements: inputMeasurement,
|
|
||||||
duration: inputDuration,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as any
|
|
||||||
);
|
|
||||||
if (response.status === 200) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// console.log("Unexpected response:", response);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
echo.error("Failed to send input");
|
|
||||||
console.error("There was an error!", error);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let response = await adding3dWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
|
||||||
|
|
||||||
|
if (response.message === "widget update successfully") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// const response = await axios.post(
|
||||||
|
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`,
|
||||||
|
// {
|
||||||
|
// headers: {
|
||||||
|
// Authorization: "Bearer <access_token>",
|
||||||
|
// "Content-Type": "application/json",
|
||||||
|
// token: localStorage.getItem("token") || "",
|
||||||
|
// refresh_token: localStorage.getItem("refreshToken") || "",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// organization,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// widget: {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// projectId: projectId,
|
||||||
|
// versionId: selectedVersion?.versionId || ""
|
||||||
|
// } as any
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (response.status === 200) {
|
||||||
|
// return true;
|
||||||
|
// } else {
|
||||||
|
// //
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// echo.error("Failed to send input");
|
||||||
|
//
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelect = async (
|
const handleSelect = async (
|
||||||
@@ -132,7 +148,7 @@ const Widget3InputCard3D = () => {
|
|||||||
newSelections[inputKey] = selectedData;
|
newSelections[inputKey] = selectedData;
|
||||||
}
|
}
|
||||||
// setMeasurements(newSelections); // Update Zustand store
|
// setMeasurements(newSelections); // Update Zustand store
|
||||||
// console.log(newSelections);
|
//
|
||||||
if (await sendInputes(newSelections, duration, widgetName)) {
|
if (await sendInputes(newSelections, duration, widgetName)) {
|
||||||
setSelections(newSelections);
|
setSelections(newSelections);
|
||||||
}
|
}
|
||||||
@@ -145,7 +161,7 @@ const Widget3InputCard3D = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleNameChange = async (name: any) => {
|
const handleNameChange = async (name: any) => {
|
||||||
// console.log("name change requested", name);
|
//
|
||||||
|
|
||||||
if (await sendInputes(selections, duration, name)) {
|
if (await sendInputes(selections, duration, name)) {
|
||||||
setWidgetName(name);
|
setWidgetName(name);
|
||||||
|
|||||||
@@ -38,15 +38,15 @@ const Widget4InputCard3D = (props: Props) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
|
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// console.log("dropdown data:", response.data);
|
//
|
||||||
setDropDownData(response.data);
|
setDropDownData(response.data);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} else {
|
} else {
|
||||||
// console.log("Unexpected response:", response);
|
//
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
echo.error("Failed to fetch zone data");
|
echo.error("Failed to fetch zone data");
|
||||||
console.error("There was an error!", error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchZoneData();
|
fetchZoneData();
|
||||||
@@ -55,14 +55,17 @@ const Widget4InputCard3D = (props: Props) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchSavedInputes = async () => {
|
const fetchSavedInputes = async () => {
|
||||||
if (selectedChartId.id !== "") {
|
if (selectedChartId.id !== "") {
|
||||||
let response = await get3dWidgetInput(selectedChartId.id, organization)
|
|
||||||
console.log('response: ', response);
|
|
||||||
|
|
||||||
|
let response = await get3dWidgetInput(selectedChartId.id, organization, projectId, selectedVersion?.versionId || "")
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
setSelections(response.data.Data.measurements);
|
setSelections(response.Datastructure.measurements);
|
||||||
setDuration(response.data.Data.duration);
|
setDuration(response.Datastructure.duration);
|
||||||
setWidgetName(response.data.widgetName);
|
setWidgetName(response.widgetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -81,44 +84,61 @@ const Widget4InputCard3D = (props: Props) => {
|
|||||||
inputDuration: any,
|
inputDuration: any,
|
||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
// let newWidget = {
|
let newWidget = {
|
||||||
// id: selectedChartId.id,
|
id: selectedChartId.id,
|
||||||
// widgetName: inputName,
|
widgetName: inputName,
|
||||||
// Data: {
|
Data: {
|
||||||
// measurements: inputMeasurement,
|
measurements: inputMeasurement,
|
||||||
// duration: inputDuration,
|
duration: inputDuration,
|
||||||
// },
|
},
|
||||||
// }
|
|
||||||
|
|
||||||
// let response = await adding3dWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
|
|
||||||
// console.log('response: ', response);
|
|
||||||
try {
|
|
||||||
const response = await axios.post(
|
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`,
|
|
||||||
{
|
|
||||||
organization,
|
|
||||||
zoneUuid: selectedZone.zoneUuid,
|
|
||||||
widget: {
|
|
||||||
id: selectedChartId.id,
|
|
||||||
widgetName: inputName,
|
|
||||||
Data: {
|
|
||||||
measurements: inputMeasurement,
|
|
||||||
duration: inputDuration,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as any
|
|
||||||
);
|
|
||||||
if (response.status === 200) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// console.log("Unexpected response:", response);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
echo.error("Failed to send input");
|
|
||||||
console.error("There was an error!", error);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let response = await adding3dWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
|
||||||
|
|
||||||
|
if (response.message === "widget update successfully") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// const response = await axios.post(
|
||||||
|
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`,
|
||||||
|
// {
|
||||||
|
// headers: {
|
||||||
|
// Authorization: "Bearer <access_token>",
|
||||||
|
// "Content-Type": "application/json",
|
||||||
|
// token: localStorage.getItem("token") || "",
|
||||||
|
// refresh_token: localStorage.getItem("refreshToken") || "",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// organization,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// widget: {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// projectId: projectId,
|
||||||
|
// versionId: selectedVersion?.versionId || ""
|
||||||
|
// } as any
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (response.status === 200) {
|
||||||
|
// return true;
|
||||||
|
// } else {
|
||||||
|
// //
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// echo.error("Failed to send input");
|
||||||
|
//
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelect = async (
|
const handleSelect = async (
|
||||||
@@ -133,7 +153,7 @@ const Widget4InputCard3D = (props: Props) => {
|
|||||||
newSelections[inputKey] = selectedData;
|
newSelections[inputKey] = selectedData;
|
||||||
}
|
}
|
||||||
// setMeasurements(newSelections); // Update Zustand store
|
// setMeasurements(newSelections); // Update Zustand store
|
||||||
// console.log(newSelections);
|
//
|
||||||
if (await sendInputes(newSelections, duration, widgetName)) {
|
if (await sendInputes(newSelections, duration, widgetName)) {
|
||||||
setSelections(newSelections);
|
setSelections(newSelections);
|
||||||
}
|
}
|
||||||
@@ -150,7 +170,7 @@ const Widget4InputCard3D = (props: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleNameChange = async (name: any) => {
|
const handleNameChange = async (name: any) => {
|
||||||
console.log("name change requested", name);
|
|
||||||
|
|
||||||
if (await sendInputes(selections, duration, name)) {
|
if (await sendInputes(selections, duration, name)) {
|
||||||
setWidgetName(name);
|
setWidgetName(name);
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ const DxfFile = ({
|
|||||||
userId
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('input: ', input);
|
||||||
socket.emit('v1:Line:create', input);
|
socket.emit('v1:Line:create', input);
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ async function drawOnlyFloor(
|
|||||||
userId,
|
userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('input: ', input);
|
||||||
socket.emit("v1:Line:create", input);
|
socket.emit("v1:Line:create", input);
|
||||||
|
|
||||||
setNewLines([newLines[0], newLines[1], line.current]);
|
setNewLines([newLines[0], newLines[1], line.current]);
|
||||||
@@ -248,6 +249,7 @@ async function drawOnlyFloor(
|
|||||||
userId,
|
userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('input: ', input);
|
||||||
socket.emit("v1:Line:create", input);
|
socket.emit("v1:Line:create", input);
|
||||||
|
|
||||||
setNewLines([line.current]);
|
setNewLines([line.current]);
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ async function drawWall(
|
|||||||
userId,
|
userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('input: ', input);
|
||||||
socket.emit("v1:Line:create", input);
|
socket.emit("v1:Line:create", input);
|
||||||
|
|
||||||
setNewLines([newLines[0], newLines[1], line.current]);
|
setNewLines([newLines[0], newLines[1], line.current]);
|
||||||
@@ -222,6 +223,7 @@ async function drawWall(
|
|||||||
userId,
|
userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('input: ', input);
|
||||||
socket.emit("v1:Line:create", input);
|
socket.emit("v1:Line:create", input);
|
||||||
|
|
||||||
setNewLines([line.current]);
|
setNewLines([line.current]);
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ function splitLine(
|
|||||||
userId,
|
userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('input1: ', input1);
|
||||||
socket.emit("v1:Line:create", input1);
|
socket.emit("v1:Line:create", input1);
|
||||||
|
|
||||||
//REST
|
//REST
|
||||||
@@ -126,6 +127,7 @@ function splitLine(
|
|||||||
userId,
|
userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('input2: ', input2);
|
||||||
socket.emit("v1:Line:create", input2);
|
socket.emit("v1:Line:create", input2);
|
||||||
|
|
||||||
lines.current.push(newLine1, newLine2);
|
lines.current.push(newLine1, newLine2);
|
||||||
|
|||||||
@@ -106,17 +106,17 @@ export default function Dropped3dWidgets() {
|
|||||||
const hasEntered = { current: false };
|
const hasEntered = { current: false };
|
||||||
|
|
||||||
const handleDragEnter = (event: DragEvent) => {
|
const handleDragEnter = (event: DragEvent) => {
|
||||||
console.log("dragEnter");
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
if (hasEntered.current || !widgetSelect.startsWith("ui")) return;
|
if (hasEntered.current || !widgetSelect.startsWith("ui")) return;
|
||||||
console.log('hasEntered.current : ', hasEntered.current );
|
|
||||||
hasEntered.current = true;
|
hasEntered.current = true;
|
||||||
|
|
||||||
const group1 = scene.getObjectByName("itemsGroup");
|
// const group1 = scene.getObjectByName("itemsGroup");
|
||||||
console.log('group1: ', group1);
|
//
|
||||||
if (!group1) return;
|
// if (!group1) return;
|
||||||
|
|
||||||
const rect = canvasElement.getBoundingClientRect();
|
const rect = canvasElement.getBoundingClientRect();
|
||||||
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
||||||
@@ -139,7 +139,7 @@ export default function Dropped3dWidgets() {
|
|||||||
intersect.object.type !== "GridHelper"
|
intersect.object.type !== "GridHelper"
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('intersects: ', intersects);
|
|
||||||
if (intersects.length > 0) {
|
if (intersects.length > 0) {
|
||||||
const { x, y, z } = intersects[0].point;
|
const { x, y, z } = intersects[0].point;
|
||||||
const newWidget: WidgetData = {
|
const newWidget: WidgetData = {
|
||||||
@@ -238,10 +238,11 @@ export default function Dropped3dWidgets() {
|
|||||||
organization,
|
organization,
|
||||||
widget: newWidget,
|
widget: newWidget,
|
||||||
zoneUuid: selectedZone.zoneUuid,
|
zoneUuid: selectedZone.zoneUuid,
|
||||||
version: selectedVersion?.versionId || '',
|
versionId: selectedVersion?.versionId || '',
|
||||||
projectId,
|
projectId,
|
||||||
userId
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (visualizationSocket) {
|
if (visualizationSocket) {
|
||||||
visualizationSocket.emit("v1:viz-3D-widget:add", add3dWidget);
|
visualizationSocket.emit("v1:viz-3D-widget:add", add3dWidget);
|
||||||
@@ -276,7 +277,7 @@ export default function Dropped3dWidgets() {
|
|||||||
const widgetToDuplicate = activeZoneWidgets.find(
|
const widgetToDuplicate = activeZoneWidgets.find(
|
||||||
(w: WidgetData) => w.id === rightClickSelected
|
(w: WidgetData) => w.id === rightClickSelected
|
||||||
);
|
);
|
||||||
console.log("3d widget to duplecate", widgetToDuplicate);
|
|
||||||
|
|
||||||
if (!widgetToDuplicate) return;
|
if (!widgetToDuplicate) return;
|
||||||
const newWidget: any = {
|
const newWidget: any = {
|
||||||
@@ -301,6 +302,7 @@ export default function Dropped3dWidgets() {
|
|||||||
projectId,
|
projectId,
|
||||||
userId
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
if (visualizationSocket) {
|
if (visualizationSocket) {
|
||||||
visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
||||||
}
|
}
|
||||||
@@ -470,20 +472,20 @@ export default function Dropped3dWidgets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if (rightSelect === "Vertical Move") {
|
// if (rightSelect === "Vertical Move") {
|
||||||
// // console.log('rightSelect: ', rightSelect);
|
// //
|
||||||
|
|
||||||
// // console.log('floorPlanesVertical: ', floorPlanesVertical);
|
// //
|
||||||
// // console.log('planeIntersect.current: ', planeIntersect.current);
|
// //
|
||||||
// // const intersect = raycaster.ray.intersectPlane(
|
// // const intersect = raycaster.ray.intersectPlane(
|
||||||
// // floorPlanesVertical,
|
// // floorPlanesVertical,
|
||||||
// // planeIntersect.current
|
// // planeIntersect.current
|
||||||
// // );
|
// // );
|
||||||
// // console.log('intersect: ', intersect);
|
// //
|
||||||
|
|
||||||
// let intersect = event.clientY
|
// let intersect = event.clientY
|
||||||
|
|
||||||
// if (intersect && typeof intersectcontextmenu === "number") {
|
// if (intersect && typeof intersectcontextmenu === "number") {
|
||||||
// console.log('intersect: ', intersect);
|
//
|
||||||
// const diff = intersect - intersectcontextmenu;
|
// const diff = intersect - intersectcontextmenu;
|
||||||
// const unclampedY = selectedWidget.position[1] + diff;
|
// const unclampedY = selectedWidget.position[1] + diff;
|
||||||
// const newY = Math.max(0, unclampedY); // Prevent going below floor (y=0)
|
// const newY = Math.max(0, unclampedY); // Prevent going below floor (y=0)
|
||||||
@@ -495,7 +497,7 @@ export default function Dropped3dWidgets() {
|
|||||||
// newY,
|
// newY,
|
||||||
// selectedWidget.position[2],
|
// selectedWidget.position[2],
|
||||||
// ];
|
// ];
|
||||||
// console.log('newPosition: ', newPosition);
|
//
|
||||||
|
|
||||||
|
|
||||||
// updateWidgetPosition(selectedzoneUuid, rightClickSelected, newPosition);
|
// updateWidgetPosition(selectedzoneUuid, rightClickSelected, newPosition);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
|||||||
import useChartStore from "../../../../../store/visualization/useChartStore";
|
import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||||
import { getUserData } from "../../../../../functions/getUserData";
|
import { getUserData } from "../../../../../functions/getUserData";
|
||||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||||
|
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
// Register ChartJS components
|
// Register ChartJS components
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
@@ -70,6 +72,9 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
|
|||||||
});
|
});
|
||||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||||
const { userName, userId, organization, email } = getUserData();
|
const { userName, userId, organization, email } = getUserData();
|
||||||
|
const { selectedVersionStore } = useVersionContext();
|
||||||
|
const { selectedVersion } = selectedVersionStore();
|
||||||
|
const { projectId } = useParams()
|
||||||
// Chart data for a week
|
// Chart data for a week
|
||||||
const defaultChartData = {
|
const defaultChartData = {
|
||||||
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], // Days of the week
|
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], // Days of the week
|
||||||
@@ -171,12 +176,15 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
|
|||||||
|
|
||||||
const fetchSavedInputes = async () => {
|
const fetchSavedInputes = async () => {
|
||||||
if (id !== "") {
|
if (id !== "") {
|
||||||
let response = await get3dWidgetInput(id, organization)
|
let response = await get3dWidgetInput(id, organization, projectId, selectedVersion?.versionId || "")
|
||||||
console.log('response: ', response);
|
|
||||||
|
if (response.message === "Widget not found") {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (response) {
|
if (response) {
|
||||||
setmeasurements(response.data.Data.measurements);
|
setmeasurements(response.Datastructure.measurements);
|
||||||
setDuration(response.data.Data.duration);
|
setDuration(response.Datastructure.duration);
|
||||||
setName(response.data.widgetName);
|
setName(response.widgetName);
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// const response = await axios.get(
|
// const response = await axios.get(
|
||||||
@@ -215,7 +223,7 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
|
|||||||
scale={scale}
|
scale={scale}
|
||||||
rotation={rotation}
|
rotation={rotation}
|
||||||
// class
|
// class
|
||||||
wrapperClass="pointer-none"
|
// wrapperClass="pointer-none"
|
||||||
// other
|
// other
|
||||||
transform
|
transform
|
||||||
zIndexRange={[1, 0]}
|
zIndexRange={[1, 0]}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import useChartStore from "../../../../../store/visualization/useChartStore";
|
|||||||
import { WavyIcon } from "../../../../../components/icons/3dChartIcons";
|
import { WavyIcon } from "../../../../../components/icons/3dChartIcons";
|
||||||
import { getUserData } from "../../../../../functions/getUserData";
|
import { getUserData } from "../../../../../functions/getUserData";
|
||||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||||
|
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
// Register Chart.js components
|
// Register Chart.js components
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
@@ -79,6 +81,9 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
|
|||||||
datasets: [],
|
datasets: [],
|
||||||
});
|
});
|
||||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||||
|
const { selectedVersionStore } = useVersionContext();
|
||||||
|
const { selectedVersion } = selectedVersionStore();
|
||||||
|
const { projectId } = useParams()
|
||||||
const { userName, userId, organization, email } = getUserData();
|
const { userName, userId, organization, email } = getUserData();
|
||||||
// Improved sample data for the smooth curve graph (single day)
|
// Improved sample data for the smooth curve graph (single day)
|
||||||
const graphData: ChartData<"line"> = {
|
const graphData: ChartData<"line"> = {
|
||||||
@@ -200,8 +205,11 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
|
|||||||
|
|
||||||
const fetchSavedInputes = async () => {
|
const fetchSavedInputes = async () => {
|
||||||
if (id !== "") {
|
if (id !== "") {
|
||||||
let response = await get3dWidgetInput(id, organization)
|
let response = await get3dWidgetInput(id, organization, projectId, selectedVersion?.versionId || "")
|
||||||
console.log('response: ', response);
|
|
||||||
|
if (response.message === "Widget not found") {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (response) {
|
if (response) {
|
||||||
setmeasurements(response.data.Data.measurements);
|
setmeasurements(response.data.Data.measurements);
|
||||||
setDuration(response.data.Data.duration);
|
setDuration(response.data.Data.duration);
|
||||||
@@ -216,11 +224,11 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
|
|||||||
// setDuration(response.data.Data.duration);
|
// setDuration(response.data.Data.duration);
|
||||||
// setName(response.data.widgetName);
|
// setName(response.data.widgetName);
|
||||||
// } else {
|
// } else {
|
||||||
// // console.log("Unexpected response:", response);
|
// //
|
||||||
// }
|
// }
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
// echo.error("Failed to fetch saved inputs");
|
// echo.error("Failed to fetch saved inputs");
|
||||||
// console.error("There was an error!", error);
|
//
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
|||||||
import useChartStore from "../../../../../store/visualization/useChartStore";
|
import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||||
import { getUserData } from "../../../../../functions/getUserData";
|
import { getUserData } from "../../../../../functions/getUserData";
|
||||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||||
|
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
// import image from "../../../../assets/image/temp/image.png";
|
// import image from "../../../../assets/image/temp/image.png";
|
||||||
interface StateWorkingProps {
|
interface StateWorkingProps {
|
||||||
@@ -41,6 +43,9 @@ const StateWorking: React.FC<StateWorkingProps> = ({
|
|||||||
const [datas, setDatas] = useState<any>({});
|
const [datas, setDatas] = useState<any>({});
|
||||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||||
const { userName, userId, organization, email } = getUserData();
|
const { userName, userId, organization, email } = getUserData();
|
||||||
|
const { selectedVersionStore } = useVersionContext();
|
||||||
|
const { selectedVersion } = selectedVersionStore();
|
||||||
|
const { projectId } = useParams()
|
||||||
// const datas = [
|
// const datas = [
|
||||||
// { key: "Oil Tank:", value: "24/341" },
|
// { key: "Oil Tank:", value: "24/341" },
|
||||||
// { key: "Oil Refin:", value: 36.023 },
|
// { key: "Oil Refin:", value: 36.023 },
|
||||||
@@ -78,12 +83,15 @@ const StateWorking: React.FC<StateWorkingProps> = ({
|
|||||||
|
|
||||||
const fetchSavedInputes = async () => {
|
const fetchSavedInputes = async () => {
|
||||||
if (id !== "") {
|
if (id !== "") {
|
||||||
let response = await get3dWidgetInput(id, organization)
|
let response = await get3dWidgetInput(id, organization, projectId, selectedVersion?.versionId || "")
|
||||||
console.log('response: ', response);
|
|
||||||
|
if (response.message === "Widget not found") {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (response) {
|
if (response) {
|
||||||
setmeasurements(response.data.Data.measurements);
|
setmeasurements(response.Datastructure.measurements);
|
||||||
setDuration(response.data.Data.duration);
|
setDuration(response.Datastructure.duration);
|
||||||
setName(response.data.widgetName);
|
setName(response.widgetName);
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// const response = await axios.get(
|
// const response = await axios.get(
|
||||||
@@ -94,17 +102,17 @@ const StateWorking: React.FC<StateWorkingProps> = ({
|
|||||||
// setDuration(response.data.Data.duration);
|
// setDuration(response.data.Data.duration);
|
||||||
// setName(response.data.widgetName);
|
// setName(response.data.widgetName);
|
||||||
// } else {
|
// } else {
|
||||||
// // console.log("Unexpected response:", response);
|
// //
|
||||||
// }
|
// }
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
// echo.error("Failed to fetch saved inputs");
|
// echo.error("Failed to fetch saved inputs");
|
||||||
// console.error("There was an error!", error);
|
//
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchSavedInputes();
|
// fetchSavedInputes();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import useChartStore from "../../../../../store/visualization/useChartStore";
|
|||||||
import { ThroughputIcon } from "../../../../../components/icons/3dChartIcons";
|
import { ThroughputIcon } from "../../../../../components/icons/3dChartIcons";
|
||||||
import { getUserData } from "../../../../../functions/getUserData";
|
import { getUserData } from "../../../../../functions/getUserData";
|
||||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||||
|
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
// Register Chart.js components
|
// Register Chart.js components
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
@@ -83,6 +85,9 @@ const Throughput: React.FC<ThroughputProps> = ({
|
|||||||
});
|
});
|
||||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||||
const { userName, userId, organization, email } = getUserData();
|
const { userName, userId, organization, email } = getUserData();
|
||||||
|
const { selectedVersionStore } = useVersionContext();
|
||||||
|
const { selectedVersion } = selectedVersionStore();
|
||||||
|
const { projectId } = useParams()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -180,12 +185,15 @@ const Throughput: React.FC<ThroughputProps> = ({
|
|||||||
|
|
||||||
const fetchSavedInputes = async () => {
|
const fetchSavedInputes = async () => {
|
||||||
if (id !== "") {
|
if (id !== "") {
|
||||||
let response = await get3dWidgetInput(id, organization)
|
let response = await get3dWidgetInput(id, organization, projectId, selectedVersion?.versionId || "")
|
||||||
console.log('response: ', response);
|
|
||||||
|
if (response.message === "Widget not found") {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (response) {
|
if (response) {
|
||||||
setmeasurements(response.data.Data.measurements);
|
setmeasurements(response.Datastructure.measurements);
|
||||||
setDuration(response.data.Data.duration);
|
setDuration(response.Datastructure.duration);
|
||||||
setName(response.data.widgetName);
|
setName(response.widgetName);
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// const response = await axios.get(
|
// const response = await axios.get(
|
||||||
@@ -196,17 +204,17 @@ const Throughput: React.FC<ThroughputProps> = ({
|
|||||||
// setDuration(response.data.Data.duration);
|
// setDuration(response.data.Data.duration);
|
||||||
// setName(response.data.widgetName);
|
// setName(response.data.widgetName);
|
||||||
// } else {
|
// } else {
|
||||||
// // console.log("Unexpected response:", response);
|
// //
|
||||||
// }
|
// }
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
// echo.error("Failed to fetch saved inputs");
|
// echo.error("Failed to fetch saved inputs");
|
||||||
// console.error("There was an error!", error);
|
//
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchSavedInputes();
|
// fetchSavedInputes();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ export const adding3dWidgets = async (
|
|||||||
widget: {},
|
widget: {},
|
||||||
projectId?: string,
|
projectId?: string,
|
||||||
versionId?: string
|
versionId?: string
|
||||||
|
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/widget3d/save`, {
|
const response = await fetch(`${url_Backend_dwinzo}/api/V1/widget3d/save`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -20,15 +22,16 @@ export const adding3dWidgets = async (
|
|||||||
body: JSON.stringify({ organization, zoneUuid, widget, projectId, versionId }),
|
body: JSON.stringify({ organization, zoneUuid, widget, projectId, versionId }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const newAccessToken = response.headers.get("x-access-token");
|
const newAccessToken = response.headers.get("x-access-token");
|
||||||
if (newAccessToken) {
|
if (newAccessToken) {
|
||||||
//console.log("New token received:", newAccessToken);
|
//
|
||||||
localStorage.setItem("token", newAccessToken);
|
localStorage.setItem("token", newAccessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error("Failed to add 3dwidget in the zone");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
@@ -36,9 +39,9 @@ export const adding3dWidgets = async (
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
echo.error("Failed to add 3d widget");
|
echo.error("Failed to add 3d widget");
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
console.log(error.message);
|
|
||||||
} else {
|
} else {
|
||||||
console.log("An unknown error occurred");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
|||||||
|
|
||||||
|
|
||||||
export const get3dWidgetInput = async (chartId: string, organization: string, projectId?: string, versionId?: string) => {
|
export const get3dWidgetInput = async (chartId: string, organization: string, projectId?: string, versionId?: string) => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`${url_Backend_dwinzo}/api/v2/widget3D/${chartId}/${organization}`,
|
`${url_Backend_dwinzo}/api/V1/widget3dData/${chartId}/${projectId}/${versionId}`,
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -15,9 +19,10 @@ export const get3dWidgetInput = async (chartId: string, organization: string, pr
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const newAccessToken = response.headers.get("x-access-token");
|
const newAccessToken = response.headers.get("x-access-token");
|
||||||
if (newAccessToken) {
|
if (newAccessToken) {
|
||||||
//console.log("New token received:", newAccessToken);
|
//
|
||||||
localStorage.setItem("token", newAccessToken);
|
localStorage.setItem("token", newAccessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,10 +30,10 @@ export const get3dWidgetInput = async (chartId: string, organization: string, pr
|
|||||||
throw new Error("Failed to fetch zoneDatas");
|
throw new Error("Failed to fetch zoneDatas");
|
||||||
}
|
}
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
console.log('result: ', result);
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
echo.error("Failed to fetch 2d widget data");
|
echo.error("Failed to fetch 2d widget data");
|
||||||
console.log(error.message);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user