diff --git a/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx b/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx
index a5e6d04..7415878 100644
--- a/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx
+++ b/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx
@@ -11,6 +11,7 @@ import {
import { zoneCameraUpdate } from "../../../../services/visulization/zone/zoneCameraUpdation";
import { useParams } from "react-router-dom";
import { getUserData } from "../../../../functions/getUserData";
+import { useVersionContext } from "../../../../modules/builder/version/versionContext";
const ZoneProperties: React.FC = () => {
const { Edit, setEdit } = useEditPosition();
@@ -20,6 +21,8 @@ const ZoneProperties: React.FC = () => {
const { zones, setZones } = useZones();
const { projectId } = useParams();
const { userName, userId, organization, email } = getUserData();
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
useEffect(() => {
setZonePosition(selectedZone.zoneViewPortPosition);
@@ -35,7 +38,7 @@ const ZoneProperties: React.FC = () => {
viewPortCenter: zoneTarget,
};
- let response = await zoneCameraUpdate(zonesdata, organization, projectId);
+ let response = await zoneCameraUpdate(zonesdata, organization, projectId, selectedVersion?.versionId || "");
// console.log('response: ', response);
if (response.message === "zone updated") {
setEdit(false);
@@ -57,7 +60,7 @@ const ZoneProperties: React.FC = () => {
zoneName: newName,
};
// Call your API to update the zone
- let response = await zoneCameraUpdate(zonesdata, organization, projectId);
+ let response = await zoneCameraUpdate(zonesdata, organization, projectId, selectedVersion?.versionId || "");
if (response.message === "zone updated") {
setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
setZones((prevZones: any[]) =>
diff --git a/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx b/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx
index 622f0e9..9d24ba0 100644
--- a/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx
+++ b/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx
@@ -30,9 +30,9 @@ const VersionHistory = () => {
getVersionDataApi(projectId, version.versionId).then((verdionData) => {
setSelectedVersion(version);
- console.log(verdionData);
+ // console.log(verdionData);
}).catch((err) => {
- console.log(err);
+ // console.log(err);
})
};
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx
index d8cb41e..3b7e67a 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx
@@ -12,6 +12,7 @@ import { useSocketStore } from "../../../../../store/builder/store";
import { getUserData } from "../../../../../functions/getUserData";
import { addingWidgets } from "../../../../../services/visulization/zone/addWidgets";
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
type Props = {};
@@ -43,11 +44,11 @@ const BarChartInput = (props: Props) => {
setDropDownData(response.data);
setLoading(false);
} else {
-
+
}
} catch (error) {
echo.log("Failed to fetch zone data");
-
+
}
};
fetchZoneData();
@@ -56,33 +57,15 @@ const BarChartInput = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer
",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setSelections(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setWidgetName(response.data.widgetName);
- } else {
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
+ let response = await getWidgetInputData(selectedChartId.id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setSelections(response.Datastructure.measurements);
+ setDuration(response.Datastructure.duration);
+ setWidgetName(response.widgetName);
}
}
};
-
fetchSavedInputes();
}, [selectedChartId]);
@@ -118,47 +101,16 @@ const BarChartInput = (props: Props) => {
// 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") {
return true;
- }else{
-
+ } else {
+
return false;
};
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
- // {
- // headers: {
- // Authorization: "Bearer ",
- // "Content-Type": "application/json",
- // token: localStorage.getItem("token") || "",
- // refresh_token: localStorage.getItem("refreshToken") || "",
- // },
- // },
- // {
- // zoneUuid: selectedZone.zoneUuid,
- // organization: organization,
- // widget: {
- // id: selectedChartId.id,
- // panel: selectedChartId.panel,
- // widgetName: inputName,
- // Data: {
- // measurements: inputMeasurement,
- // duration: inputDuration,
- // },
- // },
- // } as any
- // );
-
- // } catch (error) {
- // echo.error("Failed to send input");
- //
- // return false;
- // }
};
const handleSelect = async (
@@ -190,7 +142,7 @@ const BarChartInput = (props: Props) => {
};
const handleNameChange = async (name: any) => {
-
+
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx
index da01d0c..fa6ef5c 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx
@@ -10,6 +10,8 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
import { getUserData } from "../../../../../functions/getUserData";
import { addingFloatingWidgets } from "../../../../../services/visulization/zone/addFloatingWidgets";
import { useParams } from "react-router-dom";
+import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
type Props = {};
@@ -27,7 +29,8 @@ const FleetEfficiencyInputComponent = (props: Props) => {
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
const { userName, userId, organization, email } = getUserData();
const [isLoading, setLoading] = useState(true);
-
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
const { projectId } = useParams()
const isSelected = () => { };
@@ -38,15 +41,15 @@ const FleetEfficiencyInputComponent = (props: Props) => {
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
setLoading(true);
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,30 +58,15 @@ const FleetEfficiencyInputComponent = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
- setSelections(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setWidgetName(response.data.header);
- } else {
- // console.log("Unexpected response:", response);
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
- console.error("There was an error!", error);
+ let response = await getFloatingWidgetInput(selectedChartId.id, organization,projectId,selectedVersion?.versionId||"")
+
+ if (response) {
+
+ setSelections(response.Data.Datastructure.measurements);
+ setDuration(response.Data.Datastructure.duration);
+ setWidgetName(response.Data.header);
}
+
}
};
@@ -105,43 +93,17 @@ const FleetEfficiencyInputComponent = (props: Props) => {
duration: inputDuration,
},
}
- const response = await addingFloatingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId)
- // console.log('response: ', response);
+
+
+ const response = await addingFloatingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
+
if (response.message === "Widget updated successfully") {
return true;
} else {
- console.log("Unexpected response:", response);
+
return false;
}
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`,
- // {
- // organization: organization,
- // zoneUuid: selectedZone.zoneUuid,
- // widget: {
- // id: selectedChartId.id,
- // header: 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;
- // }
};
const handleSelect = async (
@@ -156,7 +118,7 @@ const FleetEfficiencyInputComponent = (props: Props) => {
newSelections[inputKey] = selectedData;
}
// setMeasurements(newSelections); // Update Zustand store
- // console.log(newSelections);
+ //
if (await sendInputes(newSelections, duration, widgetName)) {
setSelections(newSelections);
}
@@ -173,7 +135,7 @@ const FleetEfficiencyInputComponent = (props: Props) => {
};
const handleNameChange = async (name: any) => {
- console.log("name change requested", name);
+
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx
index 826fbae..c8247b6 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx
@@ -10,6 +10,8 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
import { getUserData } from "../../../../../functions/getUserData";
import { addingFloatingWidgets } from "../../../../../services/visulization/zone/addFloatingWidgets";
import { useParams } from "react-router-dom";
+import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
type Props = {};
@@ -28,6 +30,8 @@ const FlotingWidgetInput = (props: Props) => {
const { userName, userId, organization, email } = getUserData();
const [isLoading, setLoading] = useState(true);
const { projectId } = useParams()
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
useEffect(() => {
const fetchZoneData = async () => {
@@ -35,16 +39,16 @@ const FlotingWidgetInput = (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();
@@ -53,30 +57,14 @@ const FlotingWidgetInput = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
- setSelections(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setWidgetName(response.data.header);
- } else {
- // console.log("Unexpected response:", response);
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
- console.error("There was an error!", error);
+ let response = await getFloatingWidgetInput(selectedChartId.id, organization, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setSelections(response.Data.Datastructure.measurements);
+ setDuration(response.Data.Datastructure.duration);
+ setWidgetName(response.Data.header);
}
+
}
};
@@ -104,42 +92,16 @@ const FlotingWidgetInput = (props: Props) => {
},
}
- const response = await addingFloatingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId)
- // console.log('response: ', response);
+
+ const response = await addingFloatingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
+
if (response.message === "Widget updated successfully") {
return true;
} else {
- // console.log("Unexpected response:", response);
+ //
return false;
}
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`,
- // {
- // organization: organization,
- // zoneUuid: selectedZone.zoneUuid,
- // widget: {
- // id: selectedChartId.id,
- // header: 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;
- // }
};
const handleSelect = async (
@@ -154,7 +116,7 @@ const FlotingWidgetInput = (props: Props) => {
newSelections[inputKey] = selectedData;
}
// setMeasurements(newSelections); // Update Zustand store
- // console.log(newSelections);
+ //
if (await sendInputes(newSelections, duration, widgetName)) {
setSelections(newSelections);
}
@@ -171,7 +133,7 @@ const FlotingWidgetInput = (props: Props) => {
};
const handleNameChange = async (name: any) => {
- console.log("name change requested", name);
+
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx
index 83cfb75..646ba88 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx
@@ -128,6 +128,7 @@ import { useSocketStore } from "../../../../../store/builder/store";
import { getUserData } from "../../../../../functions/getUserData";
import { addingWidgets } from "../../../../../services/visulization/zone/addWidgets";
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
type Props = {};
@@ -159,11 +160,11 @@ const LineGrapInput = (props: Props) => {
setDropDownData(response.data);
setLoading(false);
} else {
-
+
}
} catch (error) {
echo.error("Failed to fetch zone data");
-
+
}
};
fetchZoneData();
@@ -172,30 +173,14 @@ const LineGrapInput = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setSelections(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setWidgetName(response.data.widgetName);
- } else {
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
+ let response = await getWidgetInputData(selectedChartId.id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setSelections(response.Datastructure.measurements);
+ setDuration(response.Datastructure.duration);
+ setWidgetName(response.widgetName);
}
+
}
};
@@ -224,7 +209,7 @@ const LineGrapInput = (props: Props) => {
duration: inputDuration,
}
}
-
+
// const adding3dWidget = {
// organization: organization,
// widget: newWidget,
@@ -235,45 +220,15 @@ const LineGrapInput = (props: Props) => {
// 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") {
-
+
return true;
} else {
-
+
return false;
}
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
- // {
- // headers: {
- // Authorization: "Bearer ",
- // "Content-Type": "application/json",
- // token: localStorage.getItem("token") || "",
- // refresh_token: localStorage.getItem("refreshToken") || "",
- // },
- // },
- // {
- // zoneUuid: selectedZone.zoneUuid,
- // organization: organization,
- // widget: {
- // id: selectedChartId.id,
- // panel: selectedChartId.panel,
- // widgetName: inputName,
- // Data: {
- // measurements: inputMeasurement,
- // duration: inputDuration,
- // },
- // },
- // } as any
- // );
-
- // } catch (error) {
- // echo.error("Failed to send input");
- //
- // return false;
- // }
+
};
const handleSelect = async (
@@ -305,7 +260,7 @@ const LineGrapInput = (props: Props) => {
};
const handleNameChange = async (name: any) => {
-
+
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx
index 701be3a..04ac73b 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx
@@ -12,6 +12,7 @@ import { useSocketStore } from "../../../../../store/builder/store";
import { getUserData } from "../../../../../functions/getUserData";
import { addingWidgets } from "../../../../../services/visulization/zone/addWidgets";
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
type Props = {};
@@ -56,30 +57,14 @@ const PieChartInput = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setSelections(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setWidgetName(response.data.widgetName);
- } else {
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
+ let response = await getWidgetInputData(selectedChartId.id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+ if (response) {
+ setSelections(response.Datastructure.measurements);
+ setDuration(response.Datastructure.duration);
+ setWidgetName(response.widgetName);
}
+
}
};
@@ -129,37 +114,7 @@ const PieChartInput = (props: Props) => {
return false;
}
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
- // {
- // headers: {
- // Authorization: "Bearer ",
- // "Content-Type": "application/json",
- // token: localStorage.getItem("token") || "",
- // refresh_token: localStorage.getItem("refreshToken") || "",
- // },
- // },
- // {
- // zoneUuid: selectedZone.zoneUuid,
- // organization: organization,
- // widget: {
- // id: selectedChartId.id,
- // panel: selectedChartId.panel,
- // widgetName: inputName,
- // Data: {
- // measurements: inputMeasurement,
- // duration: inputDuration,
- // },
- // },
- // } as any
- // );
-
- // } catch (error) {
- // echo.error("Failed to send input");
- //
- // return false;
- // }
+
};
const handleSelect = async (
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx
index b2103b5..1f573b3 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx
@@ -12,6 +12,7 @@ import { useSocketStore } from "../../../../../store/builder/store";
import { getUserData } from "../../../../../functions/getUserData";
import { addingWidgets } from "../../../../../services/visulization/zone/addWidgets";
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
type Props = {};
@@ -56,30 +57,14 @@ const Progress1Input = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setSelections(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setWidgetName(response.data.widgetName);
- } else {
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
+ let response = await getWidgetInputData(selectedChartId.id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setSelections(response.Datastructure.measurements);
+ setDuration(response.Datastructure.duration);
+ setWidgetName(response.widgetName);
}
+
}
};
@@ -127,37 +112,7 @@ const Progress1Input = (props: Props) => {
return false;
}
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
- // {
- // headers: {
- // Authorization: "Bearer ",
- // "Content-Type": "application/json",
- // token: localStorage.getItem("token") || "",
- // refresh_token: localStorage.getItem("refreshToken") || "",
- // },
- // },
- // {
- // zoneUuid: selectedZone.zoneUuid,
- // organization: organization,
- // widget: {
- // id: selectedChartId.id,
- // panel: selectedChartId.panel,
- // widgetName: inputName,
- // Data: {
- // measurements: inputMeasurement,
- // duration: inputDuration,
- // },
- // },
- // } as any
- // );
-
- // } catch (error) {
- // echo.error("Failed to send input");
- //
- // return false;
- // }
+
};
const handleSelect = async (
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx
index 3382ebe..f1af380 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx
@@ -12,6 +12,7 @@ import { useSocketStore } from "../../../../../store/builder/store";
import { getUserData } from "../../../../../functions/getUserData";
import { addingWidgets } from "../../../../../services/visulization/zone/addWidgets";
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
type Props = {};
@@ -56,30 +57,14 @@ const Progress2Input = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setSelections(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setWidgetName(response.data.widgetName);
- } else {
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
+ let response = await getWidgetInputData(selectedChartId.id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setSelections(response.Datastructure.measurements);
+ setDuration(response.Datastructure.duration);
+ setWidgetName(response.widgetName);
}
+
}
};
@@ -129,37 +114,7 @@ const Progress2Input = (props: Props) => {
return false;
}
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
- // {
- // headers: {
- // Authorization: "Bearer ",
- // "Content-Type": "application/json",
- // token: localStorage.getItem("token") || "",
- // refresh_token: localStorage.getItem("refreshToken") || "",
- // },
- // },
- // {
- // zoneUuid: selectedZone.zoneUuid,
- // organization: organization,
- // widget: {
- // id: selectedChartId.id,
- // panel: selectedChartId.panel,
- // widgetName: inputName,
- // Data: {
- // measurements: inputMeasurement,
- // duration: inputDuration,
- // },
- // },
- // } as any
- // );
-
- // } catch (error) {
- // echo.error("Failed to send input");
- //
- // return false;
- // }
+
};
const handleSelect = async (
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx
index 1eb77bc..e82aa58 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx
@@ -10,6 +10,8 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
import { getUserData } from "../../../../../functions/getUserData";
import { addingFloatingWidgets } from "../../../../../services/visulization/zone/addFloatingWidgets";
import { useParams } from "react-router-dom";
+import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
type Props = {};
@@ -28,6 +30,8 @@ const WarehouseThroughputInputComponent = (props: Props) => {
const { userName, userId, organization, email } = getUserData();
const [isLoading, setLoading] = useState(true);
const { projectId } = useParams();
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
useEffect(() => {
const fetchZoneData = async () => {
@@ -35,15 +39,15 @@ const WarehouseThroughputInputComponent = (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();
@@ -52,29 +56,14 @@ const WarehouseThroughputInputComponent = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
- setSelections(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setWidgetName(response.data.header);
- } else {
- // console.log("Unexpected response:", response);
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
- console.error("There was an error!", error);
+ let response = await getFloatingWidgetInput(selectedChartId.id, organization,projectId,selectedVersion?.versionId||"")
+
+ if (response) {
+ setSelections(response.Data.Datastructure.measurements);
+ setDuration(response.Data.Datastructure.duration);
+ setWidgetName(response.Data.header);
}
+
}
};
@@ -102,36 +91,16 @@ const WarehouseThroughputInputComponent = (props: Props) => {
duration: inputDuration,
},
}
- const response = await addingFloatingWidgets(selectedZone.zoneUuid, organization, newWidget,projectId)
- // console.log('response: ', response);
+
+ const response = await addingFloatingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
+ //
if (response.message === "Widget updated successfully") {
return true;
} else {
- // console.log("Unexpected response:", response);
+ //
return false;
}
- // try {
- // const response = await axios.post(
- // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`,
- // {
- // organization: organization,
- // zoneUuid: selectedZone.zoneUuid,
- // widget: {
- // id: selectedChartId.id,
- // header: inputName,
- // Data: {
- // measurements: inputMeasurement,
- // duration: inputDuration,
- // },
- // },
- // } as any
- // );
- // } catch (error) {
- // echo.error("Failed to send input");
- // console.error("There was an error!", error);
- // return false;
- // }
};
const handleSelect = async (
@@ -146,7 +115,7 @@ const WarehouseThroughputInputComponent = (props: Props) => {
newSelections[inputKey] = selectedData;
}
// setMeasurements(newSelections); // Update Zustand store
- // console.log(newSelections);
+ //
if (await sendInputes(newSelections, duration, widgetName)) {
setSelections(newSelections);
}
@@ -163,7 +132,7 @@ const WarehouseThroughputInputComponent = (props: Props) => {
};
const handleNameChange = async (name: any) => {
- // console.log("name change requested", name);
+ //
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx
index defe09a..79fd00e 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx
@@ -8,6 +8,10 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
import axios from "axios";
import RenameInput from "../../../../ui/inputs/RenameInput";
import { getUserData } from "../../../../../functions/getUserData";
+import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
+import { adding3dWidgets } from "../../../../../services/visulization/zone/add3dWidget";
+import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { useParams } from "react-router-dom";
type Props = {};
@@ -24,6 +28,9 @@ const Widget2InputCard3D = (props: Props) => {
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
const { userName, userId, organization, email } = getUserData();
const [isLoading, setLoading] = useState(true);
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
+ const { projectId } = useParams()
useEffect(() => {
const fetchZoneData = async () => {
@@ -48,21 +55,14 @@ const Widget2InputCard3D = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`
- );
- if (response.status === 200) {
- setSelections(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setWidgetName(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);
+ let response = await get3dWidgetInput(selectedChartId.id, organization)
+ console.log('response: ', response);
+ if (response) {
+ setSelections(response.data.Data.measurements);
+ setDuration(response.data.Data.duration);
+ setWidgetName(response.data.widgetName);
}
+
}
};
@@ -81,6 +81,17 @@ 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`,
@@ -100,7 +111,7 @@ const Widget2InputCard3D = (props: Props) => {
if (response.status === 200) {
return true;
} else {
- console.log("Unexpected response:", response);
+ // console.log("Unexpected response:", response);
return false;
}
} catch (error) {
@@ -139,7 +150,7 @@ const Widget2InputCard3D = (props: Props) => {
};
const handleNameChange = async (name: any) => {
- console.log("name change requested", name);
+ // console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx
index 51f9cd7..3e0ddde 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx
@@ -8,6 +8,10 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
import axios from "axios";
import RenameInput from "../../../../ui/inputs/RenameInput";
import { getUserData } from "../../../../../functions/getUserData";
+import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
+import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { useParams } from "react-router-dom";
+import { adding3dWidgets } from "../../../../../services/visulization/zone/add3dWidget";
const Widget3InputCard3D = () => {
const { selectedChartId } = useWidgetStore();
@@ -22,6 +26,9 @@ const Widget3InputCard3D = () => {
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
const { userName, userId, organization, email } = getUserData();
const [isLoading, setLoading] = useState(true);
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
+ const { projectId } = useParams()
useEffect(() => {
const fetchZoneData = async () => {
@@ -46,21 +53,14 @@ const Widget3InputCard3D = () => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`
- );
- if (response.status === 200) {
- setSelections(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setWidgetName(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);
+ let response = await get3dWidgetInput(selectedChartId.id, organization)
+ console.log('response: ', response);
+ if (response) {
+ setSelections(response.data.Data.measurements);
+ setDuration(response.data.Data.duration);
+ setWidgetName(response.data.widgetName);
}
+
}
};
@@ -78,6 +78,19 @@ const Widget3InputCard3D = () => {
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`,
@@ -132,7 +145,7 @@ const Widget3InputCard3D = () => {
};
const handleNameChange = async (name: any) => {
- console.log("name change requested", name);
+ // console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx
index ade052b..2da2e61 100644
--- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx
+++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx
@@ -8,6 +8,10 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
import axios from "axios";
import RenameInput from "../../../../ui/inputs/RenameInput";
import { getUserData } from "../../../../../functions/getUserData";
+import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
+import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
+import { useParams } from "react-router-dom";
+import { adding3dWidgets } from "../../../../../services/visulization/zone/add3dWidget";
type Props = {};
@@ -24,6 +28,9 @@ const Widget4InputCard3D = (props: Props) => {
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
const { userName, userId, organization, email } = getUserData();
const [isLoading, setLoading] = useState(true);
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
+ const { projectId } = useParams()
useEffect(() => {
const fetchZoneData = async () => {
@@ -48,21 +55,14 @@ const Widget4InputCard3D = (props: Props) => {
useEffect(() => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`
- );
- if (response.status === 200) {
- setSelections(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setWidgetName(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);
+ let response = await get3dWidgetInput(selectedChartId.id, organization)
+ console.log('response: ', response);
+ if (response) {
+ setSelections(response.data.Data.measurements);
+ setDuration(response.data.Data.duration);
+ setWidgetName(response.data.widgetName);
}
+
}
};
@@ -81,6 +81,17 @@ 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`,
diff --git a/app/src/components/ui/list/List.tsx b/app/src/components/ui/list/List.tsx
index 4171b62..0d81bda 100644
--- a/app/src/components/ui/list/List.tsx
+++ b/app/src/components/ui/list/List.tsx
@@ -21,6 +21,7 @@ import { setAssetsApi } from "../../../services/factoryBuilder/assest/floorAsset
import { useParams } from "react-router-dom";
import { getUserData } from "../../../functions/getUserData";
import { useSceneContext } from "../../../modules/scene/sceneContext";
+import { useVersionContext } from "../../../modules/builder/version/versionContext";
interface Asset {
id: string;
@@ -52,6 +53,8 @@ const List: React.FC = ({ items = [], remove }) => {
const { assetStore } = useSceneContext();
const { setName } = assetStore();
const { organization } = getUserData();
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
useEffect(() => {
useSelectedZoneStore.getState().setSelectedZone({
@@ -81,7 +84,7 @@ const List: React.FC = ({ items = [], remove }) => {
setSubModule("zoneProperties");
- let response = await getZoneData(id, organization, projectId);
+ let response = await getZoneData(id, organization, projectId, selectedVersion?.versionId || "");
setSelectedZone({
zoneName: response?.zoneName,
activeSides: response?.activeSides ?? [],
@@ -117,7 +120,7 @@ const List: React.FC = ({ items = [], remove }) => {
zoneUuid: selectedZone.zoneUuid,
zoneName: newName,
};
- const response = await zoneCameraUpdate(zonesdata, organization, projectId);
+ const response = await zoneCameraUpdate(zonesdata, organization, projectId, selectedVersion?.versionId || "");
if (response.message === "zone updated") {
setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
setZones((prevZones: any[]) =>
diff --git a/app/src/hooks/temp.md b/app/src/hooks/temp.md
deleted file mode 100644
index e69de29..0000000
diff --git a/app/src/hooks/useResetStates.ts b/app/src/hooks/useResetStates.ts
new file mode 100644
index 0000000..87bef11
--- /dev/null
+++ b/app/src/hooks/useResetStates.ts
@@ -0,0 +1,26 @@
+import { useVersionContext } from "../modules/builder/version/versionContext";
+import { useSceneContext } from "../modules/scene/sceneContext";
+import { useProductContext } from "../modules/simulation/products/productContext";
+import { useVersionHistoryStore } from "../store/builder/useVersionHistoryStore";
+
+const useRestStates = () => {
+ const { selectedVersionStore } = useVersionContext();
+ const { clearSelectedVersion } = selectedVersionStore();
+ const { selectedProductStore } = useProductContext();
+ const { clearSelectedProduct } = selectedProductStore();
+ const { clearVersions } = useVersionHistoryStore();
+ const { clearStores } = useSceneContext();
+
+ const resetStates = () => {
+ clearSelectedVersion();
+ clearSelectedProduct();
+ clearVersions();
+ clearStores();
+ };
+
+ return {
+ resetStates,
+ };
+};
+
+export default useRestStates;
\ No newline at end of file
diff --git a/app/src/modules/scene/sceneContext.tsx b/app/src/modules/scene/sceneContext.tsx
index 8d742ed..a339ddf 100644
--- a/app/src/modules/scene/sceneContext.tsx
+++ b/app/src/modules/scene/sceneContext.tsx
@@ -28,6 +28,8 @@ type SceneContextValue = {
vehicleStore: VehicleStoreType;
storageUnitStore: StorageUnitStoreType;
+ clearStores: () => void;
+
layout: 'Main Layout' | 'Comparison Layout';
};
@@ -55,8 +57,17 @@ export function SceneProvider({
const storageUnitStore = useMemo(() => createStorageUnitStore(), []);
const clearStores = useMemo(() => () => {
- assetStore().clearAssets();
- }, [assetStore]);
+ assetStore.getState().clearAssets();
+ aisleStore.getState().clearAisles();
+ eventStore.getState().clearEvents();
+ productStore.getState().clearProducts();
+ materialStore.getState().clearMaterials();
+ armBotStore.getState().clearArmBots();
+ machineStore.getState().clearMachines();
+ conveyorStore.getState().clearConveyors();
+ vehicleStore.getState().clearVehicles();
+ storageUnitStore.getState().clearStorageUnits();
+ }, [assetStore, aisleStore, eventStore, productStore, materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore]);
const contextValue = useMemo(() => (
{
diff --git a/app/src/modules/visualization/RealTimeVisulization.tsx b/app/src/modules/visualization/RealTimeVisulization.tsx
index 67d4dab..4f24e05 100644
--- a/app/src/modules/visualization/RealTimeVisulization.tsx
+++ b/app/src/modules/visualization/RealTimeVisulization.tsx
@@ -14,7 +14,7 @@ import EditWidgetOption from "../../components/ui/menu/EditWidgetOption";
import { useEditWidgetOptionsStore, useRightClickSelected, useRightSelected, } from "../../store/visualization/useZone3DWidgetStore";
import OuterClick from "../../utils/outerClick";
import { useWidgetStore } from "../../store/useWidgetStore";
-import { useParams } from "react-router-dom";
+import { useNavigate, useParams } from "react-router-dom";
import { getUserData } from "../../functions/getUserData";
import { useVersionContext } from "../builder/version/versionContext";
@@ -63,6 +63,7 @@ const RealTimeVisulization: React.FC = () => {
const { selectedVersionStore } = useVersionContext();
const { selectedVersion } = selectedVersionStore();
const { projectId } = useParams();
+ const navigate = useNavigate();
OuterClick({
contextClassName: [
@@ -81,6 +82,12 @@ const RealTimeVisulization: React.FC = () => {
useEffect(() => {
if (!projectId || !selectedVersion) return;
getZone2dData(organization, projectId, selectedVersion?.versionId || '').then((response) => {
+ if (!response) return;
+ // if (response.status === 401) {
+ // console.log("force logout");
+ // navigate("/");
+ // return;
+ // }
if (!Array.isArray(response)) {
return;
}
diff --git a/app/src/modules/visualization/widgets/2d/charts/BarGraphComponent.tsx b/app/src/modules/visualization/widgets/2d/charts/BarGraphComponent.tsx
index cc3d922..77001eb 100644
--- a/app/src/modules/visualization/widgets/2d/charts/BarGraphComponent.tsx
+++ b/app/src/modules/visualization/widgets/2d/charts/BarGraphComponent.tsx
@@ -11,6 +11,7 @@ import useChartStore from "../../../../../store/visualization/useChartStore";
import { useSelectedZoneStore } from "../../../../../store/visualization/useZoneStore";
import { useParams } from "react-router-dom";
import { useVersionContext } from "../../../../builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
interface ChartComponentProps {
id: string;
@@ -181,30 +182,14 @@ const BarGraphComponent = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ''}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setmeasurements(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setName(response.data.widgetName);
- } else {
- echo.error("Failed to fetch saved inputs");
-
- }
- } catch (error) {
+ let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+ if (response) {
+ setmeasurements(response.Datastructure.measurements);
+ setDuration(response.Datastructure.duration);
+ setName(response.widgetName);
}
+
}
};
diff --git a/app/src/modules/visualization/widgets/2d/charts/DoughnutGraphComponent.tsx b/app/src/modules/visualization/widgets/2d/charts/DoughnutGraphComponent.tsx
index 028ce95..69b92ac 100644
--- a/app/src/modules/visualization/widgets/2d/charts/DoughnutGraphComponent.tsx
+++ b/app/src/modules/visualization/widgets/2d/charts/DoughnutGraphComponent.tsx
@@ -10,6 +10,7 @@ import { useParams } from "react-router-dom";
import { useSelectedZoneStore } from "../../../../../store/visualization/useZoneStore";
import { getUserData } from "../../../../../functions/getUserData";
import { useVersionContext } from "../../../../builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
interface ChartComponentProps {
id: string;
@@ -164,30 +165,14 @@ const DoughnutGraphComponent = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setmeasurements(response.data.Datastructure.measurements)
- setDuration(response.data.Datastructure.duration)
- setName(response.data.widgetName)
- } else {
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
+ let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setmeasurements(response.Datastructure.measurements)
+ setDuration(response.Datastructure.duration)
+ setName(response.widgetName)
}
+
}
}
diff --git a/app/src/modules/visualization/widgets/2d/charts/LineGraphComponent.tsx b/app/src/modules/visualization/widgets/2d/charts/LineGraphComponent.tsx
index ca57217..ecacd26 100644
--- a/app/src/modules/visualization/widgets/2d/charts/LineGraphComponent.tsx
+++ b/app/src/modules/visualization/widgets/2d/charts/LineGraphComponent.tsx
@@ -10,6 +10,7 @@ import { useParams } from "react-router-dom";
import { useSelectedZoneStore } from "../../../../../store/visualization/useZoneStore";
import { getUserData } from "../../../../../functions/getUserData";
import { useVersionContext } from "../../../../builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
interface ChartComponentProps {
id: string;
@@ -181,29 +182,12 @@ const LineGraphComponent = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setmeasurements(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setName(response.data.widgetName);
- } else {
- echo.error("Failed to fetch saved inputs");
-
- }
- } catch (error) {
-
+ let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setmeasurements(response.Datastructure.measurements)
+ setDuration(response.Datastructure.duration)
+ setName(response.widgetName)
}
}
};
diff --git a/app/src/modules/visualization/widgets/2d/charts/PieGraphComponent.tsx b/app/src/modules/visualization/widgets/2d/charts/PieGraphComponent.tsx
index 10dbe56..6879f34 100644
--- a/app/src/modules/visualization/widgets/2d/charts/PieGraphComponent.tsx
+++ b/app/src/modules/visualization/widgets/2d/charts/PieGraphComponent.tsx
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
import { useParams } from "react-router-dom";
import { getUserData } from "../../../../../functions/getUserData";
import { useVersionContext } from "../../../../builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
interface ChartComponentProps {
id: string;
@@ -181,30 +182,13 @@ const PieChartComponent = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setmeasurements(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setName(response.data.widgetName);
- } else {
- echo.error("Failed to fetch saved inputs");
-
- }
- } catch (error) {
-
- }
+ let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setmeasurements(response.Datastructure.measurements)
+ setDuration(response.Datastructure.duration)
+ setName(response.widgetName)
+ }
}
};
diff --git a/app/src/modules/visualization/widgets/2d/charts/PolarAreaGraphComponent.tsx b/app/src/modules/visualization/widgets/2d/charts/PolarAreaGraphComponent.tsx
index 0c40782..b99e55b 100644
--- a/app/src/modules/visualization/widgets/2d/charts/PolarAreaGraphComponent.tsx
+++ b/app/src/modules/visualization/widgets/2d/charts/PolarAreaGraphComponent.tsx
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
import { useParams } from "react-router-dom";
import { getUserData } from "../../../../../functions/getUserData";
import { useVersionContext } from "../../../../builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
interface ChartComponentProps {
id: string;
@@ -181,30 +182,13 @@ const PolarAreaGraphComponent = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
- setmeasurements(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setName(response.data.widgetName);
- } else {
- echo.error("Failed to fetch saved inputs");
-
- }
- } catch (error) {
-
- }
+ let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setmeasurements(response.Datastructure.measurements)
+ setDuration(response.Datastructure.duration)
+ setName(response.widgetName)
+ }
}
};
diff --git a/app/src/modules/visualization/widgets/2d/charts/ProgressCard1.tsx b/app/src/modules/visualization/widgets/2d/charts/ProgressCard1.tsx
index 1a4159b..0506424 100644
--- a/app/src/modules/visualization/widgets/2d/charts/ProgressCard1.tsx
+++ b/app/src/modules/visualization/widgets/2d/charts/ProgressCard1.tsx
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
import { useParams } from "react-router-dom";
import { getUserData } from "../../../../../functions/getUserData";
import { useVersionContext } from "../../../../builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
const ProgressCard1 = ({ id, title }: { id: string; title: string }) => {
const {
@@ -61,31 +62,13 @@ const ProgressCard1 = ({ id, title }: { id: string; title: string }) => {
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
+ let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setmeasurements(response.Datastructure.measurements)
+ setDuration(response.Datastructure.duration)
+ setName(response.widgetName)
}
- );
- if (response.status === 200) {
-
- setmeasurements(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setName(response.data.widgetName);
- } else {
- echo.error("Failed to fetch saved inputs");
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
- }
}
};
diff --git a/app/src/modules/visualization/widgets/2d/charts/ProgressCard2.tsx b/app/src/modules/visualization/widgets/2d/charts/ProgressCard2.tsx
index c006438..b538f4d 100644
--- a/app/src/modules/visualization/widgets/2d/charts/ProgressCard2.tsx
+++ b/app/src/modules/visualization/widgets/2d/charts/ProgressCard2.tsx
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
import { useParams } from "react-router-dom";
import { getUserData } from "../../../../../functions/getUserData";
import { useVersionContext } from "../../../../builder/version/versionContext";
+import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
const ProgressCard2 = ({ id, title }: { id: string; title: string }) => {
const {
@@ -65,30 +66,12 @@ const ProgressCard2 = ({ id, title }: { id: string; title: string }) => {
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
-
-
- setmeasurements(response.data.Datastructure.measurements);
- setDuration(response.data.Datastructure.duration);
- setName(response.data.widgetName);
- } else {
-
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
-
+ let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setmeasurements(response.Datastructure.measurements)
+ setDuration(response.Datastructure.duration)
+ setName(response.widgetName)
}
}
};
diff --git a/app/src/modules/visualization/widgets/3d/Dropped3dWidget.tsx b/app/src/modules/visualization/widgets/3d/Dropped3dWidget.tsx
index c659697..a9b65ea 100644
--- a/app/src/modules/visualization/widgets/3d/Dropped3dWidget.tsx
+++ b/app/src/modules/visualization/widgets/3d/Dropped3dWidget.tsx
@@ -66,7 +66,6 @@ export default function Dropped3dWidgets() {
const [horizontalZ, setHorizontalZ] = useState();
const { selectedVersionStore } = useVersionContext();
const { selectedVersion } = selectedVersionStore();
-
const activeZoneWidgets = zoneWidgetData[selectedZone.zoneUuid] || [];
const { projectId } = useParams();
const { userId, organization, email } = getUserData();
@@ -107,13 +106,16 @@ 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 rect = canvasElement.getBoundingClientRect();
@@ -137,6 +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 = {
diff --git a/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx b/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx
index c4d55e0..f951456 100644
--- a/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx
+++ b/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx
@@ -17,6 +17,7 @@ import io from "socket.io-client";
import { useWidgetStore } from "../../../../../store/useWidgetStore";
import useChartStore from "../../../../../store/visualization/useChartStore";
import { getUserData } from "../../../../../functions/getUserData";
+import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
// Register ChartJS components
ChartJS.register(
@@ -170,20 +171,27 @@ const ProductionCapacity: React.FC = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
- );
-
- if (response.status === 200) {
- setmeasurements(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setName(response.data.widgetName);
- } else {
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
+ let response = await get3dWidgetInput(id, organization)
+ console.log('response: ', response);
+ if (response) {
+ setmeasurements(response.data.Data.measurements);
+ setDuration(response.data.Data.duration);
+ setName(response.data.widgetName);
}
+ // try {
+ // const response = await axios.get(
+ // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
+ // );
+
+ // if (response.status === 200) {
+ // setmeasurements(response.data.Data.measurements);
+ // setDuration(response.data.Data.duration);
+ // setName(response.data.widgetName);
+ // } else {
+ // }
+ // } catch (error) {
+ // echo.error("Failed to fetch saved inputs");
+ // }
}
};
diff --git a/app/src/modules/visualization/widgets/3d/cards/ReturnOfInvestment.tsx b/app/src/modules/visualization/widgets/3d/cards/ReturnOfInvestment.tsx
index e593902..80cd269 100644
--- a/app/src/modules/visualization/widgets/3d/cards/ReturnOfInvestment.tsx
+++ b/app/src/modules/visualization/widgets/3d/cards/ReturnOfInvestment.tsx
@@ -18,6 +18,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
import useChartStore from "../../../../../store/visualization/useChartStore";
import { WavyIcon } from "../../../../../components/icons/3dChartIcons";
import { getUserData } from "../../../../../functions/getUserData";
+import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
// Register Chart.js components
ChartJS.register(
@@ -199,21 +200,28 @@ const ReturnOfInvestment: React.FC = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
- );
- if (response.status === 200) {
- setmeasurements(response.data.Data.measurements);
- 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);
+ let response = await get3dWidgetInput(id, organization)
+ console.log('response: ', response);
+ if (response) {
+ setmeasurements(response.data.Data.measurements);
+ setDuration(response.data.Data.duration);
+ setName(response.data.widgetName);
}
+ // try {
+ // const response = await axios.get(
+ // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
+ // );
+ // if (response.status === 200) {
+ // setmeasurements(response.data.Data.measurements);
+ // 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);
+ // }
}
};
diff --git a/app/src/modules/visualization/widgets/3d/cards/StateWorking.tsx b/app/src/modules/visualization/widgets/3d/cards/StateWorking.tsx
index ed9da1a..f664661 100644
--- a/app/src/modules/visualization/widgets/3d/cards/StateWorking.tsx
+++ b/app/src/modules/visualization/widgets/3d/cards/StateWorking.tsx
@@ -6,6 +6,7 @@ import io from "socket.io-client";
import { useWidgetStore } from "../../../../../store/useWidgetStore";
import useChartStore from "../../../../../store/visualization/useChartStore";
import { getUserData } from "../../../../../functions/getUserData";
+import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
// import image from "../../../../assets/image/temp/image.png";
interface StateWorkingProps {
@@ -77,21 +78,28 @@ const StateWorking: React.FC = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
- );
- if (response.status === 200) {
- setmeasurements(response.data.Data.measurements);
- 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);
+ let response = await get3dWidgetInput(id, organization)
+ console.log('response: ', response);
+ if (response) {
+ setmeasurements(response.data.Data.measurements);
+ setDuration(response.data.Data.duration);
+ setName(response.data.widgetName);
}
+ // try {
+ // const response = await axios.get(
+ // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
+ // );
+ // if (response.status === 200) {
+ // setmeasurements(response.data.Data.measurements);
+ // 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);
+ // }
}
};
diff --git a/app/src/modules/visualization/widgets/3d/cards/Throughput.tsx b/app/src/modules/visualization/widgets/3d/cards/Throughput.tsx
index 5439a5b..ea87c7f 100644
--- a/app/src/modules/visualization/widgets/3d/cards/Throughput.tsx
+++ b/app/src/modules/visualization/widgets/3d/cards/Throughput.tsx
@@ -20,6 +20,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
import useChartStore from "../../../../../store/visualization/useChartStore";
import { ThroughputIcon } from "../../../../../components/icons/3dChartIcons";
import { getUserData } from "../../../../../functions/getUserData";
+import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
// Register Chart.js components
ChartJS.register(
@@ -179,21 +180,28 @@ const Throughput: React.FC = ({
const fetchSavedInputes = async () => {
if (id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
- );
- if (response.status === 200) {
- setmeasurements(response.data.Data.measurements);
- 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);
+ let response = await get3dWidgetInput(id, organization)
+ console.log('response: ', response);
+ if (response) {
+ setmeasurements(response.data.Data.measurements);
+ setDuration(response.data.Data.duration);
+ setName(response.data.widgetName);
}
+ // try {
+ // const response = await axios.get(
+ // `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
+ // );
+ // if (response.status === 200) {
+ // setmeasurements(response.data.Data.measurements);
+ // 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);
+ // }
}
};
diff --git a/app/src/modules/visualization/widgets/floating/DroppedFloatingWidgets.tsx b/app/src/modules/visualization/widgets/floating/DroppedFloatingWidgets.tsx
index 3aba161..ee2d2fd 100644
--- a/app/src/modules/visualization/widgets/floating/DroppedFloatingWidgets.tsx
+++ b/app/src/modules/visualization/widgets/floating/DroppedFloatingWidgets.tsx
@@ -50,6 +50,7 @@ const DroppedObjects: React.FC = () => {
const { selectedVersion } = selectedVersionStore();
const { projectId } = useParams();
+
const [openKebabId, setOpenKebabId] = useState(null);
const updateObjectPosition = useDroppedObjectsStore(
(state) => state.updateObjectPosition
@@ -116,7 +117,7 @@ const DroppedObjects: React.FC = () => {
function handleDuplicate(zoneName: string, index: number) {
setOpenKebabId(null);
- duplicateObject(zoneName, index, projectId, selectedVersion?.versionId ||''); // Call the duplicateObject method from the store
+ duplicateObject(zoneName, index, projectId, selectedVersion?.versionId || ''); // Call the duplicateObject method from the store
setSelectedChartId(null);
}
@@ -129,7 +130,7 @@ const DroppedObjects: React.FC = () => {
organization,
zoneUuid: zone.zoneUuid,
versionId: selectedVersion?.versionId || '',
- userId,
+ userId,
projectId
};
@@ -168,6 +169,7 @@ const DroppedObjects: React.FC = () => {
setActiveEdges({ vertical, horizontal });
// Store the initial position strategy and active edges
+
setDraggingIndex({
zone: zoneName,
index,
@@ -190,6 +192,8 @@ const DroppedObjects: React.FC = () => {
offsetX = rect.width - relativeX - (obj.position.right as number);
}
+
+
setOffset([offsetY, offsetX]);
// Add native event listeners for smoother tracking
@@ -254,11 +258,14 @@ const DroppedObjects: React.FC = () => {
};
const handlePointerUpNative = async (e: PointerEvent) => {
+
// Clean up native event listeners
element.removeEventListener("pointermove", handlePointerMoveNative);
element.removeEventListener("pointerup", handlePointerUpNative);
element.releasePointerCapture(e.pointerId);
+
+
if (!draggingIndex || !offset) return;
const rect = container.getBoundingClientRect();
@@ -305,15 +312,18 @@ const DroppedObjects: React.FC = () => {
{
...zone.objects[draggingIndex.index],
position: boundedPosition,
- }
+ },
+ projectId,
+ selectedVersion?.versionId || ""
);
+
if (response.message === "Widget updated successfully") {
updateObjectPosition(zoneName, draggingIndex.index, boundedPosition);
}
} catch (error) {
echo.error("Failed to add widget");
- console.log(error);
+
} finally {
setDraggingIndex(null);
setOffset(null);
@@ -449,7 +459,7 @@ const DroppedObjects: React.FC = () => {
updateObjectPosition(zoneName, draggingIndex.index, boundedPosition);
} catch (error) {
echo.error("Failed to add widget");
- console.log(error);
+
} finally {
// Clean up regardless of success or failure
setDraggingIndex(null);
diff --git a/app/src/modules/visualization/widgets/floating/cards/FleetEfficiencyComponent.tsx b/app/src/modules/visualization/widgets/floating/cards/FleetEfficiencyComponent.tsx
index 80d1b4a..ae48014 100644
--- a/app/src/modules/visualization/widgets/floating/cards/FleetEfficiencyComponent.tsx
+++ b/app/src/modules/visualization/widgets/floating/cards/FleetEfficiencyComponent.tsx
@@ -7,6 +7,8 @@ import io from "socket.io-client";
import { usePlayButtonStore } from "../../../../../store/usePlayButtonStore";
import { getUserData } from "../../../../../functions/getUserData";
import { useParams } from "react-router-dom";
+import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
+import { useVersionContext } from "../../../../builder/version/versionContext";
const FleetEfficiencyComponent = ({ object }: any) => {
const [progress, setProgress] = useState(0);
@@ -18,6 +20,8 @@ const FleetEfficiencyComponent = ({ object }: any) => {
const { selectedChartId } = useWidgetStore();
const { isPlaying } = usePlayButtonStore();
const { projectId } = useParams()
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
@@ -44,10 +48,10 @@ const FleetEfficiencyComponent = ({ object }: any) => {
socket.on("lastOutput", (response) => {
const responseData = response.input1;
- // console.log(responseData);
+ //
if (typeof responseData === "number") {
- // console.log("It's a number!");
+ //
setProgress(responseData);
}
});
@@ -61,28 +65,11 @@ const FleetEfficiencyComponent = ({ object }: any) => {
const fetchSavedInputes = async () => {
if (object?.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${object?.id}/${organization}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
- setmeasurements(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setName(response.data.header);
- } else {
- // console.log("Unexpected response:", response);
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
- console.error("There was an error!", error);
+ let response = await getFloatingWidgetInput(object?.id, organization,projectId,selectedVersion?.versionId||"")
+ if (response) {
+ setmeasurements(response.Data.Datastructure.measurements);
+ setDuration(response.Data.Datastructure.duration);
+ setName(response.Data.header);
}
}
};
diff --git a/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx b/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx
index c0516d7..377ce3f 100644
--- a/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx
+++ b/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx
@@ -1,17 +1,14 @@
import React, { useState, useEffect } from "react";
-import { Line } from "react-chartjs-2";
+
import useChartStore from "../../../../../store/visualization/useChartStore";
import { useWidgetStore } from "../../../../../store/useWidgetStore";
import axios from "axios";
import io from "socket.io-client";
-import {
- CartIcon,
- DocumentIcon,
- GlobeIcon,
- WalletIcon,
-} from "../../../../../components/icons/3dChartIcons";
+import {CartIcon,DocumentIcon,GlobeIcon,WalletIcon,} from "../../../../../components/icons/3dChartIcons";
import { getUserData } from "../../../../../functions/getUserData";
import { useParams } from "react-router-dom";
+import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
+import { useVersionContext } from "../../../../builder/version/versionContext";
const TotalCardComponent = ({ object }: any) => {
const [progress, setProgress] = useState(0);
@@ -22,6 +19,8 @@ const TotalCardComponent = ({ object }: any) => {
const { header, flotingDuration, flotingMeasurements } = useChartStore();
const { selectedChartId } = useWidgetStore();
const { projectId } = useParams()
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
@@ -60,25 +59,12 @@ const TotalCardComponent = ({ object }: any) => {
const fetchSavedInputes = async () => {
if (object?.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${object?.id}/${organization}`, {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
- setmeasurements(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setName(response.data.header);
- } else {
- echo.error("Failed to fetch saved inputs");
- }
- } catch (error) { }
+ let response = await getFloatingWidgetInput(object?.id, organization,projectId,selectedVersion?.versionId||"")
+ if (response) {
+ setmeasurements(response.Data.Datastructure.measurements);
+ setDuration(response.Data.Datastructure.duration);
+ setName(response.Data.header);
+ }
}
};
diff --git a/app/src/modules/visualization/widgets/floating/cards/WarehouseThroughputComponent.tsx b/app/src/modules/visualization/widgets/floating/cards/WarehouseThroughputComponent.tsx
index 46a64d7..395a253 100644
--- a/app/src/modules/visualization/widgets/floating/cards/WarehouseThroughputComponent.tsx
+++ b/app/src/modules/visualization/widgets/floating/cards/WarehouseThroughputComponent.tsx
@@ -6,6 +6,8 @@ import axios from "axios";
import io from "socket.io-client";
import { getUserData } from "../../../../../functions/getUserData";
import { useParams } from "react-router-dom";
+import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
+import { useVersionContext } from "../../../../builder/version/versionContext";
const WarehouseThroughputComponent = ({ object }: any) => {
const [measurements, setmeasurements] = useState({});
@@ -22,22 +24,12 @@ const WarehouseThroughputComponent = ({ object }: any) => {
const { header, flotingDuration, flotingMeasurements } = useChartStore();
const { selectedChartId } = useWidgetStore();
const { projectId } = useParams()
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
const lineGraphData = {
- labels: [
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec",
+ labels: ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",
], // Months of the year
datasets: [
{
@@ -159,29 +151,14 @@ const WarehouseThroughputComponent = ({ object }: any) => {
const fetchSavedInputes = async () => {
if (object?.id !== "") {
- try {
- const response = await axios.get(
- `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${object?.id}/${organization}`,
- {
- headers: {
- Authorization: "Bearer ",
- "Content-Type": "application/json",
- token: localStorage.getItem("token") || "",
- refresh_token: localStorage.getItem("refreshToken") || "",
- },
- }
- );
- if (response.status === 200) {
- setmeasurements(response.data.Data.measurements);
- setDuration(response.data.Data.duration);
- setName(response.data.header);
- } else {
- console.log("Unexpected response:", response);
- }
- } catch (error) {
- echo.error("Failed to fetch saved inputs");
- console.error("There was an error!", error);
+ let response = await getFloatingWidgetInput(object?.id, organization, projectId, selectedVersion?.versionId || "")
+
+ if (response) {
+ setmeasurements(response.Data.measurements);
+ setDuration(response.Data.duration);
+ setName(response?.header);
}
+
}
};
diff --git a/app/src/pages/Project.tsx b/app/src/pages/Project.tsx
index 26341b9..ed9eb06 100644
--- a/app/src/pages/Project.tsx
+++ b/app/src/pages/Project.tsx
@@ -131,7 +131,6 @@ const Project: React.FC = () => {
)}
-
);
};
diff --git a/app/src/pages/sessionValidity.tsx b/app/src/pages/sessionValidity.tsx
new file mode 100644
index 0000000..4eecef6
--- /dev/null
+++ b/app/src/pages/sessionValidity.tsx
@@ -0,0 +1,15 @@
+import React, { useEffect } from 'react'
+
+function sessionValidity() {
+
+ useEffect(() => {
+
+ }, [])
+
+ return (
+ <>
+ >
+ )
+}
+
+export default sessionValidity
diff --git a/app/src/services/dashboard/createProject.ts b/app/src/services/dashboard/createProject.ts
index fe08526..fe14a0a 100644
--- a/app/src/services/dashboard/createProject.ts
+++ b/app/src/services/dashboard/createProject.ts
@@ -13,6 +13,11 @@ export const createProject = async (projectUuid: string, userId: string, thumbna
},
body: JSON.stringify({ projectUuid, userId, thumbnail, organization, }),
});
+ 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 project");
}
diff --git a/app/src/services/dashboard/deleteProject.ts b/app/src/services/dashboard/deleteProject.ts
index 4695028..b1c90a9 100644
--- a/app/src/services/dashboard/deleteProject.ts
+++ b/app/src/services/dashboard/deleteProject.ts
@@ -21,6 +21,11 @@ export const deleteProject = async (
body: JSON.stringify({ userId, organization }),
}
);
+ const newAccessToken = response.headers.get("x-access-token");
+ if (newAccessToken) {
+ //console.log("New token received:", newAccessToken);
+ localStorage.setItem("token", newAccessToken);
+ }
console.log("response: ", response);
if (!response.ok) {
console.error("Failed to clearPanel in the zone");
diff --git a/app/src/services/dashboard/deleteTrash.ts b/app/src/services/dashboard/deleteTrash.ts
index bb2840a..561ce28 100644
--- a/app/src/services/dashboard/deleteTrash.ts
+++ b/app/src/services/dashboard/deleteTrash.ts
@@ -15,6 +15,11 @@ export const deleteTrash = async (organization: string, projectId: string) => {
},
}
);
+ const newAccessToken = response.headers.get("x-access-token");
+ if (newAccessToken) {
+ //console.log("New token received:", newAccessToken);
+ localStorage.setItem("token", newAccessToken);
+ }
console.log("restore: ", response);
if (!response.ok) {
diff --git a/app/src/services/dashboard/duplicateProject.ts b/app/src/services/dashboard/duplicateProject.ts
index a77cbd0..837bb0e 100644
--- a/app/src/services/dashboard/duplicateProject.ts
+++ b/app/src/services/dashboard/duplicateProject.ts
@@ -19,14 +19,18 @@ export const duplicateProject = async (
body: JSON.stringify({ projectUuid, thumbnail, projectName }),
}
);
-
- console.log("response: ", response);
+ const newAccessToken = response.headers.get("x-access-token");
+ if (newAccessToken) {
+ //console.log("New token received:", newAccessToken);
+ localStorage.setItem("token", newAccessToken);
+ }
+ // console.log("response: ", response);
if (!response.ok) {
console.error("Failed to add project");
}
const result = await response.json();
- console.log("result: ", result);
+ // console.log("result: ", result);
return result;
} catch (error) {
if (error instanceof Error) {
diff --git a/app/src/services/dashboard/getAllProjects.ts b/app/src/services/dashboard/getAllProjects.ts
index 45adab6..ffe08a2 100644
--- a/app/src/services/dashboard/getAllProjects.ts
+++ b/app/src/services/dashboard/getAllProjects.ts
@@ -14,6 +14,11 @@ export const getAllProjects = async (userId: string, organization: string) => {
},
}
);
+ const newAccessToken = response.headers.get("x-access-token");
+ if (newAccessToken) {
+ //console.log("New token received:", newAccessToken);
+ localStorage.setItem("token", newAccessToken);
+ }
if (!response.ok) {
throw new Error("Failed to fetch assets");
diff --git a/app/src/services/dashboard/getTrash.ts b/app/src/services/dashboard/getTrash.ts
index 9e01276..0d71e13 100644
--- a/app/src/services/dashboard/getTrash.ts
+++ b/app/src/services/dashboard/getTrash.ts
@@ -16,7 +16,11 @@ export const getTrash = async (organization: string) => {
},
}
);
-
+ 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 fetch trash data");
}
diff --git a/app/src/services/dashboard/projectTutorial.ts b/app/src/services/dashboard/projectTutorial.ts
index a323b22..835dfbe 100644
--- a/app/src/services/dashboard/projectTutorial.ts
+++ b/app/src/services/dashboard/projectTutorial.ts
@@ -5,10 +5,17 @@ export const projectTutorial = async () => {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/tutorials`, {
method: "GET",
headers: {
+ Authorization: "Bearer