From 0d98892dffa3949932f1fa1c7c99446aca75a553 Mon Sep 17 00:00:00 2001 From: Gomathi9520 Date: Wed, 4 Jun 2025 11:55:59 +0530 Subject: [PATCH] updated api and socket for builder and visualization --- app/package-lock.json | 1 + app/src/components/Dashboard/SidePannel.tsx | 9 +- .../properties/GlobalProperties.tsx | 22 +- .../properties/ZoneProperties.tsx | 8 +- .../IotInputCards/BarChartInput.tsx | 25 +- .../FleetEfficiencyInputComponent.tsx | 4 +- .../IotInputCards/FlotingWidgetInput.tsx | 4 +- .../IotInputCards/LineGrapInput.tsx | 24 +- .../IotInputCards/PieChartInput.tsx | 25 +- .../IotInputCards/Progress1Input.tsx | 25 +- .../IotInputCards/Progress2Input.tsx | 25 +- .../WarehouseThroughputInputComponent.tsx | 4 +- .../IotInputCards/Widget2InputCard3D.tsx | 4 +- .../IotInputCards/Widget3InputCard3D.tsx | 4 +- .../IotInputCards/Widget4InputCard3D.tsx | 4 +- app/src/components/ui/Tools.tsx | 3 + app/src/components/ui/list/DropDownList.tsx | 4 +- app/src/components/ui/list/List.tsx | 26 +- .../IntialLoad/loadInitialFloorItems.ts | 7 +- .../IntialLoad/loadInitialWallItems.ts | 3 +- .../builder/assetGroup/assetsGroup.tsx | 7 +- app/src/modules/builder/builder.tsx | 4 +- app/src/modules/builder/dfx/LoadBlueprint.tsx | 6 +- .../dragControlDeclaration.ts | 7 +- .../geomentries/assets/addAssetModel.ts | 25 +- .../geomentries/assets/deleteFloorItems.ts | 10 +- .../geomentries/floors/drawOnlyFloor.ts | 12 +- .../builder/geomentries/layers/deleteLayer.ts | 7 +- .../builder/geomentries/lines/deleteLine.ts | 7 +- .../lines/distanceText/distanceText.tsx | 4 +- .../builder/geomentries/lines/drawWall.ts | 15 +- .../builder/geomentries/lines/splitLine.ts | 8 +- .../builder/geomentries/points/deletePoint.ts | 7 +- .../builder/geomentries/walls/addWallItems.ts | 7 +- .../geomentries/walls/deleteWallItems.ts | 6 +- .../builder/groups/floorGroupAisle.tsx | 563 +++++++++++------- .../builder/groups/floorItemsGroup.tsx | 18 +- .../modules/builder/groups/floorPlanGroup.tsx | 18 +- .../modules/builder/groups/wallItemsGroup.tsx | 14 +- app/src/modules/builder/groups/wallsMesh.tsx | 4 +- app/src/modules/builder/groups/zoneGroup.tsx | 94 ++- .../collaboration/camera/collabCams.tsx | 4 +- .../socket/socketResponses.dev.tsx | 52 +- app/src/modules/scene/camera/switchView.tsx | 4 +- .../scene/camera/updateCameraPosition.ts | 5 +- app/src/modules/scene/controls/controls.tsx | 11 +- .../selectionControls/copyPasteControls.tsx | 11 +- .../selectionControls/duplicationControls.tsx | 10 +- .../selectionControls/moveControls.tsx | 6 +- .../selectionControls/rotateControls.tsx | 6 +- .../selectionControls/selectionControls.tsx | 6 +- .../transformControls/transformControls.tsx | 8 +- .../visualization/RealTimeVisulization.tsx | 21 +- .../functions/handleSaveTemplate.ts | 7 +- .../visualization/functions/handleUiDrop.ts | 27 +- .../socket/realTimeVizSocket.dev.tsx | 49 +- .../visualization/template/Templates.tsx | 17 +- .../widgets/2d/DraggableWidget.tsx | 20 +- .../widgets/2d/charts/BarGraphComponent.tsx | 15 +- .../2d/charts/DoughnutGraphComponent.tsx | 17 +- .../widgets/2d/charts/LineGraphComponent.tsx | 15 +- .../widgets/2d/charts/PieGraphComponent.tsx | 14 +- .../2d/charts/PolarAreaGraphComponent.tsx | 14 +- .../widgets/2d/charts/ProgressCard1.tsx | 14 +- .../widgets/2d/charts/ProgressCard2.tsx | 14 +- .../widgets/3d/Dropped3dWidget.tsx | 152 ++--- .../floating/DroppedFloatingWidgets.tsx | 14 +- .../widgets/floating/cards/SimpleCard.tsx | 2 +- .../widgets/panel/AddButtons.tsx | 88 +-- .../visualization/widgets/panel/Panel.tsx | 41 +- .../visualization/zone/DisplayZone.tsx | 46 +- app/src/pages/Dashboard.tsx | 3 - app/src/pages/Project.tsx | 8 +- app/src/services/dashboard/createProject.ts | 4 +- .../assest/floorAsset/getFloorItemsApi.ts | 8 +- .../assest/floorAsset/setFloorItemApi.ts | 5 +- .../assest/wallAsset/getWallItemsApi.ts | 9 +- .../factoryBuilder/camera/getCameraApi.ts | 15 +- .../environment/findEnvironment.ts | 12 +- .../environment/setEnvironment.ts | 19 +- .../factoryBuilder/lines/getLinesApi.ts | 8 +- .../factoryBuilder/zones/deleteZoneApi.ts | 4 +- .../factoryBuilder/zones/getZonesApi.ts | 14 +- .../services/visulization/zone/add3dWidget.ts | 9 +- .../visulization/zone/addFloatingWidgets.ts | 9 +- .../services/visulization/zone/addWidgets.ts | 10 +- .../services/visulization/zone/clearPanel.ts | 9 +- .../visulization/zone/delete3dWidget.ts | 9 +- .../visulization/zone/deleteFloatingWidget.ts | 5 +- .../services/visulization/zone/deletePanel.ts | 9 +- .../visulization/zone/deleteTemplate.ts | 5 +- .../visulization/zone/deleteWidgetApi.ts | 9 +- .../visulization/zone/duplicateWidget.ts | 9 +- .../visulization/zone/get3dWidgetData.ts | 12 +- .../visulization/zone/getFloatingData.ts | 10 +- .../visulization/zone/getSelect2dZoneData.ts | 10 +- .../services/visulization/zone/getTemplate.ts | 7 +- .../services/visulization/zone/getZoneData.ts | 8 +- .../services/visulization/zone/getZones.ts | 7 +- .../visulization/zone/loadTemplate.ts | 9 +- .../services/visulization/zone/lockPanel.ts | 4 +- app/src/services/visulization/zone/panel.ts | 9 +- .../visulization/zone/saveTempleteApi.ts | 5 +- .../visulization/zone/update3dWidget.ts | 26 +- .../visulization/zone/zoneCameraUpdation.ts | 7 +- app/src/store/builder/store.ts | 9 +- .../visualization/useDroppedObjectsStore.ts | 23 +- .../visualization/useZone3DWidgetStore.ts | 42 +- app/src/store/visualization/useZoneStore.ts | 6 +- 109 files changed, 1382 insertions(+), 788 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index a752e9c..fff13e1 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -10133,6 +10133,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/dxf-parser/-/dxf-parser-1.1.2.tgz", "integrity": "sha512-GPTumUvRkounlIazLIyJMmTWt+nlg+ksS0Hdm8jWvejmZKBTz6gvHTam76wRm4PQMma5sgKLThblQyeIJcH79Q==", + "license": "MIT", "dependencies": { "loglevel": "^1.7.1" } diff --git a/app/src/components/Dashboard/SidePannel.tsx b/app/src/components/Dashboard/SidePannel.tsx index 4bb7f61..03392f4 100644 --- a/app/src/components/Dashboard/SidePannel.tsx +++ b/app/src/components/Dashboard/SidePannel.tsx @@ -39,9 +39,8 @@ const SidePannel: React.FC = ({ setActiveTab, activeTab }) => { try { const projectId = generateProjectId(); useSocketStore.getState().initializeSocket(email, organization, token); - console.log('projectId: ', projectId); - navigate(`/${projectId}`); - setLoadingProgress(1) + + //API for creating new Project // const project = await createProject( // projectId, @@ -63,6 +62,10 @@ const SidePannel: React.FC = ({ setActiveTab, activeTab }) => { // console.log('addProject: ', addProject); const handleResponse = (data: any) => { console.log('Project add response:', data); + if (data.message === "Project created successfully") { + setLoadingProgress(1) + navigate(`/${data.data.projectId}`); + } projectSocket.off("v1-project:response:add", handleResponse); // Clean up }; projectSocket.on("v1-project:response:add", handleResponse); diff --git a/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx b/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx index 0422e2b..191bb15 100644 --- a/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx @@ -20,6 +20,7 @@ import { import { setEnvironment } from "../../../../services/factoryBuilder/environment/setEnvironment"; import * as CONSTANTS from "../../../../types/world/worldConstants"; import { validateBBox } from "@turf/helpers"; +import { useParams } from "react-router-dom"; const GlobalProperties: React.FC = () => { const { toggleView, setToggleView } = useToggleView(); const { selectedWallItem, setSelectedWallItem } = useSelectedWallItem(); @@ -37,6 +38,7 @@ const GlobalProperties: React.FC = () => { const [limitGridDistance, setLimitGridDistance] = useState(false); const [gridDistance, setGridDistance] = useState(3); + const { projectId } = useParams(); const optimizeScene = async (value: any) => { const email = localStorage.getItem("email"); @@ -49,7 +51,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, 30, - true + true, + projectId ); setRenderDistance(30); setLimitDistance(true); @@ -67,7 +70,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, 75, - !limitDistance + !limitDistance, + projectId ); setRenderDistance(75); } else { @@ -78,7 +82,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, renderDistance, - !limitDistance + !limitDistance, + projectId ); } setLimitDistance(!limitDistance); @@ -111,7 +116,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, value, - limitDistance + limitDistance, + projectId ); }; @@ -128,7 +134,8 @@ const GlobalProperties: React.FC = () => { !roofVisibility, shadows, renderDistance, - limitDistance + limitDistance, + projectId ); // @@ -157,7 +164,7 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, renderDistance, - limitDistance + limitDistance,projectId ); // @@ -186,7 +193,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, !shadows, renderDistance, - limitDistance + limitDistance, + projectId ); // diff --git a/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx b/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx index e116c15..35f3bb5 100644 --- a/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx @@ -28,7 +28,7 @@ const ZoneProperties: React.FC = () => { const organization = email?.split("@")[1]?.split(".")[0]; let zonesdata = { - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, viewPortposition: zonePosition, viewPortCenter: zoneTarget, }; @@ -52,7 +52,7 @@ const ZoneProperties: React.FC = () => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const zonesdata = { - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, zoneName: newName, }; // Call your API to update the zone @@ -61,7 +61,7 @@ const ZoneProperties: React.FC = () => { if (response.message === "updated successfully") { setZones((prevZones: any[]) => prevZones.map((zone) => - zone.zoneId === selectedZone.zoneId + zone.zoneUuid === selectedZone.zoneUuid ? { ...zone, zoneName: newName } : zone ) @@ -80,7 +80,7 @@ const ZoneProperties: React.FC = () => { return zones.some( (zone: any) => zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() && - zone.zoneId !== selectedZone.zoneId + zone.zoneUuid !== selectedZone.zoneUuid ); }; diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx index 742569c..27ac2f9 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const BarChartInput = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const BarChartInput = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const BarChartInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx index 6b3559c..4d858ff 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx @@ -87,10 +87,10 @@ const FleetEfficiencyInputComponent = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, header: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx index 166070e..9fc36b9 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx @@ -86,10 +86,10 @@ const FlotingWidgetInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, header: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx index 49d4525..330560f 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx @@ -123,6 +123,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -140,6 +141,7 @@ const LineGrapInput = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); useEffect(() => { const fetchZoneData = async () => { @@ -166,7 +168,15 @@ const LineGrapInput = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -199,10 +209,18 @@ const LineGrapInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx index aa0acaa..a78e391 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const PieChartInput = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const PieChartInput = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const PieChartInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx index 2f1fdb5..15ecee5 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const Progress1Input = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const Progress1Input = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const Progress1Input = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx index 2d2e089..842821c 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const Progress2Input = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const Progress2Input = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const Progress2Input = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx index 6c8eda4..b963c8c 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx @@ -84,10 +84,10 @@ const WarehouseThroughputInputComponent = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, header: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx index 0723c80..10c905c 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx @@ -83,10 +83,10 @@ const Widget2InputCard3D = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, widgetName: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx index 2e2b051..d9e4314 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx @@ -80,10 +80,10 @@ const Widget3InputCard3D = () => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, widgetName: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx index cc8d9ca..2498d3d 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx @@ -83,10 +83,10 @@ const Widget4InputCard3D = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, widgetName: inputName, diff --git a/app/src/components/ui/Tools.tsx b/app/src/components/ui/Tools.tsx index fcc40b8..b36b00f 100644 --- a/app/src/components/ui/Tools.tsx +++ b/app/src/components/ui/Tools.tsx @@ -37,6 +37,7 @@ import { use3DWidget, useFloatingWidget, } from "../../store/visualization/useDroppedObjectsStore"; +import { useParams } from "react-router-dom"; // Utility component const ToolButton = ({ @@ -89,6 +90,7 @@ const Tools: React.FC = () => { const dropdownRef = useRef(null); const [openDrop, setOpenDrop] = useState(false); + const { projectId } = useParams(); // 1. Set UI toggles on initial render useEffect(() => { @@ -257,6 +259,7 @@ const Tools: React.FC = () => { selectedZone, templates, visualizationSocket, + projectId }) } /> diff --git a/app/src/components/ui/list/DropDownList.tsx b/app/src/components/ui/list/DropDownList.tsx index 77c9c4b..8c76aba 100644 --- a/app/src/components/ui/list/DropDownList.tsx +++ b/app/src/components/ui/list/DropDownList.tsx @@ -17,7 +17,7 @@ interface DropDownListProps { } interface Zone { - zoneId: string; + zoneUuid: string; zoneName: string; points: [number, number, number][]; // polygon vertices } @@ -93,7 +93,7 @@ const DropDownList: React.FC = ({ })); return { - id: zone.zoneId, + id: zone.zoneUuid, name: zone.zoneName, assets: assetsInZone, }; diff --git a/app/src/components/ui/list/List.tsx b/app/src/components/ui/list/List.tsx index d5db7fb..dd610d6 100644 --- a/app/src/components/ui/list/List.tsx +++ b/app/src/components/ui/list/List.tsx @@ -20,6 +20,7 @@ import { import { zoneCameraUpdate } from "../../../services/visulization/zone/zoneCameraUpdation"; import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi"; import OuterClick from "../../../utils/outerClick"; +import { useParams } from "react-router-dom"; interface Asset { id: string; @@ -50,6 +51,7 @@ const List: React.FC = ({ items = [], remove }) => { {} ); const { setFloorItems } = useFloorItems(); + const { projectId } = useParams(); useEffect(() => { @@ -58,23 +60,23 @@ const List: React.FC = ({ items = [], remove }) => { activeSides: [], panelOrder: [], lockedPanels: [], - zoneId: "", + zoneUuid: "", zoneViewPortTarget: [], zoneViewPortPosition: [], widgets: [], }); }, [activeModule]); - const toggleZoneExpansion = (zoneId: string) => { + const toggleZoneExpansion = (zoneUuid: string) => { setExpandedZones((prev) => ({ ...prev, - [zoneId]: !prev[zoneId], + [zoneUuid]: !prev[zoneUuid], })); }; async function handleSelectZone(id: string) { try { - if (selectedZone?.zoneId === id) { + if (selectedZone?.zoneUuid === id) { return; } @@ -83,14 +85,14 @@ const List: React.FC = ({ items = [], remove }) => { const email = localStorage.getItem("email"); const organization = email?.split("@")[1]?.split(".")[0] ?? ""; - let response = await getZoneData(id, organization); + let response = await getZoneData(id, organization, projectId); setSelectedZone({ zoneName: response?.zoneName, activeSides: response?.activeSides ?? [], panelOrder: response?.panelOrder ?? [], lockedPanels: response?.lockedPanels ?? [], widgets: response?.widgets ?? [], - zoneId: response?.zoneId, + zoneUuid: response?.zoneUuid, zoneViewPortTarget: response?.viewPortCenter ?? [], zoneViewPortPosition: response?.viewPortposition ?? [], }); @@ -110,7 +112,7 @@ const List: React.FC = ({ items = [], remove }) => { const isDuplicate = zones.some( (zone: any) => zone.zoneName.trim().toLowerCase() === newName.trim().toLowerCase() && - zone.zoneId !== selectedZone.zoneId + zone.zoneUuid !== selectedZone.zoneUuid ); if (isDuplicate) { @@ -119,7 +121,7 @@ const List: React.FC = ({ items = [], remove }) => { } const zonesdata = { - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, zoneName: newName, }; @@ -129,7 +131,7 @@ const List: React.FC = ({ items = [], remove }) => { setZones((prevZones: any[]) => prevZones.map((zone) => - zone.zoneId === selectedZone.zoneId + zone.zoneUuid === selectedZone.zoneUuid ? { ...zone, zoneName: newName } : zone ) @@ -161,7 +163,7 @@ const List: React.FC = ({ items = [], remove }) => { return zones.some( (zone: any) => zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() && - zone.zoneId !== selectedZone.zoneId + zone.zoneUuid !== selectedZone.zoneUuid ); }; @@ -199,7 +201,7 @@ const List: React.FC = ({ items = [], remove }) => { if (isOutsideClick(evt.target)) { // Clear selected zone setSelectedZone({ - zoneId: '', + zoneUuid: '', zoneName: '', activeSides: [], panelOrder: [], @@ -241,7 +243,7 @@ const List: React.FC = ({ items = [], remove }) => { toggleZoneExpansion(item.id); }} > -
+