merged with main branch to clear the testing commits
This commit is contained in:
@@ -1,50 +1,56 @@
|
|||||||
let url_Backend_dwinzoMajor = "http://192.168.0.110:3503";
|
let url_Backend_dwinzoMajor = "http://192.168.0.110:3503";
|
||||||
//Login Api
|
|
||||||
export const createCamera = async (userId:string, position:Object) => {
|
export const createCamera = async (userId: string, position: Object) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/createCamera`, {
|
const response = await fetch(
|
||||||
|
`${url_Backend_dwinzoMajor}/api/v1/createCamera`,
|
||||||
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ userId, position }),
|
body: JSON.stringify({ userId, position }),
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error("Failed to create Camera");
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const result = await response.json();
|
if (!response.ok) {
|
||||||
return result;
|
throw new Error("Failed to create Camera");
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error`
|
|
||||||
} else {
|
|
||||||
throw new Error("An unknown error occurred");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
export const getCamera = async (userId:string) => {
|
const result = await response.json();
|
||||||
try {
|
return result;
|
||||||
const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/getCamera/${userId}`, {
|
} catch (error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
} else {
|
||||||
|
throw new Error("An unknown error occurred");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCamera = async (userId: string) => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`${url_Backend_dwinzoMajor}/api/v1/getCamera/${userId}`,
|
||||||
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error("Failed to get Camera");
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const result = await response.json();
|
if (!response.ok) {
|
||||||
return result;
|
throw new Error("Failed to get Camera");
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error`
|
|
||||||
} else {
|
|
||||||
throw new Error("An unknown error occurred");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
const result = await response.json();
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
} else {
|
||||||
|
throw new Error("An unknown error occurred");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -7,20 +7,19 @@ ENV NODE_ENV = development
|
|||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
RUN npm install -g tsx
|
RUN npm install -g tsx --ignore-scripts
|
||||||
|
|
||||||
COPY package.json /usr/src/app/package.json
|
COPY package.json ./
|
||||||
|
COPY package-lock.json ./
|
||||||
|
RUN npm install --ignore-scripts
|
||||||
|
|
||||||
|
|
||||||
# COPY package-lock.json /usr/src/app/package-lock.json
|
RUN addgroup -S appgroup && \
|
||||||
|
adduser -S appuser -G appgroup && \
|
||||||
|
chown -R appuser:appgroup /usr/src/app
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
RUN npm install
|
USER appuser
|
||||||
|
|
||||||
# Run the application as a non-root user.
|
|
||||||
USER root
|
|
||||||
|
|
||||||
# Copy the rest of the source files into the image.
|
|
||||||
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -8,5 +8,4 @@ router.patch(
|
|||||||
AssetsFloorService.updateAssetPositionRotation
|
AssetsFloorService.updateAssetPositionRotation
|
||||||
);
|
);
|
||||||
router.patch("/eventDataUpdate", AssetsFloorService.replaceEventDatas);
|
router.patch("/eventDataUpdate", AssetsFloorService.replaceEventDatas);
|
||||||
// router.get("/pointData/:modelfileID/:organization", AssetsFloorService.gettypePoints);
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import express from "express";
|
import express from 'express';
|
||||||
import { FloorItems } from "../controller/assets/flooritem-Services.ts";
|
import { FloorItems } from '../controller/assets/flooritem-Services.ts';
|
||||||
import { AssetsFloorService } from "../controller/simulation/assetsFloorservice.ts";
|
import { AssetsFloorService } from '../controller/simulation/assetsFloorservice.ts';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/setfloorItems", FloorItems.setFloorItems);
|
router.post('/setfloorItems',FloorItems.setFloorItems)
|
||||||
router.get("/findfloorItems/:organization", FloorItems.getFloorItems);
|
router.get('/findfloorItems/:organization',FloorItems.getFloorItems)
|
||||||
// router.delete('/deletefloorItem',floorItems.deleteFloorItems)
|
router.delete('/deletefloorItem',AssetsFloorService.deleteFloorItems)
|
||||||
router.delete("/deletefloorItem", AssetsFloorService.deleteFloorItems);
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import express from "express";
|
import express from 'express';
|
||||||
import { Lines } from "../controller/lines/line-Services.ts";
|
import { Lines } from '../controller/lines/line-Services.ts';
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/setLine", Lines.setLines);
|
router.post('/setLine',Lines.setLines)
|
||||||
router.post("/updatePoint", Lines.updateLines);
|
router.post('/updatePoint',Lines.updateLines)
|
||||||
router.get("/findLines/:organization", Lines.getLines);
|
router.get('/findLines/:organization',Lines.getLines)
|
||||||
router.delete("/deleteLine", Lines.deleteLineItems);
|
router.delete('/deleteLine',Lines.deleteLineItems)
|
||||||
router.delete("/deletePoint", Lines.deleteLinPoiteItems);
|
router.delete('/deletePoint',Lines.deleteLinPoiteItems)
|
||||||
router.post("/deleteLayer", Lines.deleteLayer);
|
router.post('/deleteLayer',Lines.deleteLayer)
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -138,5 +138,4 @@ router.post("/panel/save", PanelService.AddPanel);
|
|||||||
router.patch("/panel/delete", PanelService.deletePanel);
|
router.patch("/panel/delete", PanelService.deletePanel);
|
||||||
router.patch("/clearpanel", PanelService.clearPanel);
|
router.patch("/clearpanel", PanelService.clearPanel);
|
||||||
|
|
||||||
// router.get("/zone/:sceneID", Zoneservice.allZones);
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { ProductFlowservice } from "../controller/simulation/productService.ts";
|
import { ProductFlowService } from "../controller/simulation/productService.ts";
|
||||||
const productRouter = express.Router();
|
const productRouter = express.Router();
|
||||||
productRouter.post("/UpsertProductOrEvent", ProductFlowservice.productAdd);
|
productRouter.post("/UpsertProductOrEvent", ProductFlowService.productAdd);
|
||||||
productRouter.get("/productData", ProductFlowservice.getProductDatas);
|
productRouter.get("/productData", ProductFlowService.getProductDatas);
|
||||||
productRouter.patch("/EventDataDelete", ProductFlowservice.EventDataDelete);
|
productRouter.patch("/EventDataDelete", ProductFlowService.EventDataDelete);
|
||||||
productRouter.patch("/productDataDelete", ProductFlowservice.productDataDelete);
|
productRouter.patch("/productDataDelete", ProductFlowService.productDataDelete);
|
||||||
productRouter.get(
|
productRouter.get("/AllProducts/:organization", ProductFlowService.AllProductDatas);
|
||||||
"/AllProducts/:organization",
|
productRouter.patch("/productRename", ProductFlowService.productRename);
|
||||||
ProductFlowservice.AllProductDatas
|
|
||||||
);
|
|
||||||
productRouter.patch("/productRename", ProductFlowservice.productRename);
|
|
||||||
export default productRouter;
|
export default productRouter;
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ router.post("/TemplatetoZone", TemplateService.AddToZone);
|
|||||||
router.patch(
|
router.patch(
|
||||||
"/TemplateDelete/:templateID/:organization",
|
"/TemplateDelete/:templateID/:organization",
|
||||||
TemplateService.Deletezone
|
TemplateService.Deletezone
|
||||||
); //delete zone
|
);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import express from "express";
|
import express from 'express';
|
||||||
import { User } from "../controller/user-Controller.ts";
|
import { User } from '../controller/user-Controller.ts';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.post("/signup", User.signup);
|
router.post('/signup',User.signup)
|
||||||
router.post("/login", User.login);
|
router.post('/login',User.login)
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import express from "express";
|
import express from 'express';
|
||||||
import { WallItems } from "../controller/assets/wallitem-Services.ts";
|
import { WallItems } from '../controller/assets/wallitem-Services.ts';
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/setWallItems", WallItems.setWallItems);
|
router.post('/setWallItems',WallItems.setWallItems)
|
||||||
router.get("/findWallItems/:organization", WallItems.getWallItems);
|
router.get('/findWallItems/:organization',WallItems.getWallItems)
|
||||||
router.delete("/deleteWallItem", WallItems.deleteWallItems);
|
router.delete('/deleteWallItem',WallItems.deleteWallItems)
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { ZoneService } from "../controller/lines/zoneService.ts";
|
import { ZoneService } from "../controller/lines/zoneService.ts";
|
||||||
import { zone } from "../controller/lines/zone-Services.ts";
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -247,7 +245,7 @@ const router = express.Router();
|
|||||||
* type: string
|
* type: string
|
||||||
* example: "Internal server error"
|
* example: "Internal server error"
|
||||||
*/
|
*/
|
||||||
router.post("/zone/save", ZoneService.addandUpdateZone); //Zone create and update for the points
|
router.post("/zone/save", ZoneService.addandUpdateZone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -538,8 +536,7 @@ router.get("/A_zone/:zoneId/:organization", ZoneService.ZoneData);
|
|||||||
* type: string
|
* type: string
|
||||||
* example: "Internal Server Error"
|
* example: "Internal Server Error"
|
||||||
*/
|
*/
|
||||||
router.patch("/zone/:zoneId", ZoneService.deleteAZone); //delete Zone
|
router.patch("/zone/:zoneId", ZoneService.deleteAZone);
|
||||||
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
|
||||||
|
|
||||||
router.get("/findZones/:organization", zone.getZones);
|
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ export const GetProjects = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization, role } = req.user || {};
|
const { userId, organization, role } = req.user || {};
|
||||||
// const { userId, organization } = req.params;
|
|
||||||
if (!userId || !organization || !role) {
|
if (!userId || !organization || !role) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
@@ -106,7 +105,6 @@ export const RemoveProject = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { projectId } = req.params;
|
const { projectId } = req.params;
|
||||||
// const { organization, userId } = req.body;
|
|
||||||
const { organization, userId } = req.user || {};
|
const { organization, userId } = req.user || {};
|
||||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||||
res.status(401).json({ message: "Unauthorized" });
|
res.status(401).json({ message: "Unauthorized" });
|
||||||
|
|||||||
@@ -8,12 +8,7 @@ export const versioncontroller = async (
|
|||||||
try {
|
try {
|
||||||
console.log("req.body: ", req.body);
|
console.log("req.body: ", req.body);
|
||||||
const { projectId, userId, description, db } = req.body;
|
const { projectId, userId, description, db } = req.body;
|
||||||
// if (!userName || !Email || !description) {
|
|
||||||
// res.status(400).json({
|
|
||||||
// message: "All fields are required",
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
const result = await versionService.saveCurrentStateAsVersion(
|
const result = await versionService.saveCurrentStateAsVersion(
|
||||||
db,
|
db,
|
||||||
projectId,
|
projectId,
|
||||||
|
|||||||
@@ -11,46 +11,36 @@ import {
|
|||||||
|
|
||||||
const v1Zone = express.Router();
|
const v1Zone = express.Router();
|
||||||
|
|
||||||
//Zone-Page
|
|
||||||
v1Zone.post(
|
v1Zone.post(
|
||||||
"/zones",
|
"/zones",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
CreateZoneController
|
CreateZoneController
|
||||||
);
|
);
|
||||||
v1Zone.patch(
|
v1Zone.patch(
|
||||||
"/zones/delete",
|
"/zones/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DeleteZoneController
|
DeleteZoneController
|
||||||
);
|
);
|
||||||
|
|
||||||
//viz
|
|
||||||
v1Zone.get(
|
v1Zone.get(
|
||||||
"/zones/visualization/:projectId",
|
"/zones/visualization/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
VizZoneController
|
VizZoneController
|
||||||
);
|
);
|
||||||
|
|
||||||
//getzones
|
|
||||||
v1Zone.get(
|
v1Zone.get(
|
||||||
"/zones/:projectId/:zoneId",
|
"/zones/:projectId/:zoneId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
ZoneDataController
|
ZoneDataController
|
||||||
);
|
);
|
||||||
// viz
|
|
||||||
v1Zone.get(
|
v1Zone.get(
|
||||||
"/zones/panel/:projectId/:zoneId",
|
"/zones/panel/:projectId/:zoneId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
SingleZonePanelController
|
SingleZonePanelController
|
||||||
);
|
);
|
||||||
v1Zone.get(
|
v1Zone.get(
|
||||||
"/zones/:projectId",
|
"/zones/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetZoneController
|
GetZoneController
|
||||||
);
|
);
|
||||||
export default v1Zone;
|
export default v1Zone;
|
||||||
|
|||||||
@@ -9,29 +9,24 @@ import {
|
|||||||
|
|
||||||
const v1Asset = express.Router();
|
const v1Asset = express.Router();
|
||||||
|
|
||||||
//Asset-Page
|
|
||||||
v1Asset.post(
|
v1Asset.post(
|
||||||
"/setAsset",
|
"/setAsset",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
CreateAssetController
|
CreateAssetController
|
||||||
);
|
);
|
||||||
v1Asset.patch(
|
v1Asset.patch(
|
||||||
"/updateFloorAssetPositions",
|
"/updateFloorAssetPositions",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
AssetUpdatePosRotController
|
AssetUpdatePosRotController
|
||||||
);
|
);
|
||||||
v1Asset.get(
|
v1Asset.get(
|
||||||
"/floorAssets/:projectId",
|
"/floorAssets/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetAssetController
|
GetAssetController
|
||||||
);
|
);
|
||||||
v1Asset.patch(
|
v1Asset.patch(
|
||||||
"/updateEventData",
|
"/updateEventData",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
ReplaceEventDataController
|
ReplaceEventDataController
|
||||||
);
|
);
|
||||||
export default v1Asset;
|
export default v1Asset;
|
||||||
|
|||||||
@@ -8,23 +8,19 @@ import {
|
|||||||
|
|
||||||
const v1Camera = express.Router();
|
const v1Camera = express.Router();
|
||||||
|
|
||||||
//Camera-Page
|
|
||||||
v1Camera.post(
|
v1Camera.post(
|
||||||
"/setCamera",
|
"/setCamera",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
SetNewCamera
|
SetNewCamera
|
||||||
);
|
);
|
||||||
v1Camera.get(
|
v1Camera.get(
|
||||||
"/activeCameras",
|
"/activeCameras",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
ActiveOnlineController
|
ActiveOnlineController
|
||||||
);
|
);
|
||||||
v1Camera.get(
|
v1Camera.get(
|
||||||
"/cameras/:projectId",
|
"/cameras/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
CameraList
|
CameraList
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -11,41 +11,34 @@ import {
|
|||||||
|
|
||||||
const v1Line = express.Router();
|
const v1Line = express.Router();
|
||||||
|
|
||||||
//Line-Page
|
|
||||||
v1Line.post(
|
v1Line.post(
|
||||||
"/lines",
|
"/lines",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
NewLineController
|
NewLineController
|
||||||
);
|
);
|
||||||
v1Line.post(
|
v1Line.post(
|
||||||
"/points",
|
"/points",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
UpdateLineController
|
UpdateLineController
|
||||||
);
|
);
|
||||||
v1Line.patch(
|
v1Line.patch(
|
||||||
"/layers/delete",
|
"/layers/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DeleteLayerController
|
DeleteLayerController
|
||||||
);
|
);
|
||||||
v1Line.patch(
|
v1Line.patch(
|
||||||
"/lines/delete",
|
"/lines/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DeleteLineController
|
DeleteLineController
|
||||||
);
|
);
|
||||||
v1Line.patch(
|
v1Line.patch(
|
||||||
"/points/delete",
|
"/points/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DeleteLinePointsController
|
DeleteLinePointsController
|
||||||
);
|
);
|
||||||
v1Line.get(
|
v1Line.get(
|
||||||
"/lines/:projectId",
|
"/lines/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetLinesController
|
GetLinesController
|
||||||
);
|
);
|
||||||
export default v1Line;
|
export default v1Line;
|
||||||
|
|||||||
@@ -8,23 +8,19 @@ import {
|
|||||||
|
|
||||||
const v1Wall = express.Router();
|
const v1Wall = express.Router();
|
||||||
|
|
||||||
//Wall-Page
|
|
||||||
v1Wall.post(
|
v1Wall.post(
|
||||||
"/walls",
|
"/walls",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
WallSetup
|
WallSetup
|
||||||
);
|
);
|
||||||
v1Wall.patch(
|
v1Wall.patch(
|
||||||
"/walls/delete",
|
"/walls/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
WallDelete
|
WallDelete
|
||||||
);
|
);
|
||||||
v1Wall.get(
|
v1Wall.get(
|
||||||
"/walls/:projectId",
|
"/walls/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
WallGet
|
WallGet
|
||||||
);
|
);
|
||||||
export default v1Wall;
|
export default v1Wall;
|
||||||
|
|||||||
@@ -9,23 +9,19 @@ import {
|
|||||||
|
|
||||||
const v1homeRoutes = express.Router();
|
const v1homeRoutes = express.Router();
|
||||||
|
|
||||||
//home-Page
|
|
||||||
v1homeRoutes.get(
|
v1homeRoutes.get(
|
||||||
"/RecentlyViewed",
|
"/RecentlyViewed",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
recentDataController
|
recentDataController
|
||||||
);
|
);
|
||||||
v1homeRoutes.get(
|
v1homeRoutes.get(
|
||||||
"/searchProjects",
|
"/searchProjects",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
searchProjectController
|
searchProjectController
|
||||||
);
|
);
|
||||||
v1homeRoutes.get(
|
v1homeRoutes.get(
|
||||||
"/searchTrashProjects",
|
"/searchTrashProjects",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
searchTrashProjectController
|
searchTrashProjectController
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ import {
|
|||||||
ViewData,
|
ViewData,
|
||||||
} from "../../V1/v1Controllers/projectController/v1projectController.ts";
|
} from "../../V1/v1Controllers/projectController/v1projectController.ts";
|
||||||
import { tokenValidator } from "../../../shared/utils/token.ts";
|
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||||
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
|
||||||
|
|
||||||
const v1projectRouter = express.Router();
|
const v1projectRouter = express.Router();
|
||||||
|
|
||||||
// project
|
|
||||||
v1projectRouter.post("/NewProject", tokenValidator, createProjectController);
|
v1projectRouter.post("/NewProject", tokenValidator, createProjectController);
|
||||||
v1projectRouter.post(
|
v1projectRouter.post(
|
||||||
"/project/Duplicate",
|
"/project/Duplicate",
|
||||||
@@ -22,26 +20,22 @@ v1projectRouter.post(
|
|||||||
v1projectRouter.get(
|
v1projectRouter.get(
|
||||||
"/Projects",
|
"/Projects",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetProjects
|
GetProjects
|
||||||
);
|
);
|
||||||
v1projectRouter.patch(
|
v1projectRouter.patch(
|
||||||
"/Projects/Archive/:projectId",
|
"/Projects/Archive/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
RemoveProject
|
RemoveProject
|
||||||
);
|
);
|
||||||
|
|
||||||
v1projectRouter.patch(
|
v1projectRouter.patch(
|
||||||
"/Projects/:projectId",
|
"/Projects/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
updateProjectController
|
updateProjectController
|
||||||
);
|
);
|
||||||
v1projectRouter.get(
|
v1projectRouter.get(
|
||||||
"/Project/:projectId",
|
"/Project/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
ViewData
|
ViewData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -8,24 +8,20 @@ import {
|
|||||||
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
|
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
|
||||||
|
|
||||||
const v1TrashRoutes = express.Router();
|
const v1TrashRoutes = express.Router();
|
||||||
//trash
|
|
||||||
v1TrashRoutes.get(
|
v1TrashRoutes.get(
|
||||||
"/TrashItems",
|
"/TrashItems",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetTrashList
|
GetTrashList
|
||||||
);
|
);
|
||||||
|
|
||||||
v1TrashRoutes.patch(
|
v1TrashRoutes.patch(
|
||||||
"/Trash/restore",
|
"/Trash/restore",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
RestoreTrash
|
RestoreTrash
|
||||||
);
|
);
|
||||||
v1TrashRoutes.patch(
|
v1TrashRoutes.patch(
|
||||||
"/Trash/Delete",
|
"/Trash/Delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DeleteTrashData
|
DeleteTrashData
|
||||||
);
|
);
|
||||||
export default v1TrashRoutes;
|
export default v1TrashRoutes;
|
||||||
|
|||||||
@@ -10,35 +10,29 @@ import {
|
|||||||
|
|
||||||
const v1FloatWidget = express.Router();
|
const v1FloatWidget = express.Router();
|
||||||
|
|
||||||
//floatWidget-Page
|
|
||||||
v1FloatWidget.post(
|
v1FloatWidget.post(
|
||||||
"/floatWidget/save",
|
"/floatWidget/save",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
FloatAddController
|
FloatAddController
|
||||||
);
|
);
|
||||||
v1FloatWidget.patch(
|
v1FloatWidget.patch(
|
||||||
"/floatWidget/delete",
|
"/floatWidget/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DeleteFloatController
|
DeleteFloatController
|
||||||
);
|
);
|
||||||
v1FloatWidget.get(
|
v1FloatWidget.get(
|
||||||
"/floatWidgets/:zoneId/:projectId",
|
"/floatWidgets/:zoneId/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetFloatController
|
GetFloatController
|
||||||
);
|
);
|
||||||
v1FloatWidget.get(
|
v1FloatWidget.get(
|
||||||
"/floatWidget/:floatWidgetId",
|
"/floatWidget/:floatWidgetId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
SingleFloatController
|
SingleFloatController
|
||||||
);
|
);
|
||||||
v1FloatWidget.post(
|
v1FloatWidget.post(
|
||||||
"/floatWidget/duplicate",
|
"/floatWidget/duplicate",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DuplicateFloatController
|
DuplicateFloatController
|
||||||
);
|
);
|
||||||
export default v1FloatWidget;
|
export default v1FloatWidget;
|
||||||
|
|||||||
@@ -9,29 +9,24 @@ import {
|
|||||||
|
|
||||||
const v1Template = express.Router();
|
const v1Template = express.Router();
|
||||||
|
|
||||||
//template-Page
|
|
||||||
v1Template.post(
|
v1Template.post(
|
||||||
"/template/save",
|
"/template/save",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
AddTemplateController
|
AddTemplateController
|
||||||
);
|
);
|
||||||
v1Template.post(
|
v1Template.post(
|
||||||
"/template/toZone",
|
"/template/toZone",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
AddTemToZoneController
|
AddTemToZoneController
|
||||||
);
|
);
|
||||||
v1Template.get(
|
v1Template.get(
|
||||||
"/template/data/:projectId",
|
"/template/data/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetTemplateController
|
GetTemplateController
|
||||||
);
|
);
|
||||||
v1Template.patch(
|
v1Template.patch(
|
||||||
"/template/delete",
|
"/template/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
TemplateDeleteController
|
TemplateDeleteController
|
||||||
);
|
);
|
||||||
export default v1Template;
|
export default v1Template;
|
||||||
|
|||||||
@@ -8,23 +8,19 @@ import {
|
|||||||
|
|
||||||
const v1PanelRoutes = express.Router();
|
const v1PanelRoutes = express.Router();
|
||||||
|
|
||||||
//panel-Page
|
|
||||||
v1PanelRoutes.post(
|
v1PanelRoutes.post(
|
||||||
"/panel/save",
|
"/panel/save",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
AddPanelController
|
AddPanelController
|
||||||
);
|
);
|
||||||
v1PanelRoutes.patch(
|
v1PanelRoutes.patch(
|
||||||
"/panel/delete",
|
"/panel/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
DeletePanelController
|
DeletePanelController
|
||||||
);
|
);
|
||||||
v1PanelRoutes.patch(
|
v1PanelRoutes.patch(
|
||||||
"/panel/clear",
|
"/panel/clear",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
ClearPanelController
|
ClearPanelController
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -10,29 +10,26 @@ import {
|
|||||||
|
|
||||||
const v1Widget3d = express.Router();
|
const v1Widget3d = express.Router();
|
||||||
|
|
||||||
//widget3d-Page
|
|
||||||
v1Widget3d.post(
|
v1Widget3d.post(
|
||||||
"/widget3d/save",
|
"/widget3d/save",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
Add3dWidgetController
|
Add3dWidgetController
|
||||||
);
|
);
|
||||||
v1Widget3d.patch(
|
v1Widget3d.patch(
|
||||||
"/widget3d/update",
|
"/widget3d/update",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
Update3DwidgetController
|
Update3DwidgetController
|
||||||
);
|
);
|
||||||
v1Widget3d.get(
|
v1Widget3d.get(
|
||||||
"/widget3d/data/:zoneId/:projectId",
|
"/widget3d/data/:zoneId/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
Get3DWidgetController
|
Get3DWidgetController
|
||||||
);
|
);
|
||||||
v1Widget3d.patch(
|
v1Widget3d.patch(
|
||||||
"/widget3d/delete",
|
"/widget3d/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
Delete3DwidgetController
|
Delete3DwidgetController
|
||||||
);
|
);
|
||||||
export default v1Widget3d;
|
export default v1Widget3d;
|
||||||
|
|||||||
@@ -9,29 +9,24 @@ import {
|
|||||||
|
|
||||||
const v1Widget = express.Router();
|
const v1Widget = express.Router();
|
||||||
|
|
||||||
//widget-Page
|
|
||||||
v1Widget.post(
|
v1Widget.post(
|
||||||
"/widget/save",
|
"/widget/save",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
AddWidgetController
|
AddWidgetController
|
||||||
);
|
);
|
||||||
v1Widget.patch(
|
v1Widget.patch(
|
||||||
"/widget/:widgetID",
|
"/widget/:widgetID",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
WidgetUpdateController
|
WidgetUpdateController
|
||||||
);
|
);
|
||||||
v1Widget.get(
|
v1Widget.get(
|
||||||
"/widget/data",
|
"/widget/data",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
GetWidgetController
|
GetWidgetController
|
||||||
);
|
);
|
||||||
v1Widget.patch(
|
v1Widget.patch(
|
||||||
"/widget/delete",
|
"/widget/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
// authorizedRoles("Admin", "User"),
|
|
||||||
WidgetDeleteController
|
WidgetDeleteController
|
||||||
);
|
);
|
||||||
export default v1Widget;
|
export default v1Widget;
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import flooritemRoutes from "./Routes/flooritem-Routes.ts";
|
|||||||
import WallitemRoutes from "./Routes/wallItems-Routes.ts";
|
import WallitemRoutes from "./Routes/wallItems-Routes.ts";
|
||||||
import userRoutes from "./Routes/user-Routes.ts";
|
import userRoutes from "./Routes/user-Routes.ts";
|
||||||
import shareRoutes from "./Routes/share-Routes.ts";
|
import shareRoutes from "./Routes/share-Routes.ts";
|
||||||
import zoneRoutes from "./Routes/zoneRoutes.ts"; //update
|
import zoneRoutes from "./Routes/zone-Routes.ts";
|
||||||
|
import zoneRoutes2 from "./Routes/zoneRoutes.ts";
|
||||||
import panelRouter from "./Routes/panelRoutes.ts";
|
import panelRouter from "./Routes/panelRoutes.ts";
|
||||||
import widgetRouter from "./Routes/widgetRoute.ts";
|
import widgetRouter from "./Routes/widgetRoute.ts";
|
||||||
import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
||||||
@@ -35,51 +36,20 @@ import v1PanelRoutes from "./V1/v1Routes/vizRoutes.ts/v1-panelRoutes.ts";
|
|||||||
import v1Template from "./V1/v1Routes/vizRoutes.ts/v1-TemplateRoutes.ts";
|
import v1Template from "./V1/v1Routes/vizRoutes.ts/v1-TemplateRoutes.ts";
|
||||||
import v1Widget from "./V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts";
|
import v1Widget from "./V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts";
|
||||||
import v1Widget3d from "./V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts";
|
import v1Widget3d from "./V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts";
|
||||||
// import productFlowRoutes from "./Routes/productFlowRouts.ts";
|
|
||||||
redis;
|
redis;
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
// const allowedOriginsDev = [
|
|
||||||
// "http://localhost:3000",
|
|
||||||
// "http://192.168.0.183:8200",
|
|
||||||
// "http://192.168.0.101:8200",
|
|
||||||
// "http://192.168.0.105:8200",
|
|
||||||
// "http://192.168.0.134:8200"
|
|
||||||
// ];
|
|
||||||
// const allowedOrigin =
|
|
||||||
// process.env.NODE_ENV === "production"
|
|
||||||
// ? process.env.FRONTEND_ORIGIN_PROD
|
|
||||||
// : allowedOriginsDev;
|
|
||||||
// app.use(cors({
|
|
||||||
// origin: (origin, callback) => {
|
|
||||||
// if (!origin) return callback(null, true);
|
|
||||||
// if (
|
|
||||||
// Array.isArray(allowedOrigin) &&
|
|
||||||
// allowedOrigin.includes(origin)
|
|
||||||
// ) {
|
|
||||||
// return callback(null, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (typeof allowedOrigin === "string" && origin === allowedOrigin) {
|
|
||||||
// return callback(null, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return callback(new Error("Not allowed by CORS"));
|
|
||||||
// },
|
|
||||||
// credentials: true
|
|
||||||
// }));
|
|
||||||
|
|
||||||
app.use(express.json({ limit: "50mb" }));
|
app.use(express.json({ limit: "50mb" }));
|
||||||
app.use(
|
app.use(
|
||||||
express.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 })
|
express.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 })
|
||||||
);
|
);
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
app.use(cors());
|
||||||
|
app.use(express.json());
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.send("Hello, I am Major-Dwinzo API!");
|
res.send("Hello, I am Major-Dwinzo API!");
|
||||||
});
|
});
|
||||||
app.get("/health", (req, res) => {
|
|
||||||
res.status(200).json({ message: "Server is running" });
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use("/api/v1", cameraRoutes);
|
app.use("/api/v1", cameraRoutes);
|
||||||
app.use("/api/v1", environmentsRoutes);
|
app.use("/api/v1", environmentsRoutes);
|
||||||
@@ -88,8 +58,9 @@ app.use("/api/v1", flooritemRoutes);
|
|||||||
app.use("/api/v1", WallitemRoutes);
|
app.use("/api/v1", WallitemRoutes);
|
||||||
app.use("/api/v1", userRoutes);
|
app.use("/api/v1", userRoutes);
|
||||||
app.use("/api/v1", shareRoutes);
|
app.use("/api/v1", shareRoutes);
|
||||||
//update
|
app.use("/api/v2", zoneRoutes);
|
||||||
app.use("/api/v2", zoneRoutes); //updates
|
|
||||||
|
app.use("/api/v2", zoneRoutes2);
|
||||||
app.use("/api/v2", panelRouter);
|
app.use("/api/v2", panelRouter);
|
||||||
app.use("/api/v2", widgetRouter);
|
app.use("/api/v2", widgetRouter);
|
||||||
app.use("/api/v2", assetpointRouter);
|
app.use("/api/v2", assetpointRouter);
|
||||||
@@ -98,12 +69,10 @@ app.use("/api/v2", floadWidgetRoutes);
|
|||||||
app.use("/api/v2", templateRoutes);
|
app.use("/api/v2", templateRoutes);
|
||||||
app.use("/api/v2", widget3dRoutes);
|
app.use("/api/v2", widget3dRoutes);
|
||||||
app.use("/api/v2", productRouter);
|
app.use("/api/v2", productRouter);
|
||||||
// app.use("/api/v2", productFlowRoutes);
|
|
||||||
app.use("/api/v1", projectRouter);
|
app.use("/api/v1", projectRouter);
|
||||||
app.use("/api/v1", trashRouter);
|
app.use("/api/v1", trashRouter);
|
||||||
app.use("/api/v1", homePageRouter);
|
app.use("/api/v1", homePageRouter);
|
||||||
|
|
||||||
//New versions--based on the token and role based
|
|
||||||
app.use("/api/V1", Authrouter);
|
app.use("/api/V1", Authrouter);
|
||||||
app.use("/api/V1", v1projectRouter);
|
app.use("/api/V1", v1projectRouter);
|
||||||
app.use("/api/V1", v1TrashRoutes);
|
app.use("/api/V1", v1TrashRoutes);
|
||||||
|
|||||||
@@ -48,9 +48,7 @@ export class FloorItems {
|
|||||||
res.status(201).json(newValue);
|
res.status(201).json(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating flooritems:", error);
|
|
||||||
res.status(500).json({ message: "Failed to create flooritems" });
|
res.status(500).json({ message: "Failed to create flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +63,6 @@ export class FloorItems {
|
|||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get flooritems:", error);
|
|
||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,7 +80,6 @@ export class FloorItems {
|
|||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get flooritems:", error);
|
|
||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ interface IPointStaticMachine extends IPointBase {
|
|||||||
export class PointService {
|
export class PointService {
|
||||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||||
const { type, modelfileID, organization } = req.body;
|
const { type, modelfileID, organization } = req.body;
|
||||||
|
|
||||||
// Validate type
|
|
||||||
if (!["Conveyor", "Vehicle", "ArmBot", "StaticMachine"].includes(type)) {
|
if (!["Conveyor", "Vehicle", "ArmBot", "StaticMachine"].includes(type)) {
|
||||||
return res.status(400).json({ message: "Invalid type requested" });
|
return res.status(400).json({ message: "Invalid type requested" });
|
||||||
}
|
}
|
||||||
@@ -92,7 +90,6 @@ export class PointService {
|
|||||||
|
|
||||||
if (type === "Conveyor") {
|
if (type === "Conveyor") {
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "672a090f80d91ac979f4d0bd",
|
|
||||||
modelfileID: "7dc04e36882e4debbc1a8e3d",
|
modelfileID: "7dc04e36882e4debbc1a8e3d",
|
||||||
type: "Conveyor",
|
type: "Conveyor",
|
||||||
};
|
};
|
||||||
@@ -118,8 +115,6 @@ export class PointService {
|
|||||||
name: "trigger 1",
|
name: "trigger 1",
|
||||||
type: "triggerType",
|
type: "triggerType",
|
||||||
bufferTime: 0,
|
bufferTime: 0,
|
||||||
// delay: "Inherit",
|
|
||||||
// spawnInterval: "Inherit",
|
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -195,7 +190,6 @@ export class PointService {
|
|||||||
} else if (type === "Vehicle") {
|
} else if (type === "Vehicle") {
|
||||||
console.log("vehcile data");
|
console.log("vehcile data");
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "67e3da19c2e8f37134526e6a",
|
|
||||||
modelfileID: "a1ee92554935007b10b3eb05",
|
modelfileID: "a1ee92554935007b10b3eb05",
|
||||||
type: "Vehicle",
|
type: "Vehicle",
|
||||||
};
|
};
|
||||||
@@ -231,7 +225,6 @@ export class PointService {
|
|||||||
} else if (type === "ArmBot") {
|
} else if (type === "ArmBot") {
|
||||||
console.log("ArmBot data");
|
console.log("ArmBot data");
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "67eb7904c2e8f37134527eae",
|
|
||||||
modelfileID: "52e6681fbb743a890d96c914",
|
modelfileID: "52e6681fbb743a890d96c914",
|
||||||
type: "ArmBot",
|
type: "ArmBot",
|
||||||
};
|
};
|
||||||
@@ -269,7 +262,6 @@ export class PointService {
|
|||||||
} else if (type === "StaticMachine") {
|
} else if (type === "StaticMachine") {
|
||||||
console.log("StaticMachine data");
|
console.log("StaticMachine data");
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "67e3db5ac2e8f37134526f40",
|
|
||||||
modelfileID: "ca164ffdfa74f6622536bb0f",
|
modelfileID: "ca164ffdfa74f6622536bb0f",
|
||||||
type: "StaticMachine",
|
type: "StaticMachine",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class WallItems {
|
|||||||
quaternion,
|
quaternion,
|
||||||
scale,
|
scale,
|
||||||
},
|
},
|
||||||
{ new: true } // Return the updated document
|
{ new: true }
|
||||||
);
|
);
|
||||||
res.status(201).json(updatevalue);
|
res.status(201).json(updatevalue);
|
||||||
} else {
|
} else {
|
||||||
@@ -49,8 +49,6 @@ export class WallItems {
|
|||||||
|
|
||||||
res.status(201).json(newValue);
|
res.status(201).json(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating wallitems:", error);
|
console.error("Error creating wallitems:", error);
|
||||||
res.status(500).json({ message: "Failed to create wallitems" });
|
res.status(500).json({ message: "Failed to create wallitems" });
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ export class Camera {
|
|||||||
|
|
||||||
res.status(201).json(newCamera);
|
res.status(201).json(newCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating camera:", error);
|
console.error("Error creating camera:", error);
|
||||||
res.status(500).json({ message: "Failed to create camera" });
|
res.status(500).json({ message: "Failed to create camera" });
|
||||||
@@ -38,7 +36,6 @@ export class Camera {
|
|||||||
static async getCamera(req: Request, res: Response) {
|
static async getCamera(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.params;
|
const { userId, organization } = req.params;
|
||||||
|
|
||||||
const findCamera = await cameraModel(organization).findOne({
|
const findCamera = await cameraModel(organization).findOne({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
});
|
});
|
||||||
@@ -79,8 +76,6 @@ export class Camera {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return null if no camera data is found for the user
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export class Environment {
|
|||||||
res.status(201).json(newValue);
|
res.status(201).json(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating environments:", error);
|
console.error("Error creating environments:", error);
|
||||||
res.status(500).json({ message: "Failed to create environments" });
|
res.status(500).json({ message: "Failed to create environments" });
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ export class Lines {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.status(201).json(newLine);
|
res.status(201).json(newLine);
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating Lines:", error);
|
console.error("Error creating Lines:", error);
|
||||||
res.status(500).json({ message: "Failed to create Lines" });
|
res.status(500).json({ message: "Failed to create Lines" });
|
||||||
@@ -22,16 +20,12 @@ export class Lines {
|
|||||||
static async updateLines(req: Request, res: Response) {
|
static async updateLines(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, uuid, position } = req.body;
|
const { organization, uuid, position } = req.body;
|
||||||
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
|
||||||
// Update the position of the line matching the uuid
|
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
const updateResult = await lineModel(organization).updateMany(
|
||||||
{ "line.uuid": uuid }, // Filter: Find the line with the given uuid
|
{ "line.uuid": uuid },
|
||||||
{ $set: { "line.$.position": position } } // Update the position and type
|
{ $set: { "line.$.position": position } }
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(201).json(updateResult);
|
res.status(201).json(updateResult);
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating Lines:", error);
|
console.error("Error creating Lines:", error);
|
||||||
res.status(500).json({ message: "Failed to create Lines" });
|
res.status(500).json({ message: "Failed to create Lines" });
|
||||||
@@ -54,9 +48,10 @@ export class Lines {
|
|||||||
}
|
}
|
||||||
static async deleteLineItems(req: Request, res: Response) {
|
static async deleteLineItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, layer, line, type } = req.body;
|
const { organization, line } = req.body;
|
||||||
|
|
||||||
const inputUuids = line.map((item: any) => item.uuid);
|
const inputUuids = line.map((item: any) => item.uuid);
|
||||||
|
|
||||||
const findValue = await lineModel(organization).findOneAndDelete({
|
const findValue = await lineModel(organization).findOneAndDelete({
|
||||||
"line.uuid": { $all: inputUuids },
|
"line.uuid": { $all: inputUuids },
|
||||||
});
|
});
|
||||||
@@ -73,7 +68,7 @@ export class Lines {
|
|||||||
}
|
}
|
||||||
static async deleteLinPoiteItems(req: Request, res: Response) {
|
static async deleteLinPoiteItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, layer, uuid, type } = req.body;
|
const { organization, uuid } = req.body;
|
||||||
|
|
||||||
const findValue = await lineModel(organization).deleteMany({
|
const findValue = await lineModel(organization).deleteMany({
|
||||||
"line.uuid": uuid,
|
"line.uuid": uuid,
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
||||||
export class zone {
|
export class Zone {
|
||||||
static async setZone(req: Request, res: Response) {
|
static async setZone(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, zoneData } = req.body;
|
const { organization, userId, zoneData } = req.body;
|
||||||
// console.log('req.body: ', req.body);
|
|
||||||
const zoneId = zoneData.zoneId;
|
const zoneId = zoneData.zoneId;
|
||||||
const points = zoneData.points;
|
const points = zoneData.points;
|
||||||
const zoneName = zoneData.zoneName;
|
const zoneName = zoneData.zoneName;
|
||||||
@@ -26,11 +25,13 @@ export class zone {
|
|||||||
{ new: true }
|
{ new: true }
|
||||||
)
|
)
|
||||||
.select("-_id -__v");
|
.select("-_id -__v");
|
||||||
res.status(201).json({
|
res
|
||||||
message: "zone updated",
|
.status(201)
|
||||||
data: updateZone,
|
.json({
|
||||||
organization: organization,
|
message: "zone updated",
|
||||||
});
|
data: updateZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const zoneCreate = await zoneModel(organization).create({
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
zoneId,
|
zoneId,
|
||||||
@@ -45,11 +46,13 @@ export class zone {
|
|||||||
.findById(zoneCreate._id)
|
.findById(zoneCreate._id)
|
||||||
.select("-_id -__v")
|
.select("-_id -__v")
|
||||||
.lean();
|
.lean();
|
||||||
res.status(201).json({
|
res
|
||||||
message: "zone created",
|
.status(201)
|
||||||
data: createdZone,
|
.json({
|
||||||
organization: organization,
|
message: "zone created",
|
||||||
});
|
data: createdZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("error: ", error);
|
console.log("error: ", error);
|
||||||
@@ -67,11 +70,13 @@ export class zone {
|
|||||||
const deleteZone = await zoneModel(organization)
|
const deleteZone = await zoneModel(organization)
|
||||||
.findOneAndDelete({ zoneId: zoneId, createBy: userId })
|
.findOneAndDelete({ zoneId: zoneId, createBy: userId })
|
||||||
.select("-_id -__v");
|
.select("-_id -__v");
|
||||||
res.status(201).json({
|
res
|
||||||
message: "zone deleted",
|
.status(201)
|
||||||
data: deleteZone,
|
.json({
|
||||||
organization: organization,
|
message: "zone deleted",
|
||||||
});
|
data: deleteZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
res.status(500).json({ message: "Invalid zone ID" });
|
res.status(500).json({ message: "Invalid zone ID" });
|
||||||
}
|
}
|
||||||
@@ -82,7 +87,7 @@ export class zone {
|
|||||||
}
|
}
|
||||||
static async getZones(req: Request, res: Response) {
|
static async getZones(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, userId } = req.params;
|
const { organization } = req.params;
|
||||||
|
|
||||||
const findZoneId = await zoneModel(organization)
|
const findZoneId = await zoneModel(organization)
|
||||||
.find()
|
.find()
|
||||||
@@ -93,7 +98,7 @@ export class zone {
|
|||||||
if (!findZoneId) {
|
if (!findZoneId) {
|
||||||
res.status(500).json({ message: "Invalid zone" });
|
res.status(500).json({ message: "Invalid zone" });
|
||||||
}
|
}
|
||||||
res.status(200).json({ data: findZoneId, organization: organization });
|
res.status(201).json({ data: findZoneId, organization: organization });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("error: ", error);
|
console.log("error: ", error);
|
||||||
res.status(500).json({ message: "Zone not found", error });
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
@@ -107,7 +112,6 @@ export class zone {
|
|||||||
const findZone = await zoneModel(organization).findOne({
|
const findZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
// .select("zoneName");
|
|
||||||
console.log("findZone: ", findZone);
|
console.log("findZone: ", findZone);
|
||||||
if (findZone) return res.status(200).json(findZone);
|
if (findZone) return res.status(200).json(findZone);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@@ -33,13 +33,6 @@ export class ZoneService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// const existingZoneName = await zoneSchema(organization).find({
|
|
||||||
// zoneName: zoneDatas.zoneName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (existingZoneName.length > 0) {
|
|
||||||
// return res.json({ message: "Zone name already exists" });
|
|
||||||
// }
|
|
||||||
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
|
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
|
||||||
{ zoneId: zoneDatas.zoneId, isArchive: false },
|
{ zoneId: zoneDatas.zoneId, isArchive: false },
|
||||||
{
|
{
|
||||||
@@ -96,7 +89,6 @@ export class ZoneService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//single zode panel and widget data
|
|
||||||
static async singleZonePanelDatas(req: Request, res: Response): Promise<any> {
|
static async singleZonePanelDatas(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.query.organization;
|
const organization = req.query.organization;
|
||||||
const zoneId = req.params.zoneId;
|
const zoneId = req.params.zoneId;
|
||||||
@@ -157,7 +149,6 @@ export class ZoneService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//page full zone Datas with panel and widget
|
|
||||||
static async vizAllDatas(req: Request, res: Response): Promise<any> {
|
static async vizAllDatas(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.query.organization;
|
const organization = req.query.organization;
|
||||||
try {
|
try {
|
||||||
@@ -173,13 +164,11 @@ export class ZoneService {
|
|||||||
} else {
|
} else {
|
||||||
const response = await Promise.all(
|
const response = await Promise.all(
|
||||||
existingZones.map(async (zone) => {
|
existingZones.map(async (zone) => {
|
||||||
// Fetch all panels associated with the current zone
|
|
||||||
const panelData = await panelSchema(organization).find({
|
const panelData = await panelSchema(organization).find({
|
||||||
zoneId: zone._id,
|
zoneId: zone._id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch widgets for each panel
|
|
||||||
const widgets = await Promise.all(
|
const widgets = await Promise.all(
|
||||||
panelData.map(async (panel) => {
|
panelData.map(async (panel) => {
|
||||||
const widgetDataArray = await widgetSchema(organization).find({
|
const widgetDataArray = await widgetSchema(organization).find({
|
||||||
@@ -218,7 +207,6 @@ export class ZoneService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//only for the name and zoneID
|
|
||||||
static async allZones(req: Request, res: Response): Promise<any> {
|
static async allZones(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.query.organization;
|
const organization = req.query.organization;
|
||||||
const sceneID = req.params.sceneID || "scene123";
|
const sceneID = req.params.sceneID || "scene123";
|
||||||
@@ -244,7 +232,7 @@ export class ZoneService {
|
|||||||
const findZone = await zoneSchema(organization).findOne({
|
const findZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
// .select("zoneName");
|
|
||||||
if (findZone) return res.status(200).json(findZone);
|
if (findZone) return res.status(200).json(findZone);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
@@ -284,21 +272,4 @@ export class ZoneService {
|
|||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static async zoneIdgenerate(req: Request, res: Response): Promise<any> {
|
|
||||||
// const organization = req.query.organization;
|
|
||||||
// const sceneID = req.params.sceneID;
|
|
||||||
// try {
|
|
||||||
// const Allzones = await zoneSchema(organization)
|
|
||||||
// .find({ sceneID: sceneID, isArchive: false })
|
|
||||||
// .select("zoneName sceneID zoneId");
|
|
||||||
|
|
||||||
// if (!Allzones || Allzones.length === 0) {
|
|
||||||
// return res.send({ message: "Zone not found for the UUID" });
|
|
||||||
// }
|
|
||||||
// return res.send(Allzones);
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return res.status(500).send(error.message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export class Share {
|
|||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(404).json({ message: "Not found" });
|
res.status(404).json({ message: "Not found" });
|
||||||
}
|
}
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating Share:", error);
|
console.error("Error creating Share:", error);
|
||||||
res.status(500).json({ message: "Failed to create Share" });
|
res.status(500).json({ message: "Failed to create Share" });
|
||||||
@@ -37,7 +36,6 @@ export class Share {
|
|||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(404).json({ message: "Not found" });
|
res.status(404).json({ message: "Not found" });
|
||||||
}
|
}
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error Share:", error);
|
console.error("Error Share:", error);
|
||||||
res.status(500).json({ message: "Failed to Share datas " });
|
res.status(500).json({ message: "Failed to Share datas " });
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ export class AssetsFloorService {
|
|||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
organization,
|
organization,
|
||||||
// modelfileID, //optional
|
|
||||||
// eventData, // Optional
|
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
const existingAsset = await assetModel(organization).findOne({
|
const existingAsset = await assetModel(organization).findOne({
|
||||||
@@ -84,11 +82,9 @@ export class AssetsFloorService {
|
|||||||
organization,
|
organization,
|
||||||
eventData,
|
eventData,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
console.log("req.body: ", req.body);
|
|
||||||
|
|
||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modelUuid,
|
modelUuid,
|
||||||
// modelName,
|
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
await pointModel(organization).findOne({
|
await pointModel(organization).findOne({
|
||||||
@@ -207,14 +203,11 @@ export class AssetsFloorService {
|
|||||||
return res.status(500).json({ message: "Failed to archive asset" });
|
return res.status(500).json({ message: "Failed to archive asset" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
await EventsDataModel(organization).updateMany(
|
||||||
{ modelUuid },
|
{ modelUuid },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("Archived asset:", archivedAsset);
|
|
||||||
console.log("Updated events:", updatedEvents.modifiedCount);
|
|
||||||
|
|
||||||
return res.status(200).json({ message: "delete Asset successfully" });
|
return res.status(200).json({ message: "delete Asset successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error deleting floor items:", error);
|
console.error("Error deleting floor items:", error);
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import { Request, Response } from "express";
|
|||||||
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
||||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||||
|
|
||||||
export class ProductFlowservice {
|
export class ProductFlowService {
|
||||||
static async productAdd(req: Request, res: Response): Promise<any> {
|
static async productAdd(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productName, productId,eventDatas, organization } = req.body;
|
const { productName, productId, eventDatas, organization } = req.body;
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
return res.json({ message: "organization not found" });
|
return res.json({ message: "organization not found" });
|
||||||
}
|
}
|
||||||
@@ -136,12 +136,10 @@ export class ProductFlowservice {
|
|||||||
productId: productId,
|
productId: productId,
|
||||||
});
|
});
|
||||||
if (existingEventDatas) {
|
if (existingEventDatas) {
|
||||||
// for (const event of existingEventDatas) {
|
await EventsDataModel(organization).updateMany(
|
||||||
await EventsDataModel(organization).updateMany(
|
{ productId },
|
||||||
{ productId },
|
{ $set: { isArchive: true } }
|
||||||
{ $set: { isArchive: true } }
|
);
|
||||||
);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return res.status(201).json({ message: "product deleted successfully" });
|
return res.status(201).json({ message: "product deleted successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -197,11 +195,9 @@ export class ProductFlowservice {
|
|||||||
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
// product: {
|
|
||||||
productName: product.productName,
|
productName: product.productName,
|
||||||
productId: product.productId,
|
productId: product.productId,
|
||||||
eventDatas,
|
eventDatas,
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ export const GetTrashList = async (
|
|||||||
|
|
||||||
case "Success":
|
case "Success":
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
// message: "Project created Successfully",
|
|
||||||
TrashDatas: result.ListDatas,
|
TrashDatas: result.ListDatas,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,76 +1,72 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import userModel from "../../shared/model/user-Model.ts";
|
import userModel from "../../shared/model/user-Model.ts";
|
||||||
import {hashGenerate,hashValidator} from "../../shared/utils/Hasing.ts"
|
import { hashGenerate, hashValidator } from "../../shared/security/Hasing.ts";
|
||||||
|
|
||||||
let serverAlive = true;
|
|
||||||
export class User {
|
export class User {
|
||||||
static async signup(req: Request, res: Response) {
|
static async signup(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
let role;
|
let role;
|
||||||
const { userName, email, password,organization,profilePicture } = req.body;
|
const { userName, email, password, organization, profilePicture } =
|
||||||
const caseChange = email.toLowerCase();
|
req.body;
|
||||||
const emailcheck = await userModel(organization).findOne({ email: caseChange });
|
const caseChange = email.toLowerCase();
|
||||||
if (emailcheck!==null) {
|
const emailcheck = await userModel(organization).findOne({
|
||||||
res.json({
|
email: caseChange,
|
||||||
message:"User already exists"
|
});
|
||||||
});
|
if (emailcheck !== null) {
|
||||||
} else {
|
res.json({
|
||||||
const hashpassword=await hashGenerate(password)
|
message: "User already exists",
|
||||||
const userCount = await userModel(organization).countDocuments({});
|
});
|
||||||
role = userCount === 0 ? "Admin" : "User";
|
} else {
|
||||||
const isShare = "true";
|
const hashpassword = await hashGenerate(password);
|
||||||
const newuser = await userModel(organization).create({
|
const userCount = await userModel(organization).countDocuments({});
|
||||||
userName: userName,
|
role = userCount === 0 ? "Admin" : "User";
|
||||||
email: caseChange,
|
const isShare = "true";
|
||||||
isShare:isShare,
|
const newuser = await userModel(organization).create({
|
||||||
password: hashpassword,
|
userName: userName,
|
||||||
role:role,
|
email: caseChange,
|
||||||
profilePicture:profilePicture
|
isShare: isShare,
|
||||||
});
|
password: hashpassword,
|
||||||
newuser.save();
|
role: role,
|
||||||
res.status(200).json({
|
profilePicture: profilePicture,
|
||||||
message:"New User created"
|
});
|
||||||
});
|
newuser.save();
|
||||||
}
|
res.status(200).json({
|
||||||
} catch (error:any) {
|
message: "New User created",
|
||||||
res.status(500).send(error);
|
});
|
||||||
}
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
res.status(500).send(error);
|
||||||
}
|
}
|
||||||
static async login(req: Request, res: Response) {
|
}
|
||||||
try {
|
static async login(req: Request, res: Response) {
|
||||||
let role;
|
try {
|
||||||
const { email, password,organization } = req.body;
|
let role;
|
||||||
|
const { email, password, organization } = req.body;
|
||||||
|
const existingMail = await userModel(organization).findOne({
|
||||||
|
email: email,
|
||||||
|
});
|
||||||
|
|
||||||
const existingMail = await userModel(organization).findOne({
|
if (existingMail === null || !existingMail) {
|
||||||
email:email
|
res.status(401).json({ message: "User Not Found!!! Kindly signup..." });
|
||||||
});
|
} else {
|
||||||
|
const hashedpassword = existingMail.password;
|
||||||
if (existingMail === null || !existingMail) {
|
const checkpassword = await hashValidator(password, hashedpassword);
|
||||||
res.status(401).json({ message: "User Not Found!!! Kindly signup..." });
|
if (checkpassword) {
|
||||||
} else {
|
res.status(200).send({
|
||||||
const hashedpassword= existingMail.password
|
message: "login successfull",
|
||||||
const checkpassword = await hashValidator(
|
email: existingMail.email,
|
||||||
password,
|
name: existingMail.userName,
|
||||||
hashedpassword
|
userId: existingMail._id,
|
||||||
)
|
isShare: existingMail.isShare,
|
||||||
if (checkpassword) {
|
});
|
||||||
// const tokenValidation=await tokenGenerator(existingMail.email)
|
} else {
|
||||||
res.status(200).send({
|
res.status(404).json({
|
||||||
message: "login successfull",
|
message: "email & password is invalid...Check the credentials",
|
||||||
email: existingMail.email,
|
});
|
||||||
name: existingMail.userName,
|
}
|
||||||
userId: existingMail._id,
|
}
|
||||||
isShare:existingMail.isShare,
|
} catch (error: any) {
|
||||||
// token:tokenValidation
|
res.status(500).send(error);
|
||||||
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
res.status(404).json({message:"email & password is invalid...Check the credentials"})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error:any) {
|
|
||||||
res.status(500).send(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ export class PanelService {
|
|||||||
try {
|
try {
|
||||||
const organization = req.body.organization;
|
const organization = req.body.organization;
|
||||||
const zoneId = req.body.zoneId;
|
const zoneId = req.body.zoneId;
|
||||||
// const panelName = req.body.panelName;
|
|
||||||
const panelOrder = req.body.panelOrder;
|
const panelOrder = req.body.panelOrder;
|
||||||
const findZone = await zoneSchema(organization).findOne({
|
const findZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
|
|||||||
@@ -8,16 +8,7 @@ import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts
|
|||||||
export class TemplateService {
|
export class TemplateService {
|
||||||
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const {
|
const { organization, template } = req.body;
|
||||||
organization,
|
|
||||||
template,
|
|
||||||
// id,
|
|
||||||
// name,
|
|
||||||
// panelOrder,
|
|
||||||
// widgets,
|
|
||||||
// snapshot,
|
|
||||||
// floatWidgets,
|
|
||||||
} = req.body;
|
|
||||||
const existingTemplate = await templateModel(organization).findOne({
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
templateID: template.id,
|
templateID: template.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -83,7 +74,6 @@ export class TemplateService {
|
|||||||
if (existingZone.panelOrder.length > 0) {
|
if (existingZone.panelOrder.length > 0) {
|
||||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||||
await existingZone.save();
|
await existingZone.save();
|
||||||
// Clear existing data before adding new data
|
|
||||||
const archivePanelDatas = await panelSchema(organization).find({
|
const archivePanelDatas = await panelSchema(organization).find({
|
||||||
zoneId,
|
zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
|
|||||||
@@ -5,12 +5,7 @@ import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
|||||||
export class WidgetService {
|
export class WidgetService {
|
||||||
static async addWidget(req: Request, res: Response): Promise<any> {
|
static async addWidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const {
|
const { organization, zoneId, widget } = req.body;
|
||||||
organization,
|
|
||||||
// panel,
|
|
||||||
zoneId,
|
|
||||||
widget,
|
|
||||||
} = req.body;
|
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -30,7 +25,6 @@ export class WidgetService {
|
|||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
// widgetOrder: widget.widgetOrder,
|
|
||||||
});
|
});
|
||||||
if (existingWidget) {
|
if (existingWidget) {
|
||||||
const updateWidget = await widgetSchema(
|
const updateWidget = await widgetSchema(
|
||||||
@@ -43,8 +37,6 @@ export class WidgetService {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
// panelID: existingPanel._id,
|
|
||||||
// widgetID: widget.id,
|
|
||||||
widgetName: widget?.widgetName,
|
widgetName: widget?.widgetName,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements || {},
|
measurements: widget?.Data?.measurements || {},
|
||||||
@@ -53,7 +45,7 @@ export class WidgetService {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
{ upsert: true, new: true }
|
||||||
);
|
);
|
||||||
if (!updateWidget) {
|
if (!updateWidget) {
|
||||||
return res.json({ message: "Widget update unsuccessful" });
|
return res.json({ message: "Widget update unsuccessful" });
|
||||||
@@ -65,7 +57,6 @@ export class WidgetService {
|
|||||||
const newWidget = await widgetSchema(organization).create({
|
const newWidget = await widgetSchema(organization).create({
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
elementType: widget.type,
|
elementType: widget.type,
|
||||||
// widgetOrder: widgetOrder,
|
|
||||||
zoneId,
|
zoneId,
|
||||||
widgetName: widget.title,
|
widgetName: widget.title,
|
||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
@@ -80,7 +71,6 @@ export class WidgetService {
|
|||||||
await existingPanel.save();
|
await existingPanel.save();
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
message: "Widget created successfully",
|
message: "Widget created successfully",
|
||||||
// widgetID: newWidget._id,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,19 +96,11 @@ export class WidgetService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
// Find all widgets in the same panel and sort them by widgetOrder
|
|
||||||
await widgetSchema(organization).find({
|
await widgetSchema(organization).find({
|
||||||
panelID: findWidget.panelID,
|
panelID: findWidget.panelID,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
// .sort({ widgetOrder: 1 });
|
|
||||||
|
|
||||||
// Reassign widgetOrder values
|
|
||||||
// for (let i = 0; i < widgets.length; i++) {
|
|
||||||
// widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
|
||||||
// await widgets[i].save();
|
|
||||||
// }
|
|
||||||
const panelData = await panelSchema(organization).findOne({
|
const panelData = await panelSchema(organization).findOne({
|
||||||
_id: findWidget.panelID,
|
_id: findWidget.panelID,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -147,7 +129,7 @@ export class WidgetService {
|
|||||||
return res.status(404).send({ message: "Data not found" });
|
return res.status(404).send({ message: "Data not found" });
|
||||||
const updateData = {
|
const updateData = {
|
||||||
widgetName: values.widgetName,
|
widgetName: values.widgetName,
|
||||||
widgetSide: values.widgetSide, // Fixed typo from widgetside to widgetSide
|
widgetSide: values.widgetSide,
|
||||||
elementType: values.type,
|
elementType: values.type,
|
||||||
Data: {
|
Data: {
|
||||||
measurement: values.Data.measurement,
|
measurement: values.Data.measurement,
|
||||||
|
|||||||
@@ -1,36 +1,25 @@
|
|||||||
import app from './app.ts';
|
import app from "./app.ts";
|
||||||
import http from 'http';
|
import http from "http";
|
||||||
|
import swaggerUi from "swagger-ui-express";
|
||||||
// import { startHealthCheck } from './controller/user-Controller';
|
import fs from "fs";
|
||||||
import swaggerUi from 'swagger-ui-express';
|
|
||||||
import fs from 'fs';
|
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
|
|
||||||
let swaggerDocument = {};
|
let swaggerDocument = {};
|
||||||
// try {
|
|
||||||
// swaggerDocument = require('../../swagger-output.json');
|
|
||||||
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('Error loading Swagger JSON:', error);
|
|
||||||
// swaggerDocument = {}; // Fallback: empty object or some default
|
|
||||||
// }
|
|
||||||
try {
|
try {
|
||||||
swaggerDocument = JSON.parse(fs.readFileSync('swagger-output.json', 'utf-8'));
|
swaggerDocument = JSON.parse(fs.readFileSync("swagger-output.json", "utf-8"));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading Swagger JSON:', error);
|
console.error("Error loading Swagger JSON:", error);
|
||||||
}
|
}
|
||||||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||||
const organization = process.env.ORGANIZATION_NAME || 'defaultOrganization'; // Replace with your logic
|
const organization = process.env.ORGANIZATION_NAME || "defaultOrganization";
|
||||||
|
|
||||||
// mongoAdminCreation()
|
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
throw new Error('ORGANIZATION_NAME is not defined in the environment');
|
throw new Error("ORGANIZATION_NAME is not defined in the environment");
|
||||||
}
|
}
|
||||||
|
|
||||||
const PORT = process.env.API_PORT
|
const PORT = process.env.API_PORT;
|
||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
console.log(`API-Server running on http://localhost:${PORT}`);
|
console.log(`API-Server running on http://localhost:${PORT}`);
|
||||||
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
|
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ const UserDataSchema: Schema = new Schema({
|
|||||||
},
|
},
|
||||||
profilePicture: {
|
profilePicture: {
|
||||||
type: String,
|
type: String,
|
||||||
// default: "default-profile-picture.jpg"
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ const AuthSchema: Schema = new Schema({
|
|||||||
Password: {
|
Password: {
|
||||||
type: String,
|
type: String,
|
||||||
min: 8,
|
min: 8,
|
||||||
// required: true,
|
|
||||||
},
|
},
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
lastPasswordReset: { type: Number },
|
lastPasswordReset: { type: Number },
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export interface AssetData extends Document {
|
|||||||
type: string;
|
type: string;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
isArchive: false;
|
isArchive: false;
|
||||||
// points: [] | {};
|
|
||||||
position: [];
|
position: [];
|
||||||
rotation: {
|
rotation: {
|
||||||
x: number;
|
x: number;
|
||||||
|
|||||||
@@ -1,26 +1,24 @@
|
|||||||
import mongoose, { Schema } from "mongoose";
|
import mongoose, { Schema } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
import { User } from "../Auth/userAuthModel.ts";
|
import { User } rom "../Version/versionModel.ts";
|
||||||
import { Project } from "../Project/project-model.ts";
|
|
||||||
import { Version } from "../Version/versionModel.ts";
|
|
||||||
const positionSchema = new mongoose.Schema({
|
const positionSchema = new mongoose.Schema({
|
||||||
x: { type: Number }, // Optional position fields
|
x: { type: Number },
|
||||||
y: { type: Number },
|
y: { type: Number },
|
||||||
z: { type: Number },
|
z: { type: Number },
|
||||||
});
|
});
|
||||||
|
|
||||||
const Vector3 = new mongoose.Schema({
|
const Vector3 = new mongoose.Schema({
|
||||||
position: { type: positionSchema, required: false }, // Optional position
|
position: { type: positionSchema, required: false },
|
||||||
uuid: { type: String, required: false }, // Optional uuid
|
uuid: { type: String, required: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const LineSchema = new mongoose.Schema({
|
const LineSchema = new mongoose.Schema({
|
||||||
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
layer: { type: Number, required: true }, // Layer is mandatory
|
layer: { type: Number, required: true },
|
||||||
line: { type: [Vector3], required: true }, // Array of line objects
|
line: { type: [Vector3], required: true },
|
||||||
type: { type: String, required: false }, // Optional type
|
type: { type: String, required: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const lineModel = (db: string) => {
|
const lineModel = (db: string) => {
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ const zoneSchema: Schema = new Schema(
|
|||||||
default: [],
|
default: [],
|
||||||
enum: ["left", "right", "top", "bottom"],
|
enum: ["left", "right", "top", "bottom"],
|
||||||
},
|
},
|
||||||
// createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
|
|
||||||
// sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
|
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// models/Product.ts
|
|
||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
@@ -118,13 +117,11 @@ interface RoboticArmEventSchema extends AssetEventSchema {
|
|||||||
|
|
||||||
interface MachineEventSchema extends AssetEventSchema {
|
interface MachineEventSchema extends AssetEventSchema {
|
||||||
type: "machine";
|
type: "machine";
|
||||||
// speed: number;
|
|
||||||
point: MachinePointSchema;
|
point: MachinePointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StorageEventSchema extends AssetEventSchema {
|
interface StorageEventSchema extends AssetEventSchema {
|
||||||
type: "storageUnit";
|
type: "storageUnit";
|
||||||
// speed: number;
|
|
||||||
point: StoragePointSchema;
|
point: StoragePointSchema;
|
||||||
}
|
}
|
||||||
interface IPointModel extends Document {
|
interface IPointModel extends Document {
|
||||||
@@ -144,7 +141,6 @@ interface IPointModel extends Document {
|
|||||||
| StorageEventSchema;
|
| StorageEventSchema;
|
||||||
points: ConveyorEventSchema[];
|
points: ConveyorEventSchema[];
|
||||||
}
|
}
|
||||||
// type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;
|
|
||||||
|
|
||||||
const BaseEventSchema = new Schema<IPointModel>(
|
const BaseEventSchema = new Schema<IPointModel>(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import { Version } from "../Version/versionModel.ts";
|
|||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
interface IComment {
|
interface IComment {
|
||||||
userId: User["_id"];
|
userId: User["_id"];
|
||||||
// createdAt: string;
|
|
||||||
comment: string;
|
comment: string;
|
||||||
// lastUpdatedAt: string;
|
|
||||||
timestamp:Number
|
timestamp:Number
|
||||||
}
|
}
|
||||||
export interface IThread extends Document {
|
export interface IThread extends Document {
|
||||||
@@ -26,14 +24,11 @@ export interface IThread extends Document {
|
|||||||
const CommentSchema = new Schema<IComment>(
|
const CommentSchema = new Schema<IComment>(
|
||||||
{
|
{
|
||||||
userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||||
// createdAt: { type: String, },
|
|
||||||
comment: { type: String,},
|
comment: { type: String,},
|
||||||
// lastUpdatedAt: { type: String, },
|
|
||||||
timestamp:{
|
timestamp:{
|
||||||
type: Number,
|
type: Number,
|
||||||
default:Date.now()}
|
default:Date.now()}
|
||||||
},
|
},
|
||||||
// { _id: false } // Prevent automatic _id for each reply object
|
|
||||||
);
|
);
|
||||||
const threadSchema = new Schema<IThread>({
|
const threadSchema = new Schema<IThread>({
|
||||||
projectId: { type: Schema.Types.ObjectId, ref: 'Project', required: true },
|
projectId: { type: Schema.Types.ObjectId, ref: 'Project', required: true },
|
||||||
|
|||||||
@@ -14,13 +14,12 @@ const MainModel = <T>(
|
|||||||
): Model<T> => {
|
): Model<T> => {
|
||||||
const db1_url = `${process.env.MONGO_URI}${db}`;
|
const db1_url = `${process.env.MONGO_URI}${db}`;
|
||||||
const authOptions = {
|
const authOptions = {
|
||||||
user: process.env.MONGO_USER, // Correct username environment variable
|
user: process.env.MONGO_USER,
|
||||||
pass: process.env.MONGO_PASSWORD, // Correct password environment variable
|
pass: process.env.MONGO_PASSWORD,
|
||||||
authSource: process.env.MONGO_AUTH_DB || "admin", // Default to 'admin' if not provided
|
authSource: process.env.MONGO_AUTH_DB || "admin",
|
||||||
maxPoolSize: 50,
|
maxPoolSize: 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if the connection already exists
|
|
||||||
if (connections[db]) {
|
if (connections[db]) {
|
||||||
return connections[db].model<T>(modelName, schema, collectionName);
|
return connections[db].model<T>(modelName, schema, collectionName);
|
||||||
}
|
}
|
||||||
@@ -28,10 +27,8 @@ const MainModel = <T>(
|
|||||||
try {
|
try {
|
||||||
const db1 = mongoose.createConnection(db1_url, authOptions);
|
const db1 = mongoose.createConnection(db1_url, authOptions);
|
||||||
|
|
||||||
// Cache the connection
|
|
||||||
connections[db] = db1;
|
connections[db] = db1;
|
||||||
|
|
||||||
// Log connection success or handle errors
|
|
||||||
db1.on("connected", () => {
|
db1.on("connected", () => {
|
||||||
console.log(`Connected to MongoDB database: ${db}`);
|
console.log(`Connected to MongoDB database: ${db}`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface FloorItems extends Document {
|
export interface FloorItenms extends Document {
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export interface AssetData extends Document {
|
|||||||
type: string;
|
type: string;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
isArchive: false;
|
isArchive: false;
|
||||||
// points: [] | {};
|
|
||||||
position: [];
|
position: [];
|
||||||
rotation: {
|
rotation: {
|
||||||
x: number;
|
x: number;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Camera extends Document {
|
export interface Camera extends Document {
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
const positionSchema = new mongoose.Schema({
|
const positionSchema = new mongoose.Schema({
|
||||||
x: { type: Number }, // Optional position fields
|
x: { type: Number },
|
||||||
y: { type: Number },
|
y: { type: Number },
|
||||||
z: { type: Number },
|
z: { type: Number },
|
||||||
});
|
});
|
||||||
|
|
||||||
const Vector3 = new mongoose.Schema({
|
const Vector3 = new mongoose.Schema({
|
||||||
position: { type: positionSchema, required: false }, // Optional position
|
position: { type: positionSchema, required: false },
|
||||||
uuid: { type: String, required: false }, // Optional uuid
|
uuid: { type: String, required: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const LineSchema = new mongoose.Schema({
|
const LineSchema = new mongoose.Schema({
|
||||||
layer: { type: Number, required: true }, // Layer is mandatory
|
layer: { type: Number, required: true },
|
||||||
line: { type: [Vector3], required: true }, // Array of line objects
|
line: { type: [Vector3], required: true },
|
||||||
type: { type: String, required: false }, // Optional type
|
type: { type: String, required: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const lineModel = (db: string) => {
|
const lineModel = (db: string) => {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
import { Schema, Document } from "mongoose";
|
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Zone extends Document {
|
export interface Zone extends Document {
|
||||||
@@ -13,8 +12,6 @@ export interface Zone extends Document {
|
|||||||
sceneID: string;
|
sceneID: string;
|
||||||
panelOrder: string[];
|
panelOrder: string[];
|
||||||
lockedPanel: string[];
|
lockedPanel: string[];
|
||||||
// createdBy: mongoose.Types.ObjectId;
|
|
||||||
// sceneID: mongoose.Types.ObjectId;
|
|
||||||
layer: number;
|
layer: number;
|
||||||
}
|
}
|
||||||
const zoneSchema: Schema = new Schema(
|
const zoneSchema: Schema = new Schema(
|
||||||
@@ -37,8 +34,6 @@ const zoneSchema: Schema = new Schema(
|
|||||||
default: [],
|
default: [],
|
||||||
enum: ["left", "right", "top", "bottom"],
|
enum: ["left", "right", "top", "bottom"],
|
||||||
},
|
},
|
||||||
// createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
|
|
||||||
// sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
|
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ export interface Camera extends Document {
|
|||||||
z: number;
|
z: number;
|
||||||
};
|
};
|
||||||
target: {
|
target: {
|
||||||
x: { type: Number; required: true };
|
x: { type: number; required: true };
|
||||||
y: { type: Number; required: true };
|
y: { type: number; required: true };
|
||||||
z: { type: Number; required: true };
|
z: { type: number; required: true };
|
||||||
};
|
};
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number; required: true };
|
x: { type: number; required: true };
|
||||||
y: { type: Number; required: true };
|
y: { type: number; required: true };
|
||||||
z: { type: Number; required: true };
|
z: { type: number; required: true };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,23 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
const positionSchema = new mongoose.Schema({
|
const positionSchema = new mongoose.Schema({
|
||||||
x: { type: Number, }, // Optional position fields
|
x: { type: Number },
|
||||||
y: { type: Number, },
|
y: { type: Number },
|
||||||
z: { type: Number},
|
z: { type: Number },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define a schema for the individual line
|
const Vector3 = new mongoose.Schema({
|
||||||
const Vector3 = new mongoose.Schema({
|
position: { type: positionSchema, required: false },
|
||||||
position: { type: positionSchema, required: false }, // Optional position
|
uuid: { type: String, required: false },
|
||||||
uuid: { type: String, required: false }, // Optional uuid
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Define the main schema
|
const LineSchema = new mongoose.Schema({
|
||||||
const LineSchema = new mongoose.Schema({
|
layer: { type: Number, required: true },
|
||||||
layer: { type: Number, required: true }, // Layer is mandatory
|
line: { type: [Vector3], required: true },
|
||||||
line: { type: [Vector3], required: true }, // Array of line objects
|
type: { type: String, required: false },
|
||||||
type: { type: String, required: false }, // Optional type
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Database connection and model creation
|
const lineModel = (db: string) => {
|
||||||
// const lineModel = (db: string) => {
|
return MainModel(db, "lines", LineSchema, "lines");
|
||||||
// const mongoUrl = process.env.MONGO_URI || "";
|
|
||||||
// if (!mongoUrl) {
|
|
||||||
// throw new Error("MONGO_URI environment variable is not set");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Connect to the database
|
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
||||||
// dbName: db, // Specify the database name here
|
|
||||||
// serverSelectionTimeoutMS: 30000,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Return the model
|
|
||||||
// return dbConnection.model("lines", LineSchema, "lines");
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export default lineModel;
|
|
||||||
const lineModel = (db:string) => {
|
|
||||||
return MainModel(db, "lines", LineSchema, "lines")
|
|
||||||
};
|
};
|
||||||
export default lineModel;
|
export default lineModel;
|
||||||
@@ -1,32 +1,28 @@
|
|||||||
import mongoose, { Document, ObjectId, Schema } from "mongoose";
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
export interface zoneSchema extends Document {
|
export interface ZoneSchema extends Document {
|
||||||
zoneId: string;//UUID
|
zoneId: string;
|
||||||
zoneName: string
|
zoneName: string;
|
||||||
createBy: mongoose.Types.ObjectId
|
createBy: mongoose.Types.ObjectId;
|
||||||
points: []
|
points: [];
|
||||||
layer: Number
|
layer: number;
|
||||||
viewPortCenter: []
|
viewPortCenter: [];
|
||||||
viewPortposition: []
|
viewPortposition: [];
|
||||||
isArchive:boolean
|
isArchive: boolean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const zoneSchema: Schema = new Schema({
|
const zoneSchema: Schema = new Schema({
|
||||||
zoneId: { type: String },//UUID
|
zoneId: { type: String },
|
||||||
zoneName: { type: String },
|
zoneName: { type: String },
|
||||||
createBy: { type: Schema.Types.ObjectId, ref: "Users", },
|
createBy: { type: Schema.Types.ObjectId, ref: "Users" },
|
||||||
points: { type: Array },
|
points: { type: Array },
|
||||||
layer: { type: Number, required: true },
|
layer: { type: Number, required: true },
|
||||||
viewPortCenter: { type: Array, required: true },
|
viewPortCenter: { type: Array, required: true },
|
||||||
viewPortposition: { type: Array, required: true },
|
viewPortposition: { type: Array, required: true },
|
||||||
isArchive:{type:Boolean,default:false}
|
isArchive: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// export default zoneModel;
|
|
||||||
const zoneModel = (db: string) => {
|
const zoneModel = (db: string) => {
|
||||||
return MainModel(db, "zones", zoneSchema, "zones")
|
return MainModel(db, "zones", zoneSchema, "zones");
|
||||||
};
|
};
|
||||||
export default zoneModel;
|
export default zoneModel;
|
||||||
@@ -7,27 +7,17 @@ export interface Project extends Document {
|
|||||||
projectName: string;
|
projectName: string;
|
||||||
createdBy: User["_id"];
|
createdBy: User["_id"];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
isDeleted: boolean;
|
|
||||||
thumbnail: string;
|
thumbnail: string;
|
||||||
sharedUsers: [];
|
sharedUsers: [];
|
||||||
DeletedAt: Date;
|
|
||||||
isViewed: number;
|
|
||||||
total_versions: string;
|
|
||||||
Present_version: string;
|
|
||||||
}
|
}
|
||||||
const projectSchema: Schema = new Schema(
|
const projectSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
projectUuid: { type: String },
|
projectUuid: { type: String, required: true },
|
||||||
projectName: { type: String },
|
projectName: { type: String },
|
||||||
thumbnail: { type: String },
|
thumbnail: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
createdBy: { type: Schema.Types.ObjectId, ref: "user" },
|
createdBy: { type: Schema.Types.ObjectId, ref: "user" },
|
||||||
sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }],
|
sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }],
|
||||||
DeletedAt: { type: Date, default: null },
|
|
||||||
isDeleted: { type: Boolean, default: false },
|
|
||||||
isViewed: { type: Number },
|
|
||||||
total_versions: { type: String },
|
|
||||||
Present_version: { type: String },
|
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// models/Product.ts
|
|
||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
@@ -118,22 +117,20 @@ interface RoboticArmEventSchema extends AssetEventSchema {
|
|||||||
|
|
||||||
interface MachineEventSchema extends AssetEventSchema {
|
interface MachineEventSchema extends AssetEventSchema {
|
||||||
type: "machine";
|
type: "machine";
|
||||||
// speed: number;
|
|
||||||
point: MachinePointSchema;
|
point: MachinePointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StorageEventSchema extends AssetEventSchema {
|
interface StorageEventSchema extends AssetEventSchema {
|
||||||
type: "storageUnit";
|
type: "storageUnit";
|
||||||
// speed: number;
|
|
||||||
point: StoragePointSchema;
|
point: StoragePointSchema;
|
||||||
}
|
}
|
||||||
interface IPointModel extends Document {
|
interface IPointModel extends Document {
|
||||||
modelUuid: String;
|
modelUuid: string;
|
||||||
modelName: String;
|
modelName: string;
|
||||||
position: String;
|
position: [number];
|
||||||
rotation: String;
|
rotation: [number];
|
||||||
state: String;
|
state: string;
|
||||||
productId: String;
|
productId: string;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
||||||
speed: number;
|
speed: number;
|
||||||
@@ -144,7 +141,6 @@ interface IPointModel extends Document {
|
|||||||
| StorageEventSchema;
|
| StorageEventSchema;
|
||||||
points: ConveyorEventSchema[];
|
points: ConveyorEventSchema[];
|
||||||
}
|
}
|
||||||
// type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;
|
|
||||||
|
|
||||||
const BaseEventSchema = new Schema<IPointModel>(
|
const BaseEventSchema = new Schema<IPointModel>(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ import MainModel from "../../connect/mongoose.ts";
|
|||||||
|
|
||||||
export interface Trigger extends Document {
|
export interface Trigger extends Document {
|
||||||
pointsUUID: string;
|
pointsUUID: string;
|
||||||
// triggerUUID: string;
|
|
||||||
isArchive: string;
|
isArchive: string;
|
||||||
// sceneID: string;
|
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -16,7 +14,6 @@ const triggerSchema: Schema = new Schema(
|
|||||||
{
|
{
|
||||||
pointsUUID: { type: String },
|
pointsUUID: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
// triggerUUID: { type: String },
|
|
||||||
uuid: { type: String, default: "" },
|
uuid: { type: String, default: "" },
|
||||||
name: { type: String },
|
name: { type: String },
|
||||||
type: { type: String },
|
type: { type: String },
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ const signupschema: Schema = new Schema({
|
|||||||
},
|
},
|
||||||
profilePicture: {
|
profilePicture: {
|
||||||
type: String,
|
type: String,
|
||||||
// default: "default-profile-picture.jpg"
|
|
||||||
},
|
},
|
||||||
isShare: {
|
isShare: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -43,14 +42,9 @@ const signupschema: Schema = new Schema({
|
|||||||
enum: ["online", "offline"],
|
enum: ["online", "offline"],
|
||||||
default: "offline",
|
default: "offline",
|
||||||
},
|
},
|
||||||
recentlyViewed: {
|
|
||||||
type: [String],
|
|
||||||
default: [],
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const userModel = (db: string) => {
|
const userModel = (db: string) => {
|
||||||
return MainModel(db, "Users", signupschema, "Users")
|
return MainModel(db, "Users", signupschema, "Users");
|
||||||
// return MainModel(db, "UserAuth", signupschema, "UserAuth");
|
|
||||||
};
|
};
|
||||||
export default userModel;
|
export default userModel;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Widget3d extends Document {
|
export interface Widget3d extends Document {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface FloatingWidget extends Document {
|
export interface FloatingWidget extends Document {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export interface Panel extends Document {
|
|||||||
}
|
}
|
||||||
const panelSchema: Schema = new Schema(
|
const panelSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
zoneId: { type: String },
|
zoneId: { type: String },
|
||||||
panelName: { type: String },
|
panelName: { type: String },
|
||||||
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Template extends Document {
|
export interface Template extends Document {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import mongoose, { Schema, Document } from "mongoose";
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface widget extends Document {
|
export interface Widget extends Document {
|
||||||
widgetName: string;
|
widgetName: string;
|
||||||
widgetside: string;
|
widgetside: string;
|
||||||
widgetID: string;
|
widgetID: string;
|
||||||
@@ -17,7 +17,7 @@ export interface widget extends Document {
|
|||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
zoneId:string
|
zoneId: string;
|
||||||
}
|
}
|
||||||
const widgetSchema: Schema = new Schema(
|
const widgetSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
@@ -36,7 +36,7 @@ const widgetSchema: Schema = new Schema(
|
|||||||
fontWeight: { type: String },
|
fontWeight: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||||
zoneId:{ type: String }
|
zoneId: { type: String },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ export const AuthLogin = async (
|
|||||||
name: existingMail.userName,
|
name: existingMail.userName,
|
||||||
userId: existingMail._id,
|
userId: existingMail._id,
|
||||||
isShare: UserData.isShare,
|
isShare: UserData.isShare,
|
||||||
// updatedUser: updatedUser as IUser,
|
|
||||||
token: tokenValidation,
|
token: tokenValidation,
|
||||||
refreshToken: refreshTokenvalidation,
|
refreshToken: refreshTokenvalidation,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ type MulterFile = {
|
|||||||
|
|
||||||
const bucketName = "assets-public-bucket";
|
const bucketName = "assets-public-bucket";
|
||||||
|
|
||||||
// Define public read policy
|
|
||||||
const publicReadPolicy = {
|
const publicReadPolicy = {
|
||||||
Version: "2012-10-17",
|
Version: "2012-10-17",
|
||||||
Statement: [
|
Statement: [
|
||||||
@@ -35,7 +34,7 @@ async function ensureBucketExists() {
|
|||||||
async function ensureFolderExists(folderName: string) {
|
async function ensureFolderExists(folderName: string) {
|
||||||
const folderPrefix = folderName.endsWith("/") ? folderName : `${folderName}/`;
|
const folderPrefix = folderName.endsWith("/") ? folderName : `${folderName}/`;
|
||||||
const objects = minioClient.listObjects(bucketName, folderPrefix, true);
|
const objects = minioClient.listObjects(bucketName, folderPrefix, true);
|
||||||
for await (const _ of objects) return; // Folder exists
|
for await (const _ of objects) return;
|
||||||
await minioClient.putObject(bucketName, folderPrefix, Buffer.from(""));
|
await minioClient.putObject(bucketName, folderPrefix, Buffer.from(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
interface setAssetInput {
|
interface setAssetInput {
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
position: []; // user ID
|
position: [];
|
||||||
rotation: object;
|
rotation: object;
|
||||||
eventData: Mixed;
|
eventData: Mixed;
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
@@ -22,7 +22,7 @@ interface setAssetInput {
|
|||||||
interface AssetUpdate {
|
interface AssetUpdate {
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
position: []; // user ID
|
position: [];
|
||||||
rotation: object;
|
rotation: object;
|
||||||
isLocked: boolean;
|
isLocked: boolean;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
@@ -98,12 +98,7 @@ export const setAssetModel = async (
|
|||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model updated successfully",
|
|
||||||
// data: updatevalue,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
return {
|
return {
|
||||||
status: "Updated successfully",
|
status: "Updated successfully",
|
||||||
data: updatevalue,
|
data: updatevalue,
|
||||||
@@ -121,21 +116,6 @@ export const setAssetModel = async (
|
|||||||
isVisible,
|
isVisible,
|
||||||
};
|
};
|
||||||
|
|
||||||
// if (eventData) {
|
|
||||||
// if (eventData?.type === "Conveyor") {
|
|
||||||
// assetData.eventData = {
|
|
||||||
// type: eventData.type,
|
|
||||||
// // point:undefined,
|
|
||||||
// points: eventData.points,
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// assetData.eventData = {
|
|
||||||
// type: eventData.type,
|
|
||||||
// point: eventData.point,
|
|
||||||
// // points: undefined
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if (eventData) {
|
if (eventData) {
|
||||||
const typedEventData = eventData as unknown as {
|
const typedEventData = eventData as unknown as {
|
||||||
type: string;
|
type: string;
|
||||||
@@ -254,12 +234,7 @@ export const setAssetModel = async (
|
|||||||
isVisible: assetDoc.isVisible,
|
isVisible: assetDoc.isVisible,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model created successfully",
|
|
||||||
// data: assetDatas,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
data: assetDatas,
|
data: assetDatas,
|
||||||
@@ -307,11 +282,6 @@ export const deleteAssetModel = async (
|
|||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
if (!archivedAsset) {
|
if (!archivedAsset) {
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// status: "Failed to archive asset",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
return {
|
return {
|
||||||
status: "Failed to archive asset",
|
status: "Failed to archive asset",
|
||||||
};
|
};
|
||||||
@@ -321,13 +291,6 @@ export const deleteAssetModel = async (
|
|||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
|
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model deleted successfully",
|
|
||||||
// data: archivedAsset,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
data: archivedAsset,
|
data: archivedAsset,
|
||||||
@@ -364,11 +327,6 @@ export const replaceEventDatas = async (
|
|||||||
});
|
});
|
||||||
if (!existingModel) {
|
if (!existingModel) {
|
||||||
return { status: "Model not for this UUID" };
|
return { status: "Model not for this UUID" };
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "Model not for this UUID",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
} else {
|
} else {
|
||||||
const typedEventData = eventData as unknown as {
|
const typedEventData = eventData as unknown as {
|
||||||
speed: number;
|
speed: number;
|
||||||
@@ -384,23 +342,11 @@ export const replaceEventDatas = async (
|
|||||||
{ modelUuid, projectId, isArchive: false },
|
{ modelUuid, projectId, isArchive: false },
|
||||||
{
|
{
|
||||||
points: typedEventData?.points,
|
points: typedEventData?.points,
|
||||||
// speed: speed,
|
|
||||||
type: typedEventData?.type || existingModel?.type,
|
type: typedEventData?.type || existingModel?.type,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
// if (updatedModel)
|
|
||||||
// // return {
|
|
||||||
// // success: true,
|
|
||||||
// // message: "Data updated successfully",
|
|
||||||
// // data: updatedModel,
|
|
||||||
// // organization: organization,
|
|
||||||
// // };
|
|
||||||
// return {
|
|
||||||
// status: "Success",
|
|
||||||
// data: updatedModel,
|
|
||||||
// };
|
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
data: updatedModel,
|
data: updatedModel,
|
||||||
@@ -448,7 +394,6 @@ export const updateAssetPositionRotation = async (
|
|||||||
});
|
});
|
||||||
if (!existingAsset) {
|
if (!existingAsset) {
|
||||||
return { status: "Asset not found" };
|
return { status: "Asset not found" };
|
||||||
// return res.send("Asset not found");
|
|
||||||
}
|
}
|
||||||
const updateAsset = await assetModel(organization).updateMany(
|
const updateAsset = await assetModel(organization).updateMany(
|
||||||
{
|
{
|
||||||
@@ -464,12 +409,10 @@ export const updateAssetPositionRotation = async (
|
|||||||
isLocked: isLocked,
|
isLocked: isLocked,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// if (updateAsset)
|
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
data: updateAsset,
|
data: updateAsset,
|
||||||
};
|
};
|
||||||
// return res.status(200).json({ message: "Asset updated successfully" });
|
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
return {
|
return {
|
||||||
@@ -501,7 +444,6 @@ export const getFloorItems = async (
|
|||||||
|
|
||||||
if (!findValues || findValues.length === 0) {
|
if (!findValues || findValues.length === 0) {
|
||||||
return { status: "floorItems not found" };
|
return { status: "floorItems not found" };
|
||||||
// return res.status(200).json({ message: "floorItems not found" });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = findValues.map((item) => {
|
const response = findValues.map((item) => {
|
||||||
@@ -519,8 +461,6 @@ export const getFloorItems = async (
|
|||||||
return responseItem;
|
return responseItem;
|
||||||
});
|
});
|
||||||
|
|
||||||
// return res.status(200).json(response);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
data: response,
|
data: response,
|
||||||
|
|||||||
@@ -68,13 +68,12 @@ export const setWallItems = async (data: IWallSetupData): Promise<IWallItemResul
|
|||||||
quaternion,
|
quaternion,
|
||||||
scale,
|
scale,
|
||||||
},
|
},
|
||||||
{ new: true } // Return the updated document
|
{ new: true }
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
status: "Updated successfully",
|
status: "Updated successfully",
|
||||||
data: updatevalue,
|
data: updatevalue,
|
||||||
};
|
};
|
||||||
// res.status(201).json(updatevalue);
|
|
||||||
} else {
|
} else {
|
||||||
const newValue = await wallItemModel(organization).create({
|
const newValue = await wallItemModel(organization).create({
|
||||||
modelUuid,
|
modelUuid,
|
||||||
@@ -91,7 +90,6 @@ export const setWallItems = async (data: IWallSetupData): Promise<IWallItemResul
|
|||||||
status: "wall Item created successfully",
|
status: "wall Item created successfully",
|
||||||
data: newValue,
|
data: newValue,
|
||||||
};
|
};
|
||||||
// res.status(201).json(newValue);
|
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const previousVersion = async (
|
|||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
// .sort({ version: -1 });
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
export const generateUntitledProjectName = async (
|
export const generateUntitledProjectName = async (
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export const previousVersion = async (
|
|||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
// .sort({ version: -1 });
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
export const generateUntitledProjectName = async (
|
export const generateUntitledProjectName = async (
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export const searchProject = async (data: searchProjectInterface) => {
|
|||||||
const userExisting = await existingUser(userId, organization);
|
const userExisting = await existingUser(userId, organization);
|
||||||
if (!userExisting) return { status: "User not found" };
|
if (!userExisting) return { status: "User not found" };
|
||||||
const findprojectName = await projectModel(organization).find({
|
const findprojectName = await projectModel(organization).find({
|
||||||
projectName: { $regex: `${searchName}`, $options: "i" }, // 'i' makes it case-insensitive
|
projectName: { $regex: `${searchName}`, $options: "i" },
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findprojectName || findprojectName.length === 0)
|
if (!findprojectName || findprojectName.length === 0)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
interface CreateProjectInput {
|
interface CreateProjectInput {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectUuid: string;
|
projectUuid: string;
|
||||||
userId: string; // user ID
|
userId: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization: string;
|
organization: string;
|
||||||
@@ -19,7 +19,7 @@ interface CreateProjectInput {
|
|||||||
interface updateProjectInput {
|
interface updateProjectInput {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
userId: string; // user ID
|
userId: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization: string;
|
organization: string;
|
||||||
|
|||||||
@@ -1,375 +1,364 @@
|
|||||||
import { Mixed } from "mongoose";
|
import { Mixed } from "mongoose";
|
||||||
import EventsDataModel from "../../V1Models/Simulation/eventsDataModel.ts";
|
import EventsDataModel from "../../V1Models/Simulation/eventsDataModel.ts";
|
||||||
import ProductModel from "../../V1Models/Simulation/productModel.ts";
|
import ProductModel from "../../V1Models/Simulation/productModel.ts";
|
||||||
import { existingProjectById, existingUser } from "../helpers/v1projecthelperFns.ts";
|
import {
|
||||||
|
existingProjectById,
|
||||||
|
existingUser,
|
||||||
|
} from "../helpers/v1projecthelperFns.ts";
|
||||||
|
|
||||||
interface Iproduct {
|
interface Iproduct {
|
||||||
productName: string;
|
productName: string;
|
||||||
productId: string;
|
productId: string;
|
||||||
eventDatas: {
|
eventDatas: {
|
||||||
modelUuid: string
|
modelUuid: string;
|
||||||
modelName: string
|
modelName: string;
|
||||||
position: [Number]
|
position: [Number];
|
||||||
rotation: [Number]
|
rotation: [Number];
|
||||||
type: string
|
type: string;
|
||||||
speed: string
|
speed: string;
|
||||||
point: Mixed
|
point: Mixed;
|
||||||
points: Mixed
|
points: Mixed;
|
||||||
};
|
};
|
||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
interface IResult {
|
interface IResult {
|
||||||
status: string;
|
status: string;
|
||||||
data?: object;
|
data?: object;
|
||||||
}
|
}
|
||||||
interface IEventDataDelete {
|
interface IEventDataDelete {
|
||||||
productId: string;
|
productId: string;
|
||||||
modelUuid: string
|
modelUuid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
export const productAdd = async (data: Iproduct): Promise<IResult> => {
|
export const productAdd = async (data: Iproduct): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { productName, productId, eventDatas, projectId, userId, organization } = data
|
const {
|
||||||
const UserExists = await existingUser(userId, organization);
|
productName,
|
||||||
if (!UserExists) return { status: "User not found" };
|
productId,
|
||||||
const LivingProject = await existingProjectById(
|
eventDatas,
|
||||||
projectId,
|
projectId,
|
||||||
organization,
|
userId,
|
||||||
userId
|
organization,
|
||||||
);
|
} = data;
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
const UserExists = await existingUser(userId, organization);
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
if (!UserExists) return { status: "User not found" };
|
||||||
productId: productId, projectId: projectId,
|
const LivingProject = await existingProjectById(
|
||||||
isArchive: false,
|
projectId,
|
||||||
});
|
organization,
|
||||||
if (existingProduct) {
|
userId
|
||||||
const existingEventData = await EventsDataModel(organization).findOne({
|
);
|
||||||
productId: productId,
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
projectId: projectId,
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
modelUuid: eventDatas.modelUuid,
|
productId: productId,
|
||||||
isArchive: false,
|
projectId: projectId,
|
||||||
});
|
isArchive: false,
|
||||||
if (existingEventData) {
|
});
|
||||||
await EventsDataModel(organization).findOneAndUpdate(
|
if (existingProduct) {
|
||||||
{
|
const existingEventData = await EventsDataModel(organization).findOne({
|
||||||
modelUuid: eventDatas.modelUuid,
|
productId: productId,
|
||||||
productId: productId,
|
projectId: projectId,
|
||||||
isArchive: false,
|
modelUuid: eventDatas.modelUuid,
|
||||||
},
|
isArchive: false,
|
||||||
{
|
});
|
||||||
modelUuid: eventDatas?.modelUuid,
|
if (existingEventData) {
|
||||||
modelName: eventDatas?.modelName,
|
|
||||||
position: eventDatas?.position,
|
|
||||||
rotation: eventDatas?.rotation,
|
|
||||||
type: eventDatas?.type,
|
|
||||||
speed: eventDatas?.speed,
|
|
||||||
point: eventDatas?.point,
|
|
||||||
points: eventDatas?.points,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
status: "EventData updated successfully"
|
|
||||||
}
|
|
||||||
// return res
|
|
||||||
// .status(200)
|
|
||||||
// .json({ message: "EventData updated successfully" });
|
|
||||||
} else {
|
|
||||||
await EventsDataModel(organization).create({
|
|
||||||
productId: productId,
|
|
||||||
modelUuid: eventDatas?.modelUuid,
|
|
||||||
modelName: eventDatas?.modelName,
|
|
||||||
position: eventDatas?.position,
|
|
||||||
rotation: eventDatas?.rotation,
|
|
||||||
type: eventDatas?.type,
|
|
||||||
speed: eventDatas?.speed,
|
|
||||||
point: eventDatas?.point,
|
|
||||||
points: eventDatas?.points,
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
status: "EventData add successfully"
|
|
||||||
}
|
|
||||||
// return res
|
|
||||||
// .status(201)
|
|
||||||
// .json({ message: "EventData add successfully" });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const newProduct = await ProductModel(organization).create({
|
|
||||||
productId: productId,
|
|
||||||
productName: productName,
|
|
||||||
});
|
|
||||||
if (newProduct) {
|
|
||||||
if (eventDatas) {
|
|
||||||
await EventsDataModel(organization).create({
|
|
||||||
productId: productId,
|
|
||||||
modelUuid: eventDatas?.modelUuid,
|
|
||||||
modelName: eventDatas?.modelName,
|
|
||||||
position: eventDatas?.position,
|
|
||||||
rotation: eventDatas?.rotation,
|
|
||||||
type: eventDatas?.type,
|
|
||||||
speed: eventDatas?.speed,
|
|
||||||
point: eventDatas?.point,
|
|
||||||
points: eventDatas?.points,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
status: "Success"
|
|
||||||
}
|
|
||||||
// return res
|
|
||||||
// .status(201)
|
|
||||||
// .json({ message: "Product created successfully" });
|
|
||||||
}
|
|
||||||
} catch (error: unknown) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
return {
|
|
||||||
status: error.message,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
status: "An unexpected error occurred",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export const getProductDatas = async (data: Iproduct): Promise<IResult> => {
|
|
||||||
try {
|
|
||||||
const { productId, projectId, userId, organization } = data
|
|
||||||
const UserExists = await existingUser(userId, organization);
|
|
||||||
if (!UserExists) return { status: "User not found" };
|
|
||||||
const LivingProject = await existingProjectById(
|
|
||||||
projectId,
|
|
||||||
organization,
|
|
||||||
userId
|
|
||||||
);
|
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
|
||||||
productId: productId, projectId: projectId,
|
|
||||||
isArchive: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!existingProduct)
|
|
||||||
return { status: "Product not found" };
|
|
||||||
// return res.status(404).json({ message: "Product not found" });
|
|
||||||
|
|
||||||
const existingEventDatas = await EventsDataModel(organization)
|
|
||||||
.find({ productId: productId, projectId: projectId })
|
|
||||||
.select("-productId");
|
|
||||||
return { status: "Success", data: existingEventDatas };
|
|
||||||
// return res.status(200).json(existingEventDatas);
|
|
||||||
} catch (error: unknown) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
return {
|
|
||||||
status: error.message,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
status: "An unexpected error occurred",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export const productDataDelete = async (data: Iproduct): Promise<IResult> => {
|
|
||||||
try {
|
|
||||||
const { productId, projectId, userId, organization } = data
|
|
||||||
const UserExists = await existingUser(userId, organization);
|
|
||||||
if (!UserExists) return { status: "User not found" };
|
|
||||||
const LivingProject = await existingProjectById(
|
|
||||||
projectId,
|
|
||||||
organization,
|
|
||||||
userId
|
|
||||||
);
|
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
|
||||||
productId: productId,
|
|
||||||
isArchive: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!existingProduct)
|
|
||||||
return { status: "Product not found" };
|
|
||||||
// return res.status(404).json({ message: "Product not found" });
|
|
||||||
|
|
||||||
await ProductModel(organization).findOneAndUpdate(
|
|
||||||
{ productId: productId, projectId: projectId },
|
|
||||||
{
|
|
||||||
isArchive: true,
|
|
||||||
},
|
|
||||||
{ new: true }
|
|
||||||
);
|
|
||||||
const existingEventDatas = await EventsDataModel(organization).find({
|
|
||||||
productId: productId,
|
|
||||||
});
|
|
||||||
if (existingEventDatas) {
|
|
||||||
await EventsDataModel(organization).updateMany(
|
|
||||||
{ productId, projectId },
|
|
||||||
{ $set: { isArchive: true } }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
status: "Success",
|
|
||||||
// data: assetDatas,
|
|
||||||
};
|
|
||||||
// return res.status(201).json({ message: "product deleted successfully" });
|
|
||||||
} catch (error: unknown) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
return {
|
|
||||||
status: error.message,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
status: "An unexpected error occurred",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export const EventDataDelete = async (data: IEventDataDelete): Promise<IResult> => {
|
|
||||||
try {
|
|
||||||
const { modelUuid, productId, projectId, userId, organization } = data
|
|
||||||
const UserExists = await existingUser(userId, organization);
|
|
||||||
if (!UserExists) return { status: "User not found" };
|
|
||||||
const LivingProject = await existingProjectById(
|
|
||||||
projectId,
|
|
||||||
organization,
|
|
||||||
userId
|
|
||||||
);
|
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
|
||||||
productId: productId, projectId: projectId,
|
|
||||||
isArchive: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!existingProduct)
|
|
||||||
return { status: "Product not found" };
|
|
||||||
// return res.status(404).json({ message: "Product not found" });
|
|
||||||
await EventsDataModel(organization).findOneAndUpdate(
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
{ productId: productId, projectId: projectId, modelUuid: modelUuid },
|
{
|
||||||
{
|
modelUuid: eventDatas.modelUuid,
|
||||||
isArchive: true,
|
productId: productId,
|
||||||
},
|
|
||||||
{ new: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
// return res
|
|
||||||
// .status(201)
|
|
||||||
// .json({ message: "EventData deleted successfully" });
|
|
||||||
return {
|
|
||||||
status: "Success",
|
|
||||||
// data: assetDatas,
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (error: unknown) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
return {
|
|
||||||
status: error.message,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
status: "An unexpected error occurred",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export const AllProductDatas = async (data: IEventDataDelete): Promise<IResult> => {
|
|
||||||
try {
|
|
||||||
const { projectId, userId, organization } = data
|
|
||||||
const UserExists = await existingUser(userId, organization);
|
|
||||||
if (!UserExists) return { status: "User not found" };
|
|
||||||
const LivingProject = await existingProjectById(
|
|
||||||
projectId,
|
|
||||||
organization,
|
|
||||||
userId
|
|
||||||
);
|
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
|
||||||
const existingProduct = await ProductModel(organization).find({
|
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
},
|
||||||
if (!existingProduct) {
|
{
|
||||||
// return res.status(404).json({ message: "No products found" });
|
modelUuid: eventDatas?.modelUuid,
|
||||||
return {
|
modelName: eventDatas?.modelName,
|
||||||
status: "No products found",
|
position: eventDatas?.position,
|
||||||
// data: result,
|
rotation: eventDatas?.rotation,
|
||||||
};
|
type: eventDatas?.type,
|
||||||
}
|
speed: eventDatas?.speed,
|
||||||
const result = [];
|
point: eventDatas?.point,
|
||||||
|
points: eventDatas?.points,
|
||||||
for (const product of existingProduct) {
|
}
|
||||||
const eventDatas = await EventsDataModel(organization)
|
);
|
||||||
.find({ projectId: product.projectId, productId: product.productId, isArchive: false })
|
|
||||||
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
|
||||||
|
|
||||||
result.push({
|
|
||||||
// product: {
|
|
||||||
projectId: product.projectId,
|
|
||||||
productName: product.productName,
|
|
||||||
productId: product.productId,
|
|
||||||
eventDatas,
|
|
||||||
// },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// return res.status(200).json(result);
|
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "EventData updated successfully",
|
||||||
data: result,
|
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
} catch (error: unknown) {
|
await EventsDataModel(organization).create({
|
||||||
if (error instanceof Error) {
|
productId: productId,
|
||||||
return {
|
modelUuid: eventDatas?.modelUuid,
|
||||||
status: error.message,
|
modelName: eventDatas?.modelName,
|
||||||
};
|
position: eventDatas?.position,
|
||||||
} else {
|
rotation: eventDatas?.rotation,
|
||||||
return {
|
type: eventDatas?.type,
|
||||||
status: "An unexpected error occurred",
|
speed: eventDatas?.speed,
|
||||||
};
|
point: eventDatas?.point,
|
||||||
|
points: eventDatas?.points,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
status: "EventData add successfully",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const newProduct = await ProductModel(organization).create({
|
||||||
|
productId: productId,
|
||||||
|
productName: productName,
|
||||||
|
});
|
||||||
|
if (newProduct) {
|
||||||
|
if (eventDatas) {
|
||||||
|
await EventsDataModel(organization).create({
|
||||||
|
productId: productId,
|
||||||
|
modelUuid: eventDatas?.modelUuid,
|
||||||
|
modelName: eventDatas?.modelName,
|
||||||
|
position: eventDatas?.position,
|
||||||
|
rotation: eventDatas?.rotation,
|
||||||
|
type: eventDatas?.type,
|
||||||
|
speed: eventDatas?.speed,
|
||||||
|
point: eventDatas?.point,
|
||||||
|
points: eventDatas?.points,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
status: "Success",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
|
status: error.message,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
status: "An unexpected error occurred",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const getProductDatas = async (data: Iproduct): Promise<IResult> => {
|
||||||
|
try {
|
||||||
|
const { productId, projectId, userId, organization } = data;
|
||||||
|
const UserExists = await existingUser(userId, organization);
|
||||||
|
if (!UserExists) return { status: "User not found" };
|
||||||
|
const LivingProject = await existingProjectById(
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
projectId: projectId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!existingProduct) return { status: "Product not found" };
|
||||||
|
|
||||||
|
const existingEventDatas = await EventsDataModel(organization)
|
||||||
|
.find({ productId: productId, projectId: projectId })
|
||||||
|
.select("-productId");
|
||||||
|
return { status: "Success", data: existingEventDatas };
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
|
status: error.message,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
status: "An unexpected error occurred",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const productDataDelete = async (data: Iproduct): Promise<IResult> => {
|
||||||
|
try {
|
||||||
|
const { productId, projectId, userId, organization } = data;
|
||||||
|
const UserExists = await existingUser(userId, organization);
|
||||||
|
if (!UserExists) return { status: "User not found" };
|
||||||
|
const LivingProject = await existingProjectById(
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!existingProduct) return { status: "Product not found" };
|
||||||
|
|
||||||
|
await ProductModel(organization).findOneAndUpdate(
|
||||||
|
{ productId: productId, projectId: projectId },
|
||||||
|
{
|
||||||
|
isArchive: true,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
const existingEventDatas = await EventsDataModel(organization).find({
|
||||||
|
productId: productId,
|
||||||
|
});
|
||||||
|
if (existingEventDatas) {
|
||||||
|
await EventsDataModel(organization).updateMany(
|
||||||
|
{ productId, projectId },
|
||||||
|
{ $set: { isArchive: true } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
status: "Success",
|
||||||
|
};
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
|
status: error.message,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
status: "An unexpected error occurred",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const EventDataDelete = async (
|
||||||
|
data: IEventDataDelete
|
||||||
|
): Promise<IResult> => {
|
||||||
|
try {
|
||||||
|
const { modelUuid, productId, projectId, userId, organization } = data;
|
||||||
|
const UserExists = await existingUser(userId, organization);
|
||||||
|
if (!UserExists) return { status: "User not found" };
|
||||||
|
const LivingProject = await existingProjectById(
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
projectId: projectId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!existingProduct) return { status: "Product not found" };
|
||||||
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
|
{ productId: productId, projectId: projectId, modelUuid: modelUuid },
|
||||||
|
{
|
||||||
|
isArchive: true,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: "Success",
|
||||||
|
};
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
|
status: error.message,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
status: "An unexpected error occurred",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const AllProductDatas = async (
|
||||||
|
data: IEventDataDelete
|
||||||
|
): Promise<IResult> => {
|
||||||
|
try {
|
||||||
|
const { projectId, userId, organization } = data;
|
||||||
|
const UserExists = await existingUser(userId, organization);
|
||||||
|
if (!UserExists) return { status: "User not found" };
|
||||||
|
const LivingProject = await existingProjectById(
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
|
const existingProduct = await ProductModel(organization).find({
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingProduct) {
|
||||||
|
return {
|
||||||
|
status: "No products found",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const result = [];
|
||||||
|
|
||||||
|
for (const product of existingProduct) {
|
||||||
|
const eventDatas = await EventsDataModel(organization)
|
||||||
|
.find({
|
||||||
|
projectId: product.projectId,
|
||||||
|
productId: product.productId,
|
||||||
|
isArchive: false,
|
||||||
|
})
|
||||||
|
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
||||||
|
|
||||||
|
result.push({
|
||||||
|
projectId: product.projectId,
|
||||||
|
productName: product.productName,
|
||||||
|
productId: product.productId,
|
||||||
|
eventDatas,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: "Success",
|
||||||
|
data: result,
|
||||||
|
};
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
|
status: error.message,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
status: "An unexpected error occurred",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
export const productRename = async (data: Iproduct): Promise<IResult> => {
|
export const productRename = async (data: Iproduct): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { productName, productId, projectId, userId, organization } = data
|
const { productName, productId, projectId, userId, organization } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
projectId,
|
projectId,
|
||||||
organization,
|
organization,
|
||||||
userId
|
userId
|
||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId, projectId: projectId,
|
productId: productId,
|
||||||
isArchive: false,
|
projectId: projectId,
|
||||||
});
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct) return { status: "Product not found" };
|
||||||
return { status: "Product not found" };
|
|
||||||
|
|
||||||
await ProductModel(organization).findOneAndUpdate(
|
await ProductModel(organization).findOneAndUpdate(
|
||||||
{ productId: productId },
|
{ productId: productId },
|
||||||
{
|
{
|
||||||
productName: productName,
|
productName: productName,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
// return res.status(201).json({ message: "product Rename successfully" });
|
return {
|
||||||
return {
|
status: "Success",
|
||||||
status: "Success",
|
};
|
||||||
// data: assetDatas,
|
} catch (error: unknown) {
|
||||||
};
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
} catch (error: unknown) {
|
status: error.message,
|
||||||
if (error instanceof Error) {
|
};
|
||||||
return {
|
} else {
|
||||||
status: error.message,
|
return {
|
||||||
};
|
status: "An unexpected error occurred",
|
||||||
} else {
|
};
|
||||||
return {
|
|
||||||
status: "An unexpected error occurred",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import UsersDataModel from "../../V1Models/Auth/user.ts";
|
|||||||
interface CreateProjectInput {
|
interface CreateProjectInput {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectUuid: string;
|
projectUuid: string;
|
||||||
userId: string; // user ID
|
userId: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization: string;
|
organization: string;
|
||||||
@@ -19,7 +19,7 @@ interface CreateProjectInput {
|
|||||||
interface IProjectDuplicate {
|
interface IProjectDuplicate {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectUuid: string;
|
projectUuid: string;
|
||||||
userId: string; // user ID
|
userId: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization: string;
|
organization: string;
|
||||||
@@ -27,7 +27,7 @@ interface IProjectDuplicate {
|
|||||||
interface updateProjectInput {
|
interface updateProjectInput {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
userId: string; // user ID
|
userId: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization: string;
|
organization: string;
|
||||||
@@ -116,9 +116,7 @@ export const GetAllProjects = async (data: GetProjectsInterface) => {
|
|||||||
await existingUser(userId, organization);
|
await existingUser(userId, organization);
|
||||||
if (!existingUser) return { status: "User not found" };
|
if (!existingUser) return { status: "User not found" };
|
||||||
let filter = { isArchive: false } as RoleFilter;
|
let filter = { isArchive: false } as RoleFilter;
|
||||||
// if (role === "User") {
|
|
||||||
// filter.createdBy = userId;
|
|
||||||
// }
|
|
||||||
const projectDatas = await projectModel(organization)
|
const projectDatas = await projectModel(organization)
|
||||||
.find(filter)
|
.find(filter)
|
||||||
.select("_id projectName createdBy thumbnail createdAt projectUuid");
|
.select("_id projectName createdBy thumbnail createdAt projectUuid");
|
||||||
@@ -135,9 +133,7 @@ export const DeleteProject = async (data: ProjectDelInterface) => {
|
|||||||
if (!ExistingUser) return { status: "User not found" };
|
if (!ExistingUser) return { status: "User not found" };
|
||||||
|
|
||||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||||
// if (role === "User") {
|
|
||||||
// filter.createdBy = userId;
|
|
||||||
// }
|
|
||||||
const existingProject = await projectModel(organization).findOne(filter);
|
const existingProject = await projectModel(organization).findOne(filter);
|
||||||
console.log("existingProject: ", existingProject);
|
console.log("existingProject: ", existingProject);
|
||||||
if (!existingProject) return { status: "Project not found" };
|
if (!existingProject) return { status: "Project not found" };
|
||||||
@@ -158,9 +154,7 @@ export const updateProject = async (data: updateProjectInput) => {
|
|||||||
const ExistingUser = await existingUser(userId, organization);
|
const ExistingUser = await existingUser(userId, organization);
|
||||||
if (!ExistingUser) return { status: "User not found" };
|
if (!ExistingUser) return { status: "User not found" };
|
||||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||||
// if (role === "User") {
|
|
||||||
// filter.createdBy = userId;
|
|
||||||
// }
|
|
||||||
const existingProject = await projectModel(organization).findOne(filter);
|
const existingProject = await projectModel(organization).findOne(filter);
|
||||||
if (!existingProject) return { status: "Project not found" };
|
if (!existingProject) return { status: "Project not found" };
|
||||||
if (projectName !== undefined) projectName;
|
if (projectName !== undefined) projectName;
|
||||||
@@ -245,9 +239,7 @@ export const viewProject = async (data: ProjectInterface) => {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||||
// if (role === "User") {
|
|
||||||
// filter.createdBy = userId;
|
|
||||||
// }
|
|
||||||
const existingProject = await projectModel(organization).findOne(filter);
|
const existingProject = await projectModel(organization).findOne(filter);
|
||||||
if (!existingProject) return { status: "Project not found" };
|
if (!existingProject) return { status: "Project not found" };
|
||||||
const newArr = RecentUserDoc?.recentlyViewed || [];
|
const newArr = RecentUserDoc?.recentlyViewed || [];
|
||||||
|
|||||||
@@ -36,12 +36,8 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
|||||||
model: projectModel(organization),
|
model: projectModel(organization),
|
||||||
select: "_id",
|
select: "_id",
|
||||||
});
|
});
|
||||||
let filter = { isArchive: false } as RoleFilter;
|
|
||||||
// if (role === "User") {
|
|
||||||
// filter.createdBy = userId;
|
|
||||||
// }
|
|
||||||
const populatedProjects = userRecentData.recentlyViewed as IProject[];
|
const populatedProjects = userRecentData.recentlyViewed as IProject[];
|
||||||
console.log("populatedProjects: ", populatedProjects);
|
|
||||||
const RecentDatas = await Promise.all(
|
const RecentDatas = await Promise.all(
|
||||||
populatedProjects.map(async (project) => {
|
populatedProjects.map(async (project) => {
|
||||||
const projectExisting = await projectModel(organization)
|
const projectExisting = await projectModel(organization)
|
||||||
@@ -50,7 +46,6 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
|||||||
return projectExisting;
|
return projectExisting;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
console.log("RecentDatas: ", RecentDatas);
|
|
||||||
|
|
||||||
const filteredProjects = RecentDatas.filter(Boolean);
|
const filteredProjects = RecentDatas.filter(Boolean);
|
||||||
console.log("filteredProjects: ", filteredProjects);
|
console.log("filteredProjects: ", filteredProjects);
|
||||||
@@ -65,7 +60,7 @@ export const searchProject = async (data: searchProjectInterface) => {
|
|||||||
const userExisting = await existingUser(userId, organization);
|
const userExisting = await existingUser(userId, organization);
|
||||||
if (!userExisting) return { status: "User not found" };
|
if (!userExisting) return { status: "User not found" };
|
||||||
const findprojectName = await projectModel(organization).find({
|
const findprojectName = await projectModel(organization).find({
|
||||||
projectName: { $regex: `${searchName}`, $options: "i" }, // 'i' makes it case-insensitive
|
projectName: { $regex: `${searchName}`, $options: "i" },
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findprojectName || findprojectName.length === 0)
|
if (!findprojectName || findprojectName.length === 0)
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ export const TrashDatas = async (data: IOrg) => {
|
|||||||
try {
|
try {
|
||||||
const { organization, role, userId } = data;
|
const { organization, role, userId } = data;
|
||||||
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
|
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
|
||||||
// if (role === "User") {
|
|
||||||
// filter.createdBy = userId;
|
|
||||||
// }
|
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const TrashLists = await projectModel(organization).find(filter);
|
const TrashLists = await projectModel(organization).find(filter);
|
||||||
@@ -62,9 +60,7 @@ export const RestoreTrashData = async (data: IRestore) => {
|
|||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
let filter = { isArchive: true, _id: projectId } as RoleFilter;
|
let filter = { isArchive: true, _id: projectId } as RoleFilter;
|
||||||
// if (role === "User") {
|
|
||||||
// filter.createdBy = userId;
|
|
||||||
// }
|
|
||||||
const findProject = await projectModel(organization).findOne(filter);
|
const findProject = await projectModel(organization).findOne(filter);
|
||||||
if (!findProject) return { status: "Project not found" };
|
if (!findProject) return { status: "Project not found" };
|
||||||
const restoreData = await projectModel(organization).findOneAndUpdate(
|
const restoreData = await projectModel(organization).findOneAndUpdate(
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ class VersionService {
|
|||||||
userId: string,
|
userId: string,
|
||||||
description?: string
|
description?: string
|
||||||
) {
|
) {
|
||||||
// Create new version
|
|
||||||
const newVersion = await this.createNewVersion(
|
const newVersion = await this.createNewVersion(
|
||||||
db,
|
db,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -56,7 +55,6 @@ class VersionService {
|
|||||||
description
|
description
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get all assets from previous version
|
|
||||||
const previousVersion = parseFloat((newVersion.version - 0.1).toFixed(1));
|
const previousVersion = parseFloat((newVersion.version - 0.1).toFixed(1));
|
||||||
const previousVersionDoc = await versionModel(db).findOne({
|
const previousVersionDoc = await versionModel(db).findOne({
|
||||||
projectId,
|
projectId,
|
||||||
@@ -73,7 +71,6 @@ class VersionService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy assets to new version
|
|
||||||
const newAssets = await Promise.all(
|
const newAssets = await Promise.all(
|
||||||
previousAssets.map(async (asset) => {
|
previousAssets.map(async (asset) => {
|
||||||
console.log("previousAssets: ", previousAssets);
|
console.log("previousAssets: ", previousAssets);
|
||||||
|
|||||||
@@ -45,13 +45,12 @@ export class WallItems {
|
|||||||
quaternion,
|
quaternion,
|
||||||
scale,
|
scale,
|
||||||
},
|
},
|
||||||
{ new: true } // Return the updated document
|
{ new: true }
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
state: "Updated successfully",
|
state: "Updated successfully",
|
||||||
data: updatevalue,
|
data: updatevalue,
|
||||||
};
|
};
|
||||||
// res.status(201).json(updatevalue);
|
|
||||||
} else {
|
} else {
|
||||||
const newValue = await wallItemModel(organization).create({
|
const newValue = await wallItemModel(organization).create({
|
||||||
modelUuid,
|
modelUuid,
|
||||||
@@ -67,16 +66,12 @@ export class WallItems {
|
|||||||
state: "wall Item created successfully",
|
state: "wall Item created successfully",
|
||||||
data: newValue,
|
data: newValue,
|
||||||
};
|
};
|
||||||
// res.status(201).json(newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error:unknown) {
|
} catch (error:unknown) {
|
||||||
const err = error as Error;
|
const err = error as Error;
|
||||||
console.error("Error creating wallitems:", error);
|
console.error("Error creating wallitems:", error);
|
||||||
return { state: "Failed to create wallitems", data: { message: err.message } };
|
return { state: "Failed to create wallitems", data: { message: err.message } };
|
||||||
// return { state: "Failed to create wallitems", data: error } };
|
|
||||||
// res.status(500).json({ message: "Failed to create wallitems" });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getWallItems(req: Request, res: Response) {
|
static async getWallItems(req: Request, res: Response) {
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ const doc = {
|
|||||||
description: "Description",
|
description: "Description",
|
||||||
},
|
},
|
||||||
host: "185.100.212.76:5000",
|
host: "185.100.212.76:5000",
|
||||||
// host: "192.168.0.102:5000",
|
|
||||||
// basePath: "/api/v1",
|
|
||||||
schemes: ["http"],
|
schemes: ["http"],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
import { MongoClient } from 'mongodb'
|
import { MongoClient } from "mongodb";
|
||||||
export default async function mongoAdminCreation() {
|
export default async function mongoAdminCreation() {
|
||||||
const uri = process.env.MONGO_URI!; // Replace with your MongoDB URI
|
const uri = process.env.MONGO_URI!;
|
||||||
const client = new MongoClient(uri);
|
const client = new MongoClient(uri);
|
||||||
const user = {
|
const user = {
|
||||||
user:"admin",
|
user: "admin",
|
||||||
pwd: process.env.MONGO_PASSWORD!,
|
pwd: process.env.MONGO_PASSWORD!,
|
||||||
roles: [{ role: "root", db: process.env.MONGO_AUTH_DB || "admin" }],
|
roles: [{ role: "root", db: process.env.MONGO_AUTH_DB || "admin" }],
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
const db = client.db('admin'); // Specify the actual database where the user should be created
|
const db = client.db("admin");
|
||||||
|
|
||||||
// Check if the user already exists
|
const userExists = await db
|
||||||
const userExists = await db.collection('system.users').findOne({ user: user.user});
|
.collection("system.users")
|
||||||
|
.findOne({ user: user.user });
|
||||||
|
|
||||||
if (userExists) {
|
if (userExists) {
|
||||||
console.log(`User ${user} already exists`);
|
console.log(`User ${user} already exists`);
|
||||||
return; // Exit if the user already exists
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create the user
|
|
||||||
await db.command({ createUser: user.user, pwd: user.pwd, roles: user.roles });
|
|
||||||
console.log("User created successfully!")
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error creating user:",error);
|
|
||||||
} finally {
|
|
||||||
await client.close();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// mongoAdminCreation
|
await db.command({
|
||||||
|
createUser: user.user,
|
||||||
|
pwd: user.pwd,
|
||||||
|
roles: user.roles,
|
||||||
|
});
|
||||||
|
console.log("User created successfully!");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating user:", error);
|
||||||
|
} finally {
|
||||||
|
await client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,9 +77,7 @@ const tokenValidator = async (
|
|||||||
req.user = decoded;
|
req.user = decoded;
|
||||||
next();
|
next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// res.status(401).json({
|
|
||||||
// msg: "Invalid Token",
|
|
||||||
// });
|
|
||||||
if (!refresh_token) {
|
if (!refresh_token) {
|
||||||
res.status(403).json({
|
res.status(403).json({
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ ARG NODE_VERSION=lts
|
|||||||
FROM node:${NODE_VERSION}-alpine AS development
|
FROM node:${NODE_VERSION}-alpine AS development
|
||||||
# Use production node environment by default.
|
# Use production node environment by default.
|
||||||
|
|
||||||
ENV NODE_ENV development
|
ENV NODE_ENV=development
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
RUN npm install -g tsx
|
RUN npm install -g tsx --ignore-scripts
|
||||||
|
|
||||||
COPY package.json /usr/src/app/package.json
|
COPY package.json /usr/src/app/package.json
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ COPY package.json /usr/src/app/package.json
|
|||||||
# COPY package-lock.json /usr/src/app/package-lock.json
|
# COPY package-lock.json /usr/src/app/package-lock.json
|
||||||
|
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install --ignore-scripts
|
||||||
|
|
||||||
# Run the application as a non-root user.
|
# Run the application as a non-root user.
|
||||||
USER root
|
USER root
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
|
import express,{ Response, Request } from "express";
|
||||||
import express from "express"
|
|
||||||
import { Response, Request } from "express";
|
|
||||||
import http from "http";
|
import http from "http";
|
||||||
import dotenv from "dotenv"; // Import dotenv
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
import { initSocketServer } from "./socket/socketManager.ts";
|
|
||||||
import { SocketServer } from "./manager/manager.ts";
|
import { SocketServer } from "./manager/manager.ts";
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = process.env.SOCKET_PORT;
|
const PORT = process.env.SOCKET_PORT;
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
app.get('/', (req: Request, res: Response) => {
|
app.get("/", (req: Request, res: Response) => {
|
||||||
res.send('Hello, I am Major-Dwinzo RealTime!');
|
res.send("Hello, I am Major-Dwinzo RealTime!");
|
||||||
});
|
});
|
||||||
// initSocketServer(server);
|
|
||||||
SocketServer(server)
|
SocketServer(server)
|
||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
console.log(`socket-Server is running on http://localhost:${PORT}`);
|
console.log(`socket-Server is running on http://localhost:${PORT}`);
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ import { getUserRole } from '../utils/getUsers.ts';
|
|||||||
interface UserSocketInfo {
|
interface UserSocketInfo {
|
||||||
socketId: string;
|
socketId: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
role: string; // e.g., "admin" or "user"
|
role: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const connectedUsersByOrg: { [organization: string]: UserSocketInfo[] } = {};
|
const connectedUsersByOrg: { [organization: string]: UserSocketInfo[] } = {};
|
||||||
export const SocketServer = (httpServer: any) => {
|
export const SocketServer = (httpServer: any) => {
|
||||||
const io = new Server(httpServer, {
|
const io = new Server(httpServer, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: '*', // Allow CORS for all origins (adjust in production)
|
origin: '*',
|
||||||
methods: ['GET', 'POST'],
|
methods: ['GET', 'POST'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -43,15 +43,15 @@ export const SocketServer = (httpServer: any) => {
|
|||||||
visualization: io.of("/Visualization"),
|
visualization: io.of("/Visualization"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// const onlineUsers = new Map<string, Set<string>>();
|
|
||||||
const onlineUsers: { [organization: string]: Set<string> } = {};
|
const onlineUsers: { [organization: string]: Set<string> } = {};
|
||||||
|
|
||||||
|
|
||||||
const handleNamespace = (namespace: any, ...eventHandlers: Function[]) => {
|
const handleNamespace = (namespace: any, ...eventHandlers: Function[]) => {
|
||||||
namespace.use(async (socket: Socket, next: any) => {
|
namespace.use(async (socket: Socket, next: any) => {
|
||||||
// console.log(`🔌 Connecting to namespace: ${namespace.name}`);
|
|
||||||
const token = socket.handshake.auth.token;
|
const token = socket.handshake.auth.token;
|
||||||
// const token = socket.handshake.query.token as string;
|
|
||||||
const jwt_secret = process.env.JWT_SECRET as string;
|
const jwt_secret = process.env.JWT_SECRET as string;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
@@ -63,13 +63,13 @@ export const SocketServer = (httpServer: any) => {
|
|||||||
return next(new Error("Server configuration error: Missing secret"));
|
return next(new Error("Server configuration error: Missing secret"));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 1. Verify token
|
|
||||||
const decoded = jwt.verify(token, jwt_secret) as {
|
const decoded = jwt.verify(token, jwt_secret) as {
|
||||||
userId: string;
|
userId: string;
|
||||||
Email: string;
|
Email: string;
|
||||||
organization: string
|
organization: string
|
||||||
};
|
};
|
||||||
// 2. Find user in DB
|
|
||||||
const user = await AuthModel(decoded.organization).findOne({ _id: decoded.userId, Email: decoded.Email, });
|
const user = await AuthModel(decoded.organization).findOne({ _id: decoded.userId, Email: decoded.Email, });
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@@ -77,12 +77,12 @@ export const SocketServer = (httpServer: any) => {
|
|||||||
return next(new Error("Authentication error: User not found"));
|
return next(new Error("Authentication error: User not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Attach to socket for later use
|
|
||||||
(socket as any).user = {
|
(socket as any).user = {
|
||||||
// ...user.toObject(), // convert Mongoose doc to plain object
|
|
||||||
organization: decoded.organization, // manually add org
|
organization: decoded.organization,
|
||||||
Email: decoded.Email, // manually add org
|
Email: decoded.Email,
|
||||||
userId: decoded.userId, // manually add org
|
userId: decoded.userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -93,38 +93,21 @@ export const SocketServer = (httpServer: any) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
namespace.on("connection",async (socket: Socket) => {
|
namespace.on("connection",async (socket: Socket) => {
|
||||||
// Extract organization from query parameters
|
|
||||||
const user = (socket as any).user;
|
const user = (socket as any).user;
|
||||||
const organization = user.organization;
|
const organization = user.organization;
|
||||||
const Email = user.Email;
|
const Email = user.Email;
|
||||||
const userId = user.userId;
|
const userId = user.userId;
|
||||||
|
|
||||||
// namespace.on("connection", (socket: Socket) => {
|
|
||||||
// console.log(`✅ Client connected to ${namespace.name}: ${socket.id}`);
|
|
||||||
// // Extract organization from query parameters
|
|
||||||
|
|
||||||
// const organization = socket.handshake.query.organization as string;
|
|
||||||
// const email = socket.handshake.query.email as string;
|
|
||||||
// // const {organization,email} = socket.handshake.auth
|
|
||||||
// console.log(`🔍 Received organization: ${organization}`);
|
|
||||||
|
|
||||||
if (organization) {
|
if (organization) {
|
||||||
socket.join(organization);
|
socket.join(organization);
|
||||||
// console.log(`🔹 Socket ${socket.id} joined room: ${organization}`);
|
|
||||||
}
|
}
|
||||||
// // Handle all events
|
|
||||||
// if (organization && email) {
|
|
||||||
// if (!onlineUsers[organization]) {
|
|
||||||
// onlineUsers[organization] = new Set();
|
|
||||||
// }
|
|
||||||
// onlineUsers[organization].add(socket.id);
|
|
||||||
|
|
||||||
// }
|
|
||||||
const role = await getUserRole(userId, organization);
|
const role = await getUserRole(userId, organization);
|
||||||
if (role === "Admin") {
|
if (role === "Admin") {
|
||||||
socket.join(`${organization}_admins`);
|
socket.join(`${organization}_admins`);
|
||||||
}
|
}
|
||||||
// Save user info somewhere
|
|
||||||
if (organization && userId && role) {
|
if (organization && userId && role) {
|
||||||
if (!connectedUsersByOrg[organization]) {
|
if (!connectedUsersByOrg[organization]) {
|
||||||
connectedUsersByOrg[organization] = [];
|
connectedUsersByOrg[organization] = [];
|
||||||
@@ -136,30 +119,22 @@ export const SocketServer = (httpServer: any) => {
|
|||||||
role,
|
role,
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(`🔗 User connected: ${userId} with role ${role} in ${organization}`);
|
|
||||||
// console.log("🧩 connectedUsersByOrg: ", connectedUsersByOrg);
|
|
||||||
} else {
|
} else {
|
||||||
console.warn(`❌ Cannot store user. Missing data:`,);
|
console.warn(`❌ Cannot store user. Missing data:`,);
|
||||||
}
|
}
|
||||||
// userStatus(EVENTS.connection, socket, socket.handshake.auth, socket);
|
|
||||||
|
|
||||||
socket.onAny((event: string, data: any, callback: any) => {
|
socket.onAny((event: string, data: any, callback: any) => {
|
||||||
eventHandlers.forEach(handler =>
|
eventHandlers.forEach(handler =>
|
||||||
handler(event, socket, io, data, connectedUsersByOrg, callback) // ✅ fixed
|
handler(event, socket, io, data, connectedUsersByOrg, callback)
|
||||||
);
|
);
|
||||||
// eventHandlers.forEach(handler =>
|
|
||||||
// handler(event, socket,io,namespace, data, connectedUsersByOrg, callback));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle disconnection
|
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
onlineUsers[organization]?.delete(socket.id);
|
onlineUsers[organization]?.delete(socket.id);
|
||||||
if (onlineUsers[organization]?.size === 0) delete onlineUsers[organization];
|
if (onlineUsers[organization]?.size === 0) delete onlineUsers[organization];
|
||||||
// userStatus(EVENTS.disconnect, socket, socket.handshake.auth, socket);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle reconnection (Auto rejoin)
|
|
||||||
socket.on("reconnect", (attempt: number) => {
|
socket.on("reconnect", (attempt: number) => {
|
||||||
|
|
||||||
if (organization) {
|
if (organization) {
|
||||||
|
|||||||
@@ -1,208 +1,6 @@
|
|||||||
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||||
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
|
||||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
|
||||||
|
|
||||||
// export const setAssetModel = async (data: any) => {
|
|
||||||
// const {
|
|
||||||
// modelUuid,
|
|
||||||
// modelName,
|
|
||||||
// position,
|
|
||||||
// rotation,
|
|
||||||
// eventData,
|
|
||||||
// modelfileID,
|
|
||||||
// isLocked,
|
|
||||||
// isVisible,
|
|
||||||
// organization,
|
|
||||||
// } = data;
|
|
||||||
// try {
|
|
||||||
// const findvalue = await assetModel(organization).findOne({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// // modelName: modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (findvalue) {
|
|
||||||
// const updatevalue = await assetModel(organization).findOneAndUpdate(
|
|
||||||
// { modelUuid: modelUuid, isArchive: false },
|
|
||||||
// {
|
|
||||||
// modelName: modelName,
|
|
||||||
// position: position,
|
|
||||||
// rotation: rotation,
|
|
||||||
// isVisible: isVisible,
|
|
||||||
// isLocked: isLocked,
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model updated successfully",
|
|
||||||
// data: updatevalue,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// let assetData: any = {
|
|
||||||
// modelUuid,
|
|
||||||
// modelName,
|
|
||||||
// position,
|
|
||||||
// modelfileID,
|
|
||||||
// rotation,
|
|
||||||
// isLocked,
|
|
||||||
// isVisible,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if (eventData) {
|
|
||||||
// if (eventData.type === "Conveyor") {
|
|
||||||
// assetData.speed = eventData.speed;
|
|
||||||
// } else if (eventData.type === "Vehicle") {
|
|
||||||
// assetData.speed = eventData.points.speed;
|
|
||||||
// if (!eventData.points) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "Vehicle points must be a single object",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// // if (eventData.points.rotation) {
|
|
||||||
// // return {
|
|
||||||
// // success: false,
|
|
||||||
// // message: "Rotation is not allowed for Vehicle points",
|
|
||||||
// // organization: organization,
|
|
||||||
// // };
|
|
||||||
// // }
|
|
||||||
// if (eventData.points.triggers) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "triggers is not allowed for Vehicle points",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// assetData.points = eventData.points;
|
|
||||||
// assetData.type = eventData.type;
|
|
||||||
// }
|
|
||||||
// const assetDoc = await assetModel(organization).create(assetData);
|
|
||||||
// await assetDoc.save();
|
|
||||||
// let assetDatas;
|
|
||||||
// if (assetDoc.type === "Conveyor") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// speed: assetDoc.speed,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else if (assetDoc.type === "Vehicle") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else if (assetDoc.type === "ArmBot") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else if (assetDoc.type === "StaticMachine") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model created successfully",
|
|
||||||
// data: assetDatas,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// } catch (error: any) {
|
|
||||||
// // console.error("Error creating flooritems:", error);
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: error?.message || "Error occurred while ModelAsset",
|
|
||||||
// error,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const deleteAssetModel = async (data: any) => {
|
|
||||||
// const { modelUuid, modelName, organization } = data;
|
|
||||||
// try {
|
|
||||||
// const findValue = await assetModel(organization).findOneAndDelete({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// modelName: modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!findValue) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "model not found",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model deleted successfully",
|
|
||||||
// data: findValue,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// // console.error('Error get flooritems:', error);
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "Failed to delete asset",
|
|
||||||
// error,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//update 30/4..//setAssetModel//deleteAssetModel...........
|
|
||||||
export const setAssetModel = async (data: any) => {
|
export const setAssetModel = async (data: any) => {
|
||||||
const {
|
const {
|
||||||
modelUuid,
|
modelUuid,
|
||||||
@@ -218,7 +16,6 @@ export const setAssetModel = async (data: any) => {
|
|||||||
try {
|
try {
|
||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modelUuid: modelUuid,
|
modelUuid: modelUuid,
|
||||||
// modelName: modelName,
|
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -256,49 +53,16 @@ export const setAssetModel = async (data: any) => {
|
|||||||
if (eventData?.type === "Conveyor") {
|
if (eventData?.type === "Conveyor") {
|
||||||
assetData.eventData = {
|
assetData.eventData = {
|
||||||
type: eventData.type,
|
type: eventData.type,
|
||||||
// point:undefined,
|
|
||||||
points: eventData.points,
|
points: eventData.points,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
assetData.eventData = {
|
assetData.eventData = {
|
||||||
type: eventData.type,
|
type: eventData.type,
|
||||||
point: eventData.point,
|
point: eventData.point,
|
||||||
// points: undefined
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (eventData) {
|
|
||||||
|
|
||||||
// if (eventData.type === "Conveyor") {
|
|
||||||
// assetData.speed = eventData.speed;
|
|
||||||
// } else if (eventData.type === "Vehicle") {
|
|
||||||
// assetData.speed = eventData.points.speed;
|
|
||||||
// if (!eventData.points) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "Vehicle points must be a single object",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// // if (eventData.points.rotation) {
|
|
||||||
// // return {
|
|
||||||
// // success: false,
|
|
||||||
// // message: "Rotation is not allowed for Vehicle points",
|
|
||||||
// // organization: organization,
|
|
||||||
// // };
|
|
||||||
// // }
|
|
||||||
// if (eventData.points.triggers) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "triggers is not allowed for Vehicle points",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// assetData.points = eventData.points;
|
|
||||||
// assetData.type = eventData.type;
|
|
||||||
// }
|
|
||||||
const assetDoc = await assetModel(organization).create(assetData);
|
const assetDoc = await assetModel(organization).create(assetData);
|
||||||
await assetDoc.save();
|
await assetDoc.save();
|
||||||
let assetDatas;
|
let assetDatas;
|
||||||
@@ -374,7 +138,6 @@ export const setAssetModel = async (data: any) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// console.error("Error creating flooritems:", error);
|
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while ModelAsset",
|
message: error?.message || "Error occurred while ModelAsset",
|
||||||
@@ -392,11 +155,7 @@ export const deleteAssetModel = async (data: any) => {
|
|||||||
modelName,
|
modelName,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
// const findmodelValue = await assetModel(organization).findOne({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// modelName: modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
if (!asset) {
|
if (!asset) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -416,22 +175,11 @@ export const deleteAssetModel = async (data: any) => {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
await EventsDataModel(organization).updateMany(
|
||||||
{ modelUuid },
|
{ modelUuid },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
// const findProductEventData = await EventsDataModel(organization).find(modelUuid)
|
|
||||||
// console.log('findProductEventData: ', findProductEventData);
|
|
||||||
// if (findProductEventData) {
|
|
||||||
// for (const event of findProductEventData) {
|
|
||||||
// console.log("Event ID:", event);
|
|
||||||
// await EventsDataModel(organization).updateMany(
|
|
||||||
// { modelUuid },
|
|
||||||
// { $set: { isArchive: true } }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Model deleted successfully",
|
message: "Model deleted successfully",
|
||||||
@@ -439,7 +187,6 @@ export const deleteAssetModel = async (data: any) => {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.error('Error get flooritems:', error);
|
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Failed to delete asset",
|
message: "Failed to delete asset",
|
||||||
@@ -466,14 +213,11 @@ export const replaceEventDatas = async (data: any) => {
|
|||||||
if (existingModel.type === "Conveyor") {
|
if (existingModel.type === "Conveyor") {
|
||||||
speed = eventData?.speed;
|
speed = eventData?.speed;
|
||||||
}
|
}
|
||||||
// if (existingModel.type === "Vehicle") {
|
|
||||||
// speed = eventData?.points?.speed;
|
|
||||||
// }
|
|
||||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modelUuid, isArchive: false },
|
{ modelUuid, isArchive: false },
|
||||||
{
|
{
|
||||||
points: eventData?.points,
|
points: eventData?.points,
|
||||||
// speed: speed,
|
|
||||||
type: eventData?.type || existingModel?.type,
|
type: eventData?.type || existingModel?.type,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
|
|||||||
@@ -1,53 +1,94 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
|
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||||
|
|
||||||
export const setFloorItems = async (data: any) => {
|
export const setFloorItems = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
const { modelfileID,modelUuid, modelName, position, rotation,isLocked,isVisible, organization } = data
|
const {
|
||||||
|
modelfileID,
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
organization,
|
||||||
|
} = data;
|
||||||
|
|
||||||
|
const findvalue = await floorItemsModel(organization).findOne({
|
||||||
|
modelUuid: modelUuid,
|
||||||
|
modelName: modelName,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (findvalue) {
|
||||||
|
const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
|
||||||
|
{ modelUuid: modelUuid, modelName: modelName },
|
||||||
|
{
|
||||||
|
position: position,
|
||||||
|
rotation: rotation,
|
||||||
|
isVisible: isVisible,
|
||||||
|
isLocked: isLocked,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "flooritems updated",
|
||||||
|
data: updatevalue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const newValue = await floorItemsModel(organization).create({
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
modelfileID,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
});
|
||||||
|
|
||||||
const findvalue = await floorItemsModel(organization).findOne({ modelUuid: modelUuid, modelName: modelName })
|
return {
|
||||||
|
success: true,
|
||||||
if (findvalue) {
|
message: "flooritem created",
|
||||||
|
data: newValue,
|
||||||
const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
|
organization: organization,
|
||||||
{ modelUuid: modelUuid, modelName: modelName }, { position: position, rotation: rotation ,isVisible:isVisible,isLocked:isLocked}, { new: true });
|
};
|
||||||
return { success: true, message: 'flooritems updated', data: updatevalue,organization:organization }
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
const newValue = await floorItemsModel(organization).create({ modelUuid, modelName, modelfileID,position, rotation,isLocked,isVisible });
|
|
||||||
|
|
||||||
|
|
||||||
return { success: true, message: 'flooritem created', data: newValue,organization:organization }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating flooritems:', error);
|
|
||||||
return { success: false, message: 'Error creating or updating camera', error }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const deleteFloorItems = async (data: any)=>{
|
|
||||||
try {
|
|
||||||
const { modelUuid,modelName,organization } = data;
|
|
||||||
|
|
||||||
const findValue = await floorItemsModel(organization).findOneAndDelete({modelUuid:modelUuid,modelName:modelName})
|
|
||||||
if (!findValue) {
|
|
||||||
return { success: false, message: 'model not found',organization:organization }
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return { success: true, message: 'flooritem deleted', data: findValue,organization:organization }
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error get flooritems:', error);
|
|
||||||
return { success: false, message: 'Failed to delete flooritems', error }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating flooritems:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error creating or updating camera",
|
||||||
|
error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteFloorItems = async (data: any) => {
|
||||||
|
try {
|
||||||
|
const { modelUuid, modelName, organization } = data;
|
||||||
|
|
||||||
|
const findValue = await floorItemsModel(organization).findOneAndDelete({
|
||||||
|
modelUuid: modelUuid,
|
||||||
|
modelName: modelName,
|
||||||
|
});
|
||||||
|
if (!findValue) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "model not found",
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "flooritem deleted",
|
||||||
|
data: findValue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get flooritems:", error);
|
||||||
|
return { success: false, message: "Failed to delete flooritems", error };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const setWallItems = async (data: any) => {
|
|||||||
quaternion,
|
quaternion,
|
||||||
scale,
|
scale,
|
||||||
},
|
},
|
||||||
{ new: true } // Return the updated document
|
{ new: true }
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -58,8 +58,6 @@ export const setWallItems = async (data: any) => {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating wallIitem:", error);
|
console.error("Error creating wallIitem:", error);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,31 +1,45 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import { Socket } from "socket.io";
|
|
||||||
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
||||||
|
|
||||||
export const createCamera = async (data: any,) => {
|
export const createCamera = async (data: any) => {
|
||||||
const { userId, position, target, organization,rotation } = data
|
const { userId, position, target, organization, rotation } = data;
|
||||||
try {
|
try {
|
||||||
|
const findCamera = await cameraModel(organization).findOne({
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
if (findCamera) {
|
||||||
|
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
||||||
|
{ userId: userId },
|
||||||
|
{ position: position, target: target, rotation: rotation },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Camera updated",
|
||||||
|
data: updateCamera,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const newCamera = await cameraModel(organization).create({
|
||||||
|
userId,
|
||||||
|
position,
|
||||||
|
target,
|
||||||
|
rotation,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
success: true,
|
||||||
if (findCamera) {
|
message: "Camera created",
|
||||||
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
data: newCamera,
|
||||||
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
|
organization: organization,
|
||||||
// io.emit('cameraUpdateResponse', { success: true, message: 'Camera updated', data: updateCamera });
|
};
|
||||||
return { success: true, message: 'Camera updated', data: updateCamera,organization:organization}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation })
|
|
||||||
|
|
||||||
return { success: true, message: 'Camera created' ,data:newCamera,organization:organization}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating camera:', error);
|
|
||||||
return { success: false, message: 'Error creating or updating camera', error, organization:organization}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.error("Error creating camera:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error creating or updating camera",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,33 +1,55 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
||||||
|
|
||||||
|
export const setEnvironment = async (data: any) => {
|
||||||
|
const {
|
||||||
|
userId,
|
||||||
|
roofVisibility,
|
||||||
|
wallVisibility,
|
||||||
|
shadowVisibility,
|
||||||
|
organization,
|
||||||
|
} = data;
|
||||||
|
try {
|
||||||
|
const findvalue = await environmentModel(organization).findOne({
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
if (findvalue) {
|
||||||
|
const updatevalue = await environmentModel(organization).findOneAndUpdate(
|
||||||
|
{ userId: userId },
|
||||||
|
{
|
||||||
|
roofVisibility: roofVisibility,
|
||||||
|
wallVisibility: wallVisibility,
|
||||||
|
shadowVisibility: shadowVisibility,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "evironments updated",
|
||||||
|
data: updatevalue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const newValue = await environmentModel(organization).create({
|
||||||
|
userId,
|
||||||
|
roofVisibility,
|
||||||
|
wallVisibility,
|
||||||
|
shadowVisibility,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
export const setEnvironment = async (data: any,) => {
|
success: true,
|
||||||
const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = data
|
message: "evironments created",
|
||||||
try {
|
data: newValue,
|
||||||
|
organization: organization,
|
||||||
const findvalue = await environmentModel(organization).findOne({ userId: userId })
|
};
|
||||||
if (findvalue) {
|
|
||||||
const updatevalue = await environmentModel(organization).findOneAndUpdate(
|
|
||||||
{ userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility,shadowVisibility:shadowVisibility }, { new: true });
|
|
||||||
// res.status(201).json(updatevalue);
|
|
||||||
return { success: true, message: 'evironments updated', data: updatevalue,organization:organization }
|
|
||||||
|
|
||||||
} else {
|
|
||||||
const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility,shadowVisibility });
|
|
||||||
|
|
||||||
return { success: true, message: 'evironments created', data: newValue,organization:organization }
|
|
||||||
// res.status(201).json(newValue);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating evironments:', error);
|
|
||||||
return { success: false, message: 'Error creating or updating evironments', error ,organization:organization}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.error("Error creating evironments:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error creating or updating evironments",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import lineModel from "../../../shared/model/lines/lines-Model.ts";
|
import lineModel from "../../../shared/model/lines/lines-Model.ts";
|
||||||
|
|
||||||
export const createLineItems = async (data: any) => {
|
export const createLineItems = async (data: any) => {
|
||||||
@@ -11,8 +10,6 @@ export const createLineItems = async (data: any) => {
|
|||||||
data: newLine,
|
data: newLine,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -25,11 +22,9 @@ export const createLineItems = async (data: any) => {
|
|||||||
export const updateLineItems = async (data: any) => {
|
export const updateLineItems = async (data: any) => {
|
||||||
const { organization, uuid, position } = data;
|
const { organization, uuid, position } = data;
|
||||||
try {
|
try {
|
||||||
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
await lineModel(organization).updateMany(
|
||||||
// Update the position of the line matching the uuid
|
{ "line.uuid": uuid },
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
{ $set: { "line.$.position": position } }
|
||||||
{ "line.uuid": uuid }, // Filter: Find the line with the given uuid
|
|
||||||
{ $set: { "line.$.position": position } } // Update the position and type
|
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -37,8 +32,6 @@ export const updateLineItems = async (data: any) => {
|
|||||||
data: { uuid: uuid, position: position },
|
data: { uuid: uuid, position: position },
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating Lines:", error);
|
console.error("Error creating Lines:", error);
|
||||||
return {
|
return {
|
||||||
@@ -55,12 +48,8 @@ export const deleteLineItems = async (data: any) => {
|
|||||||
try {
|
try {
|
||||||
const inputUuids = line.map((item: any) => item.uuid);
|
const inputUuids = line.map((item: any) => item.uuid);
|
||||||
|
|
||||||
// const findValue = await lineModel(organization).findOneAndDelete({
|
|
||||||
|
|
||||||
// line: { $elemMatch: { uuid: { $in: inputUuids } } },
|
|
||||||
// });
|
|
||||||
const findValue = await lineModel(organization).findOneAndDelete({
|
const findValue = await lineModel(organization).findOneAndDelete({
|
||||||
"line.uuid": { $all: inputUuids }, // Ensure all UUIDs are present in the `line` key
|
"line.uuid": { $all: inputUuids },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
@@ -97,10 +86,9 @@ export const deleteLayer = async (data: any) => {
|
|||||||
} else {
|
} else {
|
||||||
await lineModel(organization).deleteMany({ layer: layer });
|
await lineModel(organization).deleteMany({ layer: layer });
|
||||||
|
|
||||||
// Update documents with layer greater than -1
|
await lineModel(organization).updateMany(
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
|
||||||
{ layer: { $gt: layer } },
|
{ layer: { $gt: layer } },
|
||||||
{ $inc: { layer: -1 } } // Example operation: decrementing layer by 1
|
{ $inc: { layer: -1 } }
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
import zoneModel from "../../../shared/model/builder/lines/zone-Model.ts";
|
|
||||||
|
|
||||||
// export const setZone = async (data: any) => {
|
|
||||||
// const { organization, userId, zoneData } = data
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// console.log('data: ', data);
|
|
||||||
// const zoneId = zoneData.zoneId
|
|
||||||
// const points = zoneData.points
|
|
||||||
// const zoneName = zoneData.zoneName
|
|
||||||
// const layer = zoneData.layer
|
|
||||||
// const viewPortCenter = zoneData.viewPortCenter
|
|
||||||
// const viewPortposition = zoneData.viewPortposition
|
|
||||||
// const sceneID = zoneData.sceneID
|
|
||||||
|
|
||||||
// const existingZone = await zoneModel(organization).findOne({
|
|
||||||
// zoneId: zoneId,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!existingZone) {
|
|
||||||
// const newZone = await zoneModel(organization).create({
|
|
||||||
// zoneName: zoneName,
|
|
||||||
// zoneId: zoneId,
|
|
||||||
// zonePoints: points,
|
|
||||||
// viewPortposition: viewPortposition,
|
|
||||||
// viewPortCenter: viewPortCenter,
|
|
||||||
// createdBy: userId,
|
|
||||||
// layer: layer,
|
|
||||||
// sceneID: sceneID,
|
|
||||||
// });
|
|
||||||
// if (newZone)
|
|
||||||
// return { success: true, message: 'zone created', data: newZone, organization: organization }
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// const replaceZone = await zoneModel(organization).findOneAndUpdate(
|
|
||||||
// { zoneId: zoneId, isArchive: false },
|
|
||||||
// {
|
|
||||||
// zonePoints: points,
|
|
||||||
// viewPortposition: viewPortposition,
|
|
||||||
// viewPortCenter: viewPortCenter,
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
// if (!replaceZone)
|
|
||||||
// return { success: false, message: 'Zone not updated',organization: organization }
|
|
||||||
// else
|
|
||||||
// return { success: true, message: 'zone updated', data: replaceZone, organization: organization }
|
|
||||||
|
|
||||||
// }
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return { success: false, message: 'Zone not found', error,organization: organization }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// export const deleteZone = async (data: any) => {
|
|
||||||
// const { organization, userId, zoneId } = data
|
|
||||||
// try {
|
|
||||||
// const existingZone = await zoneModel(organization).findOne({
|
|
||||||
// zoneId: zoneId,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!existingZone) {
|
|
||||||
// return { success: true, message: 'Invalid zone ID', organization: organization }
|
|
||||||
// } else {
|
|
||||||
// const deleteZone = await zoneModel(organization).findOneAndUpdate(
|
|
||||||
// { zoneId: zoneId, isArchive: false },
|
|
||||||
// {
|
|
||||||
// isArchive: true,
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (deleteZone) {
|
|
||||||
// return { success: true, message: 'zone deleted', data: deleteZone, organization: organization }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return { success: false, message: 'Zone not found', error,organization: organization }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -5,137 +5,131 @@ import panelModel from "../../../shared/model/vizualization/panelmodel.ts";
|
|||||||
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
||||||
import widgetModel from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetModel from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
export const setZone = async (data: any) => {
|
export const setZone = async (data: any) => {
|
||||||
const { organization, userId, zoneData } = data
|
const { organization, userId, zoneData } = data;
|
||||||
try {
|
try {
|
||||||
const zoneId = zoneData.zoneId
|
const zoneId = zoneData.zoneId;
|
||||||
const points = zoneData.points
|
const points = zoneData.points;
|
||||||
const zoneName = zoneData.zoneName
|
const zoneName = zoneData.zoneName;
|
||||||
const layer = zoneData.layer
|
const layer = zoneData.layer;
|
||||||
const viewPortCenter = zoneData.viewPortCenter
|
const viewPortCenter = zoneData.viewPortCenter;
|
||||||
const viewPortposition = zoneData.viewPortposition
|
const viewPortposition = zoneData.viewPortposition;
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
if (findZoneId) {
|
zoneId: zoneId,
|
||||||
const updateZone = await zoneModel(organization).findOneAndUpdate(
|
});
|
||||||
{ zoneId: zoneId }, { points: points, viewPortposition: viewPortposition, viewPortCenter: viewPortCenter }, { new: true }
|
if (findZoneId) {
|
||||||
).select("-_id -__v")
|
const updateZone = await zoneModel(organization)
|
||||||
return { success: true, message: 'zone updated', data: updateZone, organization: organization }
|
.findOneAndUpdate(
|
||||||
} else {
|
{ zoneId: zoneId },
|
||||||
const zoneCreate = await zoneModel(organization).create({
|
{
|
||||||
zoneId, createdBy: userId, zoneName: zoneName, points, layer, viewPortCenter, viewPortposition
|
points: points,
|
||||||
})
|
viewPortposition: viewPortposition,
|
||||||
const createdZone = await zoneModel(organization)
|
viewPortCenter: viewPortCenter,
|
||||||
.findById(zoneCreate._id)
|
},
|
||||||
.select('-_id -__v')
|
{ new: true }
|
||||||
.lean();
|
)
|
||||||
return { success: true, message: 'zone created', data: createdZone, organization: organization }
|
.select("-_id -__v");
|
||||||
}
|
return {
|
||||||
} catch (error) {
|
success: true,
|
||||||
console.log('error: ', error);
|
message: "zone updated",
|
||||||
return { success: false, message: 'Zone not found', error , organization: organization}
|
data: updateZone,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
|
zoneId,
|
||||||
|
createdBy: userId,
|
||||||
|
zoneName: zoneName,
|
||||||
|
points,
|
||||||
|
layer,
|
||||||
|
viewPortCenter,
|
||||||
|
viewPortposition,
|
||||||
|
});
|
||||||
|
const createdZone = await zoneModel(organization)
|
||||||
|
.findById(zoneCreate._id)
|
||||||
|
.select("-_id -__v")
|
||||||
|
.lean();
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "zone created",
|
||||||
|
data: createdZone,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Zone not found",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const deleteZone = async (data: any) => {
|
export const deleteZone = async (data: any) => {
|
||||||
const { organization, userId, zoneId } = data
|
const { organization, userId, zoneId } = data;
|
||||||
try {
|
try {
|
||||||
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
if (findZoneId) {
|
||||||
|
const deleteZone = await zoneModel(organization)
|
||||||
|
.findOneAndDelete({ zoneId: zoneId, createdBy: userId })
|
||||||
|
.select("-_id -__v");
|
||||||
|
if (deleteZone) {
|
||||||
|
const panels = await panelModel(organization).find({ zoneId });
|
||||||
|
console.log("panels: ", panels);
|
||||||
|
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
const allWidgetIds = panels.reduce((ids: string[], panel: any) => {
|
||||||
if (findZoneId) {
|
return ids.concat(panel.widgets || []);
|
||||||
const deleteZone = await zoneModel(organization).findOneAndDelete(
|
}, []);
|
||||||
{ zoneId: zoneId, createdBy: userId }
|
|
||||||
).select("-_id -__v")
|
|
||||||
if (deleteZone) {
|
|
||||||
const panels = await panelModel(organization).find({ zoneId });
|
|
||||||
console.log('panels: ', panels);
|
|
||||||
|
|
||||||
// Collect all widget IDs from all panels
|
await widgetModel(organization).updateMany(
|
||||||
const allWidgetIds = panels.reduce((ids: string[], panel: any) => {
|
{ _id: { $in: allWidgetIds } },
|
||||||
return ids.concat(panel.widgets || []);
|
{ $set: { isArchive: true } }
|
||||||
}, []);
|
);
|
||||||
|
|
||||||
// Soft delete all widgets
|
await panelModel(organization).updateMany(
|
||||||
await widgetModel(organization).updateMany(
|
{ zoneId },
|
||||||
{ _id: { $in: allWidgetIds } },
|
{ $set: { isArchive: true } }
|
||||||
{ $set: { isArchive: true } }
|
);
|
||||||
);
|
|
||||||
|
|
||||||
// Soft delete all panels for the zone
|
await Promise.all([
|
||||||
await panelModel(organization).updateMany(
|
widget3dModel(organization).updateMany(
|
||||||
{ zoneId },
|
{ zoneId },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
),
|
||||||
|
templateModel(organization).updateMany(
|
||||||
|
{ zoneId },
|
||||||
|
{ $set: { isArchive: true } }
|
||||||
|
),
|
||||||
|
floatWidgetModel(organization).updateMany(
|
||||||
|
{ zoneId },
|
||||||
|
{ $set: { isArchive: true } }
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Soft delete from other models
|
return {
|
||||||
await Promise.all([
|
success: true,
|
||||||
widget3dModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
message: "zone deleted",
|
||||||
templateModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
data: deleteZone,
|
||||||
floatWidgetModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
organization: organization,
|
||||||
]);
|
};
|
||||||
}
|
} else {
|
||||||
|
return {
|
||||||
return { success: true, message: 'zone deleted', data: deleteZone, organization: organization }
|
success: true,
|
||||||
} else {
|
message: "Invalid zone ID",
|
||||||
|
organization: organization,
|
||||||
return { success: true, message: 'Invalid zone ID', organization: organization }
|
};
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log('error: ', error);
|
|
||||||
return { success: false, message: 'Zone not found', error, organization: organization }
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
// export const zoneDatasDeleted = async (data: { organization: string; userId: string; zoneId: string }) => {
|
console.log("error: ", error);
|
||||||
// const { organization, userId, zoneId } = data;
|
return {
|
||||||
// console.log('data: ', data);
|
success: false,
|
||||||
|
message: "Zone not found",
|
||||||
// try {
|
error,
|
||||||
// const findZone = await zoneModel(organization).findOne({ zoneId });
|
organization: organization,
|
||||||
|
};
|
||||||
// if (!findZone) {
|
}
|
||||||
// return { success: false, message: 'Invalid zone ID', organization };
|
};
|
||||||
// }
|
|
||||||
|
|
||||||
// // Soft delete the zone
|
|
||||||
// const deleteZone = await zoneModel(organization).findOneAndDelete(
|
|
||||||
// { zoneId, createdBy: userId },
|
|
||||||
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (deleteZone) {
|
|
||||||
// const panels = await panelModel(organization).find({ zoneId });
|
|
||||||
// console.log('panels: ', panels);
|
|
||||||
|
|
||||||
// // Collect all widget IDs from all panels
|
|
||||||
// const allWidgetIds = panels.reduce((ids: string[], panel: any) => {
|
|
||||||
// return ids.concat(panel.widgets || []);
|
|
||||||
// }, []);
|
|
||||||
// console.log('allWidgetIds: ', allWidgetIds);
|
|
||||||
|
|
||||||
// // Soft delete all widgets
|
|
||||||
// await widgetModel(organization).updateMany(
|
|
||||||
// { _id: { $in: allWidgetIds } },
|
|
||||||
// { $set: { isArchive: true } }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Soft delete all panels for the zone
|
|
||||||
// await panelModel(organization).updateMany(
|
|
||||||
// { zoneId },
|
|
||||||
// { $set: { isArchive: true } }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Soft delete from other models
|
|
||||||
// await Promise.all([
|
|
||||||
// widget3dModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
|
||||||
// templateModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
|
||||||
// floatWidgetModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log("Zone and associated data archived");
|
|
||||||
// return { success: true, message: 'Zone and associated data archived', data: deleteZone, organization };
|
|
||||||
|
|
||||||
// return { success: true, message: 'Zone and associated data deleted', data: deleteZone, organization };
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('Zone deletion error:', error);
|
|
||||||
// return { success: false, message: 'An error occurred while deleting the zone', error, organization };
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|||||||
@@ -1,137 +1,109 @@
|
|||||||
import cameraModel from "../../../shared/model/camera/camera-Model.ts"
|
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
||||||
import userModel from "../../../shared/model/user-Model.ts"
|
import userModel from "../../../shared/model/user-Model.ts";
|
||||||
|
|
||||||
export const activeUsers = async (data: any) => {
|
export const activeUsers = async (data: any) => {
|
||||||
const {organization}=data
|
const { organization } = data;
|
||||||
// console.log('data: ', data);
|
try {
|
||||||
try {
|
if (data && data.email) {
|
||||||
if (data && data.email) {
|
const email = data.email;
|
||||||
|
const organization = email.split("@")[1].split(".")[0];
|
||||||
|
|
||||||
const email = data.email
|
const findUser = await userModel(organization).findOne({ email });
|
||||||
const organization = email.split("@")[1].split(".")[0]
|
|
||||||
|
|
||||||
const findUser = await userModel(organization).findOne({email})
|
if (findUser) {
|
||||||
|
const updateActiveStatus = await userModel(
|
||||||
|
organization
|
||||||
|
).findOneAndUpdate(
|
||||||
|
{ email: findUser.email },
|
||||||
|
{ activeStatus: "online" },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
if (findUser) {
|
if (updateActiveStatus) {
|
||||||
const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:findUser.email},{activeStatus:"online"},{new:true})
|
const cameraDatas = await cameraModel(organization)
|
||||||
|
.findOne({ userId: updateActiveStatus._id })
|
||||||
|
.select("position target rotation -_id");
|
||||||
|
|
||||||
if (updateActiveStatus) {
|
if (cameraDatas) {
|
||||||
const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id})
|
const result = {
|
||||||
.select("position target rotation -_id");
|
position: cameraDatas.position,
|
||||||
|
target: cameraDatas.target,
|
||||||
|
rotation: cameraDatas.rotation,
|
||||||
|
userData: {
|
||||||
|
_id: updateActiveStatus._id,
|
||||||
|
userName: updateActiveStatus.userName,
|
||||||
|
email: updateActiveStatus.email,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if (cameraDatas) {
|
return {
|
||||||
const result = {
|
success: true,
|
||||||
position: cameraDatas.position,
|
message: "user connect ",
|
||||||
target: cameraDatas.target,
|
data: result,
|
||||||
rotation: cameraDatas.rotation,
|
organization: organization,
|
||||||
userData: {
|
};
|
||||||
_id: updateActiveStatus._id,
|
}
|
||||||
userName: updateActiveStatus.userName,
|
|
||||||
email: updateActiveStatus.email,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { success: true, message: 'user connect ', data: result,organization:organization }
|
|
||||||
// return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
// console.error('Invalid data or missing email:', data);
|
|
||||||
// Handle the error or return a default value
|
|
||||||
// Example: Return an error response if the email is invalid
|
|
||||||
|
|
||||||
return { success: false, message: 'Email is missing or invalid', organization:organization }
|
|
||||||
// return res.status(400).send({ message: 'Email is missing or invalid' });
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// // return [];
|
return {
|
||||||
} catch (error:any) {
|
success: false,
|
||||||
return { success: false, message: error?.message || "Error occurred while activeUser", error, organization: organization }
|
message: "Email is missing or invalid",
|
||||||
|
organization: organization,
|
||||||
// return { success: false, message:error}
|
};
|
||||||
}
|
}
|
||||||
}
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: error?.message || "Error occurred while activeUser",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const activeUserOffline = async (data: any) => {
|
export const activeUserOffline = async (data: any) => {
|
||||||
|
const email = data.email;
|
||||||
|
const organization = email.split("@")[1].split(".")[0];
|
||||||
|
try {
|
||||||
|
const findUsers = await userModel(organization).findOne({ email });
|
||||||
|
if (findUsers) {
|
||||||
|
const updateActiveStatus = await userModel(organization).findOneAndUpdate(
|
||||||
|
{ email: email },
|
||||||
|
{ activeStatus: "offline" },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
if (updateActiveStatus) {
|
||||||
|
const cameraDatas = await cameraModel(organization)
|
||||||
|
.findOne({ userId: updateActiveStatus._id })
|
||||||
|
.select("position target rotation -_id");
|
||||||
|
if (cameraDatas) {
|
||||||
|
const result = {
|
||||||
|
position: cameraDatas.position,
|
||||||
|
target: cameraDatas.target,
|
||||||
|
rotation: cameraDatas.rotation,
|
||||||
|
userData: {
|
||||||
|
_id: updateActiveStatus._id,
|
||||||
|
userName: updateActiveStatus.userName,
|
||||||
|
email: updateActiveStatus.email,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
const email = data.email
|
success: true,
|
||||||
const organization = email.split("@")[1].split(".")[0]
|
message: "user disconnect",
|
||||||
try {
|
data: result,
|
||||||
|
organization: organization,
|
||||||
const findUsers = await userModel(organization).findOne({email})
|
};
|
||||||
// console.log('findUsers: ', findUsers);
|
|
||||||
if (findUsers) {
|
|
||||||
const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:email},{activeStatus:"offline"},{new:true})
|
|
||||||
// console.log('updateActiveStatus: ',updateActiveStatus);
|
|
||||||
if (updateActiveStatus) {
|
|
||||||
const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id})
|
|
||||||
.select("position target rotation -_id");
|
|
||||||
// console.log('cameraDatas: ', cameraDatas);
|
|
||||||
if (cameraDatas) {
|
|
||||||
const result = {
|
|
||||||
position: cameraDatas.position,
|
|
||||||
target: cameraDatas.target,
|
|
||||||
rotation: cameraDatas.rotation,
|
|
||||||
userData: {
|
|
||||||
_id: updateActiveStatus._id,
|
|
||||||
userName: updateActiveStatus.userName,
|
|
||||||
email: updateActiveStatus.email,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// console.log("Formatted Result:", result);
|
|
||||||
|
|
||||||
|
|
||||||
// return result;
|
|
||||||
return { success: true, message: 'user disconnect', data: result,organization:organization }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// // return [];
|
}
|
||||||
} catch (error:any) {
|
|
||||||
return { success: false, message: error?.message || "Error occurred while activeUser", error, organization: organization }
|
|
||||||
|
|
||||||
// return { success: false, message: error}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error: any) {
|
||||||
type OnlineUsersMap = Map<string, Set<string>>;
|
return {
|
||||||
|
success: false,
|
||||||
// export const addUserToOnlineList = async (
|
message: error?.message || "Error occurred while activeUser",
|
||||||
// organization: string,
|
error,
|
||||||
// email: string,
|
organization: organization,
|
||||||
// onlineUsers: OnlineUsersMap,
|
};
|
||||||
// socket: any,
|
}
|
||||||
// namespace: string
|
};
|
||||||
// ) => {
|
|
||||||
// if (!organization || !email) return;
|
|
||||||
// console.log('organization: ', organization);
|
|
||||||
|
|
||||||
// // Ensure the organization entry exists
|
|
||||||
// if (!onlineUsers.has(organization)) {
|
|
||||||
// onlineUsers.set(organization, new Set());
|
|
||||||
// }
|
|
||||||
// const findUser = await userModel(organization).findOne({email})
|
|
||||||
// if (!findUser) {
|
|
||||||
// return { success: false, message: "User not found", organization };
|
|
||||||
// }
|
|
||||||
// const userId = findUser._id;
|
|
||||||
// console.log(`🔍 Found user with ID: ${userId}`);
|
|
||||||
// // Add user to the online set
|
|
||||||
// onlineUsers.get(organization)!.add(userId);
|
|
||||||
|
|
||||||
// console.log(`✅ User ${userId} is online (Org: ${organization})`);
|
|
||||||
|
|
||||||
// // Emit updated online users list
|
|
||||||
// socket.emit("users:online", {
|
|
||||||
// organization,
|
|
||||||
// users: [...onlineUsers.get(organization)!],
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
|||||||
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
|
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
|
||||||
export const add3Dwidget = async (data: any,callback:any) => {
|
export const add3Dwidget = async (data: any,callback:any) => {
|
||||||
const { organization, widget, zoneId } = data;
|
const { organization, widget, zoneId } = data;
|
||||||
// console.log("data: ", data);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
|||||||
@@ -143,12 +143,11 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: "FloatWidget update unsuccessfull",
|
message: "FloatWidget update unsuccessfull",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "FloatWidget update unsuccessfull",
|
message: "FloatWidget update unsuccessfull",
|
||||||
// data: updateWidget,
|
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -162,7 +161,7 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget updated successfully",
|
message: "Widget updated successfully",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -203,7 +202,7 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "duplicate FloatWidget created successfully",
|
message: "duplicate FloatWidget created successfully",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -217,7 +216,7 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while float",
|
message: error?.message || "Error occurred while float",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -256,9 +255,7 @@ export const deletefloat = async (data: any) => {
|
|||||||
{ isArchive: true },
|
{ isArchive: true },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
// if(!widgetData) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
const floatDeleteData = {
|
const floatDeleteData = {
|
||||||
floatWidgetID: findfloatWidget.floatWidgetID,
|
floatWidgetID: findfloatWidget.floatWidgetID,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user