(null);
const wall = useMemo(() => getWallById(wallAsset.wallUuid), [getWallById, wallAsset.wallUuid, walls]);
const draggingRef = useRef(false);
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
+ const { userId, organization } = getUserData();
+ const { projectId } = useParams();
useEffect(() => {
const loader = new GLTFLoader();
@@ -131,11 +142,31 @@ function WallAssetInstance({ wallAsset }: { wallAsset: WallAsset }) {
const wallRotation = intersect.object.rotation.clone();
- updateWallAsset(wallAsset.modelUuid, {
+ const updatedWallAsset = updateWallAsset(wallAsset.modelUuid, {
wallUuid: intersect.object.userData.wallUuid,
position: [newPoint.x, wallAsset.wallAssetType === 'fixed-move' ? 0 : intersect.point.y, newPoint.z],
rotation: [wallRotation.x, wallRotation.y, wallRotation.z],
});
+
+ if (projectId && updatedWallAsset) {
+
+ // API
+
+ // upsertWallAssetApi(projectId, selectedVersion?.versionId || '', updatedWallAsset);
+
+ // SOCKET
+
+ const data = {
+ wallAssetData: updatedWallAsset,
+ projectId: projectId,
+ versionId: selectedVersion?.versionId || '',
+ userId: userId,
+ organization: organization
+ }
+
+ socket.emit('v1:wall-asset:add', data);
+
+ }
}
};
@@ -149,13 +180,34 @@ function WallAssetInstance({ wallAsset }: { wallAsset: WallAsset }) {
canvasElement.removeEventListener('pointerup', onPointerUp);
};
- }, [gl, camera, toggleView, activeModule, selectedWallAsset])
+ }, [gl, camera, toggleView, activeModule, selectedWallAsset, socket])
const handlePointerClick = useCallback((wallAsset: WallAsset) => {
if (activeTool === 'delete' && deletableWallAsset && deletableWallAsset.userData.modelUuid === wallAsset.modelUuid) {
- removeWallAsset(wallAsset.modelUuid);
+ const removedWallAsset = removeWallAsset(wallAsset.modelUuid);
+
+ if (projectId && removedWallAsset) {
+
+ // API
+
+ // deleteWallAssetApi(projectId, selectedVersion?.versionId || '', removedWallAsset.modelUuid, removedWallAsset.wallUuid);
+
+ // SOCKET
+
+ const data = {
+ projectId: projectId,
+ versionId: selectedVersion?.versionId || '',
+ userId: userId,
+ organization: organization,
+ modelUuid: removedWallAsset.modelUuid,
+ wallUuid: removedWallAsset.wallUuid
+ }
+
+ socket.emit('v1:wall-asset:delete', data);
+
+ }
}
- }, [activeTool, activeModule, deletableWallAsset])
+ }, [activeTool, activeModule, deletableWallAsset, socket])
const handlePointerOver = useCallback((wallAsset: WallAsset, currentObject: THREE.Object3D) => {
if (activeTool === "delete" && activeModule === 'builder') {
diff --git a/app/src/modules/builder/wallAsset/wallAssetCreator.tsx b/app/src/modules/builder/wallAsset/wallAssetCreator.tsx
index aacca0e..c27646f 100644
--- a/app/src/modules/builder/wallAsset/wallAssetCreator.tsx
+++ b/app/src/modules/builder/wallAsset/wallAssetCreator.tsx
@@ -1,11 +1,16 @@
import { useThree } from '@react-three/fiber';
import { useEffect } from 'react'
-import { useSelectedItem, useSocketStore, useToggleView } from '../../../store/builder/store';
import useModuleStore from '../../../store/useModuleStore';
+import { useSelectedItem, useSocketStore, useToggleView } from '../../../store/builder/store';
import { MathUtils, Vector3 } from 'three';
import { useSceneContext } from '../../scene/sceneContext';
+import { useParams } from 'react-router-dom';
+import { useVersionContext } from '../version/versionContext';
+import { getUserData } from '../../../functions/getUserData';
import closestPointOnLineSegment from '../line/helpers/getClosestPointOnLineSegment';
+import { upsertWallAssetApi } from '../../../services/factoryBuilder/asset/wallAsset/upsertWallAssetApi';
+
function WallAssetCreator() {
const { socket } = useSocketStore();
const { pointer, camera, raycaster, scene, gl } = useThree();
@@ -14,6 +19,10 @@ function WallAssetCreator() {
const { wallAssetStore } = useSceneContext();
const { addWallAsset } = wallAssetStore();
const { selectedItem, setSelectedItem } = useSelectedItem();
+ const { selectedVersionStore } = useVersionContext();
+ const { selectedVersion } = selectedVersionStore();
+ const { userId, organization } = getUserData();
+ const { projectId } = useParams();
useEffect(() => {
const canvasElement = gl.domElement;
@@ -52,6 +61,25 @@ function WallAssetCreator() {
};
addWallAsset(newWallAsset);
+ if (projectId) {
+
+ // API
+
+ // upsertWallAssetApi(projectId, selectedVersion?.versionId || '', newWallAsset);
+
+ // SOCKET
+
+ const data = {
+ wallAssetData: newWallAsset,
+ projectId: projectId,
+ versionId: selectedVersion?.versionId || '',
+ userId: userId,
+ organization: organization
+ }
+
+ socket.emit('v1:wall-asset:add', data);
+
+ }
}
}
};
diff --git a/app/src/modules/builder/wallAsset/wallAssetGroup.tsx b/app/src/modules/builder/wallAsset/wallAssetGroup.tsx
index f9d1290..bae9f87 100644
--- a/app/src/modules/builder/wallAsset/wallAssetGroup.tsx
+++ b/app/src/modules/builder/wallAsset/wallAssetGroup.tsx
@@ -7,6 +7,7 @@ import { useParams } from 'react-router-dom';
import useModuleStore from '../../../store/useModuleStore';
import WallAssetCreator from './wallAssetCreator'
import WallAssetInstances from './Instances/wallAssetInstances'
+import { getWallAssetsApi } from '../../../services/factoryBuilder/asset/wallAsset/getWallAssetsApi';
function WallAssetGroup() {
const { togglView } = useToggleView();
@@ -26,6 +27,20 @@ function WallAssetGroup() {
setDeletableWallAsset(null);
}, [togglView, activeModule, activeTool])
+ useEffect(() => {
+ if (projectId && selectedVersion) {
+ getWallAssetsApi(projectId, selectedVersion?.versionId || '').then((wallAssets) => {
+ if (wallAssets && wallAssets.length > 0) {
+ setWallAssets(wallAssets);
+ } else {
+ setWallAssets([]);
+ }
+ }).catch((err) => {
+ console.log(err);
+ })
+ }
+ }, [projectId, selectedVersion?.versionId])
+
return (
<>
diff --git a/app/src/modules/collaboration/socket/socketResponses.dev.tsx b/app/src/modules/collaboration/socket/socketResponses.dev.tsx
index 3f4bfdb..db9e96a 100644
--- a/app/src/modules/collaboration/socket/socketResponses.dev.tsx
+++ b/app/src/modules/collaboration/socket/socketResponses.dev.tsx
@@ -1,6 +1,17 @@
-import React from 'react';
+import { useEffect } from 'react';
+import { useSocketStore } from '../../../store/builder/store';
export default function SocketResponses() {
+ const { socket } = useSocketStore();
+
+ useEffect(() => {
+ socket.on("v1:wall-asset:response:delete", (data: any) => {
+ });
+
+ return () => {
+ socket.off("v1:wall-asset:response:delete");
+ }
+ }, [socket])
return (
<>
diff --git a/app/src/pages/UserAuth.tsx b/app/src/pages/UserAuth.tsx
index 4ac7078..fec9a47 100644
--- a/app/src/pages/UserAuth.tsx
+++ b/app/src/pages/UserAuth.tsx
@@ -129,7 +129,7 @@ const UserAuth: React.FC = () => {
- Welcome to Dwinzo
+ Welcome to Aalai
{isSignIn ? (
<>
diff --git a/app/src/services/factoryBuilder/asset/wallAsset/deleteWallAssetApi.ts b/app/src/services/factoryBuilder/asset/wallAsset/deleteWallAssetApi.ts
new file mode 100644
index 0000000..3751aae
--- /dev/null
+++ b/app/src/services/factoryBuilder/asset/wallAsset/deleteWallAssetApi.ts
@@ -0,0 +1,40 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const deleteWallAssetApi = async (
+ projectId: string,
+ versionId: string,
+ modelUuid: string,
+ wallUuid: string,
+) => {
+ try {
+ const response = await fetch(`${url_Backend_dwinzo}/api/V1/delete/wallasset`, {
+ method: "PATCH",
+ headers: {
+ Authorization: "Bearer ",
+ "Content-Type": "application/json",
+ token: localStorage.getItem("token") || "",
+ refresh_token: localStorage.getItem("refreshToken") || "",
+ },
+ body: JSON.stringify({ projectId, versionId, modelUuid, wallUuid }),
+ });
+
+ const newAccessToken = response.headers.get("x-access-token");
+ if (newAccessToken) {
+ localStorage.setItem("token", newAccessToken);
+ }
+
+ if (!response.ok) {
+ console.error("Failed to delete wall asset:", response.statusText);
+ }
+
+ const result = await response.json();
+ return result;
+ } catch (error) {
+ echo.error("Failed to delete wall asset");
+ if (error instanceof Error) {
+ console.log(error.message);
+ } else {
+ console.log("An unknown error occurred");
+ }
+ }
+};
diff --git a/app/src/services/factoryBuilder/asset/wallAsset/getWallAssetsApi.ts b/app/src/services/factoryBuilder/asset/wallAsset/getWallAssetsApi.ts
new file mode 100644
index 0000000..d6b12ed
--- /dev/null
+++ b/app/src/services/factoryBuilder/asset/wallAsset/getWallAssetsApi.ts
@@ -0,0 +1,37 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const getWallAssetsApi = async (
+ projectId: string,
+ versionId: string,
+) => {
+ try {
+ const response = await fetch(`${url_Backend_dwinzo}/api/V1/wallassets/${projectId}/${versionId}`, {
+ method: "GET",
+ headers: {
+ Authorization: "Bearer ",
+ "Content-Type": "application/json",
+ token: localStorage.getItem("token") || "",
+ refresh_token: localStorage.getItem("refreshToken") || "",
+ },
+ });
+
+ const newAccessToken = response.headers.get("x-access-token");
+ if (newAccessToken) {
+ localStorage.setItem("token", newAccessToken);
+ }
+
+ if (!response.ok) {
+ console.error("Failed to get wall assets:", response.statusText);
+ }
+
+ const result = await response.json();
+ return result;
+ } catch (error) {
+ echo.error("Failed to get wall assets");
+ if (error instanceof Error) {
+ console.log(error.message);
+ } else {
+ console.log("An unknown error occurred");
+ }
+ }
+};
diff --git a/app/src/services/factoryBuilder/asset/wallAsset/upsertWallAssetApi.ts b/app/src/services/factoryBuilder/asset/wallAsset/upsertWallAssetApi.ts
new file mode 100644
index 0000000..9f94183
--- /dev/null
+++ b/app/src/services/factoryBuilder/asset/wallAsset/upsertWallAssetApi.ts
@@ -0,0 +1,39 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const upsertWallAssetApi = async (
+ projectId: string,
+ versionId: string,
+ wallAssetData: WallAsset
+) => {
+ try {
+ const response = await fetch(`${url_Backend_dwinzo}/api/V1/wall-asset`, {
+ method: "POST",
+ headers: {
+ Authorization: "Bearer ",
+ "Content-Type": "application/json",
+ token: localStorage.getItem("token") || "",
+ refresh_token: localStorage.getItem("refreshToken") || "",
+ },
+ body: JSON.stringify({ projectId, versionId, wallAssetData }),
+ });
+
+ const newAccessToken = response.headers.get("x-access-token");
+ if (newAccessToken) {
+ localStorage.setItem("token", newAccessToken);
+ }
+
+ if (!response.ok) {
+ console.error("Failed to upsert wall asset:", response.statusText);
+ }
+
+ const result = await response.json();
+ return result;
+ } catch (error) {
+ echo.error("Failed to upsert wall asset");
+ if (error instanceof Error) {
+ console.log(error.message);
+ } else {
+ console.log("An unknown error occurred");
+ }
+ }
+};
diff --git a/app/src/store/builder/useWallAssetStore.ts b/app/src/store/builder/useWallAssetStore.ts
index 3d4e89d..d6081d7 100644
--- a/app/src/store/builder/useWallAssetStore.ts
+++ b/app/src/store/builder/useWallAssetStore.ts
@@ -5,9 +5,9 @@ interface WallAssetStore {
wallAssets: WallAsset[];
setWallAssets: (assets: WallAsset[]) => void;
addWallAsset: (asset: WallAsset) => void;
- updateWallAsset: (uuid: string, updated: Partial) => void;
+ updateWallAsset: (uuid: string, updated: Partial) => WallAsset | undefined;
setWallAssetPosition: (uuid: string, position: [number, number, number]) => void;
- removeWallAsset: (uuid: string) => void;
+ removeWallAsset: (uuid: string) => WallAsset | undefined;
clearWallAssets: () => void;
setVisibility: (uuid: string, isVisible: boolean) => void;
@@ -31,12 +31,17 @@ export const createWallAssetStore = () => {
state.wallAssets.push(asset);
}),
- updateWallAsset: (uuid, updated) => set(state => {
- const asset = state.wallAssets.find(a => a.modelUuid === uuid);
- if (asset) {
- Object.assign(asset, updated);
- }
- }),
+ updateWallAsset: (uuid, updated) => {
+ let updatedWallAsset: WallAsset | undefined;
+ set(state => {
+ const asset = state.wallAssets.find(a => a.modelUuid === uuid);
+ if (asset) {
+ Object.assign(asset, updated);
+ updatedWallAsset = JSON.parse(JSON.stringify(asset));
+ }
+ });
+ return updatedWallAsset;
+ },
setWallAssetPosition: (uuid, position) => set(state => {
const asset = state.wallAssets.find(a => a.modelUuid === uuid);
@@ -45,9 +50,17 @@ export const createWallAssetStore = () => {
}
}),
- removeWallAsset: (uuid) => set(state => {
- state.wallAssets = state.wallAssets.filter(a => a.modelUuid !== uuid);
- }),
+ removeWallAsset: (uuid) => {
+ let removedAsset: WallAsset | undefined;
+ set(state => {
+ const asset = state.wallAssets.find(a => a.modelUuid === uuid);
+ if (asset) {
+ removedAsset = JSON.parse(JSON.stringify(asset));
+ state.wallAssets = state.wallAssets.filter(a => a.modelUuid !== uuid);
+ }
+ });
+ return removedAsset;
+ },
clearWallAssets: () => {
set(state => {
diff --git a/app/src/styles/layout/loading.scss b/app/src/styles/layout/loading.scss
index 5b4fe12..5331c2f 100644
--- a/app/src/styles/layout/loading.scss
+++ b/app/src/styles/layout/loading.scss
@@ -7,7 +7,6 @@
background: var(--background-color-solid);
&.comparisionLoading {
-
position: fixed;
top: 0;
right: 0;
@@ -48,11 +47,15 @@
}
.loading-hero-container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
.logo {
@include flex-center;
width: 100%;
margin-bottom: 35px;
-
+ scale: 0.8;
circle {
fill: transparent;
}
@@ -99,4 +102,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/types/world/worldConstants.ts b/app/src/types/world/worldConstants.ts
index 1d49585..83933b7 100644
--- a/app/src/types/world/worldConstants.ts
+++ b/app/src/types/world/worldConstants.ts
@@ -331,7 +331,7 @@ export const lineConfig: LineConfig = {
export const wallConfig: WallConfig = {
defaultColor: "#f2f2f2", // Default color of the walls
- height: 7, // Height of the walls
+ height: 7.5, // Height of the walls
width: 0.05, // Width of the walls
};
diff --git a/compose.yaml b/compose.yaml
index a747cd9..60ae66f 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -7,18 +7,10 @@ services:
- REACT_APP_SERVER_SOCKET_API_BASE_URL=185.100.212.76:7999
- REACT_APP_SERVER_REST_API_BASE_URL=185.100.212.76:4999
- REACT_APP_SERVER_MARKETPLACE_URL=185.100.212.76:50011
- container_name: dwinzo-beta-Demo
+ container_name: aalai-beta-Demo
stdin_open: true
tty: true
ports:
- - "8300:3000"
- environment:
- - WDS_SOCKET_PORT=0
- - PORT=3000
- - DOCSIFY_PORT=8201
+ - "8300:80"
volumes:
- ./app:/app
-
-volumes:
- frontend:
- driver: local
diff --git a/nginx-host.conf b/nginx-host.conf
new file mode 100644
index 0000000..ee620a5
--- /dev/null
+++ b/nginx-host.conf
@@ -0,0 +1,13 @@
+server {
+ listen 80;
+ server_name aalai.ai www.aalai.ai;
+
+ location / {
+ proxy_pass http://127.0.0.1:8300;
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection 'upgrade';
+ proxy_set_header Host $host;
+ proxy_cache_bypass $http_upgrade;
+ }
+}