feat: Integrate versioning into collaboration and simulation modules
- Added version context to socket responses, enabling version-specific data retrieval. - Updated API calls in various components to include versionId for better data management. - Removed deprecated setFloorItemApi and replaced it with setAssetsApi for asset management. - Enhanced error handling and logging for API interactions. - Refactored multiple components to utilize selectedVersion for consistent behavior across the application.
This commit is contained in:
parent
4697dbc6f0
commit
f295a04322
|
@ -69,9 +69,9 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
|||
switch (option) {
|
||||
case "delete":
|
||||
if (handleDeleteProject) {
|
||||
await handleDeleteProject(projectId);
|
||||
handleDeleteProject(projectId);
|
||||
} else if (handleTrashDeleteProject) {
|
||||
await handleTrashDeleteProject(projectId);
|
||||
handleTrashDeleteProject(projectId);
|
||||
}
|
||||
break;
|
||||
case "restore":
|
||||
|
@ -102,7 +102,6 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
|||
});
|
||||
await handleDuplicateWorkspaceProject(projectId, projectName, thumbnail);
|
||||
} else if (handleDuplicateRecentProject) {
|
||||
console.log('projectId:dup ', projectId);
|
||||
setRecentDuplicateData &&
|
||||
setRecentDuplicateData({
|
||||
projectId,
|
||||
|
|
|
@ -83,6 +83,7 @@ const DashboardTrash: React.FC = () => {
|
|||
};
|
||||
|
||||
const handleTrashDeleteProject = async (projectId: any) => {
|
||||
console.log('projectId: ', projectId);
|
||||
try {
|
||||
// const deletedProject = await deleteTrash(
|
||||
// organization, projectId
|
||||
|
|
|
@ -33,11 +33,9 @@ import { useProductContext } from "../../../modules/simulation/products/productC
|
|||
import { useProductStore } from "../../../store/simulation/useProductStore";
|
||||
import RegularDropDown from "../../ui/inputs/RegularDropDown";
|
||||
import RenameTooltip from "../../ui/features/RenameTooltip";
|
||||
import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
|
||||
import { setAssetsApi } from "../../../services/factoryBuilder/assest/floorAsset/setAssetsApi";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../../modules/scene/sceneContext";
|
||||
import { getVersionHistoryApi } from "../../../services/factoryBuilder/versionControl/getVersionHistoryApi";
|
||||
import { useVersionHistoryStore } from "../../../store/builder/useVersionHistoryStore";
|
||||
import { useVersionContext } from "../../../modules/builder/version/versionContext";
|
||||
import VersionSaved from "../sidebarRight/versionHisory/VersionSaved";
|
||||
|
@ -67,7 +65,6 @@ function MainScene() {
|
|||
const { versionHistory } = useVersionHistoryStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { setSelectedVersion } = selectedVersionStore();
|
||||
const { organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
if (activeModule !== 'simulation') {
|
||||
|
@ -88,14 +85,14 @@ function MainScene() {
|
|||
setMainProduct(product.productUuid, product.productName);
|
||||
}
|
||||
};
|
||||
|
||||
const handleObjectRename = async (newName: string) => {
|
||||
if (!projectId) return
|
||||
let response = await setFloorItemApi(
|
||||
organization,
|
||||
selectedFloorItem.userData.modelUuid,
|
||||
newName,
|
||||
let response = await setAssetsApi({
|
||||
modelUuid: selectedFloorItem.userData.modelUuid,
|
||||
modelName: newName,
|
||||
projectId
|
||||
);
|
||||
});
|
||||
selectedFloorItem.userData = {
|
||||
...selectedFloorItem.userData,
|
||||
modelName: newName
|
||||
|
|
|
@ -14,6 +14,7 @@ import { handleAddEventToProduct } from "../../../../../modules/simulation/event
|
|||
import { useEventsStore } from "../../../../../store/simulation/useEventsStore";
|
||||
import { useProductContext } from "../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
|
||||
|
||||
const EventProperties: React.FC = () => {
|
||||
const { selectedEventData } = useSelectedEventData();
|
||||
|
@ -26,6 +27,8 @@ const EventProperties: React.FC = () => {
|
|||
const [assetType, setAssetType] = useState<string | null>(null);
|
||||
const { products, addEvent } = useProductStore();
|
||||
const { selectedEventSphere } = useSelectedEventSphere();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -109,7 +112,8 @@ const EventProperties: React.FC = () => {
|
|||
),
|
||||
addEvent,
|
||||
selectedProduct,
|
||||
projectId: projectId || ''
|
||||
projectId: projectId || '',
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -13,6 +13,7 @@ import { useProductStore } from "../../../../../../store/simulation/useProductSt
|
|||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
|
||||
|
||||
interface ActionsListProps {
|
||||
selectedPointData: any;
|
||||
|
@ -34,6 +35,8 @@ const ActionsList: React.FC<ActionsListProps> = ({
|
|||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { selectedAction, setSelectedAction } = useSelectedAction();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const handleRenameAction = (newName: string) => {
|
||||
|
@ -50,6 +53,7 @@ const ActionsList: React.FC<ActionsListProps> = ({
|
|||
productUuid: selectedProduct.productUuid,
|
||||
projectId,
|
||||
eventDatas: event,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,6 +14,7 @@ import ActionsList from "../components/ActionsList";
|
|||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
|
||||
|
||||
function ConveyorMechanics() {
|
||||
const [activeOption, setActiveOption] = useState<"default" | "spawn" | "swap" | "delay" | "despawn">("default");
|
||||
|
@ -24,7 +25,9 @@ function ConveyorMechanics() {
|
|||
const { selectedProduct } = selectedProductStore();
|
||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedEventData) {
|
||||
const point = getPointByUuid(
|
||||
|
@ -52,7 +55,8 @@ function ConveyorMechanics() {
|
|||
productName: productName,
|
||||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -66,7 +70,7 @@ function ConveyorMechanics() {
|
|||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId ||'',
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
|
@ -85,7 +89,7 @@ function ConveyorMechanics() {
|
|||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId ||'',
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
|
@ -99,7 +103,7 @@ function ConveyorMechanics() {
|
|||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId ||'',
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
|
@ -115,7 +119,7 @@ function ConveyorMechanics() {
|
|||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId ||'',
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
|
@ -131,7 +135,7 @@ function ConveyorMechanics() {
|
|||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId ||'',
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
|
@ -145,7 +149,7 @@ function ConveyorMechanics() {
|
|||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId ||'',
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
|
@ -161,7 +165,7 @@ function ConveyorMechanics() {
|
|||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId ||'',
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import ActionsList from "../components/ActionsList";
|
|||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
|
||||
|
||||
function MachineMechanics() {
|
||||
const [activeOption, setActiveOption] = useState<"default" | "process">("default");
|
||||
|
@ -18,7 +19,8 @@ function MachineMechanics() {
|
|||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -48,7 +50,8 @@ function MachineMechanics() {
|
|||
productName: productName,
|
||||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import ActionsList from "../components/ActionsList";
|
|||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
|
||||
|
||||
function RoboticArmMechanics() {
|
||||
const [activeOption, setActiveOption] = useState<"default" | "pickAndPlace">("default");
|
||||
|
@ -20,7 +21,8 @@ function RoboticArmMechanics() {
|
|||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { selectedAction, setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -58,6 +60,7 @@ function RoboticArmMechanics() {
|
|||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import { useSelectedAction, useSelectedEventData } from "../../../../../../store
|
|||
import * as THREE from 'three';
|
||||
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
|
||||
|
||||
function StorageMechanics() {
|
||||
const [activeOption, setActiveOption] = useState<"default" | "store" | "spawn">("default");
|
||||
|
@ -19,7 +20,8 @@ function StorageMechanics() {
|
|||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const updateSelectedPointData = () => {
|
||||
|
@ -66,7 +68,8 @@ function StorageMechanics() {
|
|||
productName: productName,
|
||||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import ActionsList from "../components/ActionsList";
|
|||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
|
||||
|
||||
function VehicleMechanics() {
|
||||
const [activeOption, setActiveOption] = useState<"default" | "travel">("default");
|
||||
|
@ -22,7 +23,8 @@ function VehicleMechanics() {
|
|||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -54,6 +56,7 @@ function VehicleMechanics() {
|
|||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { useSelectedAction } from "../../../../../../store/simulation/useSimulat
|
|||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
|
||||
|
||||
type TriggerProps = {
|
||||
selectedPointData?: PointsScheme | undefined;
|
||||
|
@ -25,7 +26,8 @@ const Trigger = ({ selectedPointData, type }: TriggerProps) => {
|
|||
const [activeOption, setActiveOption] = useState<"onComplete" | "onStart" | "onStop" | "delay" | "onError">("onComplete");
|
||||
const triggersContainerRef = useRef<HTMLDivElement>(null);
|
||||
const { selectedAction } = useSelectedAction();
|
||||
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -53,6 +55,7 @@ const Trigger = ({ selectedPointData, type }: TriggerProps) => {
|
|||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import { useCompareStore, useSaveVersion, } from "../../../../store/builder/stor
|
|||
import { useToggleStore } from "../../../../store/useUIToggleStore";
|
||||
import { useProductContext } from "../../../../modules/simulation/products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../modules/builder/version/versionContext";
|
||||
|
||||
interface Event {
|
||||
modelName: string;
|
||||
|
@ -49,7 +50,8 @@ const Simulations: React.FC = () => {
|
|||
const { setToggleUI } = useToggleStore();
|
||||
const { projectId } = useParams();
|
||||
const { setMainProduct } = useMainProduct();
|
||||
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { comparePopUp, setComparePopUp } = useCompareStore();
|
||||
const { setIsVersionSaved } = useSaveVersion();
|
||||
|
||||
|
@ -67,6 +69,7 @@ const Simulations: React.FC = () => {
|
|||
productName: name,
|
||||
productUuid: id,
|
||||
projectId: projectId,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -99,13 +102,14 @@ const Simulations: React.FC = () => {
|
|||
removeProduct(productUuid);
|
||||
deleteProductApi({
|
||||
productUuid,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId
|
||||
});
|
||||
};
|
||||
|
||||
const handleRenameProduct = (productUuid: string, newName: string) => {
|
||||
renameProduct(productUuid, newName);
|
||||
renameProductApi({ productName: newName, productUuid, projectId: projectId || '' });
|
||||
renameProductApi({ productName: newName, productUuid, projectId: projectId || '', versionId: selectedVersion?.versionId || '' });
|
||||
if (selectedProduct.productUuid === productUuid) {
|
||||
setSelectedProduct(productUuid, newName);
|
||||
setMainProduct(productUuid, newName);
|
||||
|
@ -118,6 +122,7 @@ const Simulations: React.FC = () => {
|
|||
deleteEventDataApi({
|
||||
productUuid: selectedProduct.productUuid,
|
||||
modelUuid: selectedAsset.modelUuid,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId: projectId,
|
||||
});
|
||||
removeEvent(selectedProduct.productUuid, selectedAsset.modelUuid);
|
||||
|
@ -265,7 +270,8 @@ const Simulations: React.FC = () => {
|
|||
addEvent,
|
||||
selectedProduct,
|
||||
clearSelectedAsset,
|
||||
projectId: projectId || ''
|
||||
projectId: projectId || '',
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
} else {
|
||||
handleRemoveEventFromProduct();
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
useZones,
|
||||
} from "../../../store/builder/store";
|
||||
import { zoneCameraUpdate } from "../../../services/visulization/zone/zoneCameraUpdation";
|
||||
import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
|
||||
import { setAssetsApi } from "../../../services/factoryBuilder/assest/floorAsset/setAssetsApi";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../../modules/scene/sceneContext";
|
||||
|
@ -133,12 +133,11 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
|||
async function handleZoneAssetName(newName: string) {
|
||||
|
||||
if (zoneAssetId?.id) {
|
||||
let response = await setFloorItemApi(
|
||||
organization,
|
||||
zoneAssetId.id,
|
||||
newName,
|
||||
let response = await setAssetsApi({
|
||||
modelUuid: zoneAssetId.id,
|
||||
modelName: newName,
|
||||
projectId
|
||||
);
|
||||
});
|
||||
// console.log("response: ", response);
|
||||
|
||||
setName(zoneAssetId.id, response.modelName);
|
||||
|
|
|
@ -8,16 +8,18 @@ import { getUserData } from "../../../functions/getUserData";
|
|||
|
||||
async function loadInitialWallItems(
|
||||
setWallItems: Types.setWallItemSetState,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string
|
||||
): Promise<void> {
|
||||
if (!projectId || !versionId) return;
|
||||
try {
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { organization, email } = getUserData();
|
||||
|
||||
if (!email) {
|
||||
throw new Error("No email found in localStorage");
|
||||
}
|
||||
|
||||
const items = await getWallItems(organization, projectId);
|
||||
const items = await getWallItems(organization, projectId, versionId);
|
||||
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import { useBuilderStore } from '../../../../store/builder/useBuilderStore';
|
|||
import ReferencePoint from '../../point/reference/referencePoint';
|
||||
import { createAisleApi } from '../../../../services/factoryBuilder/aisle/createAisleApi';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useVersionContext } from '../../version/versionContext';
|
||||
|
||||
function AisleCreator() {
|
||||
const { scene, camera, raycaster, gl, pointer } = useThree();
|
||||
|
@ -19,6 +20,8 @@ function AisleCreator() {
|
|||
const { addAisle, getAislePointById } = useAisleStore();
|
||||
const drag = useRef(false);
|
||||
const isLeftMouseDown = useRef(false);
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const [tempPoints, setTempPoints] = useState<Point[]>([]);
|
||||
|
@ -100,7 +103,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -123,7 +126,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -145,7 +148,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -166,7 +169,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -189,7 +192,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -211,7 +214,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -232,7 +235,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -254,7 +257,7 @@ function AisleCreator() {
|
|||
};
|
||||
addAisle(aisle);
|
||||
if (projectId) {
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId)
|
||||
createAisleApi(aisle.aisleUuid, aisle.points, aisle.type, projectId, selectedVersion?.versionId || '')
|
||||
}
|
||||
setTempPoints([newPoint]);
|
||||
}
|
||||
|
@ -298,7 +301,7 @@ function AisleCreator() {
|
|||
canvasElement.removeEventListener("click", onMouseClick);
|
||||
canvasElement.removeEventListener("contextmenu", onContext);
|
||||
};
|
||||
}, [gl, camera, scene, raycaster, pointer, plane, toggleView, toolMode, activeLayer, socket, tempPoints, isCreating, addAisle, getAislePointById, aisleType, aisleWidth, aisleColor, dashLength, gapLength, dotRadius, aisleLength, snappedPosition, snappedPoint]);
|
||||
}, [gl, camera, scene, raycaster, pointer, plane, toggleView, toolMode, activeLayer, socket, tempPoints, isCreating, addAisle, getAislePointById, aisleType, aisleWidth, aisleColor, dashLength, gapLength, dotRadius, aisleLength, snappedPosition, snappedPoint, selectedVersion?.versionId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -4,20 +4,27 @@ import AisleInstances from './Instances/aisleInstances'
|
|||
import { useParams } from 'react-router-dom';
|
||||
import { getAisleApi } from '../../../services/factoryBuilder/aisle/getAisleApi';
|
||||
import { useAisleStore } from '../../../store/builder/useAisleStore';
|
||||
import { useVersionContext } from '../version/versionContext';
|
||||
|
||||
function AislesGroup() {
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { setAisles } = useAisleStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (projectId) {
|
||||
getAisleApi(projectId).then((aisles) => {
|
||||
setAisles(aisles);
|
||||
getAisleApi(projectId, selectedVersion?.versionId || '').then((aisles) => {
|
||||
if (aisles && aisles.length > 0) {
|
||||
setAisles(aisles);
|
||||
}else{
|
||||
setAisles([]);
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
}, [projectId])
|
||||
}, [projectId, selectedVersion?.versionId])
|
||||
|
||||
return (
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import { useParams } from "react-router-dom";
|
|||
import { useLeftData, useTopData } from "../../../store/visualization/useZone3DWidgetStore";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../scene/sceneContext";
|
||||
import { useVersionContext } from "../version/versionContext";
|
||||
|
||||
const gltfLoaderWorker = new Worker(
|
||||
new URL(
|
||||
|
@ -29,7 +30,9 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
const { controls, gl, pointer, camera, raycaster } = useThree();
|
||||
const { setLoadingProgress } = useLoadingProgress();
|
||||
const { assetStore } = useSceneContext();
|
||||
const { setAssets, addAsset } = assetStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { setAssets, addAsset, clearAssets } = assetStore();
|
||||
const { addEvent } = useEventsStore();
|
||||
const { setSelectedFloorItem } = useSelectedFloorItem();
|
||||
const { selectedItem, setSelectedItem } = useSelectedItem();
|
||||
|
@ -48,6 +51,7 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
loader.setDRACOLoader(dracoLoader);
|
||||
|
||||
useEffect(() => {
|
||||
if (!projectId || !selectedVersion) return;
|
||||
|
||||
let totalAssets = 0;
|
||||
let loadedAssets = 0;
|
||||
|
@ -65,8 +69,8 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
}
|
||||
};
|
||||
|
||||
getFloorAssets(organization, projectId).then((data) => {
|
||||
if (data.length > 0) {
|
||||
getFloorAssets(organization, projectId, selectedVersion?.versionId || '').then((data) => {
|
||||
if (data && data.length > 0) {
|
||||
const uniqueItems = (data as FloorItems).filter((item, index, self) => index === self.findIndex((t) => t.assetId === item.assetId));
|
||||
totalAssets = uniqueItems.length;
|
||||
if (totalAssets === 0) {
|
||||
|
@ -77,8 +81,11 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
} else {
|
||||
gltfLoaderWorker.postMessage({ floorItems: [] });
|
||||
updateLoadingProgress(100);
|
||||
clearAssets();
|
||||
}
|
||||
});
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
})
|
||||
|
||||
gltfLoaderWorker.onmessage = async (event) => {
|
||||
if (event.data.message === "gltfLoaded" && event.data.modelBlob) {
|
||||
|
@ -94,7 +101,7 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
|
||||
if (loadedAssets === totalAssets) {
|
||||
const assets: Asset[] = [];
|
||||
getFloorAssets(organization, projectId).then((data: FloorItems) => {
|
||||
getFloorAssets(organization, projectId, selectedVersion.versionId || '').then((data: FloorItems) => {
|
||||
data.forEach((item) => {
|
||||
if (item.eventData) {
|
||||
assets.push({
|
||||
|
@ -257,7 +264,7 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
});
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
}, [selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
const canvasElement = gl.domElement;
|
||||
|
@ -270,13 +277,14 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
|
||||
pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
|
||||
addAssetModel(raycaster, camera, pointer, floorGroup, socket, selectedItem, setSelectedItem, addEvent, addAsset, plane, projectId, userId);
|
||||
addAssetModel(raycaster, camera, pointer, floorGroup, socket, selectedItem, setSelectedItem, addEvent, addAsset, plane, selectedVersion, projectId, userId);
|
||||
}
|
||||
};
|
||||
|
||||
const onDragOver = (event: any) => {
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
const onMouseMove = (evt: any) => {
|
||||
if (!canvasElement) return;
|
||||
const canvasRect = canvasElement.getBoundingClientRect();
|
||||
|
@ -286,14 +294,11 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
setTop(relativeY);
|
||||
setLeft(relativeX);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
const onMouseUp = (evt: any) => {
|
||||
setIsRenameMode(false);
|
||||
}
|
||||
|
||||
|
||||
if (activeModule === "builder") {
|
||||
canvasElement.addEventListener("drop", onDrop);
|
||||
canvasElement.addEventListener("dragover", onDragOver);
|
||||
|
|
|
@ -3,7 +3,7 @@ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|||
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
||||
import * as Types from "../../../../types/world/worldTypes";
|
||||
import { retrieveGLTF, storeGLTF } from "../../../../utils/indexDB/idbUtils";
|
||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||
// import { setAssetsApi } from '../../../../services/factoryBuilder/assest/floorAsset/setAssetsApi';
|
||||
import { Socket } from "socket.io-client";
|
||||
import * as CONSTANTS from "../../../../types/world/worldConstants";
|
||||
import PointsCalculator from "../../../simulation/events/points/functions/pointsCalculator";
|
||||
|
@ -20,6 +20,7 @@ async function addAssetModel(
|
|||
addEvent: (event: EventsSchema) => void,
|
||||
addAsset: (asset: Asset) => void,
|
||||
plane: Types.RefMesh,
|
||||
selectedVersion?: Version | null,
|
||||
projectId?: string,
|
||||
userId?: string
|
||||
): Promise<void> {
|
||||
|
@ -54,15 +55,15 @@ async function addAssetModel(
|
|||
intersectPoint =
|
||||
intersectedFloor.distance < intersectedPlane.distance
|
||||
? new THREE.Vector3(
|
||||
intersectedFloor.point.x,
|
||||
Math.round(intersectedFloor.point.y),
|
||||
intersectedFloor.point.z
|
||||
)
|
||||
intersectedFloor.point.x,
|
||||
Math.round(intersectedFloor.point.y),
|
||||
intersectedFloor.point.z
|
||||
)
|
||||
: new THREE.Vector3(
|
||||
intersectedPlane.point.x,
|
||||
0,
|
||||
intersectedPlane.point.z
|
||||
);
|
||||
intersectedPlane.point.x,
|
||||
0,
|
||||
intersectedPlane.point.z
|
||||
);
|
||||
} else if (intersectedFloor) {
|
||||
intersectPoint = new THREE.Vector3(
|
||||
intersectedFloor.point.x,
|
||||
|
@ -94,6 +95,7 @@ async function addAssetModel(
|
|||
addEvent,
|
||||
addAsset,
|
||||
socket,
|
||||
selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
);
|
||||
|
@ -113,6 +115,7 @@ async function addAssetModel(
|
|||
addEvent,
|
||||
addAsset,
|
||||
socket,
|
||||
selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
);
|
||||
|
@ -133,6 +136,7 @@ async function addAssetModel(
|
|||
addEvent,
|
||||
addAsset,
|
||||
socket,
|
||||
selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
);
|
||||
|
@ -155,10 +159,11 @@ async function handleModelLoad(
|
|||
addEvent: (event: EventsSchema) => void,
|
||||
addAsset: (asset: Asset) => void,
|
||||
socket: Socket<any>,
|
||||
versionId: string,
|
||||
projectId?: string,
|
||||
userId?: string
|
||||
) {
|
||||
const { userName, organization, email } = getUserData();
|
||||
const { organization } = getUserData();
|
||||
const model = gltf.scene.clone();
|
||||
model.userData = {
|
||||
name: selectedItem.name,
|
||||
|
@ -190,7 +195,7 @@ async function handleModelLoad(
|
|||
|
||||
// API
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// newFloorItem.modelUuid,
|
||||
// newFloorItem.modelName,
|
||||
|
@ -423,6 +428,7 @@ async function handleModelLoad(
|
|||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
eventData: eventData,
|
||||
versionId: versionId,
|
||||
projectId: projectId,
|
||||
userId: userId,
|
||||
};
|
||||
|
@ -462,6 +468,7 @@ async function handleModelLoad(
|
|||
isLocked: false,
|
||||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
versionId: versionId,
|
||||
projectId: projectId,
|
||||
userId: userId,
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@ import { useProductContext } from '../../../../simulation/products/productContex
|
|||
import { useParams } from 'react-router-dom';
|
||||
import { getUserData } from '../../../../../functions/getUserData';
|
||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||
import { useVersionContext } from '../../../version/versionContext';
|
||||
|
||||
function Model({ asset }: { readonly asset: Asset }) {
|
||||
const { camera, controls, gl } = useThree();
|
||||
|
@ -42,8 +43,10 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||
const [boundingBox, setBoundingBox] = useState<THREE.Box3 | null>(null);
|
||||
const groupRef = useRef<THREE.Group>(null);
|
||||
const { toolMode } = useToolMode();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { userId, organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
setDeletableFloorItem(null);
|
||||
|
@ -179,6 +182,7 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||
modelName: asset.modelName,
|
||||
socketId: socket.id,
|
||||
userId,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import * as Types from '../../../types/world/worldTypes';
|
|||
import arrayLineToObject from '../geomentries/lines/lineConvertions/arrayLineToObject';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { getUserData } from '../../../functions/getUserData';
|
||||
import { useVersionContext } from '../version/versionContext';
|
||||
|
||||
// Interface defining the props for the DxfFile component
|
||||
interface DxfFileProps {
|
||||
|
@ -36,8 +37,10 @@ const DxfFile = ({
|
|||
const { setUpdateScene } = useUpdateScene();
|
||||
const { toggleView } = useToggleView();
|
||||
const { socket } = useSocketStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { userId, organization } = getUserData();
|
||||
|
||||
// Refs for storing line objects
|
||||
const lineRefs = useRef<Line[]>([]);
|
||||
|
@ -71,6 +74,7 @@ const DxfFile = ({
|
|||
line: lineData.line,
|
||||
type: lineData.type,
|
||||
socketId: socket.id,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ export default async function addDragControl(
|
|||
lines: Types.RefLines,
|
||||
onlyFloorlines: Types.RefOnlyFloorLines,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string
|
||||
) {
|
||||
////////// Dragging Point and also change the size to indicate during hover //////////
|
||||
|
||||
|
@ -45,7 +46,7 @@ export default async function addDragControl(
|
|||
}
|
||||
});
|
||||
|
||||
dragPointControls.current.addEventListener("dragstart", function (event) {});
|
||||
dragPointControls.current.addEventListener("dragstart", function (event) { });
|
||||
|
||||
dragPointControls.current.addEventListener("dragend", async function (event) {
|
||||
if (!dragPointControls.current) return;
|
||||
|
@ -69,6 +70,7 @@ export default async function addDragControl(
|
|||
},
|
||||
uuid: event.object.uuid,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
|
|
@ -39,7 +39,8 @@ async function drawOnlyFloor(
|
|||
setDeletedLines: any,
|
||||
activeLayer: Types.Number,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string,
|
||||
): Promise<void> {
|
||||
////////// Creating lines Based on the positions clicked //////////
|
||||
|
||||
|
@ -75,7 +76,7 @@ async function drawOnlyFloor(
|
|||
(intersectsLines[0].object.userData.linePoints[0][3] ===
|
||||
CONSTANTS.lineConfig.floorName ||
|
||||
intersectsLines[0].object.userData.linePoints[0][3] ===
|
||||
CONSTANTS.lineConfig.wallName)
|
||||
CONSTANTS.lineConfig.wallName)
|
||||
) {
|
||||
let pointColor, lineColor;
|
||||
if (
|
||||
|
@ -153,6 +154,7 @@ async function drawOnlyFloor(
|
|||
type: data.type,
|
||||
socketId: socket.id,
|
||||
projectId,
|
||||
versionId,
|
||||
userId,
|
||||
};
|
||||
|
||||
|
@ -241,6 +243,7 @@ async function drawOnlyFloor(
|
|||
line: data.line,
|
||||
type: data.type,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
|
|
@ -16,14 +16,15 @@ async function DeleteLayer(
|
|||
setDeletedLines: any,
|
||||
setRemovedLayer: Types.setRemoveLayerSetState,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string,
|
||||
): Promise<void> {
|
||||
////////// Remove the Lines from the lines.current based on the removed layer and rearrange the layer number that are higher than the removed layer //////////
|
||||
|
||||
const removedLines: Types.Lines = lines.current.filter(
|
||||
(line) => line[0][2] === removedLayer
|
||||
);
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { userId, organization } = getUserData();
|
||||
|
||||
//REST
|
||||
|
||||
|
@ -35,6 +36,7 @@ async function DeleteLayer(
|
|||
organization,
|
||||
layer: removedLayer,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
|
|
@ -13,7 +13,8 @@ function deleteLine(
|
|||
floorPlanGroupPoint: Types.RefGroup,
|
||||
setDeletedLines: any,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string,
|
||||
): void {
|
||||
const { userId, organization, email } = getUserData();
|
||||
////////// Deleting a line and the points if they are not connected to any other line //////////
|
||||
|
@ -41,6 +42,7 @@ function deleteLine(
|
|||
organization,
|
||||
line: [{ uuid: linePoints[0][1] }, { uuid: linePoints[1][1] }],
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@ import getRoomsFromLines from "../getRoomsFromLines";
|
|||
import * as turf from '@turf/turf';
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../version/versionContext";
|
||||
|
||||
const DistanceText = () => {
|
||||
const [lines, setLines] = useState<
|
||||
|
@ -32,8 +33,11 @@ const DistanceText = () => {
|
|||
const { deletedLines, setDeletedLines } = useDeletedLines();
|
||||
const [linesState, setLinesState] = useState<Types.Lines>([]);
|
||||
const { roomsState, setRoomsState } = useRoomsState();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { organization, email } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
if (linesState.length === 0) return;
|
||||
|
@ -96,7 +100,7 @@ const DistanceText = () => {
|
|||
useEffect(() => {
|
||||
if (!email) return;
|
||||
|
||||
getLines(organization, projectId).then((data) => {
|
||||
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {
|
||||
data = objectLinesToArray(data);
|
||||
setLinesState(data);
|
||||
|
||||
|
@ -126,7 +130,7 @@ const DistanceText = () => {
|
|||
});
|
||||
setLines(lines);
|
||||
});
|
||||
}, [activeLayer]);
|
||||
}, [activeLayer, selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (newLines.length > 0) {
|
||||
|
|
|
@ -35,7 +35,8 @@ async function drawWall(
|
|||
setDeletedLines: any,
|
||||
activeLayer: Types.Number,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string,
|
||||
): Promise<void> {
|
||||
const { userId, organization, email } = getUserData();
|
||||
////////// Creating lines Based on the positions clicked //////////
|
||||
|
@ -62,7 +63,7 @@ async function drawWall(
|
|||
intersect.object.visible &&
|
||||
intersect.object.name !== CONSTANTS.lineConfig.referenceName &&
|
||||
intersect.object.userData.linePoints[0][3] ===
|
||||
CONSTANTS.lineConfig.wallName
|
||||
CONSTANTS.lineConfig.wallName
|
||||
);
|
||||
|
||||
if (
|
||||
|
@ -108,7 +109,8 @@ async function drawWall(
|
|||
CONSTANTS.pointConfig.wallOuterColor,
|
||||
CONSTANTS.lineConfig.wallColor,
|
||||
CONSTANTS.lineConfig.wallName,
|
||||
projectId
|
||||
projectId,
|
||||
versionId
|
||||
);
|
||||
setNewLines([newLines[0], newLines[1]]);
|
||||
|
||||
|
@ -134,6 +136,7 @@ async function drawWall(
|
|||
line: data.line,
|
||||
type: data.type,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
@ -214,6 +217,7 @@ async function drawWall(
|
|||
line: data.line,
|
||||
type: data.type,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
|
|
@ -24,7 +24,8 @@ function splitLine(
|
|||
pointColor: Types.String,
|
||||
lineColor: Types.String,
|
||||
lineType: Types.String,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string,
|
||||
): [Types.Line, Types.Line] {
|
||||
////////// Removing the clicked line and splitting it with the clicked position adding a new point and two new lines //////////
|
||||
|
||||
|
@ -53,6 +54,7 @@ function splitLine(
|
|||
{ uuid: visibleIntersect.object.userData.linePoints[1][1] },
|
||||
],
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
@ -100,6 +102,7 @@ function splitLine(
|
|||
line: line1.line,
|
||||
type: line1.type,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
@ -118,6 +121,7 @@ function splitLine(
|
|||
line: line2.line,
|
||||
type: line2.type,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
|
|
@ -15,7 +15,8 @@ function deletePoint(
|
|||
lines: Types.RefLines,
|
||||
setDeletedLines: any,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string,
|
||||
): void {
|
||||
////////// Deleting a Point and the lines that are connected to it //////////
|
||||
|
||||
|
@ -38,6 +39,7 @@ function deletePoint(
|
|||
organization,
|
||||
uuid: DeletedPointUUID,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
|
|
@ -14,9 +14,11 @@ async function AddWallItems(
|
|||
CSGGroup: Types.RefMesh,
|
||||
setWallItems: Types.setWallItemSetState,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId?: string
|
||||
): Promise<void> {
|
||||
const { userId, organization, email } = getUserData();
|
||||
|
||||
const { userId, organization } = getUserData();
|
||||
let intersects = raycaster?.intersectObject(CSGGroup.current!, true);
|
||||
const wallRaycastIntersection = intersects?.find((child) =>
|
||||
child.object.name.includes("WallRaycastReference")
|
||||
|
@ -134,10 +136,12 @@ async function AddWallItems(
|
|||
quaternion: newWallItem.quaternion,
|
||||
scale: newWallItem.scale,
|
||||
socketId: socket.id,
|
||||
versionId,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
|
||||
console.log('data: ', data);
|
||||
socket.emit("v1:wallItems:set", data);
|
||||
|
||||
setWallItems((prevItems) => {
|
||||
|
|
|
@ -8,7 +8,8 @@ function DeleteWallItems(
|
|||
setWallItems: Types.setWallItemSetState,
|
||||
wallItems: Types.wallItems,
|
||||
socket: Socket<any>,
|
||||
projectId?: string
|
||||
projectId?: string,
|
||||
versionId? : string,
|
||||
): void {
|
||||
////////// Deleting the hovered Wall GLTF from thewallItems and also update it in the localstorage //////////
|
||||
const { userId, organization, email } = getUserData();
|
||||
|
@ -38,6 +39,7 @@ function DeleteWallItems(
|
|||
modelName: removedItem?.modelName!,
|
||||
socketId: socket.id,
|
||||
projectId,
|
||||
versionId,
|
||||
userId,
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import drawOnlyFloor from "../geomentries/floors/drawOnlyFloor";
|
|||
import addDragControl from "../eventDeclaration/dragControlDeclaration";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useVersionContext } from "../version/versionContext";
|
||||
|
||||
const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoint, floorGroup, currentLayerPoint, dragPointControls, hoveredDeletablePoint, hoveredDeletableLine, plane, line, lines, onlyFloorline, onlyFloorlines, ReferenceLineMesh, LineCreated, isSnapped, ispreSnapped, snappedPoint, isSnappedUUID, isAngleSnapped, anglesnappedPoint }: any) => {
|
||||
const state = useThree();
|
||||
|
@ -30,13 +31,14 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||
const { setNewLines } = useNewLines();
|
||||
const { setDeletedLines } = useDeletedLines();
|
||||
const { socket } = useSocketStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
|
||||
const { organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
if (toolMode === 'move') {
|
||||
addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket, projectId);
|
||||
addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket, projectId, selectedVersion?.versionId || '',);
|
||||
}
|
||||
|
||||
return () => {
|
||||
|
@ -49,7 +51,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||
useEffect(() => {
|
||||
|
||||
// Load data from localStorage if available
|
||||
getLines(organization, projectId).then((data) => {
|
||||
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {
|
||||
|
||||
const Lines: Types.Lines = objectLinesToArray(data);
|
||||
|
||||
|
@ -62,7 +64,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||
setUpdateScene(true);
|
||||
}
|
||||
})
|
||||
}, []);
|
||||
}, [selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!toggleView) {
|
||||
|
@ -94,7 +96,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||
|
||||
useEffect(() => {
|
||||
if (removedLayer !== null) {
|
||||
DeleteLayer(removedLayer, lines, floorPlanGroupLine, floorPlanGroupPoint, onlyFloorlines, floorGroup, setDeletedLines, setRemovedLayer, socket, projectId);
|
||||
DeleteLayer(removedLayer, lines, floorPlanGroupLine, floorPlanGroupPoint, onlyFloorlines, floorGroup, setDeletedLines, setRemovedLayer, socket, projectId, selectedVersion?.versionId || '',);
|
||||
}
|
||||
}, [removedLayer]);
|
||||
|
||||
|
@ -140,19 +142,19 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||
|
||||
if (toolMode === "2D-Delete") {
|
||||
if (hoveredDeletablePoint.current !== null) {
|
||||
deletePoint(hoveredDeletablePoint, onlyFloorlines, floorPlanGroupPoint, floorPlanGroupLine, lines, setDeletedLines, socket, projectId);
|
||||
deletePoint(hoveredDeletablePoint, onlyFloorlines, floorPlanGroupPoint, floorPlanGroupLine, lines, setDeletedLines, socket, projectId, selectedVersion?.versionId || '',);
|
||||
}
|
||||
if (hoveredDeletableLine.current !== null) {
|
||||
deleteLine(hoveredDeletableLine, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroupPoint, setDeletedLines, socket, projectId);
|
||||
deleteLine(hoveredDeletableLine, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroupPoint, setDeletedLines, socket, projectId, selectedVersion?.versionId || '',);
|
||||
}
|
||||
}
|
||||
|
||||
if (toolMode === "Wall") {
|
||||
drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId);
|
||||
drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId, selectedVersion?.versionId || '',);
|
||||
}
|
||||
|
||||
if (toolMode === "Floor") {
|
||||
drawOnlyFloor(raycaster, state, camera, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, onlyFloorline, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId);
|
||||
drawOnlyFloor(raycaster, state, camera, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, onlyFloorline, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId, selectedVersion?.versionId || '',);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import AddWallItems from "../geomentries/walls/addWallItems";
|
|||
import useModuleStore from "../../../store/useModuleStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useVersionContext } from "../version/versionContext";
|
||||
|
||||
const WallItemsGroup = ({
|
||||
currentWallItem,
|
||||
|
@ -38,13 +39,16 @@ const WallItemsGroup = ({
|
|||
const { setSelectedWallItem } = useSelectedWallItem();
|
||||
const { activeModule } = useModuleStore();
|
||||
const { selectedItem } = useSelectedItem();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { userId, organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
// Load Wall Items from the backend
|
||||
loadInitialWallItems(setWallItems, projectId);
|
||||
}, []);
|
||||
if (!projectId || !selectedVersion) return;
|
||||
loadInitialWallItems(setWallItems, projectId, selectedVersion?.versionId);
|
||||
}, [selectedVersion?.versionId]);
|
||||
|
||||
////////// Update the Position value changes in the selected item //////////
|
||||
|
||||
|
@ -152,6 +156,7 @@ const WallItemsGroup = ({
|
|||
quaternion: currentItem.quaternion,
|
||||
scale: currentItem.scale!,
|
||||
socketId: socket.id,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
};
|
||||
|
@ -171,7 +176,7 @@ const WallItemsGroup = ({
|
|||
canvasElement.removeEventListener("pointermove", handlePointerMove);
|
||||
canvasElement.removeEventListener("pointerup", handlePointerUp);
|
||||
};
|
||||
}, [selectedItemsIndex]);
|
||||
}, [selectedItemsIndex, selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
const canvasElement = state.gl.domElement;
|
||||
|
@ -193,7 +198,9 @@ const WallItemsGroup = ({
|
|||
hoveredDeletableWallItem,
|
||||
setWallItems,
|
||||
wallItems,
|
||||
socket, projectId
|
||||
socket,
|
||||
projectId,
|
||||
selectedVersion?.versionId || '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +220,7 @@ const WallItemsGroup = ({
|
|||
|
||||
raycaster.setFromCamera(pointer, camera);
|
||||
|
||||
if (selectedItem.id) {
|
||||
if (selectedItem.id && selectedVersion && projectId) {
|
||||
if (selectedItem.subCategory) {
|
||||
AddWallItems(
|
||||
selectedItem,
|
||||
|
@ -221,7 +228,8 @@ const WallItemsGroup = ({
|
|||
CSGGroup,
|
||||
setWallItems,
|
||||
socket,
|
||||
projectId
|
||||
projectId,
|
||||
selectedVersion?.versionId || '',
|
||||
);
|
||||
}
|
||||
event.preventDefault();
|
||||
|
@ -245,7 +253,7 @@ const WallItemsGroup = ({
|
|||
canvasElement.removeEventListener("drop", onDrop);
|
||||
canvasElement.removeEventListener("dragover", onDragOver);
|
||||
};
|
||||
}, [toolMode, wallItems, selectedItem, camera]);
|
||||
}, [toolMode, wallItems, selectedItem, camera, selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (toolMode && activeModule === "builder") {
|
||||
|
|
|
@ -11,17 +11,19 @@ import loadWalls from "../geomentries/walls/loadWalls";
|
|||
import texturePath from "../../../assets/textures/floor/wall-tex.png";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useVersionContext } from "../version/versionContext";
|
||||
|
||||
const WallsMeshComponent = ({ lines }: any) => {
|
||||
const { walls, setWalls } = useWalls();
|
||||
const { updateScene, setUpdateScene } = useUpdateScene();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
if (updateScene) {
|
||||
|
||||
getLines(organization, projectId).then((data) => {
|
||||
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {
|
||||
const Lines: Types.Lines = objectLinesToArray(data);
|
||||
localStorage.setItem("Lines", JSON.stringify(Lines));
|
||||
|
||||
|
@ -31,7 +33,7 @@ const WallsMeshComponent = ({ lines }: any) => {
|
|||
});
|
||||
setUpdateScene(false);
|
||||
}
|
||||
}, [updateScene]);
|
||||
}, [updateScene, selectedVersion?.versionId]);
|
||||
|
||||
const textureLoader = new THREE.TextureLoader();
|
||||
const wallTexture = textureLoader.load(texturePath);
|
||||
|
|
|
@ -19,6 +19,7 @@ import { computeArea } from "../functions/computeArea";
|
|||
import { useSelectedZoneStore } from "../../../store/visualization/useZoneStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useVersionContext } from "../version/versionContext";
|
||||
|
||||
const ZoneGroup: React.FC = () => {
|
||||
const { camera, pointer, gl, raycaster, scene, controls } = useThree();
|
||||
|
@ -28,18 +29,15 @@ const ZoneGroup: React.FC = () => {
|
|||
const { zonePoints, setZonePoints } = useZonePoints();
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const { selectedZone } = useSelectedZoneStore();
|
||||
const [draggedSphere, setDraggedSphere] = useState<THREE.Vector3 | null>(
|
||||
null
|
||||
);
|
||||
const plane = useMemo(
|
||||
() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0),
|
||||
[]
|
||||
);
|
||||
const [draggedSphere, setDraggedSphere] = useState<THREE.Vector3 | null>(null);
|
||||
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
||||
const { toggleView } = useToggleView();
|
||||
const { removedLayer, setRemovedLayer } = useRemovedLayer();
|
||||
const { toolMode } = useToolMode();
|
||||
const { activeLayer } = useActiveLayer();
|
||||
const { socket } = useSocketStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
|
||||
|
@ -74,13 +72,8 @@ const ZoneGroup: React.FC = () => {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchZones = async () => {
|
||||
if (!email) return;
|
||||
|
||||
const data = await getZonesApi(organization, projectId);
|
||||
// console.log('data: ', data);
|
||||
|
||||
if (data.length > 0) {
|
||||
getZonesApi(organization, projectId, selectedVersion?.versionId || '').then((data) => {
|
||||
if (data && data.length > 0) {
|
||||
const fetchedZones = data.map((zone: any) => ({
|
||||
zoneUuid: zone.zoneUuid,
|
||||
zoneName: zone.zoneName,
|
||||
|
@ -97,11 +90,13 @@ const ZoneGroup: React.FC = () => {
|
|||
);
|
||||
|
||||
setZonePoints(fetchedPoints);
|
||||
}else{
|
||||
setZones([]);
|
||||
}
|
||||
};
|
||||
|
||||
fetchZones();
|
||||
}, []);
|
||||
}).catch((err)=>{
|
||||
console.error(err);
|
||||
})
|
||||
}, [selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem("zones", JSON.stringify(zones));
|
||||
|
@ -168,6 +163,7 @@ const ZoneGroup: React.FC = () => {
|
|||
|
||||
const input = {
|
||||
userId: userId,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
organization,
|
||||
zoneData: {
|
||||
|
@ -216,6 +212,7 @@ const ZoneGroup: React.FC = () => {
|
|||
|
||||
const input = {
|
||||
userId: userId,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
organization,
|
||||
zoneData: {
|
||||
|
@ -235,6 +232,7 @@ const ZoneGroup: React.FC = () => {
|
|||
|
||||
const input = {
|
||||
userId: userId,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
organization,
|
||||
zoneUuid: zoneUuid,
|
||||
|
@ -438,7 +436,7 @@ const ZoneGroup: React.FC = () => {
|
|||
canvasElement.removeEventListener("mousemove", onMouseMove);
|
||||
canvasElement.removeEventListener("contextmenu", onContext);
|
||||
};
|
||||
}, [gl, camera, startPoint, toggleView, scene, toolMode, zones, isDragging, zonePoints, draggedSphere, activeLayer, raycaster, pointer, controls, plane, setZones, setZonePoints, addZoneToBackend, handleDeleteZone, updateZoneToBackend,]);
|
||||
}, [gl, camera, startPoint, toggleView, scene, toolMode, zones, isDragging, zonePoints, draggedSphere, activeLayer, raycaster, pointer, controls, plane, setZones, setZonePoints, addZoneToBackend, handleDeleteZone, updateZoneToBackend, selectedVersion?.versionId]);
|
||||
|
||||
useFrame(() => {
|
||||
if (!startPoint) return;
|
||||
|
|
|
@ -11,6 +11,7 @@ import { useWallStore } from '../../../store/builder/useWallStore';
|
|||
import { deleteAisleApi } from '../../../services/factoryBuilder/aisle/deleteAisleApi';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { createAisleApi } from '../../../services/factoryBuilder/aisle/createAisleApi';
|
||||
import { useVersionContext } from '../version/versionContext';
|
||||
|
||||
function Point({ point }: { readonly point: Point }) {
|
||||
const materialRef = useRef<THREE.ShaderMaterial>(null);
|
||||
|
@ -22,6 +23,8 @@ function Point({ point }: { readonly point: Point }) {
|
|||
const { setPosition: setWallPosition, removePoint: removeWallPoint } = useWallStore();
|
||||
const { snapAislePoint, snapAisleAngle, snapWallPoint, snapWallAngle } = usePointSnapping({ uuid: point.pointUuid, pointType: point.pointType, position: point.position });
|
||||
const { hoveredPoint, setHoveredPoint } = useBuilderStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const boxScale: [number, number, number] = Constants.pointConfig.boxScale;
|
||||
const colors = getColor(point);
|
||||
|
@ -118,7 +121,7 @@ function Point({ point }: { readonly point: Point }) {
|
|||
const updatedAisles = getAislesByPointId(point.pointUuid);
|
||||
if (updatedAisles.length > 0 && projectId) {
|
||||
updatedAisles.forEach((updatedAisle) => {
|
||||
createAisleApi(updatedAisle.aisleUuid, updatedAisle.points, updatedAisle.type, projectId)
|
||||
createAisleApi(updatedAisle.aisleUuid, updatedAisle.points, updatedAisle.type, projectId, selectedVersion?.versionId || '')
|
||||
})
|
||||
}
|
||||
} else if (point.pointType === 'Wall') {
|
||||
|
@ -133,7 +136,7 @@ function Point({ point }: { readonly point: Point }) {
|
|||
if (removedAisles.length > 0) {
|
||||
removedAisles.forEach(aisle => {
|
||||
if (projectId)
|
||||
deleteAisleApi(aisle.aisleUuid, projectId)
|
||||
deleteAisleApi(aisle.aisleUuid, projectId, selectedVersion?.versionId || '')
|
||||
});
|
||||
setHoveredPoint(null);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import { useEventsStore } from "../../../store/simulation/useEventsStore";
|
|||
import { useProductStore } from "../../../store/simulation/useProductStore";
|
||||
import { getUserData } from "../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../scene/sceneContext";
|
||||
import { useVersionContext } from "../../builder/version/versionContext";
|
||||
|
||||
export default function SocketResponses({
|
||||
floorPlanGroup,
|
||||
|
@ -58,6 +59,8 @@ export default function SocketResponses({
|
|||
const { setNewLines } = useNewLines();
|
||||
const { zones, setZones } = useZones();
|
||||
const { zonePoints, setZonePoints } = useZonePoints();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const { assetStore } = useSceneContext();
|
||||
const { addAsset, updateAsset, removeAsset } = assetStore();
|
||||
|
@ -438,7 +441,7 @@ export default function SocketResponses({
|
|||
floorGroup.current?.remove(meshToRemove);
|
||||
}
|
||||
|
||||
const zonesData = await getZonesApi(organization, projectId);
|
||||
const zonesData = await getZonesApi(organization, projectId, selectedVersion?.versionId || '');
|
||||
const highestLayer = Math.max(
|
||||
1,
|
||||
lines.current.reduce(
|
||||
|
@ -461,7 +464,21 @@ export default function SocketResponses({
|
|||
echo.success("Layer Removed!");
|
||||
}
|
||||
});
|
||||
}, [socket]);
|
||||
|
||||
return () => {
|
||||
socket.off("cameraCreateResponse");
|
||||
socket.off("userConnectRespones");
|
||||
socket.off("userDisConnectRespones");
|
||||
socket.off("v1:camera:Response:update");
|
||||
socket.off("EnvironmentUpdateResponse");
|
||||
socket.off("v1:model-asset:response:add");
|
||||
socket.off("v1:model-asset:response:delete");
|
||||
socket.off("v1:Line:response:update");
|
||||
socket.off("v1:Line:response:delete");
|
||||
socket.off("v1:Line:response:delete:point");
|
||||
socket.off("v1:Line:response:delete:layer");
|
||||
}
|
||||
}, [socket, selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!socket) return;
|
||||
|
@ -629,7 +646,7 @@ export default function SocketResponses({
|
|||
socket.off("v1:wallItem:Response:Delete");
|
||||
socket.off("v1:wallItems:Response:Update");
|
||||
};
|
||||
}, [wallItems]);
|
||||
}, [socket, wallItems]);
|
||||
|
||||
function getPointColor(lineType: string | undefined): string {
|
||||
switch (lineType) {
|
||||
|
@ -737,7 +754,7 @@ export default function SocketResponses({
|
|||
);
|
||||
lines.current.push(line);
|
||||
|
||||
const zonesData = await getZonesApi(organization, projectId);
|
||||
const zonesData = await getZonesApi(organization, projectId, selectedVersion?.versionId || '');
|
||||
const highestLayer = Math.max(
|
||||
1,
|
||||
lines.current.reduce(
|
||||
|
@ -771,7 +788,7 @@ export default function SocketResponses({
|
|||
return () => {
|
||||
socket.off("v1:Line:response:create");
|
||||
};
|
||||
}, [socket, activeLayer]);
|
||||
}, [socket, activeLayer, selectedVersion?.versionId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!socket) return;
|
||||
|
|
|
@ -9,7 +9,7 @@ export default function updateCamPosition(
|
|||
rotation: THREE.Euler,
|
||||
projectId?: string
|
||||
) {
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { userId, organization } = getUserData();
|
||||
if (!controls.current) return;
|
||||
const target = controls.current.getTarget(new THREE.Vector3());
|
||||
|
||||
|
@ -22,7 +22,6 @@ export default function updateCamPosition(
|
|||
socketId: socket.id,
|
||||
projectId,
|
||||
};
|
||||
// console.log('CameracamData: ', camData);
|
||||
socket.emit("v1:Camera:set", camData);
|
||||
localStorage.setItem("cameraPosition", JSON.stringify(position));
|
||||
localStorage.setItem(
|
||||
|
|
|
@ -2,13 +2,14 @@ import * as THREE from "three";
|
|||
import { useEffect, useMemo } from "react";
|
||||
import { useFrame, useThree } from "@react-three/fiber";
|
||||
import { useSelectedAssets, useSocketStore, useToggleView } from "../../../../store/builder/store";
|
||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||
// import { setAssetsApi } from '../../../../services/factoryBuilder/assest/floorAsset/setAssetsApi';
|
||||
import * as Types from "../../../../types/world/worldTypes";
|
||||
import { detectModifierKeys } from "../../../../utils/shortcutkeys/detectModifierKeys";
|
||||
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../sceneContext";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
const CopyPasteControls = ({
|
||||
copiedObjects,
|
||||
|
@ -32,6 +33,8 @@ const CopyPasteControls = ({
|
|||
const { projectId } = useParams();
|
||||
const { assetStore } = useSceneContext();
|
||||
const { assets, addAsset } = assetStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { userId, organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -335,7 +338,7 @@ const CopyPasteControls = ({
|
|||
newFloorItem.eventData = eventData;
|
||||
//REST
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// obj.uuid,
|
||||
// obj.userData.name,
|
||||
|
@ -359,6 +362,7 @@ const CopyPasteControls = ({
|
|||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
eventData: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
userId,
|
||||
projectId
|
||||
};
|
||||
|
@ -392,7 +396,7 @@ const CopyPasteControls = ({
|
|||
|
||||
//REST
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// obj.uuid,
|
||||
// obj.userData.name,
|
||||
|
@ -414,6 +418,7 @@ const CopyPasteControls = ({
|
|||
isLocked: false,
|
||||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
};
|
||||
|
|
|
@ -2,13 +2,14 @@ import * as THREE from "three";
|
|||
import { useEffect, useMemo } from "react";
|
||||
import { useFrame, useThree } from "@react-three/fiber";
|
||||
import { useSelectedAssets, useSocketStore, useToggleView } from "../../../../store/builder/store";
|
||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||
// import { setAssetsApi } from '../../../../services/factoryBuilder/assest/floorAsset/setAssetsApi';
|
||||
import * as Types from "../../../../types/world/worldTypes";
|
||||
import { detectModifierKeys } from "../../../../utils/shortcutkeys/detectModifierKeys";
|
||||
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../sceneContext";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
const DuplicationControls = ({
|
||||
duplicatedObjects,
|
||||
|
@ -30,6 +31,8 @@ const DuplicationControls = ({
|
|||
const { projectId } = useParams();
|
||||
const { assetStore } = useSceneContext();
|
||||
const { assets, addAsset } = assetStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { userId, organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -310,7 +313,7 @@ const DuplicationControls = ({
|
|||
|
||||
//REST
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// obj.uuid,
|
||||
// obj.userData.name,
|
||||
|
@ -334,6 +337,7 @@ const DuplicationControls = ({
|
|||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
eventData: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
};
|
||||
|
@ -360,7 +364,7 @@ const DuplicationControls = ({
|
|||
|
||||
//REST
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// obj.uuid,
|
||||
// obj.userData.name,
|
||||
|
@ -383,6 +387,7 @@ const DuplicationControls = ({
|
|||
isLocked: false,
|
||||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
userId,
|
||||
projectId
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as THREE from "three";
|
|||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useFrame, useThree } from "@react-three/fiber";
|
||||
import { useSelectedAssets, useSocketStore, useToggleView, } from "../../../../store/builder/store";
|
||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||
// import { setAssetsApi } from '../../../../services/factoryBuilder/assest/floorAsset/setAssetsApi';
|
||||
import * as Types from "../../../../types/world/worldTypes";
|
||||
import { detectModifierKeys } from "../../../../utils/shortcutkeys/detectModifierKeys";
|
||||
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||
|
@ -14,6 +14,7 @@ import { useParams } from "react-router-dom";
|
|||
import { useProductContext } from "../../../simulation/products/productContext";
|
||||
import { getUserData } from "../../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../sceneContext";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
function MoveControls({
|
||||
movedObjects,
|
||||
|
@ -41,6 +42,8 @@ function MoveControls({
|
|||
const { assetStore } = useSceneContext();
|
||||
const { updateAsset } = assetStore();
|
||||
const AssetGroup = useRef<THREE.Group | undefined>(undefined);
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
const updateBackend = (
|
||||
productName: string,
|
||||
|
@ -53,6 +56,7 @@ function MoveControls({
|
|||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -287,7 +291,7 @@ function MoveControls({
|
|||
|
||||
//REST
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// obj.uuid,
|
||||
// obj.userData.name,
|
||||
|
@ -310,6 +314,7 @@ function MoveControls({
|
|||
isLocked: false,
|
||||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as THREE from "three";
|
|||
import { useEffect, useMemo, useRef } from "react";
|
||||
import { useFrame, useThree } from "@react-three/fiber";
|
||||
import { useSelectedAssets, useSocketStore, useToggleView } from "../../../../store/builder/store";
|
||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||
// import { setAssetsApi } from '../../../../services/factoryBuilder/assest/floorAsset/setAssetsApi';
|
||||
import * as Types from "../../../../types/world/worldTypes";
|
||||
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||
import { useProductStore } from "../../../../store/simulation/useProductStore";
|
||||
|
@ -11,6 +11,7 @@ import { useParams } from "react-router-dom";
|
|||
import { useProductContext } from "../../../simulation/products/productContext";
|
||||
import { getUserData } from "../../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../sceneContext";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
function RotateControls({
|
||||
rotatedObjects,
|
||||
|
@ -37,6 +38,8 @@ function RotateControls({
|
|||
const { assetStore } = useSceneContext();
|
||||
const { updateAsset } = assetStore();
|
||||
const AssetGroup = useRef<THREE.Group | undefined>(undefined);
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
const updateBackend = (
|
||||
productName: string,
|
||||
|
@ -48,7 +51,8 @@ function RotateControls({
|
|||
productName: productName,
|
||||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -245,7 +249,7 @@ function RotateControls({
|
|||
|
||||
//REST
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// obj.uuid,
|
||||
// obj.userData.name,
|
||||
|
@ -268,6 +272,7 @@ function RotateControls({
|
|||
isLocked: false,
|
||||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
projectId,
|
||||
userId
|
||||
};
|
||||
|
|
|
@ -18,6 +18,7 @@ import { useProductStore } from "../../../../store/simulation/useProductStore";
|
|||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../sceneContext";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
const SelectionControls: React.FC = () => {
|
||||
const { camera, controls, gl, scene, raycaster, pointer } = useThree();
|
||||
|
@ -36,6 +37,8 @@ const SelectionControls: React.FC = () => {
|
|||
const { removeAsset } = assetStore();
|
||||
const selectionBox = useMemo(() => new SelectionBox(camera, scene), [camera, scene]);
|
||||
const { toolMode } = useToolMode();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const isDragging = useRef(false);
|
||||
|
@ -45,7 +48,7 @@ const SelectionControls: React.FC = () => {
|
|||
const rightClickMoved = useRef(false);
|
||||
const isCtrlSelecting = useRef(false);
|
||||
const isShiftSelecting = useRef(false);
|
||||
const { userId, organization, email } = getUserData();
|
||||
const { userId, organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
if (!camera || !scene || toggleView) return;
|
||||
|
@ -276,6 +279,7 @@ const SelectionControls: React.FC = () => {
|
|||
modelName: selectedMesh.userData.modelName,
|
||||
socketId: socket.id,
|
||||
projectId,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
userId
|
||||
};
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@ import { detectModifierKeys } from "../../../../utils/shortcutkeys/detectModifie
|
|||
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||
import { useProductStore } from "../../../../store/simulation/useProductStore";
|
||||
import { upsertProductOrEventApi } from "../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
// import { setFloorItemApi } from "../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
|
||||
// import { setAssetsApi } from "../../../../services/factoryBuilder/assest/floorAsset/setAssetsApi";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useProductContext } from "../../../simulation/products/productContext";
|
||||
import { getUserData } from "../../../../functions/getUserData";
|
||||
import { useSceneContext } from "../../sceneContext";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
export default function TransformControl() {
|
||||
const state = useThree();
|
||||
|
@ -27,6 +28,8 @@ export default function TransformControl() {
|
|||
const { assetStore } = useSceneContext();
|
||||
const { updateAsset, getAssetById } = assetStore();
|
||||
const { userId, organization } = getUserData();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const updateBackend = (
|
||||
|
@ -40,6 +43,7 @@ export default function TransformControl() {
|
|||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -106,7 +110,7 @@ export default function TransformControl() {
|
|||
|
||||
//REST
|
||||
|
||||
// await setFloorItemApi(
|
||||
// await setAssetsApi(
|
||||
// organization,
|
||||
// asset.modelUuid,
|
||||
// asset.modelName,
|
||||
|
@ -129,6 +133,7 @@ export default function TransformControl() {
|
|||
isLocked: false,
|
||||
isVisible: true,
|
||||
socketId: socket.id,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
userId,
|
||||
projectId
|
||||
};
|
||||
|
|
|
@ -12,6 +12,7 @@ import { upsertProductOrEventApi } from "../../../../../services/simulation/prod
|
|||
import { useProductContext } from "../../../products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useToolMode } from "../../../../../store/builder/store";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
|
||||
function PointsCreator() {
|
||||
const { gl, raycaster, scene, pointer, camera } = useThree();
|
||||
|
@ -28,6 +29,8 @@ function PointsCreator() {
|
|||
const { setSelectedEventData, clearSelectedEventData } = useSelectedEventData();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { toolMode } = useToolMode();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const updateBackend = (
|
||||
|
@ -40,7 +43,8 @@ function PointsCreator() {
|
|||
productName: productName,
|
||||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ interface HandleAddEventToProductParams {
|
|||
productName: string;
|
||||
}
|
||||
clearSelectedAsset?: () => void;
|
||||
versionId: string;
|
||||
projectId: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import { ArrowOnQuadraticBezier, Arrows } from "../arrows/arrows";
|
|||
import { useProductContext } from "../../products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useToolMode } from "../../../../store/builder/store";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
interface ConnectionLine {
|
||||
id: string;
|
||||
|
@ -35,6 +36,8 @@ function TriggerConnector() {
|
|||
const { toolMode } = useToolMode();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { selectedAction } = useSelectedAction();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const [firstSelectedPoint, setFirstSelectedPoint] = useState<{
|
||||
|
@ -56,7 +59,8 @@ function TriggerConnector() {
|
|||
productName: productName,
|
||||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -282,7 +286,8 @@ function TriggerConnector() {
|
|||
event: useEventsStore.getState().getEventByModelUuid(modelUuid),
|
||||
addEvent,
|
||||
selectedProduct,
|
||||
projectId: projectId || ''
|
||||
projectId: projectId || '',
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
|
||||
const point = getPointByUuid(
|
||||
|
|
|
@ -8,6 +8,7 @@ import { useSceneContext } from '../../scene/sceneContext';
|
|||
import { useProductContext } from './productContext';
|
||||
import { useComparisonProduct, useMainProduct } from '../../../store/simulation/useSimulationStore';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useVersionContext } from '../../builder/version/versionContext';
|
||||
|
||||
function Products() {
|
||||
const { armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore, layout } = useSceneContext();
|
||||
|
@ -24,6 +25,8 @@ function Products() {
|
|||
const { isPlaying } = usePlayButtonStore();
|
||||
const { mainProduct } = useMainProduct();
|
||||
const { comparisonProduct } = useComparisonProduct();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -39,15 +42,16 @@ function Products() {
|
|||
}, [comparisonProduct])
|
||||
|
||||
useEffect(() => {
|
||||
getAllProductsApi(projectId || '').then((data) => {
|
||||
if (data.length === 0) {
|
||||
getAllProductsApi(projectId || '', selectedVersion?.versionId || '').then((data) => {
|
||||
if (data && data.length === 0) {
|
||||
const id = THREE.MathUtils.generateUUID();
|
||||
const name = 'Product 1';
|
||||
addProduct(name, id);
|
||||
upsertProductOrEventApi({
|
||||
productName: name,
|
||||
productUuid: id,
|
||||
projectId: projectId || ''
|
||||
projectId: projectId || '',
|
||||
versionId: selectedVersion?.versionId || ''
|
||||
})
|
||||
if (layout === 'Main Layout') {
|
||||
setSelectedProduct(id, name);
|
||||
|
@ -60,8 +64,10 @@ function Products() {
|
|||
setMainProduct(data[0].productUuid, data[0].productName);
|
||||
}
|
||||
}
|
||||
}).catch((err)=>{
|
||||
console.error(err);
|
||||
})
|
||||
}, [])
|
||||
}, [selectedVersion?.versionId])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedProduct.productUuid) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import { upsertProductOrEventApi } from '../../../../services/simulation/product
|
|||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
import { useProductContext } from '../../products/productContext';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useVersionContext } from '../../../builder/version/versionContext';
|
||||
|
||||
type Positions = {
|
||||
pick: [number, number, number];
|
||||
|
@ -29,6 +30,8 @@ const ArmBotUI = () => {
|
|||
const { selectedAction } = useSelectedAction();
|
||||
const { armBotStore } = useSceneContext();
|
||||
const { armBots } = armBotStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const armUiPick = useGLTF(armPick) as any;
|
||||
|
@ -48,7 +51,8 @@ const ArmBotUI = () => {
|
|||
productName: productName,
|
||||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import startEnd from "../../../../assets/gltf-glb/ui/arrow_red.glb";
|
|||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
import { useProductContext } from "../../products/productContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../builder/version/versionContext";
|
||||
|
||||
const VehicleUI = () => {
|
||||
const { scene: startScene } = useGLTF(startPoint) as any;
|
||||
|
@ -45,6 +46,8 @@ const VehicleUI = () => {
|
|||
const controls: any = state.controls;
|
||||
const [selectedVehicleData, setSelectedVechicleData] = useState<{ position: [number, number, number]; rotation: [number, number, number]; }>({ position: [0, 0, 0], rotation: [0, 0, 0] });
|
||||
const CIRCLE_RADIUS = 0.8;
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
const updateBackend = (
|
||||
|
@ -58,6 +61,7 @@ const VehicleUI = () => {
|
|||
productUuid: productUuid,
|
||||
projectId: projectId,
|
||||
eventDatas: eventData,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import OuterClick from "../../utils/outerClick";
|
|||
import { useWidgetStore } from "../../store/useWidgetStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../functions/getUserData";
|
||||
import { useVersionContext } from "../builder/version/versionContext";
|
||||
|
||||
type Side = "top" | "bottom" | "left" | "right";
|
||||
|
||||
|
@ -54,12 +55,13 @@ const RealTimeVisulization: React.FC = () => {
|
|||
const { selectedZone, setSelectedZone } = useSelectedZoneStore();
|
||||
|
||||
const { setRightSelect } = useRightSelected();
|
||||
const { editWidgetOptions, setEditWidgetOptions } =
|
||||
useEditWidgetOptionsStore();
|
||||
const { editWidgetOptions, setEditWidgetOptions } = useEditWidgetOptionsStore();
|
||||
const { rightClickSelected, setRightClickSelected } = useRightClickSelected();
|
||||
const [openConfirmationPopup, setOpenConfirmationPopup] = useState(false);
|
||||
const { setSelectedChartId } = useWidgetStore();
|
||||
const [waitingPanels, setWaitingPanels] = useState(null);
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
OuterClick({
|
||||
|
@ -73,43 +75,37 @@ const RealTimeVisulization: React.FC = () => {
|
|||
],
|
||||
setMenuVisible: () => setSelectedChartId(null),
|
||||
});
|
||||
const { userName, userId, organization, email } = getUserData();
|
||||
|
||||
const { organization } = getUserData();
|
||||
|
||||
useEffect(() => {
|
||||
async function GetZoneData() {
|
||||
try {
|
||||
const response = await getZone2dData(organization, projectId);
|
||||
// console.log('responseRt: ', response);
|
||||
|
||||
|
||||
if (!Array.isArray(response)) {
|
||||
return;
|
||||
}
|
||||
const formattedData = response.reduce<FormattedZoneData>(
|
||||
(acc, zone) => {
|
||||
|
||||
acc[zone.zoneName] = {
|
||||
activeSides: [],
|
||||
panelOrder: [],
|
||||
lockedPanels: [],
|
||||
points: zone.points,
|
||||
zoneUuid: zone.zoneUuid,
|
||||
zoneViewPortTarget: zone.viewPortCenter,
|
||||
zoneViewPortPosition: zone.viewPortposition,
|
||||
widgets: [],
|
||||
};
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
setZonesData(formattedData);
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch zone data");
|
||||
console.log(error);
|
||||
if (!projectId || !selectedVersion) return;
|
||||
getZone2dData(organization, projectId, selectedVersion?.versionId || '').then((response) => {
|
||||
if (!Array.isArray(response)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const formattedData = response.reduce<FormattedZoneData>(
|
||||
(acc, zone) => {
|
||||
|
||||
GetZoneData();
|
||||
}, [activeModule]); // Removed `zones` from dependencies
|
||||
acc[zone.zoneName] = {
|
||||
activeSides: [],
|
||||
panelOrder: [],
|
||||
lockedPanels: [],
|
||||
points: zone.points,
|
||||
zoneUuid: zone.zoneUuid,
|
||||
zoneViewPortTarget: zone.viewPortCenter,
|
||||
zoneViewPortPosition: zone.viewPortposition,
|
||||
widgets: [],
|
||||
};
|
||||
return acc;
|
||||
}, {}
|
||||
);
|
||||
setZonesData(formattedData);
|
||||
})
|
||||
|
||||
}, [activeModule, selectedVersion?.versionId]);
|
||||
|
||||
// Removed `zones` from dependencies
|
||||
|
||||
useEffect(() => {
|
||||
setZonesData((prev) => {
|
||||
|
|
|
@ -4,7 +4,8 @@ export const createAisleApi = async (
|
|||
aisleUuid: string,
|
||||
points: any,
|
||||
type: Object,
|
||||
projectId: string
|
||||
projectId: string,
|
||||
versionId: string,
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/UpsertAisle`, {
|
||||
|
@ -15,7 +16,7 @@ export const createAisleApi = async (
|
|||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({ aisleUuid, points, type, projectId }),
|
||||
body: JSON.stringify({ aisleUuid, points, type, projectId, versionId }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const deleteAisleApi = async (aisleUuid: string, projectId: string) => {
|
||||
export const deleteAisleApi = async (aisleUuid: string, projectId: string, versionId: string) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/DeleteAisle`, {
|
||||
method: "PATCH",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getAisleApi = async (projectId: string) => {
|
||||
export const getAisleApi = async (projectId: string, versionId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/Aisles/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/Aisles/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getFloorAssets = async (organization: string, projectId?: string) => {
|
||||
export const getFloorAssets = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/floorAssets/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/floorAssets/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
@ -21,7 +21,6 @@ export const getFloorAssets = async (organization: string, projectId?: string) =
|
|||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('result: ', result);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,50 +1,29 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
export const setFloorItemApi = async (
|
||||
organization: string,
|
||||
modelUuid?: string,
|
||||
modelName?: string,
|
||||
projectId?: string,
|
||||
assetId?: string,
|
||||
position?: Object,
|
||||
rotation?: Object,
|
||||
isLocked?: boolean,
|
||||
isVisible?: boolean,
|
||||
) => {
|
||||
try {
|
||||
const body: any = {
|
||||
organization,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
assetId,
|
||||
isLocked,
|
||||
isVisible,
|
||||
projectId,
|
||||
};
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/setAsset`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set or update Floor Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to set floor items");
|
||||
if (error instanceof Error) {
|
||||
console.log(error.message);
|
||||
} else {
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
export const setAssetsApi = async (data: any) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/setAsset`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set or update Floor Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to set floor items");
|
||||
if (error instanceof Error) {
|
||||
console.log(error.message);
|
||||
} else {
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,9 +1,9 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getWallItems = async (organization: string,projectId?:string) => {
|
||||
export const getWallItems = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/walls/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/walls/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getLines = async (organization: string, projectId?: string) => {
|
||||
export const getLines = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/lines/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/lines/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
|
||||
|
||||
export const getZonesApi = async (organization: string, projectId?: string) => {
|
||||
export const getZonesApi = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/zones/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/zones/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
@ -17,12 +17,12 @@ export const getZonesApi = async (organization: string, projectId?: string) => {
|
|||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Zones");
|
||||
throw new Error("Failed to get Zones");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('result:zone ', result);
|
||||
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to get zone data");
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getAllProductsApi = async (projectId: string) => {
|
||||
export const getAllProductsApi = async (projectId: string, versionId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/ProjectProducts/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/ProjectProducts/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
|
|
@ -4,6 +4,7 @@ export const renameProductApi = async (body: {
|
|||
productName: string;
|
||||
productUuid: string;
|
||||
projectId: string;
|
||||
versionId: string;
|
||||
}) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/RenameProduct`, {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
|
||||
export const getZone2dData = async (organization?: string, projectId?: string) => {
|
||||
export const getZone2dData = async (organization?: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/zones/visualization/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/zones/visualization/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
|
Loading…
Reference in New Issue