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