Compare commits
32 Commits
Main-dupli
...
branch-1
| Author | SHA1 | Date | |
|---|---|---|---|
| 1609f64695 | |||
| 4331f88c9a | |||
| c38a698692 | |||
| bea6044b25 | |||
| 7fb2a6bd2d | |||
| 6b5bee879b | |||
| 694d50b278 | |||
| 2c28ffe9aa | |||
| fdfc7a983c | |||
| 7603c1b64a | |||
| 9b4f8c0841 | |||
| fd578df59f | |||
| 089c6af1b6 | |||
| ac8de5d33d | |||
| d863465030 | |||
| 9be63d3459 | |||
| 2aa8c479fa | |||
| f62ccd1ea9 | |||
| 611bffdaa9 | |||
| 1c55013c2b | |||
| 5566b74633 | |||
| 0b30a8aeaa | |||
| c64e5ea8b5 | |||
| 6c17ba4590 | |||
| 0e7db2af8d | |||
| bd0c5013a9 | |||
| 46dafd4417 | |||
| 79b6a4fa75 | |||
| e2be6deb0a | |||
| af8510ad90 | |||
| 2997967899 | |||
| ca8e8b66f4 |
34
.env
34
.env
@@ -1,14 +1,32 @@
|
|||||||
# MONGO_URI=mongodb://192.168.0.110/
|
MONGO_URI=mongodb://192.168.0.110/
|
||||||
# MONGO_USER=mydata
|
MONGO_USER=mydata
|
||||||
# MONGO_PASSWORD=mongodb@hexr2002
|
MONGO_PASSWORD=mongodb@hexr2002
|
||||||
# MONGO_AUTH_DB=admin
|
|
||||||
|
|
||||||
MONGO_URI=mongodb://mongo/
|
|
||||||
MONGO_USER=admin
|
|
||||||
MONGO_PASSWORD=admin321
|
|
||||||
MONGO_AUTH_DB=admin
|
MONGO_AUTH_DB=admin
|
||||||
|
|
||||||
|
# MONGO_URI=mongodb://mongo/
|
||||||
|
# MONGO_USER=admin
|
||||||
|
# MONGO_PASSWORD=admin321
|
||||||
|
# MONGO_AUTH_DB=admin
|
||||||
|
|
||||||
API_PORT=5000
|
API_PORT=5000
|
||||||
SOCKET_PORT=8000
|
SOCKET_PORT=8000
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
FRONTEND_ORIGIN_PROD=http://185.100.212.76:8200
|
FRONTEND_ORIGIN_PROD=http://185.100.212.76:8200
|
||||||
|
|
||||||
|
# MinIO
|
||||||
|
MinIO_URL=185.100.212.76
|
||||||
|
MinIO_PORT=9999
|
||||||
|
MinIO_accessKey=sabarinathan
|
||||||
|
MinIO_secretKey=sabarinathan
|
||||||
|
|
||||||
|
|
||||||
|
# token
|
||||||
|
JWT_SECRET="DwinzoProject"
|
||||||
|
REFRESH_JWT_SECRET="RefreshDwinzoProject"
|
||||||
|
|
||||||
|
# redis
|
||||||
|
REDIS_ENV= true
|
||||||
|
REDIS_LOCAL =127.0.0.1
|
||||||
|
REDIS_PORT=6379
|
||||||
|
# REDIS_DOCKER =185.100.212.76
|
||||||
|
# REDIS_PORT=6666
|
||||||
766
package-lock.json
generated
766
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -18,9 +18,13 @@
|
|||||||
"express": "^4.21.1",
|
"express": "^4.21.1",
|
||||||
"fs": "^0.0.1-security",
|
"fs": "^0.0.1-security",
|
||||||
"http": "^0.0.1-security",
|
"http": "^0.0.1-security",
|
||||||
|
"ioredis": "^5.6.1",
|
||||||
"ip": "^2.0.1",
|
"ip": "^2.0.1",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
"minio": "^8.0.5",
|
||||||
"mongoose": "^8.8.1",
|
"mongoose": "^8.8.1",
|
||||||
|
"multer": "^1.4.5-lts.2",
|
||||||
|
"nodemailer": "^7.0.3",
|
||||||
"socket.io": "^4.8.1",
|
"socket.io": "^4.8.1",
|
||||||
"swagger-autogen": "^2.23.7",
|
"swagger-autogen": "^2.23.7",
|
||||||
"swagger-ui-express": "^5.0.1"
|
"swagger-ui-express": "^5.0.1"
|
||||||
@@ -31,7 +35,10 @@
|
|||||||
"@types/express": "^5.0.0",
|
"@types/express": "^5.0.0",
|
||||||
"@types/ip": "^1.1.3",
|
"@types/ip": "^1.1.3",
|
||||||
"@types/jsonwebtoken": "^9.0.7",
|
"@types/jsonwebtoken": "^9.0.7",
|
||||||
|
"@types/mime-types": "^2.1.4",
|
||||||
|
"@types/multer": "^1.4.12",
|
||||||
"@types/node": "^22.9.0",
|
"@types/node": "^22.9.0",
|
||||||
|
"@types/nodemailer": "^6.4.17",
|
||||||
"@types/swagger-ui-express": "^4.1.7",
|
"@types/swagger-ui-express": "^4.1.7",
|
||||||
"nodemon": "^3.1.7",
|
"nodemon": "^3.1.7",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { assetsFloorservice } from "../controller/simulation/assetsFloorservice.ts";
|
import { AssetsFloorService } from "../controller/simulation/assetsFloorservice.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/setasset", assetsFloorservice.setFloorassets);
|
router.post("/setasset", AssetsFloorService.setFloorassets);
|
||||||
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
router.get("/floorAssets/:organization", AssetsFloorService.getFloorItems);
|
||||||
router.patch(
|
router.patch(
|
||||||
"/updateFloorAssets",
|
"/updateFloorAssets",
|
||||||
assetsFloorservice.updateAssetPositionRotation
|
AssetsFloorService.updateAssetPositionRotation
|
||||||
);
|
);
|
||||||
router.patch("/eventDataUpdate", assetsFloorservice.replaceEventDatas);
|
router.patch("/eventDataUpdate", AssetsFloorService.replaceEventDatas);
|
||||||
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
// router.get("/pointData/:modelfileID/:organization", AssetsFloorService.gettypePoints);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { pointService } from "../controller/assets/pointService.ts";
|
import { PointService } from "../controller/assets/pointService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/pointSchema", pointService.addPoints);
|
router.post("/pointSchema", PointService.addPoints);
|
||||||
router.get("/pointData/:modelfileID/:organization", pointService.gettypePoints);
|
router.get("/pointData/:modelfileID/:organization", PointService.gettypePoints);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { camera } from '../controller/camera/camera-Services.ts';
|
import { Camera } from '../controller/camera/camera-Services.ts';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.post('/setCamera',camera.createCamera)
|
router.post('/setCamera',Camera.createCamera)
|
||||||
router.get('/getCamera/:organization/:userId',camera.getCamera)
|
router.get('/getCamera/:organization/:userId',Camera.getCamera)
|
||||||
router.get('/activeCameras/:organization',camera.onlineActiveDatas)
|
router.get('/activeCameras/:organization',Camera.onlineActiveDatas)
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { environment } from '../controller/environments/environments-Services.ts';
|
import { Environment } from '../controller/environments/environments-Services.ts';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post('/setEvironments',environment.setEnvironment)
|
router.post('/setEvironments',Environment.setEnvironment)
|
||||||
router.get('/findEnvironments/:organization/:userId',environment.getEnvironment)
|
router.get('/findEnvironments/:organization/:userId',Environment.getEnvironment)
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { floatWidgetService } from "../controller/visualization/floatWidgetService.ts";
|
import { FloatWidgetService } from "../controller/visualization/floatWidgetService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/floatwidget/save", floatWidgetService.addfloatWidget);
|
router.post("/floatwidget/save", FloatWidgetService.addfloatWidget);
|
||||||
router.patch("/floatwidget/delete", floatWidgetService.deletefloatWidget);
|
router.patch("/floatwidget/delete", FloatWidgetService.deletefloatWidget);
|
||||||
router.get(
|
router.get(
|
||||||
"/floadData/:zoneId/:organization",
|
"/floadData/:zoneId/:organization",
|
||||||
floatWidgetService.getfloatWidget
|
FloatWidgetService.getfloatWidget
|
||||||
);
|
);
|
||||||
router.get(
|
router.get(
|
||||||
"/A_floatWidget/:floatWidgetID/:organization",
|
"/A_floatWidget/:floatWidgetID/:organization",
|
||||||
floatWidgetService.getsinglefloatWidget
|
FloatWidgetService.getsinglefloatWidget
|
||||||
);
|
);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
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',floorItems.deleteFloorItems)
|
||||||
router.delete('/deletefloorItem',assetsFloorservice.deleteFloorItems)
|
router.delete("/deletefloorItem", AssetsFloorService.deleteFloorItems);
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
12
src/api-server/Routes/homepageRoutes.ts
Normal file
12
src/api-server/Routes/homepageRoutes.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import * as express from "express";
|
||||||
|
import { recentDataController, searchProjectController, searchTrashProjectController } from "../controller/home/homeControllers.ts";
|
||||||
|
import { searchTrashProject } from "../../shared/services/home/homeService.ts";
|
||||||
|
import { tutorialsDataController } from "../controller/home/tutorialControllers.ts";
|
||||||
|
|
||||||
|
const homePageRouter = express.Router();
|
||||||
|
|
||||||
|
homePageRouter.get("/RecentlyViewed/:userId/:organization", recentDataController);
|
||||||
|
homePageRouter.get("/searchProjects", searchProjectController);
|
||||||
|
homePageRouter.get("/searchTrashProjects", searchTrashProjectController);
|
||||||
|
homePageRouter.get("/tutorials", tutorialsDataController);
|
||||||
|
export default homePageRouter;
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
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;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { panelService } from "../controller/visualization/panelService.ts";
|
import { PanelService } from "../controller/visualization/panelService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -101,7 +101,7 @@ const router = express.Router();
|
|||||||
* 500:
|
* 500:
|
||||||
* description: Server error
|
* description: Server error
|
||||||
*/
|
*/
|
||||||
router.post("/panel/save", panelService.AddPanel);
|
router.post("/panel/save", PanelService.AddPanel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -135,8 +135,8 @@ router.post("/panel/save", panelService.AddPanel);
|
|||||||
* 500:
|
* 500:
|
||||||
* description: Server error
|
* description: Server error
|
||||||
*/
|
*/
|
||||||
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);
|
// router.get("/zone/:sceneID", Zoneservice.allZones);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
// import * as express from "express";
|
|
||||||
// import { productFlowservice } from "../controller/simulation/productFlowservice.ts";
|
|
||||||
// const router = express.Router();
|
|
||||||
// router.post("/createProduct", productFlowservice.setproductFlow);
|
|
||||||
// router.get("/productFlowList/:organization", productFlowservice.productpathsList);
|
|
||||||
// export default router;
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
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("/AllProducts/:organization", productFlowservice.AllProductDatas);
|
productRouter.get(
|
||||||
productRouter.patch("/productRename", productFlowservice.productRename);
|
"/AllProducts/:organization",
|
||||||
|
ProductFlowservice.AllProductDatas
|
||||||
|
);
|
||||||
|
productRouter.patch("/productRename", ProductFlowservice.productRename);
|
||||||
export default productRouter;
|
export default productRouter;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { createProjectController } from "../controller/project/projectController.ts";
|
import {
|
||||||
|
createProjectController,
|
||||||
|
GetProjects,
|
||||||
|
RemoveProject,
|
||||||
|
updateProjectController,
|
||||||
|
ViewData,
|
||||||
|
} from "../controller/project/projectController.ts";
|
||||||
|
|
||||||
const projectRouter = express.Router();
|
const projectRouter = express.Router();
|
||||||
projectRouter.post("/upsertProject",createProjectController)
|
projectRouter.post("/upsertProject", createProjectController);
|
||||||
export default projectRouter
|
projectRouter.get("/Projects/:userId/:organization", GetProjects);
|
||||||
|
projectRouter.patch("/Project/archive/:projectId", RemoveProject);
|
||||||
|
projectRouter.patch("/Project/modify", updateProjectController);
|
||||||
|
projectRouter.get("/Project/view", ViewData);
|
||||||
|
export default projectRouter;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { share } from '../controller/share/share-Controller.ts';
|
import { Share } from '../controller/share/share-Controller.ts';
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.post('/shareUser',share.shareUser)
|
router.post('/shareUser',Share.shareUser)
|
||||||
router.get('/findshareUsers',share.findshareUser)
|
router.get('/findshareUsers',Share.findshareUser)
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { templateService } from "../controller/visualization/templateService.ts";
|
import { TemplateService } from "../controller/visualization/templateService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/template/save", templateService.AddTemplate);
|
router.post("/template/save", TemplateService.AddTemplate);
|
||||||
router.get("/templateData/:organization", templateService.GetAllTemplates);
|
router.get("/templateData/:organization", TemplateService.GetAllTemplates);
|
||||||
router.post("/TemplatetoZone", templateService.AddToZone);
|
router.post("/TemplatetoZone", TemplateService.AddToZone);
|
||||||
router.patch(
|
router.patch(
|
||||||
"/TemplateDelete/:templateID/:organization",
|
"/TemplateDelete/:templateID/:organization",
|
||||||
templateService.Deletezone
|
TemplateService.Deletezone
|
||||||
); //delete zone
|
); //delete zone
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
8
src/api-server/Routes/trashRoutes.ts
Normal file
8
src/api-server/Routes/trashRoutes.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import * as express from "express";
|
||||||
|
import { GetTrashList, RestoreTrash } from "../controller/trash/trashcontrollers.ts";
|
||||||
|
|
||||||
|
const trashRouter = express.Router();
|
||||||
|
trashRouter.get("/Trash/Lists", GetTrashList);
|
||||||
|
trashRouter.patch("/restore",RestoreTrash)
|
||||||
|
|
||||||
|
export default trashRouter;
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
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,11 +1,9 @@
|
|||||||
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,9 +1,9 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { widget3dService } from "../controller/visualization/3dWidgetService.ts";
|
import { Widget3dService } from "../controller/visualization/3dWidgetService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/3dwidget/save", widget3dService.add3Dwidget);
|
router.post("/3dwidget/save", Widget3dService.add3Dwidget);
|
||||||
router.get("/3dwidgetData/:zoneId/:organization", widget3dService.get3Dwiget);
|
router.get("/3dwidgetData/:zoneId/:organization", Widget3dService.get3Dwiget);
|
||||||
router.get("/widget3D/:id/:organization", widget3dService.getSingle3Dwidget);
|
router.get("/widget3D/:id/:organization", Widget3dService.getSingle3Dwidget);
|
||||||
router.patch("/widget3D/delete", widget3dService.delete3Dwidget);
|
router.patch("/widget3D/delete", Widget3dService.delete3Dwidget);
|
||||||
router.patch("/modifyPR/widget3D", widget3dService.update3DpositionRotation);
|
router.patch("/modifyPR/widget3D", Widget3dService.update3DpositionRotation);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { widgetService } from "../controller/visualization/widgetService.ts";
|
import { WidgetService } from "../controller/visualization/widgetService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -134,11 +134,11 @@ const router = express.Router();
|
|||||||
* 500:
|
* 500:
|
||||||
* description: Server error
|
* description: Server error
|
||||||
*/
|
*/
|
||||||
router.post("/widget/save", widgetService.addWidget);
|
router.post("/widget/save", WidgetService.addWidget);
|
||||||
router.patch("/widget/:widgetID", widgetService.updatewidget);
|
router.patch("/widget/:widgetID", WidgetService.updatewidget);
|
||||||
router.patch("/delete/widget", widgetService.deleteWidget);
|
router.patch("/delete/widget", WidgetService.deleteWidget);
|
||||||
router.get(
|
router.get(
|
||||||
"/WidgetData/:widgetID/:organization",
|
"/WidgetData/:widgetID/:organization",
|
||||||
widgetService.getDatafromWidget
|
WidgetService.getDatafromWidget
|
||||||
);
|
);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import express from 'express';
|
|
||||||
|
|
||||||
import { zone } from '../controller/lines/zone-Services.ts';
|
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
|
||||||
router.post('/setZone',zone.setZone)
|
|
||||||
router.delete('/deleteZone',zone.deleteZone)
|
|
||||||
router.get('/findZones/:organization',zone.getZones)
|
|
||||||
// router.get('/A_zone/:zoneId/:organization',zone.ZoneData)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
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
|
||||||
@@ -245,7 +247,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); //Zone create and update for the points
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -318,9 +320,9 @@ router.post("/zone/save", Zoneservice.addandUpdateZone); //Zone create and updat
|
|||||||
* value:
|
* value:
|
||||||
* message: "Zone not found for the UUID"
|
* message: "Zone not found for the UUID"
|
||||||
*/
|
*/
|
||||||
router.get("/zones/:sceneID", Zoneservice.allZones);
|
router.get("/zones/:sceneID", ZoneService.allZones);
|
||||||
|
|
||||||
router.get("/pageZodeData", Zoneservice.vizAllDatas);
|
router.get("/pageZodeData", ZoneService.vizAllDatas);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -414,7 +416,7 @@ router.get("/pageZodeData", Zoneservice.vizAllDatas);
|
|||||||
* example:
|
* example:
|
||||||
* error: "Internal Server Error"
|
* error: "Internal Server Error"
|
||||||
*/
|
*/
|
||||||
router.get("/ZoneVisualization/:zoneId", Zoneservice.singleZonePanelDatas);
|
router.get("/ZoneVisualization/:zoneId", ZoneService.singleZonePanelDatas);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -483,7 +485,7 @@ router.get("/ZoneVisualization/:zoneId", Zoneservice.singleZonePanelDatas);
|
|||||||
* value:
|
* value:
|
||||||
* message: "Zone not found"
|
* message: "Zone not found"
|
||||||
*/
|
*/
|
||||||
router.get("/A_zone/:zoneId/:organization", Zoneservice.ZoneData);
|
router.get("/A_zone/:zoneId/:organization", ZoneService.ZoneData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -536,7 +538,8 @@ 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); //delete Zone
|
||||||
// router.get("/zone/:sceneID", Zoneservice.allZones);
|
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||||
router.patch("/zones/lockedPanels", Zoneservice.lockedPanel);
|
|
||||||
|
router.get("/findZones/:organization", zone.getZones);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -0,0 +1,247 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import {
|
||||||
|
AuthLogin,
|
||||||
|
AuthLogout,
|
||||||
|
AuthSignup,
|
||||||
|
forgetPassword,
|
||||||
|
} from "../../../../shared/services/auth/authServices.ts";
|
||||||
|
|
||||||
|
export const SignupController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
console.log("req.body: ", req.body);
|
||||||
|
const { userName, Email, Password, profilePicture } = req.body;
|
||||||
|
if (!userName || !Email || !Password) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AuthSignup(req.body);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User already exists":
|
||||||
|
res.status(403).json({
|
||||||
|
message: "User already exists",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json({
|
||||||
|
message: "New User created",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "An unexpected error occurred",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const SignInController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { Email, Password, fingerprint } = req.body;
|
||||||
|
console.log("req.body: ", req.body);
|
||||||
|
if (!fingerprint || !Email || !Password) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AuthLogin(req.body);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User Not Found!!! Kindly signup...":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User Not Found!!! Kindly signup...",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Email & Password is invalid...Check the credentials":
|
||||||
|
res.status(400).json({
|
||||||
|
message: "Email & Password is invalid...Check the credentials",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Already LoggedIn on another browser....Please logout!!!":
|
||||||
|
res.status(403).json({
|
||||||
|
message: "Already LoggedIn on another browser....Please logout!!!",
|
||||||
|
ForceLogoutData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "User_Datas not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User_Datas not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User update failed.":
|
||||||
|
res.status(400).json({
|
||||||
|
message: "User update failed.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "An unexpected error occurred",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const SignOutController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { Email } = req.body;
|
||||||
|
if (!Email) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "Email field is Mandatory",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AuthLogout(req.body);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Token not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Token not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Logout Successfull",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "An unexpected error occurred",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const ForgetPasswordController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { Email } = req.body;
|
||||||
|
if (!Email) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "Email field is Mandatory",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await forgetPassword(req.body);
|
||||||
|
switch (result.status) {
|
||||||
|
case "You can only reset your password once every 24 hours.":
|
||||||
|
res.status(400).json({
|
||||||
|
message: "You can only reset your password once every 24 hours.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Email not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Email not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Password reset link sent successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "An unexpected error occurred",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const ResetPasswordController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { newPassword, resetToken, confirmPassword } = req.body;
|
||||||
|
if (!newPassword || !resetToken || !confirmPassword) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are Mandatory",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await forgetPassword(req.body);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "Invalid token payload.":
|
||||||
|
res.status(400).json({
|
||||||
|
message: "Invalid token payload.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Password mismatch":
|
||||||
|
res.status(400).json({
|
||||||
|
message: "Password mismatch",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Token is invalid or expired.":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Token is invalid or expired.",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Password reset successfull!!",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "An unexpected error occurred",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
getEnvironment,
|
||||||
|
setEnvironment,
|
||||||
|
} from "../../../../shared/services/builder/EnvironmentService.ts";
|
||||||
|
|
||||||
|
export const SetEnvironmentController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const {
|
||||||
|
roofVisibility,
|
||||||
|
renderDistance,
|
||||||
|
limitDistance,
|
||||||
|
wallVisibility,
|
||||||
|
shadowVisibility,
|
||||||
|
projectId,
|
||||||
|
} = req.body;
|
||||||
|
if (
|
||||||
|
!organization ||
|
||||||
|
!userId ||
|
||||||
|
!roofVisibility ||
|
||||||
|
!wallVisibility ||
|
||||||
|
!renderDistance ||
|
||||||
|
!limitDistance ||
|
||||||
|
!shadowVisibility ||
|
||||||
|
!projectId
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
roofVisibility,
|
||||||
|
wallVisibility,
|
||||||
|
shadowVisibility,
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
renderDistance,
|
||||||
|
limitDistance,
|
||||||
|
};
|
||||||
|
const result = await setEnvironment(data);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "environments updated":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetEnvironmentController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
};
|
||||||
|
const result = await getEnvironment(data);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Environment Not found for the User":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Environment Not found for the User",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,277 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
CreateLineItems,
|
||||||
|
DeleteLayer,
|
||||||
|
DeleteLineItems,
|
||||||
|
DeleteLinePoints,
|
||||||
|
GetLinesService,
|
||||||
|
UpdateLineItems,
|
||||||
|
} from "../../../../shared/services/builder/lineService.ts";
|
||||||
|
|
||||||
|
export const NewLineController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { line, type, layer, projectId } = req.body;
|
||||||
|
if (!organization || !userId || !line || !type || !layer || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
line,
|
||||||
|
type,
|
||||||
|
layer,
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
};
|
||||||
|
const result = await CreateLineItems(data);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const UpdateLineController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { uuid, position, projectId } = req.body;
|
||||||
|
if (!organization || !userId || !uuid || !position || projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await UpdateLineItems({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
uuid,
|
||||||
|
position,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DeleteLineController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId, line } = req.body;
|
||||||
|
if (!organization || !userId || !projectId || !line) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DeleteLineItems({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
line,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "line not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "data not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DeleteLayerController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId, layer } = req.body;
|
||||||
|
if (!organization || !userId || !projectId || !layer) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DeleteLayer({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
layer,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "layer not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "data not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DeleteLinePointsController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId, uuid } = req.body;
|
||||||
|
if (!organization || !userId || !projectId || !uuid) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DeleteLinePoints({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
uuid,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Line not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "data not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetLinesController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetLinesService({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,327 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
deleteAssetModel,
|
||||||
|
getFloorItems,
|
||||||
|
replaceEventDatas,
|
||||||
|
setAssetModel,
|
||||||
|
updateAssetPositionRotation,
|
||||||
|
} from "../../../../shared/services/builder/assetService.ts";
|
||||||
|
|
||||||
|
export const CreateAssetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const {
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
eventData,
|
||||||
|
modelfileID,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
projectId,
|
||||||
|
} = req.body;
|
||||||
|
if (
|
||||||
|
!organization ||
|
||||||
|
!userId ||
|
||||||
|
!isLocked ||
|
||||||
|
!isVisible ||
|
||||||
|
!position ||
|
||||||
|
!rotation ||
|
||||||
|
!modelfileID ||
|
||||||
|
!modelName ||
|
||||||
|
!projectId ||
|
||||||
|
!modelUuid
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
eventData,
|
||||||
|
modelfileID,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
projectId,
|
||||||
|
};
|
||||||
|
const result = await setAssetModel(data);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Updated successfully":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Model stored successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DeleteAssetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { modelUuid, modelName, projectId } = req.body;
|
||||||
|
if (!organization || !userId || !modelUuid || !projectId || !modelName) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await deleteAssetModel({
|
||||||
|
organization,
|
||||||
|
modelName,
|
||||||
|
modelUuid,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "model not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Model not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Failed to archive asset":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Failed to archive asset",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Asset Deleted successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetAssetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await getFloorItems({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "floorItems not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "floorItems not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const ReplaceEventDataController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { modelUuid, eventData, projectId } = req.body;
|
||||||
|
if (!organization || !userId || !projectId || !modelUuid || !eventData) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await replaceEventDatas({
|
||||||
|
modelUuid,
|
||||||
|
organization,
|
||||||
|
eventData,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Model not for this UUID":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Model not for this UUID",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({ message: "Data updated successfully" });
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const AssetUpdatePosRotController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const {
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
projectId,
|
||||||
|
} = req.body;
|
||||||
|
if (
|
||||||
|
!organization ||
|
||||||
|
!userId ||
|
||||||
|
!isLocked ||
|
||||||
|
!isVisible ||
|
||||||
|
!position ||
|
||||||
|
!rotation ||
|
||||||
|
!modelName ||
|
||||||
|
!projectId ||
|
||||||
|
!modelUuid
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await updateAssetPositionRotation({
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Asset not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Asset not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({ message: "Asset updated successfully" });
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
GetCamers,
|
||||||
|
onlineActiveDatas,
|
||||||
|
SetCamera,
|
||||||
|
} from "../../../../shared/services/builder/cameraService.ts";
|
||||||
|
|
||||||
|
export const SetNewCamera = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { position, target, rotation, projectId, versionId } = req.body;
|
||||||
|
if (
|
||||||
|
!organization ||
|
||||||
|
!userId ||
|
||||||
|
!position ||
|
||||||
|
!target ||
|
||||||
|
!rotation ||
|
||||||
|
!projectId ||
|
||||||
|
!versionId
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
position,
|
||||||
|
target,
|
||||||
|
rotation,
|
||||||
|
projectId,
|
||||||
|
versionId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
};
|
||||||
|
const result = await SetCamera(data);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
TrashDatas: [],
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Update Success":
|
||||||
|
res.status(200).json({
|
||||||
|
TrashDatas: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
TrashDatas: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const CameraList = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!organization || !userId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetCamers({
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
TrashDatas: [],
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
TrashDatas: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const ActiveOnlineController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
if (!organization || !userId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await onlineActiveDatas({
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { WallItems } from "../../../../shared/services/builder/wallService.ts";
|
||||||
|
import { error } from "console";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
export const WallSetup = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const {
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
projectId,
|
||||||
|
} = req.body;
|
||||||
|
if (
|
||||||
|
!modelUuid ||
|
||||||
|
!modelName ||
|
||||||
|
!position ||
|
||||||
|
!type ||
|
||||||
|
!projectId ||
|
||||||
|
!csgscale ||
|
||||||
|
!csgposition ||
|
||||||
|
!quaternion ||
|
||||||
|
!scale ||
|
||||||
|
!organization ||
|
||||||
|
!userId
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required!",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await WallItems.setWallItems({
|
||||||
|
projectId,
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({ message: "User not found" });
|
||||||
|
break;
|
||||||
|
case "Updated successfully":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
case "wall Item created successfully":
|
||||||
|
res.status(201).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json(error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const WallGet = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await WallItems.getWallItems({
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({ message: "User not found" });
|
||||||
|
break;
|
||||||
|
case "wallitems not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "wallitems not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const WallDelete = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId, modelName, modelUuid } = req.body;
|
||||||
|
if (!organization || !userId || !projectId || !modelName || !modelUuid) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await WallItems.deleteWallItems({
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
projectId,
|
||||||
|
modelName,
|
||||||
|
modelUuid,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({ message: "User not found" });
|
||||||
|
break;
|
||||||
|
case "model not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "model not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
DelZone,
|
||||||
|
GetZones,
|
||||||
|
SetZone,
|
||||||
|
SingleZonePanelData,
|
||||||
|
VizZoneDatas,
|
||||||
|
ZoneData,
|
||||||
|
} from "../../../../shared/services/builder/zoneService.ts";
|
||||||
|
|
||||||
|
export const CreateZoneController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { zoneData, projectId } = req.body;
|
||||||
|
if (!organization || !userId || !zoneData || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
zoneData,
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
};
|
||||||
|
const result = await SetZone(data);
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "zone updated":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "zone updated",
|
||||||
|
ZoneData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "zone created",
|
||||||
|
ZoneData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DeleteZoneController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { zoneId, projectId } = req.body;
|
||||||
|
if (!organization || !userId || !zoneId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DelZone({
|
||||||
|
organization,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Invalid zone ID":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the UUID",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
TrashDatas: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetZoneController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetZones({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Invalid zone":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the UUID",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const VizZoneController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await VizZoneDatas({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the UUID":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the UUID",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ZoneDataController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId, zoneId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await ZoneData({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
zoneId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const SingleZonePanelController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.user || {};
|
||||||
|
const { projectId, zoneId } = req.params;
|
||||||
|
if (!organization || !userId || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await SingleZonePanelData({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
zoneId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the UUID":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the UUID",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import {
|
||||||
|
RecentlyAdded,
|
||||||
|
searchProject,
|
||||||
|
searchTrashProject,
|
||||||
|
} from "../../../../shared/services/v1home/v1homeservice.ts";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
|
||||||
|
export const recentDataController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization, role } = req.user || {};
|
||||||
|
if (!userId || !organization || !role) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await RecentlyAdded({ userId, organization, role });
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Datas were empty":
|
||||||
|
res.status(200).json({
|
||||||
|
RecentlyViewed: [],
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
RecentlyViewed: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const searchProjectController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization, role } = req.user || {};
|
||||||
|
if (!userId || !organization || !role) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { searchName } = req.query as {
|
||||||
|
searchName: string;
|
||||||
|
};
|
||||||
|
const result = await searchProject({
|
||||||
|
searchName,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const searchTrashProjectController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization, role } = req.user || {};
|
||||||
|
if (!userId || !organization || !role) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { searchName } = req.query as {
|
||||||
|
searchName: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await searchTrashProject({
|
||||||
|
searchName,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,269 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import {
|
||||||
|
createProject,
|
||||||
|
DeleteProject,
|
||||||
|
GetAllProjects,
|
||||||
|
updateProject,
|
||||||
|
viewProject,
|
||||||
|
} from "../../../../shared/services/v1Project/v1projectservice.ts";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
|
||||||
|
export const createProjectController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { projectUuid, thumbnail } = req.body;
|
||||||
|
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||||
|
res.status(401).json({ message: "Unauthorized" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!projectUuid || !thumbnail) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await createProject({ ...req.body, userId, organization });
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "project_exists":
|
||||||
|
res.status(403).json({
|
||||||
|
message: "Project already exists",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "user_not_found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json({
|
||||||
|
message: "Project created Successfully",
|
||||||
|
projectId: result.project._id,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetProjects = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization, role } = req.user || {};
|
||||||
|
// const { userId, organization } = req.params;
|
||||||
|
if (!userId || !organization || !role) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetAllProjects({ userId, organization, role });
|
||||||
|
switch (result?.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
Projects: result?.Datas,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const RemoveProject = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { projectId } = req.params;
|
||||||
|
// const { organization, userId } = req.body;
|
||||||
|
const { organization, userId, role } = req.user || {};
|
||||||
|
if (
|
||||||
|
!req.user ||
|
||||||
|
!req.user.userId ||
|
||||||
|
!req.user.organization ||
|
||||||
|
!req.user.role
|
||||||
|
) {
|
||||||
|
res.status(401).json({ message: "Unauthorized" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!projectId || !organization || !userId || !role) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DeleteProject({
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
role,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json({
|
||||||
|
message: "Project Deleted Successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const updateProjectController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization, role } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
const { projectName, thumbnail } = req.body;
|
||||||
|
if (!userId || !organization || !projectId || !role) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await updateProject({
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
projectName,
|
||||||
|
thumbnail,
|
||||||
|
role,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project updated Successfully",
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const ViewData = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, userId, role } = req.user || {};
|
||||||
|
if (
|
||||||
|
!req.user ||
|
||||||
|
!req.user.userId ||
|
||||||
|
!req.user.organization ||
|
||||||
|
!req.user.role
|
||||||
|
) {
|
||||||
|
res.status(401).json({ message: "Unauthorized" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { projectId } = req.params as {
|
||||||
|
projectId: string;
|
||||||
|
};
|
||||||
|
if (!userId || !organization || !projectId || !role) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await viewProject({
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
role,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import {
|
||||||
|
TrashDatas,
|
||||||
|
RestoreTrashData,
|
||||||
|
} from "../../../../shared/services/v1trash/v1trashservice.ts";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
|
||||||
|
export const GetTrashList = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, role, userId } = req.user || {};
|
||||||
|
if (!organization || !role || !userId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await TrashDatas({ organization, role, userId });
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Trash is Empty":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Trash is Empty",
|
||||||
|
TrashDatas: [],
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
TrashDatas: result.ListDatas,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const RestoreTrash = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, role, userId } = req.user || {};
|
||||||
|
const { projectId } = req.query as {
|
||||||
|
projectId: string;
|
||||||
|
};
|
||||||
|
if (!organization || !projectId || !role || !userId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await RestoreTrashData({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
role,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project Restore unsuccessfull":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project Restore unsuccessfull",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project Restored successfully":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project Restored successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DeleteTrash = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, role, userId } = req.user || {};
|
||||||
|
const { projectId } = req.query as {
|
||||||
|
projectId: string;
|
||||||
|
};
|
||||||
|
if (!organization || !projectId || !role || !userId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await RestoreTrashData({
|
||||||
|
organization,
|
||||||
|
projectId,
|
||||||
|
role,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project Trash Delete unsuccessfull":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project Trash Delete unsuccessfull",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Trash Project Restored successfully":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Trash Project Restored successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import versionService from "../../../../shared/services/version/versionService.ts";
|
||||||
|
|
||||||
|
export const versioncontroller = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
console.log("req.body: ", 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(
|
||||||
|
db,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
description
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(result);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "An unexpected error occurred",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,306 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AddFloat,
|
||||||
|
DelFloat,
|
||||||
|
DuplicateFloat,
|
||||||
|
GetFloatWidget,
|
||||||
|
SingleFloatWidget,
|
||||||
|
} from "../../../../shared/services/visualization/floatWidgetService.ts";
|
||||||
|
|
||||||
|
export const FloatAddController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { widget, zoneId, index, projectId } = req.body;
|
||||||
|
if (
|
||||||
|
!userId ||
|
||||||
|
!organization ||
|
||||||
|
!widget ||
|
||||||
|
!zoneId ||
|
||||||
|
!index ||
|
||||||
|
!projectId
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AddFloat({
|
||||||
|
organization,
|
||||||
|
widget,
|
||||||
|
zoneId,
|
||||||
|
index,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the zoneId",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget updated successfully":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget updated successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Failed to create FloatWidget":
|
||||||
|
res.status(400).json({
|
||||||
|
message: "Failed to create FloatWidget",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "FloatWidget created successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DeleteFloatController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { floatWidgetID, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !floatWidgetID || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DelFloat({
|
||||||
|
organization,
|
||||||
|
floatWidgetID,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the zoneId",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "FloatWidget not found for the Id":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "FloatWidget not found for the Id",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "FloatWidget not deleted":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "FloatWidget not deleted",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "FloatingWidget deleted successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DuplicateFloatController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { widget, projectId, zoneId, index } = req.body;
|
||||||
|
if (
|
||||||
|
!userId ||
|
||||||
|
!organization ||
|
||||||
|
!widget ||
|
||||||
|
!projectId ||
|
||||||
|
!zoneId ||
|
||||||
|
!index
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DuplicateFloat({
|
||||||
|
organization,
|
||||||
|
widget,
|
||||||
|
zoneId,
|
||||||
|
index,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the zoneId",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "FloatWidget update unsuccessfull":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "FloatWidget update unsuccessfull",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget updated successfully":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget updated successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Failed to duplicate FloatWidget":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Failed to duplicate FloatWidget",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Duplicate FloatWidget created successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetFloatController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { projectId, zoneId } = req.params;
|
||||||
|
if (!userId || !organization || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetFloatWidget({
|
||||||
|
organization,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "All Datas":
|
||||||
|
res.status(200).json([]);
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const SingleFloatController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { floatWidgetID } = req.params;
|
||||||
|
if (!userId || !organization || !floatWidgetID) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await SingleFloatWidget({
|
||||||
|
organization,
|
||||||
|
floatWidgetID,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Widget not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
Data: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,232 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AddPanel,
|
||||||
|
ClearPanel,
|
||||||
|
DelPanel,
|
||||||
|
LockedPanel,
|
||||||
|
} from "../../../../shared/services/visualization/panelService.ts";
|
||||||
|
|
||||||
|
export const AddPanelController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { panelOrder, zoneId, projectId } = req.body;
|
||||||
|
if (!userId || !organization || !panelOrder || !zoneId || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AddPanel({
|
||||||
|
organization,
|
||||||
|
panelOrder,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "No new panels were created. All panels already exist":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "No new panels were created. All panels already exist",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Panels created successfully",
|
||||||
|
panelID: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const DeletePanelController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { panelName, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !panelName || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DelPanel({
|
||||||
|
organization,
|
||||||
|
panelName,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Panel Already Deleted":
|
||||||
|
res.status(409).json({
|
||||||
|
message: "Panel Already Deleted",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Panel deleted successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const ClearPanelController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { panelName, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !panelName || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await ClearPanel({
|
||||||
|
organization,
|
||||||
|
panelName,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Requested Panel not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Requested Panel not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "No widgets to clear":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "No widgets to clear",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "PanelWidgets cleared successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const LockedPanelController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { projectId, zoneId, lockedPanel } = req.body;
|
||||||
|
if (!userId || !organization || !projectId || !zoneId || !lockedPanel) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await LockedPanel({
|
||||||
|
organization,
|
||||||
|
zoneId,
|
||||||
|
lockedPanel,
|
||||||
|
userId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "locked panel not updated":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "locked panel not updated",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "locked panel updated successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AddTemplate,
|
||||||
|
AddTemplateToZone,
|
||||||
|
GetAllTemplates,
|
||||||
|
TemplateDelete,
|
||||||
|
} from "../../../../shared/services/visualization/templateService.ts";
|
||||||
|
|
||||||
|
export const AddTemplateController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { template, projectId } = req.body;
|
||||||
|
if (!userId || !organization || !template || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AddTemplate({
|
||||||
|
organization,
|
||||||
|
template,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "TemplateID alreay exists":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "TemplateID alreay exists",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Template not saved":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Template not saved",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Template saved successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const AddTemToZoneController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { templateID, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !templateID || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AddTemplateToZone({
|
||||||
|
organization,
|
||||||
|
templateID,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "TemplateID not found":
|
||||||
|
res.status(409).json({
|
||||||
|
message: "TemplateID not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json({
|
||||||
|
message: "Template placed in Zone",
|
||||||
|
data: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const TemplateDeleteController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { templateID, projectId } = req.body;
|
||||||
|
if (!userId || !organization || !templateID || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await TemplateDelete({
|
||||||
|
userId,
|
||||||
|
organization,
|
||||||
|
templateID,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Template not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Template not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Template not Deleted":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Template not Deleted",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Template deleted successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetTemplateController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { projectId } = req.params;
|
||||||
|
if (!userId || !organization || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetAllTemplates({
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "All Datas":
|
||||||
|
res.status(404).json([]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AddWidget,
|
||||||
|
GetWidget,
|
||||||
|
UpdateWidget,
|
||||||
|
WidgetDelete,
|
||||||
|
} from "../../../../shared/services/visualization/widgetService.ts";
|
||||||
|
|
||||||
|
export const AddWidgetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { widget, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !widget || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await AddWidget({
|
||||||
|
organization,
|
||||||
|
widget,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
zoneId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
case "panelName not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "panelName not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget update unsuccessfull":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget update unsuccessfull",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget update successfully":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget updated successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget created successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Type mismatch":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Type mismatch",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const WidgetDeleteController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { widgetID, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !widgetID || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await WidgetDelete({
|
||||||
|
organization,
|
||||||
|
widgetID,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the zoneId",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget not found":
|
||||||
|
res.status(409).json({
|
||||||
|
message: "Widget not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget deleted successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const WidgetUpdateController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { values, projectId, zoneId, widgetID } = req.body;
|
||||||
|
if (
|
||||||
|
!userId ||
|
||||||
|
!organization ||
|
||||||
|
!widgetID ||
|
||||||
|
!values ||
|
||||||
|
!projectId ||
|
||||||
|
!zoneId
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await UpdateWidget({
|
||||||
|
organization,
|
||||||
|
values,
|
||||||
|
zoneId,
|
||||||
|
widgetID,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the zoneId",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Data not found":
|
||||||
|
res.status(409).json({
|
||||||
|
message: "Data not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget updated successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetWidgetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { projectId, zoneId, widgetID } = req.query as {
|
||||||
|
projectId: string;
|
||||||
|
zoneId: string;
|
||||||
|
widgetID: string;
|
||||||
|
};
|
||||||
|
if (!userId || !organization || !widgetID || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetWidget({
|
||||||
|
organization,
|
||||||
|
zoneId,
|
||||||
|
widgetID,
|
||||||
|
projectId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found for the zoneId",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget not found for the widgetID":
|
||||||
|
res.status(409).json({
|
||||||
|
message: "Widget not found for the widgetID",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
import { Response } from "express";
|
||||||
|
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
Add3DWidget,
|
||||||
|
Delete3Dwidget,
|
||||||
|
Get3Dwidget,
|
||||||
|
Update3Dwidget,
|
||||||
|
} from "../../../../shared/services/visualization/widget3dService.ts";
|
||||||
|
|
||||||
|
export const Add3dWidgetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { widget, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !widget || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await Add3DWidget({
|
||||||
|
organization,
|
||||||
|
widget,
|
||||||
|
userId,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found for the zoneId":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget not updated":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget not updated",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "widget update successfully":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "widget update successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget 3d not created":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget 3d not created",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget created successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const Update3DwidgetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { id, position, rotation, projectId, zoneId } = req.body;
|
||||||
|
if (
|
||||||
|
!userId ||
|
||||||
|
!organization ||
|
||||||
|
!id ||
|
||||||
|
!position ||
|
||||||
|
!rotation ||
|
||||||
|
!projectId ||
|
||||||
|
!zoneId
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await Update3Dwidget({
|
||||||
|
organization,
|
||||||
|
id,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
userId,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "widget3D update successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Widget not updated":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Widget not updated",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "widget not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "widget not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const Delete3DwidgetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { id, projectId, zoneId } = req.body;
|
||||||
|
if (!userId || !organization || !id || !projectId || !zoneId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await Delete3Dwidget({
|
||||||
|
organization,
|
||||||
|
id,
|
||||||
|
userId,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "3D widget not found for the ID":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "3D widget not found for the ID",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "3DWidget delete unsuccessfull":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "3DWidget delete unsuccessfull",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "3DWidget deleted successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const Get3DWidgetController = async (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.user || {};
|
||||||
|
const { projectId, zoneId } = req.params;
|
||||||
|
if (!userId || !organization || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await Get3Dwidget({
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
zoneId,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Zone not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Zone not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "All 3Dwidgets":
|
||||||
|
res.status(200).json([]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
56
src/api-server/V1/v1Routes/BuilderRoutes/v1-ZoneRoutes.ts
Normal file
56
src/api-server/V1/v1Routes/BuilderRoutes/v1-ZoneRoutes.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
CreateZoneController,
|
||||||
|
DeleteZoneController,
|
||||||
|
GetZoneController,
|
||||||
|
SingleZonePanelController,
|
||||||
|
VizZoneController,
|
||||||
|
ZoneDataController,
|
||||||
|
} from "../../v1Controllers/builderController/v1zoneController.ts";
|
||||||
|
|
||||||
|
const v1Zone = express.Router();
|
||||||
|
|
||||||
|
//Zone-Page
|
||||||
|
v1Zone.post(
|
||||||
|
"/zones",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
CreateZoneController
|
||||||
|
);
|
||||||
|
v1Zone.patch(
|
||||||
|
"/zones/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DeleteZoneController
|
||||||
|
);
|
||||||
|
|
||||||
|
//viz
|
||||||
|
v1Zone.get(
|
||||||
|
"/zones/visualization/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
VizZoneController
|
||||||
|
);
|
||||||
|
|
||||||
|
//getzones
|
||||||
|
v1Zone.get(
|
||||||
|
"/zones/:projectId/:zoneId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
ZoneDataController
|
||||||
|
);
|
||||||
|
// viz
|
||||||
|
v1Zone.get(
|
||||||
|
"/zones/panel/:projectId/:zoneId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
SingleZonePanelController
|
||||||
|
);
|
||||||
|
v1Zone.get(
|
||||||
|
"/zones/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetZoneController
|
||||||
|
);
|
||||||
|
export default v1Zone;
|
||||||
37
src/api-server/V1/v1Routes/BuilderRoutes/v1-assetRoutes.ts
Normal file
37
src/api-server/V1/v1Routes/BuilderRoutes/v1-assetRoutes.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AssetUpdatePosRotController,
|
||||||
|
CreateAssetController,
|
||||||
|
GetAssetController,
|
||||||
|
ReplaceEventDataController,
|
||||||
|
} from "../../v1Controllers/builderController/v1assetController.ts";
|
||||||
|
|
||||||
|
const v1Asset = express.Router();
|
||||||
|
|
||||||
|
//Asset-Page
|
||||||
|
v1Asset.post(
|
||||||
|
"/setAsset",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
CreateAssetController
|
||||||
|
);
|
||||||
|
v1Asset.patch(
|
||||||
|
"/updateFloorAssetPositions",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
AssetUpdatePosRotController
|
||||||
|
);
|
||||||
|
v1Asset.get(
|
||||||
|
"/floorAssets/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetAssetController
|
||||||
|
);
|
||||||
|
v1Asset.patch(
|
||||||
|
"/updateEventData",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
ReplaceEventDataController
|
||||||
|
);
|
||||||
|
export default v1Asset;
|
||||||
31
src/api-server/V1/v1Routes/BuilderRoutes/v1-cameraRoutes.ts
Normal file
31
src/api-server/V1/v1Routes/BuilderRoutes/v1-cameraRoutes.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
ActiveOnlineController,
|
||||||
|
CameraList,
|
||||||
|
SetNewCamera,
|
||||||
|
} from "../../v1Controllers/builderController/v1cameraController.ts";
|
||||||
|
|
||||||
|
const v1Camera = express.Router();
|
||||||
|
|
||||||
|
//Camera-Page
|
||||||
|
v1Camera.post(
|
||||||
|
"/setCamera",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
SetNewCamera
|
||||||
|
);
|
||||||
|
v1Camera.get(
|
||||||
|
"/activeCameras",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
ActiveOnlineController
|
||||||
|
);
|
||||||
|
v1Camera.get(
|
||||||
|
"/cameras/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
CameraList
|
||||||
|
);
|
||||||
|
|
||||||
|
export default v1Camera;
|
||||||
51
src/api-server/V1/v1Routes/BuilderRoutes/v1-linesRoutes.ts
Normal file
51
src/api-server/V1/v1Routes/BuilderRoutes/v1-linesRoutes.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
DeleteLayerController,
|
||||||
|
DeleteLineController,
|
||||||
|
DeleteLinePointsController,
|
||||||
|
GetLinesController,
|
||||||
|
NewLineController,
|
||||||
|
UpdateLineController,
|
||||||
|
} from "../../v1Controllers/builderController/v1LineController.ts";
|
||||||
|
|
||||||
|
const v1Line = express.Router();
|
||||||
|
|
||||||
|
//Line-Page
|
||||||
|
v1Line.post(
|
||||||
|
"/lines",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
NewLineController
|
||||||
|
);
|
||||||
|
v1Line.post(
|
||||||
|
"/points",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
UpdateLineController
|
||||||
|
);
|
||||||
|
v1Line.patch(
|
||||||
|
"/layers/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DeleteLayerController
|
||||||
|
);
|
||||||
|
v1Line.patch(
|
||||||
|
"/lines/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DeleteLineController
|
||||||
|
);
|
||||||
|
v1Line.patch(
|
||||||
|
"/points/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DeleteLinePointsController
|
||||||
|
);
|
||||||
|
v1Line.get(
|
||||||
|
"/lines/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetLinesController
|
||||||
|
);
|
||||||
|
export default v1Line;
|
||||||
30
src/api-server/V1/v1Routes/BuilderRoutes/v1-wallRoutes.ts
Normal file
30
src/api-server/V1/v1Routes/BuilderRoutes/v1-wallRoutes.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
WallDelete,
|
||||||
|
WallGet,
|
||||||
|
WallSetup,
|
||||||
|
} from "../../v1Controllers/builderController/v1wallController.ts";
|
||||||
|
|
||||||
|
const v1Wall = express.Router();
|
||||||
|
|
||||||
|
//Wall-Page
|
||||||
|
v1Wall.post(
|
||||||
|
"/walls",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
WallSetup
|
||||||
|
);
|
||||||
|
v1Wall.patch(
|
||||||
|
"/walls/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
WallDelete
|
||||||
|
);
|
||||||
|
v1Wall.get(
|
||||||
|
"/walls/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
WallGet
|
||||||
|
);
|
||||||
|
export default v1Wall;
|
||||||
19
src/api-server/V1/v1Routes/authRoutes.ts
Normal file
19
src/api-server/V1/v1Routes/authRoutes.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import express from "express";
|
||||||
|
import {
|
||||||
|
ForgetPasswordController,
|
||||||
|
ResetPasswordController,
|
||||||
|
SignInController,
|
||||||
|
SignOutController,
|
||||||
|
SignupController,
|
||||||
|
} from "../v1Controllers/authController/authControllers.ts";
|
||||||
|
import { versioncontroller } from "../v1Controllers/versionController/versioncontroller.ts";
|
||||||
|
|
||||||
|
const Authrouter = express.Router();
|
||||||
|
Authrouter.post("/Auth/signup", SignupController);
|
||||||
|
Authrouter.post("/Auth/login", SignInController);
|
||||||
|
Authrouter.post("/Auth/logout", SignOutController);
|
||||||
|
Authrouter.post("/Auth/forgetPassword", ForgetPasswordController);
|
||||||
|
Authrouter.post("/Auth/reset-password/:resetToken", ResetPasswordController);
|
||||||
|
Authrouter.post("/Auth/versionData", versioncontroller);
|
||||||
|
|
||||||
|
export default Authrouter;
|
||||||
32
src/api-server/V1/v1Routes/v1-homeRoutes.ts
Normal file
32
src/api-server/V1/v1Routes/v1-homeRoutes.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||||
|
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||||
|
import {
|
||||||
|
recentDataController,
|
||||||
|
searchProjectController,
|
||||||
|
searchTrashProjectController,
|
||||||
|
} from "../../V1/v1Controllers/homeController/v1homeController.ts";
|
||||||
|
|
||||||
|
const v1homeRoutes = express.Router();
|
||||||
|
|
||||||
|
//home-Page
|
||||||
|
v1homeRoutes.get(
|
||||||
|
"/RecentlyViewed",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
recentDataController
|
||||||
|
);
|
||||||
|
v1homeRoutes.get(
|
||||||
|
"/searchProjects",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
searchProjectController
|
||||||
|
);
|
||||||
|
v1homeRoutes.get(
|
||||||
|
"/searchTrashProjects",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
searchTrashProjectController
|
||||||
|
);
|
||||||
|
|
||||||
|
export default v1homeRoutes;
|
||||||
42
src/api-server/V1/v1Routes/v1-projectRoutes.ts
Normal file
42
src/api-server/V1/v1Routes/v1-projectRoutes.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import express from "express";
|
||||||
|
import {
|
||||||
|
createProjectController,
|
||||||
|
GetProjects,
|
||||||
|
RemoveProject,
|
||||||
|
updateProjectController,
|
||||||
|
ViewData,
|
||||||
|
} from "../../V1/v1Controllers/projectController/v1projectController.ts";
|
||||||
|
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||||
|
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||||
|
|
||||||
|
const v1projectRouter = express.Router();
|
||||||
|
|
||||||
|
// project
|
||||||
|
v1projectRouter.post("/upsertProject", tokenValidator, createProjectController);
|
||||||
|
v1projectRouter.get(
|
||||||
|
"/Projects",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetProjects
|
||||||
|
);
|
||||||
|
v1projectRouter.patch(
|
||||||
|
"/Project/archive/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
RemoveProject
|
||||||
|
);
|
||||||
|
|
||||||
|
v1projectRouter.patch(
|
||||||
|
"/Project/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
updateProjectController
|
||||||
|
);
|
||||||
|
v1projectRouter.get(
|
||||||
|
"/Project/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
ViewData
|
||||||
|
);
|
||||||
|
|
||||||
|
export default v1projectRouter;
|
||||||
32
src/api-server/V1/v1Routes/v1-trashRoutes.ts
Normal file
32
src/api-server/V1/v1Routes/v1-trashRoutes.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||||
|
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||||
|
import {
|
||||||
|
DeleteTrash,
|
||||||
|
GetTrashList,
|
||||||
|
RestoreTrash,
|
||||||
|
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
|
||||||
|
|
||||||
|
const v1TrashRoutes = express.Router();
|
||||||
|
//trash
|
||||||
|
v1TrashRoutes.get(
|
||||||
|
"/TrashItems",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetTrashList
|
||||||
|
);
|
||||||
|
|
||||||
|
v1TrashRoutes.patch(
|
||||||
|
"/Trash/restore",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
RestoreTrash
|
||||||
|
);
|
||||||
|
|
||||||
|
v1TrashRoutes.patch(
|
||||||
|
"/Trash/Delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DeleteTrash
|
||||||
|
);
|
||||||
|
export default v1TrashRoutes;
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
DeleteFloatController,
|
||||||
|
DuplicateFloatController,
|
||||||
|
FloatAddController,
|
||||||
|
GetFloatController,
|
||||||
|
SingleFloatController,
|
||||||
|
} from "../../v1Controllers/vizualizationController/v1floatWidgetController.ts";
|
||||||
|
|
||||||
|
const v1FloatWidget = express.Router();
|
||||||
|
|
||||||
|
//floatWidget-Page
|
||||||
|
v1FloatWidget.post(
|
||||||
|
"/floatWidget/save",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
FloatAddController
|
||||||
|
);
|
||||||
|
v1FloatWidget.patch(
|
||||||
|
"/floatWidget/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DeleteFloatController
|
||||||
|
);
|
||||||
|
v1FloatWidget.get(
|
||||||
|
"/floatWidgets/:zoneId/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetFloatController
|
||||||
|
);
|
||||||
|
v1FloatWidget.get(
|
||||||
|
"/floatWidget/:floatWidgetId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
SingleFloatController
|
||||||
|
);
|
||||||
|
v1FloatWidget.post(
|
||||||
|
"/floatWidget/duplicate",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DuplicateFloatController
|
||||||
|
);
|
||||||
|
export default v1FloatWidget;
|
||||||
37
src/api-server/V1/v1Routes/vizRoutes.ts/v1-TemplateRoutes.ts
Normal file
37
src/api-server/V1/v1Routes/vizRoutes.ts/v1-TemplateRoutes.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AddTemplateController,
|
||||||
|
AddTemToZoneController,
|
||||||
|
GetTemplateController,
|
||||||
|
TemplateDeleteController,
|
||||||
|
} from "../../v1Controllers/vizualizationController/v1templateController.ts";
|
||||||
|
|
||||||
|
const v1Template = express.Router();
|
||||||
|
|
||||||
|
//template-Page
|
||||||
|
v1Template.post(
|
||||||
|
"/template/save",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
AddTemplateController
|
||||||
|
);
|
||||||
|
v1Template.post(
|
||||||
|
"/template/toZone",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
AddTemToZoneController
|
||||||
|
);
|
||||||
|
v1Template.get(
|
||||||
|
"/template/data/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetTemplateController
|
||||||
|
);
|
||||||
|
v1Template.patch(
|
||||||
|
"/template/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
TemplateDeleteController
|
||||||
|
);
|
||||||
|
export default v1Template;
|
||||||
31
src/api-server/V1/v1Routes/vizRoutes.ts/v1-panelRoutes.ts
Normal file
31
src/api-server/V1/v1Routes/vizRoutes.ts/v1-panelRoutes.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AddPanelController,
|
||||||
|
ClearPanelController,
|
||||||
|
DeletePanelController,
|
||||||
|
} from "../../v1Controllers/vizualizationController/v1panelController.ts";
|
||||||
|
|
||||||
|
const v1PanelRoutes = express.Router();
|
||||||
|
|
||||||
|
//panel-Page
|
||||||
|
v1PanelRoutes.post(
|
||||||
|
"/panel/save",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
AddPanelController
|
||||||
|
);
|
||||||
|
v1PanelRoutes.patch(
|
||||||
|
"/panel/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
DeletePanelController
|
||||||
|
);
|
||||||
|
v1PanelRoutes.patch(
|
||||||
|
"/panel/clear",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
ClearPanelController
|
||||||
|
);
|
||||||
|
|
||||||
|
export default v1PanelRoutes;
|
||||||
38
src/api-server/V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts
Normal file
38
src/api-server/V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Add3dWidgetController,
|
||||||
|
Delete3DwidgetController,
|
||||||
|
Get3DWidgetController,
|
||||||
|
Update3DwidgetController,
|
||||||
|
} from "../../v1Controllers/vizualizationController/widget3Dcontroller.ts";
|
||||||
|
|
||||||
|
const v1Widget3d = express.Router();
|
||||||
|
|
||||||
|
//widget3d-Page
|
||||||
|
v1Widget3d.post(
|
||||||
|
"/widget3d/save",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
Add3dWidgetController
|
||||||
|
);
|
||||||
|
v1Widget3d.patch(
|
||||||
|
"/widget3d/update",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
Update3DwidgetController
|
||||||
|
);
|
||||||
|
v1Widget3d.get(
|
||||||
|
"/widget3d/data/:zoneId/:projectId",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
Get3DWidgetController
|
||||||
|
);
|
||||||
|
v1Widget3d.patch(
|
||||||
|
"/widget3d/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
Delete3DwidgetController
|
||||||
|
);
|
||||||
|
export default v1Widget3d;
|
||||||
37
src/api-server/V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts
Normal file
37
src/api-server/V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { tokenValidator } from "../../../../shared/utils/token.ts";
|
||||||
|
import {
|
||||||
|
AddWidgetController,
|
||||||
|
GetWidgetController,
|
||||||
|
WidgetDeleteController,
|
||||||
|
WidgetUpdateController,
|
||||||
|
} from "../../v1Controllers/vizualizationController/v1widgetController.ts";
|
||||||
|
|
||||||
|
const v1Widget = express.Router();
|
||||||
|
|
||||||
|
//widget-Page
|
||||||
|
v1Widget.post(
|
||||||
|
"/widget/save",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
AddWidgetController
|
||||||
|
);
|
||||||
|
v1Widget.patch(
|
||||||
|
"/widget/:widgetID",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
WidgetUpdateController
|
||||||
|
);
|
||||||
|
v1Widget.get(
|
||||||
|
"/widget/data",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
GetWidgetController
|
||||||
|
);
|
||||||
|
v1Widget.patch(
|
||||||
|
"/widget/delete",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
WidgetDeleteController
|
||||||
|
);
|
||||||
|
export default v1Widget;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
import connectDB from "../shared/connect/mongoose.ts";
|
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import cameraRoutes from "./Routes/camera-Routes.ts";
|
import cameraRoutes from "./Routes/camera-Routes.ts";
|
||||||
import environmentsRoutes from "./Routes/environments-Routes.ts";
|
import environmentsRoutes from "./Routes/environments-Routes.ts";
|
||||||
@@ -9,8 +8,7 @@ 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/zone-Routes.ts";
|
import zoneRoutes from "./Routes/zoneRoutes.ts"; //update
|
||||||
import zoneRoutes2 from "./Routes/zoneRoutes.ts"; //update
|
|
||||||
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";
|
||||||
@@ -20,8 +18,25 @@ import templateRoutes from "./Routes/templateRoutes.ts";
|
|||||||
import widget3dRoutes from "./Routes/widget3dRoutes.ts";
|
import widget3dRoutes from "./Routes/widget3dRoutes.ts";
|
||||||
import productRouter from "./Routes/productRoutes.ts";
|
import productRouter from "./Routes/productRoutes.ts";
|
||||||
import projectRouter from "./Routes/projectRoutes.ts";
|
import projectRouter from "./Routes/projectRoutes.ts";
|
||||||
|
import trashRouter from "./Routes/trashRoutes.ts";
|
||||||
|
import homePageRouter from "./Routes/homepageRoutes.ts";
|
||||||
|
import redis from "../shared/redis/redis.ts";
|
||||||
|
import Authrouter from "./V1/v1Routes/authRoutes.ts";
|
||||||
|
import v1TrashRoutes from "./V1/v1Routes/v1-trashRoutes.ts";
|
||||||
|
import v1homeRoutes from "./V1/v1Routes/v1-homeRoutes.ts";
|
||||||
|
import v1projectRouter from "./V1/v1Routes/v1-projectRoutes.ts";
|
||||||
|
import v1Asset from "./V1/v1Routes/BuilderRoutes/v1-assetRoutes.ts";
|
||||||
|
import v1Camera from "./V1/v1Routes/BuilderRoutes/v1-cameraRoutes.ts";
|
||||||
|
import v1Line from "./V1/v1Routes/BuilderRoutes/v1-linesRoutes.ts";
|
||||||
|
import v1Wall from "./V1/v1Routes/BuilderRoutes/v1-wallRoutes.ts";
|
||||||
|
import v1Zone from "./V1/v1Routes/BuilderRoutes/v1-ZoneRoutes.ts";
|
||||||
|
import v1FloatWidget from "./V1/v1Routes/vizRoutes.ts/v1-FloatWidgetRoutes.ts";
|
||||||
|
import v1PanelRoutes from "./V1/v1Routes/vizRoutes.ts/v1-panelRoutes.ts";
|
||||||
|
import v1Template from "./V1/v1Routes/vizRoutes.ts/v1-TemplateRoutes.ts";
|
||||||
|
import v1Widget from "./V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts";
|
||||||
|
import v1Widget3d from "./V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts";
|
||||||
// import productFlowRoutes from "./Routes/productFlowRouts.ts";
|
// import productFlowRoutes from "./Routes/productFlowRouts.ts";
|
||||||
|
redis;
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
// const allowedOriginsDev = [
|
// const allowedOriginsDev = [
|
||||||
@@ -53,15 +68,19 @@ app.use(cors());
|
|||||||
// },
|
// },
|
||||||
// credentials: true
|
// credentials: true
|
||||||
// }));
|
// }));
|
||||||
app.use(express.json());
|
|
||||||
|
app.use(express.json({ limit: "50mb" }));
|
||||||
|
app.use(
|
||||||
|
express.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 })
|
||||||
|
);
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.send("Hello, I am Major-Dwinzo API!");
|
res.send("Hello, I am Major-Dwinzo API!");
|
||||||
});
|
});
|
||||||
// connectDB();
|
|
||||||
app.get("/health", (req, res) => {
|
app.get("/health", (req, res) => {
|
||||||
res.status(200).json({ message: "Server is running" });
|
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);
|
||||||
app.use("/api/v1", linesRoutes);
|
app.use("/api/v1", linesRoutes);
|
||||||
@@ -69,9 +88,8 @@ 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);
|
||||||
app.use("/api/v2", zoneRoutes);
|
|
||||||
//update
|
//update
|
||||||
app.use("/api/v2", zoneRoutes2); //updates
|
app.use("/api/v2", zoneRoutes); //updates
|
||||||
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);
|
||||||
@@ -81,5 +99,24 @@ 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/v2", productFlowRoutes);
|
||||||
app.use("/api/v1",projectRouter)
|
app.use("/api/v1", projectRouter);
|
||||||
|
app.use("/api/v1", trashRouter);
|
||||||
|
app.use("/api/v1", homePageRouter);
|
||||||
|
|
||||||
|
//New versions--based on the token and role based
|
||||||
|
app.use("/api/V1", Authrouter);
|
||||||
|
app.use("/api/V1", v1projectRouter);
|
||||||
|
app.use("/api/V1", v1TrashRoutes);
|
||||||
|
app.use("/api/V1", v1homeRoutes);
|
||||||
|
app.use("/api/V1", v1Asset);
|
||||||
|
app.use("/api/V1", v1Camera);
|
||||||
|
app.use("/api/V1", v1Line);
|
||||||
|
app.use("/api/V1", v1Wall);
|
||||||
|
app.use("/api/V1", v1Zone);
|
||||||
|
app.use("/api/V1", v1FloatWidget);
|
||||||
|
app.use("/api/V1", v1PanelRoutes);
|
||||||
|
app.use("/api/V1", v1Template);
|
||||||
|
app.use("/api/V1", v1Widget);
|
||||||
|
app.use("/api/V1", v1Widget3d);
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
|
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||||
|
|
||||||
export class floorItems {
|
export class FloorItems {
|
||||||
static async setFloorItems(req: Request, res: Response) {
|
static async setFloorItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@@ -57,7 +57,6 @@ export class floorItems {
|
|||||||
static async getFloorItems(req: Request, res: Response) {
|
static async getFloorItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
// console.log('req.params: ', req.params);
|
|
||||||
|
|
||||||
const findValue = await floorItemsModel(organization).find();
|
const findValue = await floorItemsModel(organization).find();
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ interface IPointStaticMachine extends IPointBase {
|
|||||||
targets: { modelUUID: string; pointUUID: string }[];
|
targets: { modelUUID: string; pointUUID: string }[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,27 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
|
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
|
||||||
|
|
||||||
|
export class WallItems {
|
||||||
export class wallItems {
|
|
||||||
static async setWallItems(req: Request, res: Response) {
|
static async setWallItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { modelUuid, modelName, position, type, csgposition,csgscale,quaternion,scale,organization } = req.body
|
const {
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
organization,
|
||||||
|
} = req.body;
|
||||||
|
|
||||||
|
const findvalue = await wallItemModel(organization).findOne({
|
||||||
const findvalue = await wallItenmModel(organization).findOne({ modelUuid: modelUuid})
|
modelUuid: modelUuid,
|
||||||
|
});
|
||||||
|
|
||||||
if (findvalue) {
|
if (findvalue) {
|
||||||
const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
|
const updatevalue = await wallItemModel(organization).findOneAndUpdate(
|
||||||
{ modelUuid: modelUuid },
|
{ modelUuid: modelUuid },
|
||||||
{
|
{
|
||||||
modelName,
|
modelName,
|
||||||
@@ -25,19 +35,24 @@ export class wallItems {
|
|||||||
{ new: true } // Return the updated document
|
{ new: true } // Return the updated document
|
||||||
);
|
);
|
||||||
res.status(201).json(updatevalue);
|
res.status(201).json(updatevalue);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const newValue = await wallItenmModel(organization).create({ modelUuid,modelName, position, type, csgposition,csgscale,quaternion,scale });
|
const newValue = await wallItemModel(organization).create({
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
});
|
||||||
|
|
||||||
res.status(201).json(newValue);
|
res.status(201).json(newValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
// 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" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,35 +60,32 @@ export class wallItems {
|
|||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
|
|
||||||
|
const findValue = await wallItemModel(organization).find();
|
||||||
const findValue = await wallItenmModel
|
|
||||||
(organization).find()
|
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("wallitems not found");
|
res.status(200).json("wallitems not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error get wallitems:', error);
|
console.error("Error get wallitems:", error);
|
||||||
res.status(500).json({ error: "Failed to get wallitems" });
|
res.status(500).json({ error: "Failed to get wallitems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async deleteWallItems(req: Request, res: Response) {
|
static async deleteWallItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { modelUuid,modelName,organization } = req.body;
|
const { modelUuid, modelName, organization } = req.body;
|
||||||
|
|
||||||
|
const findValue = await wallItemModel(organization).findOneAndDelete({
|
||||||
const findValue = await wallItenmModel
|
modelUuid: modelUuid,
|
||||||
(organization).findOneAndDelete({modelUuid:modelUuid,modelName:modelName})
|
modelName: modelName,
|
||||||
|
});
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("user not found");
|
res.status(200).json("user not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error get wallitems:', error);
|
console.error("Error get wallitems:", error);
|
||||||
res.status(500).json({ error: "Failed to get wallitems" });
|
res.status(500).json({ error: "Failed to get wallitems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,59 +2,66 @@ import { Request, Response } from "express";
|
|||||||
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 class camera {
|
export class Camera {
|
||||||
static async createCamera(req: Request, res: Response) {
|
static async createCamera(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { userId, position, target, rotation,organization } = req.body
|
const { userId, position, target, rotation, organization } = req.body;
|
||||||
|
|
||||||
|
const findCamera = await cameraModel(organization).findOne({
|
||||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
userId: userId,
|
||||||
|
});
|
||||||
|
|
||||||
if (findCamera) {
|
if (findCamera) {
|
||||||
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
||||||
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
|
{ userId: userId },
|
||||||
|
{ position: position, target: target, rotation: rotation },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
res.status(201).json(updateCamera);
|
res.status(201).json(updateCamera);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation });
|
const newCamera = await cameraModel(organization).create({
|
||||||
|
userId,
|
||||||
|
position,
|
||||||
|
target,
|
||||||
|
rotation,
|
||||||
|
});
|
||||||
|
|
||||||
res.status(201).json(newCamera);
|
res.status(201).json(newCamera);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
// 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" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
// if (!userId) {
|
const findCamera = await cameraModel(organization).findOne({
|
||||||
// res.status(201).json("User data is insufficient");
|
userId: userId,
|
||||||
// }
|
});
|
||||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
|
||||||
if (!findCamera) {
|
if (!findCamera) {
|
||||||
res.status(200).json("user not found");
|
res.status(200).json("user not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
res.status(201).json(findCamera);
|
res.status(201).json(findCamera);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error get camera:', error);
|
console.error("Error get camera:", error);
|
||||||
res.status(500).json({ error: "Failed to get camera" });
|
res.status(500).json({ error: "Failed to get camera" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async onlineActiveDatas(req: Request, res: Response) {
|
static async onlineActiveDatas(req: Request, res: Response) {
|
||||||
const {organization } = req.params;
|
const { organization } = req.params;
|
||||||
try {
|
try {
|
||||||
const findactiveUsers = await userModel(organization).find({activeStatus:"online"})
|
const findactiveUsers = await userModel(organization).find({
|
||||||
|
activeStatus: "online",
|
||||||
|
});
|
||||||
|
|
||||||
|
const cameraDataPromises = findactiveUsers.map(
|
||||||
const cameraDataPromises = findactiveUsers.map(async (activeUser:any) => {
|
async (activeUser: any) => {
|
||||||
const cameraData = await cameraModel(organization)
|
const cameraData = await cameraModel(organization)
|
||||||
.findOne({ userId: activeUser._id })
|
.findOne({ userId: activeUser._id })
|
||||||
.select("position target rotation -_id");
|
.select("position target rotation -_id");
|
||||||
@@ -63,7 +70,7 @@ export class camera {
|
|||||||
return {
|
return {
|
||||||
position: cameraData.position,
|
position: cameraData.position,
|
||||||
target: cameraData.target,
|
target: cameraData.target,
|
||||||
rotation:cameraData.rotation,
|
rotation: cameraData.rotation,
|
||||||
userData: {
|
userData: {
|
||||||
_id: activeUser._id,
|
_id: activeUser._id,
|
||||||
userName: activeUser.userName,
|
userName: activeUser.userName,
|
||||||
@@ -75,14 +82,15 @@ export class camera {
|
|||||||
|
|
||||||
// Return null if no camera data is found for the user
|
// Return null if no camera data is found for the user
|
||||||
return null;
|
return null;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
const cameraDatas = (await Promise.all(cameraDataPromises)).filter((singledata:any) => singledata !== null);
|
|
||||||
|
|
||||||
|
const cameraDatas = (await Promise.all(cameraDataPromises)).filter(
|
||||||
|
(singledata: any) => singledata !== null
|
||||||
|
);
|
||||||
|
|
||||||
res.status(200).send({ cameraDatas });
|
res.status(200).send({ cameraDatas });
|
||||||
|
} catch (error: any) {
|
||||||
} catch (error:any) {
|
|
||||||
res.status(500).send(error);
|
res.status(500).send(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
||||||
|
|
||||||
export class environment {
|
export class Environment {
|
||||||
static async setEnvironment(req: Request, res: Response) {
|
static async setEnvironment(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
|
|||||||
150
src/api-server/controller/home/homeControllers.ts
Normal file
150
src/api-server/controller/home/homeControllers.ts
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import {
|
||||||
|
RecentlyAdded,
|
||||||
|
searchProject,
|
||||||
|
searchTrashProject,
|
||||||
|
} from "../../../shared/services/home/homeService.ts";
|
||||||
|
|
||||||
|
export const recentDataController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.params;
|
||||||
|
if (!userId || !organization) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await RecentlyAdded({ userId, organization });
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Datas were empty":
|
||||||
|
res.status(200).json({
|
||||||
|
RecentlyViewed: [],
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
RecentlyViewed: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const searchProjectController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { searchName, organization, userId } = req.query as {
|
||||||
|
organization: string;
|
||||||
|
searchName: string;
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
if (!userId || !organization || !searchName) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await searchProject({
|
||||||
|
searchName,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const searchTrashProjectController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { searchName, organization, userId } = req.query as {
|
||||||
|
organization: string;
|
||||||
|
searchName: string;
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
if (!userId || !organization || !searchName) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await searchTrashProject({
|
||||||
|
searchName,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
37
src/api-server/controller/home/tutorialControllers.ts
Normal file
37
src/api-server/controller/home/tutorialControllers.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { getTutorials } from "../../../shared/services/home/tutorialsService.ts";
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
|
export const tutorialsDataController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization = "tutorials" } = req.body;
|
||||||
|
if (!organization) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "Organization is required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const result = await getTutorials({ organization });
|
||||||
|
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
tutorials: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,124 +1,115 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import lineModel from "../../../shared/model/lines/lines-Model.ts";
|
import lineModel from "../../../shared/model/lines/lines-Model.ts";
|
||||||
|
|
||||||
export class lines {
|
export class Lines {
|
||||||
static async setLines(req: Request, res: Response) {
|
static async setLines(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const {organization,layer,line,type}=req.body
|
const { organization, layer, line, type } = req.body;
|
||||||
const newLine = await lineModel(organization).create({ layer,line,type });
|
const newLine = await lineModel(organization).create({
|
||||||
|
layer,
|
||||||
|
line,
|
||||||
|
type,
|
||||||
|
});
|
||||||
|
|
||||||
res.status(201).json(newLine);
|
res.status(201).json(newLine);
|
||||||
|
|
||||||
// Send response with the created document
|
// 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" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 });
|
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
||||||
// Update the position of the line matching the 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 }, // Filter: Find the line with the given uuid
|
||||||
{ $set: { 'line.$.position': position } } // Update the position and type
|
{ $set: { "line.$.position": position } } // Update the position and type
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(201).json(updateResult);
|
res.status(201).json(updateResult);
|
||||||
|
|
||||||
// Send response with the created document
|
// 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" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getLines(req: Request, res: Response) {
|
static async getLines(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
|
|
||||||
|
const findValue = await lineModel(organization).find();
|
||||||
const findValue = await lineModel(organization).find()
|
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("user not found");
|
res.status(200).json("user not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error get Lines:', error);
|
console.error("Error get Lines:", error);
|
||||||
res.status(500).json({ error: "Failed to get Lines" });
|
res.status(500).json({ error: "Failed to get 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, layer, line, type } = req.body;
|
||||||
|
|
||||||
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) {
|
||||||
res.status(200).json("data not found");
|
res.status(200).json("data not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error delete Lines:', error);
|
console.error("Error delete Lines:", error);
|
||||||
res.status(500).json({ error: "Failed to delete Lines" });
|
res.status(500).json({ error: "Failed to delete 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, layer, uuid, type } = req.body;
|
||||||
|
|
||||||
const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid })
|
const findValue = await lineModel(organization).deleteMany({
|
||||||
|
"line.uuid": uuid,
|
||||||
|
});
|
||||||
|
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("data not found");
|
res.status(200).json("data not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error delete Lines:', error);
|
console.error("Error delete Lines:", error);
|
||||||
res.status(500).json({ error: "Failed to delete Lines" });
|
res.status(500).json({ error: "Failed to delete Lines" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async deleteLayer(req: Request, res: Response) {
|
static async deleteLayer(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const {organization,layer}=req.body
|
const { organization, layer } = req.body;
|
||||||
|
|
||||||
// Fetch the documents with the specified layer value
|
|
||||||
const findValue = await lineModel(organization).find({ layer: layer });
|
const findValue = await lineModel(organization).find({ layer: layer });
|
||||||
|
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("data not found");
|
res.status(200).json("data not found");
|
||||||
} else {
|
} else {
|
||||||
await lineModel(organization).deleteMany({ layer: layer });
|
await lineModel(organization).deleteMany({ layer: layer });
|
||||||
// console.log(`Documents with layer ${layer} have been deleted.`);
|
|
||||||
|
|
||||||
// Update documents with layer greater than -1
|
|
||||||
const updateResult = 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 } }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
res.status(201).json(updateResult);
|
res.status(201).json(updateResult);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error delete Lines:', error);
|
console.error("Error delete Lines:", error);
|
||||||
res.status(500).json({ error: "Failed to delete Lines" });
|
res.status(500).json({ error: "Failed to delete Lines" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,72 +3,100 @@ 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);
|
// 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;
|
||||||
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({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
if (findZoneId) {
|
if (findZoneId) {
|
||||||
const updateZone = await zoneModel(organization).findOneAndUpdate(
|
const updateZone = await zoneModel(organization)
|
||||||
{ zoneId: zoneId }, { points: points, viewPortposition: viewPortposition, viewPortCenter: viewPortCenter }, { new: true }
|
.findOneAndUpdate(
|
||||||
).select("-_id -__v")
|
{ zoneId: zoneId },
|
||||||
res.status(201).json({ message: 'zone updated', data: updateZone, organization: organization })
|
{
|
||||||
|
points: points,
|
||||||
|
viewPortposition: viewPortposition,
|
||||||
|
viewPortCenter: viewPortCenter,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
)
|
||||||
|
.select("-_id -__v");
|
||||||
|
res.status(201).json({
|
||||||
|
message: "zone updated",
|
||||||
|
data: updateZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const zoneCreate = await zoneModel(organization).create({
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
zoneId, createBy: userId, zoneName: zoneName, points, layer, viewPortCenter, viewPortposition
|
zoneId,
|
||||||
})
|
createBy: userId,
|
||||||
|
zoneName: zoneName,
|
||||||
|
points,
|
||||||
|
layer,
|
||||||
|
viewPortCenter,
|
||||||
|
viewPortposition,
|
||||||
|
});
|
||||||
const createdZone = await zoneModel(organization)
|
const createdZone = await zoneModel(organization)
|
||||||
.findById(zoneCreate._id)
|
.findById(zoneCreate._id)
|
||||||
.select('-_id -__v')
|
.select("-_id -__v")
|
||||||
.lean();
|
.lean();
|
||||||
res.status(201).json({ message: 'zone created', data: createdZone, organization: organization })
|
res.status(201).json({
|
||||||
|
message: "zone created",
|
||||||
|
data: createdZone,
|
||||||
|
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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async deleteZone(req: Request, res: Response) {
|
static async deleteZone(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, zoneId } = req.body
|
const { organization, userId, zoneId } = req.body;
|
||||||
|
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
if (findZoneId) {
|
if (findZoneId) {
|
||||||
const deleteZone = await zoneModel(organization).findOneAndDelete(
|
const deleteZone = await zoneModel(organization)
|
||||||
{ zoneId: zoneId, createBy: userId }
|
.findOneAndDelete({ zoneId: zoneId, createBy: userId })
|
||||||
).select("-_id -__v")
|
.select("-_id -__v");
|
||||||
res.status(201).json({ message: 'zone deleted', data: deleteZone, organization: organization })
|
res.status(201).json({
|
||||||
|
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' })
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} 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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getZones(req: Request, res: Response) {
|
static async getZones(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, userId } = req.params
|
const { organization, userId } = req.params;
|
||||||
|
|
||||||
|
|
||||||
const findZoneId = await zoneModel(organization)
|
const findZoneId = await zoneModel(organization)
|
||||||
.find()
|
.find()
|
||||||
.select("zoneId zoneName layer points viewPortCenter viewPortposition -_id");
|
.select(
|
||||||
|
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
||||||
|
);
|
||||||
|
|
||||||
if (!findZoneId) {
|
if (!findZoneId) {
|
||||||
res.status(500).json({ message: 'Invalid zone' })
|
res.status(500).json({ message: "Invalid zone" });
|
||||||
|
|
||||||
}
|
}
|
||||||
res.status(201).json({ data: findZoneId, organization: organization })
|
res.status(200).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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +104,9 @@ export class zone {
|
|||||||
try {
|
try {
|
||||||
const organization = req.params.organization;
|
const organization = req.params.organization;
|
||||||
const zoneId = req.params.zoneId;
|
const zoneId = req.params.zoneId;
|
||||||
const findZone = await zoneModel(organization)
|
const findZone = await zoneModel(organization).findOne({
|
||||||
.findOne({ zoneId: zoneId })
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
// .select("zoneName");
|
// .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);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Request, Response } from "express";
|
|||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
export class Zoneservice {
|
export class ZoneService {
|
||||||
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const organization = req.body.organization;
|
const organization = req.body.organization;
|
||||||
|
|||||||
59
src/api-server/controller/newassets/wallcontroller.ts
Normal file
59
src/api-server/controller/newassets/wallcontroller.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import { WallItems } from "../../../shared/services/wall/wallItemservice.ts";
|
||||||
|
import { error } from "console";
|
||||||
|
|
||||||
|
export const WallSetup = async (req: Request, res: Response): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
organization,
|
||||||
|
} = req.body;
|
||||||
|
if (
|
||||||
|
!modelUuid ||
|
||||||
|
!modelName ||
|
||||||
|
!position ||
|
||||||
|
!type ||
|
||||||
|
!csgscale ||
|
||||||
|
!csgposition ||
|
||||||
|
!quaternion ||
|
||||||
|
!scale ||
|
||||||
|
!organization
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required!",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await WallItems.setWallItems({
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
organization,
|
||||||
|
});
|
||||||
|
switch (result.state) {
|
||||||
|
case "Updated successfully":
|
||||||
|
res.status(201).json(result.data);
|
||||||
|
break;
|
||||||
|
case "wall Item created successfully":
|
||||||
|
res.status(201).json(result.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json(error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error: unknown) {
|
||||||
|
res.status(500).json({ message: "Unknown error" });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,46 +1,233 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { createProject } from "../../../shared/services/project/project-Serivices.ts";
|
import {
|
||||||
|
createProject,
|
||||||
|
DeleteProject,
|
||||||
|
GetAllProjects,
|
||||||
|
updateProject,
|
||||||
|
viewProject,
|
||||||
|
} from "../../../shared/services/project/project-Services.ts";
|
||||||
|
|
||||||
export const createProjectController = async (req: Request, res: Response): Promise<void> => {
|
export const createProjectController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
|
const { projectUuid, userId, thumbnail, organization } = req.body;
|
||||||
|
if (!projectUuid || !userId || !thumbnail || !organization) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
const result = await createProject(req.body);
|
const result = await createProject(req.body);
|
||||||
console.log("result:", result);
|
|
||||||
|
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
case "project_exists":
|
case "project_exists":
|
||||||
res.status(409).json({
|
res.status(403).json({
|
||||||
success: false,
|
|
||||||
message: "Project already exists",
|
message: "Project already exists",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "user_not_found":
|
case "user_not_found":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
success: false,
|
|
||||||
message: "User not found",
|
message: "User not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "success":
|
case "Success":
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
success: true,
|
message: "Project created Successfully",
|
||||||
message: "Project created successfully",
|
projectId: result.project._id,
|
||||||
data: result.project,
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
success: false,
|
|
||||||
message: "Internal server error",
|
message: "Internal server error",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in controller:", error);
|
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
success: false,
|
message: "Unknown error",
|
||||||
message: "Internal server error",
|
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const GetProjects = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.params;
|
||||||
|
if (!userId || !organization) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await GetAllProjects({ userId, organization });
|
||||||
|
switch (result?.status) {
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json({
|
||||||
|
Projects: result?.Datas,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const RemoveProject = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { projectId } = req.params;
|
||||||
|
const { organization, userId } = req.body;
|
||||||
|
if (!projectId || !organization || !userId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await DeleteProject({ projectId, organization, userId });
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(201).json({
|
||||||
|
message: "Project Deleted Successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const updateProjectController = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { projectId, organization, projectName, thumbnail, userId } =
|
||||||
|
req.body;
|
||||||
|
if (!userId || !organization || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await updateProject({
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
projectName,
|
||||||
|
thumbnail,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project updated Successfully",
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const ViewData = async (req: Request, res: Response): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { projectId, organization, userId } = req.query as {
|
||||||
|
organization: string;
|
||||||
|
projectId: string;
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
if (!userId || !organization || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await viewProject({
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
switch (result?.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "User not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "User not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
projectData: result.data,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
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";
|
||||||
|
|
||||||
|
export class Share {
|
||||||
export class share {
|
|
||||||
static async shareUser(req: Request, res: Response) {
|
static async shareUser(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { email, isShare, organization } = req.body
|
const { email, isShare, organization } = req.body;
|
||||||
|
|
||||||
|
const findValue = await userModel(organization).findOneAndUpdate(
|
||||||
|
{ email: email },
|
||||||
|
{ isShare: isShare },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
const findValue = await userModel(organization).findOneAndUpdate({email:email},{isShare:isShare},{new:true})
|
res
|
||||||
|
.status(201)
|
||||||
res.status(201).json({message:"scene shared successfully",data:findValue});
|
.json({ message: "scene shared successfully", data: findValue });
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(404).json({message:"Not found"})
|
res.status(404).json({ message: "Not found" });
|
||||||
}
|
}
|
||||||
// Send response with the created document
|
// 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" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,19 +29,18 @@ export class share {
|
|||||||
try {
|
try {
|
||||||
const organization = req.query.organization as string;
|
const organization = req.query.organization as string;
|
||||||
|
|
||||||
|
const findValue = await userModel(organization)
|
||||||
|
.find({})
|
||||||
|
.select("isShare email userName -_id");
|
||||||
|
|
||||||
const findValue = await userModel(organization).find({}).select("isShare email userName -_id")
|
res.status(201).json({ message: "scene shared datas", data: findValue });
|
||||||
// console.log('findValue: ', findValue);
|
|
||||||
|
|
||||||
res.status(201).json({message:"scene shared datas",data:findValue});
|
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(404).json({message:"Not found"})
|
res.status(404).json({ message: "Not found" });
|
||||||
}
|
}
|
||||||
// Send response with the created document
|
// 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 " });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,182 +1,9 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
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 triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
|
||||||
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||||
|
|
||||||
export class assetsFloorservice {
|
export class AssetsFloorService {
|
||||||
// static async setFloorassets(req: Request, res: Response): Promise<any> {
|
|
||||||
// try {
|
|
||||||
// const {
|
|
||||||
// modelUuid,
|
|
||||||
// modelName,
|
|
||||||
// position,
|
|
||||||
// modelfileID,
|
|
||||||
// rotation,
|
|
||||||
// isLocked,
|
|
||||||
// isVisible,
|
|
||||||
// organization,
|
|
||||||
// eventData,
|
|
||||||
// } = req.body;
|
|
||||||
// console.log("req.body: ", req.body);
|
|
||||||
|
|
||||||
// const findvalue = await assetModel(organization).findOne({
|
|
||||||
// modelUuid,
|
|
||||||
// // modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// const checkpointType = await pointModel(organization).findOne({
|
|
||||||
// modelfileID: modelfileID,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (findvalue) {
|
|
||||||
// const updatevalue = await assetModel(organization).findOneAndUpdate(
|
|
||||||
// { modelUuid, isArchive: false },
|
|
||||||
// {
|
|
||||||
// modelName: modelName,
|
|
||||||
// position,
|
|
||||||
// rotation,
|
|
||||||
// isVisible,
|
|
||||||
// isLocked,
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
// return res.status(201).json(updatevalue);
|
|
||||||
// } else {
|
|
||||||
// let assetData: any = {
|
|
||||||
// modelUuid,
|
|
||||||
// modelName,
|
|
||||||
// position,
|
|
||||||
// modelfileID,
|
|
||||||
// rotation,
|
|
||||||
// isLocked,
|
|
||||||
// isVisible,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// console.log("eventData: ", eventData);
|
|
||||||
// if (eventData) {
|
|
||||||
// if (eventData.type === "Conveyor") {
|
|
||||||
// assetData.speed = eventData.speed;
|
|
||||||
// } else if (eventData.type === "Vehicle") {
|
|
||||||
// assetData.speed = eventData.points.speed;
|
|
||||||
// if (!eventData.points) {
|
|
||||||
// return res
|
|
||||||
// .status(400)
|
|
||||||
// .json({ message: "Vehicle points must be a single object" });
|
|
||||||
// }
|
|
||||||
// // if (eventData.points.rotation) {
|
|
||||||
// // return res.status(400).json({
|
|
||||||
// // message: "Rotation is not allowed for Vehicle points",
|
|
||||||
// // });
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// if (eventData.points.triggers) {
|
|
||||||
// return res.status(400).json({
|
|
||||||
// message: "triggers is not allowed for Vehicle points",
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // else if(eventData.type === "ArmBot"){
|
|
||||||
// // assetData.speed = eventData.position;
|
|
||||||
// // }else if(eventData.type === "StaticMachine"){
|
|
||||||
// // assetData.speed = eventData.position;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// assetData.points = eventData.points;
|
|
||||||
// assetData.type = eventData.type;
|
|
||||||
// }
|
|
||||||
// const assetDoc = await assetModel(organization).create(assetData);
|
|
||||||
// await assetDoc.save();
|
|
||||||
|
|
||||||
// return res.status(201).json({
|
|
||||||
// message: "Model stored successfully",
|
|
||||||
// modelId: assetDoc._id,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Error creating flooritems:", error);
|
|
||||||
// res.status(500).json({ message: "Failed to create flooritems" });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// static async getFloorItems(req: Request, res: Response): Promise<any> {
|
|
||||||
// try {
|
|
||||||
// const { organization } = req.params;
|
|
||||||
// const findValues = await assetModel(organization)
|
|
||||||
// .find({ isArchive: false })
|
|
||||||
// .select("-_id -isArchive");
|
|
||||||
|
|
||||||
// if (!findValues || findValues.length === 0) {
|
|
||||||
// return res.status(200).json({ message: "floorItems not found" });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const response = findValues.map((item) => {
|
|
||||||
// // console.log("item: ", item);
|
|
||||||
// // console.log("item: ", item.type);
|
|
||||||
// // console.log('findValues: ', findValues);
|
|
||||||
// // console.log("item.points: ", item.points);
|
|
||||||
// const responseItem: any = {
|
|
||||||
// modelUuid: item.modelUuid,
|
|
||||||
// modelName: item.modelName,
|
|
||||||
// position: item.position,
|
|
||||||
// rotation: item.rotation,
|
|
||||||
// modelfileID: item.modelfileID,
|
|
||||||
// isLocked: item.isLocked,
|
|
||||||
// isVisible: item.isVisible,
|
|
||||||
// };
|
|
||||||
// if (item.type === "Conveyor" && item.points.length > 0) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// speed: item.speed,
|
|
||||||
// points: item.points,
|
|
||||||
// type: item.type,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (item.type === "Vehicle" && item.points) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// type: item.type,
|
|
||||||
// points: item.points,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// if (item.type === "ArmBot" && item.points) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// type: item.type,
|
|
||||||
// points: item.points,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// if (item.type === "StaticMachine" && item.points) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// type: item.type,
|
|
||||||
// points: item.points,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// return responseItem;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return res.status(200).json(response);
|
|
||||||
// } catch (error) {
|
|
||||||
// res.status(500).json({ error: "Failed to get flooritems" });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
|
||||||
// try {
|
|
||||||
// const { modelUuid, modelName, organization } = req.body;
|
|
||||||
|
|
||||||
// const findValue = await assetModel(organization).findOneAndDelete({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// modelName: modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!findValue) {
|
|
||||||
// res.status(200).json("user not found");
|
|
||||||
// } else {
|
|
||||||
// res.status(201).json(findValue);
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// res.status(500).json({ error: "Failed to get flooritems" });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
static async updateAssetPositionRotation(
|
static async updateAssetPositionRotation(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response
|
||||||
@@ -186,11 +13,11 @@ export class assetsFloorservice {
|
|||||||
modelUuid,
|
modelUuid,
|
||||||
modelName,
|
modelName,
|
||||||
position,
|
position,
|
||||||
modelfileID,
|
|
||||||
rotation,
|
rotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
organization,
|
organization,
|
||||||
|
// modelfileID, //optional
|
||||||
// eventData, // Optional
|
// eventData, // Optional
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
@@ -244,7 +71,6 @@ export class assetsFloorservice {
|
|||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//update setfoolrassets//getFloorItems//deleteFloorItems.........
|
|
||||||
static async setFloorassets(req: Request, res: Response): Promise<any> {
|
static async setFloorassets(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@@ -265,7 +91,7 @@ export class assetsFloorservice {
|
|||||||
// modelName,
|
// modelName,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
const checkpointType = await pointModel(organization).findOne({
|
await pointModel(organization).findOne({
|
||||||
modelfileID: modelfileID,
|
modelfileID: modelfileID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
@@ -292,10 +118,9 @@ export class assetsFloorservice {
|
|||||||
rotation,
|
rotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
eventData
|
eventData,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("eventData: ", eventData);
|
|
||||||
if (eventData) {
|
if (eventData) {
|
||||||
if (eventData.type === "Conveyor") {
|
if (eventData.type === "Conveyor") {
|
||||||
assetData.speed = eventData.speed;
|
assetData.speed = eventData.speed;
|
||||||
@@ -306,24 +131,12 @@ export class assetsFloorservice {
|
|||||||
.status(400)
|
.status(400)
|
||||||
.json({ message: "Vehicle points must be a single object" });
|
.json({ message: "Vehicle points must be a single object" });
|
||||||
}
|
}
|
||||||
// if (eventData.points.rotation) {
|
|
||||||
// return res.status(400).json({
|
|
||||||
// message: "Rotation is not allowed for Vehicle points",
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (eventData.points.triggers) {
|
if (eventData.points.triggers) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
message: "triggers is not allowed for Vehicle points",
|
message: "triggers is not allowed for Vehicle points",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if(eventData.type === "ArmBot"){
|
|
||||||
// assetData.speed = eventData.position;
|
|
||||||
// }else if(eventData.type === "StaticMachine"){
|
|
||||||
// assetData.speed = eventData.position;
|
|
||||||
// }
|
|
||||||
|
|
||||||
assetData.points = eventData.points;
|
assetData.points = eventData.points;
|
||||||
assetData.type = eventData.type;
|
assetData.type = eventData.type;
|
||||||
}
|
}
|
||||||
@@ -352,10 +165,6 @@ export class assetsFloorservice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = findValues.map((item) => {
|
const response = findValues.map((item) => {
|
||||||
// console.log("item: ", item);
|
|
||||||
// console.log("item: ", item.type);
|
|
||||||
// console.log('findValues: ', findValues);
|
|
||||||
// console.log("item.points: ", item.points);
|
|
||||||
const responseItem: any = {
|
const responseItem: any = {
|
||||||
modelUuid: item.modelUuid,
|
modelUuid: item.modelUuid,
|
||||||
modelName: item.modelName,
|
modelName: item.modelName,
|
||||||
@@ -366,36 +175,9 @@ export class assetsFloorservice {
|
|||||||
isVisible: item.isVisible,
|
isVisible: item.isVisible,
|
||||||
eventData: item.eventData,
|
eventData: item.eventData,
|
||||||
};
|
};
|
||||||
// if (item.type === "Conveyor" && item.points.length > 0) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// speed: item.speed,
|
|
||||||
// points: item.points,
|
|
||||||
// type: item.type,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (item.type === "Vehicle" && item.points) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// type: item.type,
|
|
||||||
// points: item.points,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// if (item.type === "ArmBot" && item.points) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// type: item.type,
|
|
||||||
// points: item.points,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// if (item.type === "StaticMachine" && item.points) {
|
|
||||||
// responseItem.eventData = {
|
|
||||||
// type: item.type,
|
|
||||||
// points: item.points,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
return responseItem;
|
return responseItem;
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log('response: ', response);
|
|
||||||
return res.status(200).json(response);
|
return res.status(200).json(response);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
@@ -404,7 +186,6 @@ export class assetsFloorservice {
|
|||||||
static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { modelUuid, modelName, organization } = req.body;
|
const { modelUuid, modelName, organization } = req.body;
|
||||||
console.log('req.body:', req.body);
|
|
||||||
|
|
||||||
const asset = await assetModel(organization).findOne({
|
const asset = await assetModel(organization).findOne({
|
||||||
modelUuid,
|
modelUuid,
|
||||||
|
|||||||
@@ -1,249 +0,0 @@
|
|||||||
// import { Request, Response } from "express";
|
|
||||||
// // import assetModel from "../../../shared/model/assets/flooritems-Model.ts";
|
|
||||||
// import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
|
||||||
// import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
|
||||||
// import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
|
||||||
// import productFlowModel from "../../../shared/model/simulation/ProductFlowmodel.ts";
|
|
||||||
|
|
||||||
// export class productFlowservice {
|
|
||||||
// static async setproductFlow(req: Request, res: Response): Promise<any> {
|
|
||||||
// try {
|
|
||||||
// const {
|
|
||||||
// productName,
|
|
||||||
// modelUuid,
|
|
||||||
// modelName,
|
|
||||||
// eventData,
|
|
||||||
// organization,
|
|
||||||
// productID,
|
|
||||||
// } = req.body;
|
|
||||||
|
|
||||||
// // Validate required fields
|
|
||||||
// if (!modelUuid || !modelName || !organization) {
|
|
||||||
// return res.status(400).json({ message: "Missing required fields" });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Check if asset exists
|
|
||||||
// const existingAsset = await assetModel(organization).findOne({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!existingAsset) {
|
|
||||||
// return res.status(404).json({ message: "Asset not found for the ID" });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Prepare point references
|
|
||||||
// let pointRefs: any[] = [];
|
|
||||||
// if (eventData?.points && Array.isArray(eventData.points)) {
|
|
||||||
// for (const point of eventData.points) {
|
|
||||||
// let actionRefs: any[] = [];
|
|
||||||
// let triggerRefs: any[] = [];
|
|
||||||
|
|
||||||
// // Process actions
|
|
||||||
// if (Array.isArray(point.actions)) {
|
|
||||||
// for (const action of point.actions) {
|
|
||||||
// const actionDoc = await actionModel(organization).create({
|
|
||||||
// pointsUUID: point.uuid,
|
|
||||||
// isArchive: false,
|
|
||||||
// uuid: action.uuid,
|
|
||||||
// name: action.name,
|
|
||||||
// type: action.type,
|
|
||||||
// material: action.material || null,
|
|
||||||
// delay: action.delay || null,
|
|
||||||
// spawn_Interval: action.spawn_Interval || null,
|
|
||||||
// });
|
|
||||||
// actionRefs.push({
|
|
||||||
// _id: actionDoc._id,
|
|
||||||
// ...action,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Process triggers
|
|
||||||
// if (Array.isArray(point.triggers)) {
|
|
||||||
// for (const trigger of point.triggers) {
|
|
||||||
// const triggerDoc = await triggerModel(organization).create({
|
|
||||||
// pointsUUID: point.uuid,
|
|
||||||
// isArchive: false,
|
|
||||||
// uuid: trigger.uuid,
|
|
||||||
// name: trigger.name,
|
|
||||||
// type: trigger.type,
|
|
||||||
// bufferTime: trigger.bufferTime || null,
|
|
||||||
// });
|
|
||||||
// triggerRefs.push({
|
|
||||||
// _id: triggerDoc._id,
|
|
||||||
// ...trigger,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pointRefs.push({
|
|
||||||
// pointuuid: point.uuid,
|
|
||||||
// position: point.position || [],
|
|
||||||
// rotation: point.rotation || [],
|
|
||||||
// actions: actionRefs,
|
|
||||||
// triggers: triggerRefs,
|
|
||||||
// connections: point.connections || null,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Check if product flow exists
|
|
||||||
// const existingproductData = await productFlowModel(organization).findOne({
|
|
||||||
// _id: productID,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// let result;
|
|
||||||
// if (existingproductData) {
|
|
||||||
// // Update existing product flow
|
|
||||||
// result = await productFlowModel(organization).findOneAndUpdate(
|
|
||||||
// { _id: productID },
|
|
||||||
// {
|
|
||||||
// $push: {
|
|
||||||
// ProductData: {
|
|
||||||
// AssetName: modelName,
|
|
||||||
// Assetuuid: modelUuid,
|
|
||||||
// paths: {
|
|
||||||
// Points: pointRefs,
|
|
||||||
// },
|
|
||||||
// isArchive: false,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// // Create new product flow
|
|
||||||
// result = await productFlowModel(organization).create({
|
|
||||||
// _id: productID,
|
|
||||||
// productName: productName,
|
|
||||||
// ProductData: [
|
|
||||||
// {
|
|
||||||
// AssetName: modelName,
|
|
||||||
// Assetuuid: modelUuid,
|
|
||||||
// paths: {
|
|
||||||
// Points: pointRefs,
|
|
||||||
// },
|
|
||||||
// isArchive: false,
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// eventType: eventData?.type || null,
|
|
||||||
// speed: eventData?.speed || null,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// res.status(201).json({
|
|
||||||
// message: "Product flow processed successfully",
|
|
||||||
// data: result,
|
|
||||||
// });
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Error creating flooritems:", error);
|
|
||||||
// res.status(500).json({ message: "Failed to create flooritems" });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// static async pointActionList(req: Request, res: Response): Promise<any> {}
|
|
||||||
// static async productpathsList(req: Request, res: Response): Promise<any> {
|
|
||||||
// try {
|
|
||||||
// const { organization } = req.params;
|
|
||||||
// const productFlowList = await productFlowModel(organization)
|
|
||||||
// .find()
|
|
||||||
// .select("ProductData productName -_id")
|
|
||||||
// .exec();
|
|
||||||
|
|
||||||
// const formattedData = await Promise.all(
|
|
||||||
// productFlowList.map(async (item) => ({
|
|
||||||
// productName: item.productName,
|
|
||||||
// paths: await Promise.all(
|
|
||||||
// item.ProductData.map(async (data: any) => ({
|
|
||||||
// Points: await Promise.all(
|
|
||||||
// data.paths.Points.map(async (point: any) => {
|
|
||||||
// const actions = await actionModel(organization)
|
|
||||||
// .find({ _id: { $in: point.actions } })
|
|
||||||
// .select(
|
|
||||||
// "-_id -pointsUUID -isArchive -createdAt -updatedAt -__v"
|
|
||||||
// )
|
|
||||||
// .lean();
|
|
||||||
// const triggers = await triggerModel(organization)
|
|
||||||
// .find({ _id: { $in: point.triggers } })
|
|
||||||
// .select(
|
|
||||||
// "-_id -pointsUUID -isArchive -createdAt -updatedAt -__v"
|
|
||||||
// )
|
|
||||||
// .lean();
|
|
||||||
// return {
|
|
||||||
// connections: point.connections || null,
|
|
||||||
// pointuuid: point.pointuuid,
|
|
||||||
// actions: actions,
|
|
||||||
// triggers: triggers,
|
|
||||||
// position: point.position,
|
|
||||||
// rotation: point.rotation,
|
|
||||||
// };
|
|
||||||
// })
|
|
||||||
// ),
|
|
||||||
// }))
|
|
||||||
// ),
|
|
||||||
// }))
|
|
||||||
// );
|
|
||||||
|
|
||||||
// return res.status(200).json(formattedData);
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Error get flooritems:", error);
|
|
||||||
// res.status(500).json({ error: "Failed to get flooritems" });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
|
||||||
// // try {
|
|
||||||
// // const { modelUuid, modelName, organization } = req.body;
|
|
||||||
|
|
||||||
// // const findValue = await assetModel(organization).findOneAndDelete({
|
|
||||||
// // modelUuid: modelUuid,
|
|
||||||
// // modelName: modelName,
|
|
||||||
// // isArchive: false,
|
|
||||||
// // });
|
|
||||||
// // if (!findValue) {
|
|
||||||
// // res.status(200).json("user not found");
|
|
||||||
// // } else {
|
|
||||||
// // res.status(201).json(findValue);
|
|
||||||
// // }
|
|
||||||
// // } catch (error) {
|
|
||||||
// // console.error("Error get flooritems:", error);
|
|
||||||
// // res.status(500).json({ error: "Failed to get flooritems" });
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// // static async updateAssetPositionRotation(
|
|
||||||
// // req: Request,
|
|
||||||
// // res: Response
|
|
||||||
// // ): Promise<any> {
|
|
||||||
// // try {
|
|
||||||
// // const {
|
|
||||||
// // modelUuid,
|
|
||||||
// // modelName,
|
|
||||||
// // position,
|
|
||||||
// // modelfileID,
|
|
||||||
// // rotation,
|
|
||||||
// // isLocked,
|
|
||||||
// // isVisible,
|
|
||||||
// // organization,
|
|
||||||
// // // eventData, // Optional
|
|
||||||
// // } = req.body;
|
|
||||||
|
|
||||||
// // const existingAsset = await assetModel(organization).findOne({
|
|
||||||
// // modelUuid: modelUuid,
|
|
||||||
// // isArchive: false,
|
|
||||||
// // });
|
|
||||||
// // if (!existingAsset) return res.send("Asset not found");
|
|
||||||
// // const updateAsset = await assetModel(organization).updateMany(
|
|
||||||
// // { modelUuid: modelUuid, modelName: modelName, isArchive: false },
|
|
||||||
// // {
|
|
||||||
// // position: position,
|
|
||||||
// // rotation: rotation,
|
|
||||||
// // isVisible: isVisible,
|
|
||||||
// // isLocked: isLocked,
|
|
||||||
// // }
|
|
||||||
// // );
|
|
||||||
// // if (updateAsset)
|
|
||||||
// // return res.status(200).json({ message: "Asset updated successfully" });
|
|
||||||
// // } catch (error: any) {
|
|
||||||
// // return res.send(error.message);
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// // static async updateActionsDatas(req: Request, res: Response) {}
|
|
||||||
// }
|
|
||||||
@@ -2,34 +2,31 @@ 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
|
return res.json({ message: "organization not found" });
|
||||||
.json({ message: "organization not found" });
|
|
||||||
}
|
}
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
});
|
||||||
if (existingProduct) {
|
if (existingProduct) {
|
||||||
const existingEventData = await EventsDataModel(organization).findOne(
|
const existingEventData = await EventsDataModel(organization).findOne({
|
||||||
{
|
|
||||||
productId: productId,
|
productId: productId,
|
||||||
modelUuid: eventDatas.modelUuid,
|
modelUuid: eventDatas.modelUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
});
|
||||||
if (existingEventData) {
|
if (existingEventData) {
|
||||||
const updateEventData = await EventsDataModel(organization).findOneAndUpdate(
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
modelUuid: eventDatas.modelUuid,
|
modelUuid: eventDatas.modelUuid,
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
}
|
},
|
||||||
, {
|
{
|
||||||
modelUuid: eventDatas?.modelUuid,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
modelName: eventDatas?.modelName,
|
modelName: eventDatas?.modelName,
|
||||||
position: eventDatas?.position,
|
position: eventDatas?.position,
|
||||||
@@ -38,12 +35,13 @@ export class productFlowservice {
|
|||||||
speed: eventDatas?.speed,
|
speed: eventDatas?.speed,
|
||||||
point: eventDatas?.point,
|
point: eventDatas?.point,
|
||||||
points: eventDatas?.points,
|
points: eventDatas?.points,
|
||||||
})
|
}
|
||||||
|
);
|
||||||
return res
|
return res
|
||||||
.status(200)
|
.status(200)
|
||||||
.json({ message: "EventData updated successfully" });
|
.json({ message: "EventData updated successfully" });
|
||||||
} else {
|
} else {
|
||||||
const addEventData = await EventsDataModel(organization).create({
|
await EventsDataModel(organization).create({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
modelUuid: eventDatas?.modelUuid,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
modelName: eventDatas?.modelName,
|
modelName: eventDatas?.modelName,
|
||||||
@@ -52,8 +50,8 @@ export class productFlowservice {
|
|||||||
type: eventDatas?.type,
|
type: eventDatas?.type,
|
||||||
speed: eventDatas?.speed,
|
speed: eventDatas?.speed,
|
||||||
point: eventDatas?.point,
|
point: eventDatas?.point,
|
||||||
points: eventDatas?.points
|
points: eventDatas?.points,
|
||||||
})
|
});
|
||||||
return res
|
return res
|
||||||
.status(201)
|
.status(201)
|
||||||
.json({ message: "EventData add successfully" });
|
.json({ message: "EventData add successfully" });
|
||||||
@@ -61,13 +59,11 @@ export class productFlowservice {
|
|||||||
} else {
|
} else {
|
||||||
const newProduct = await ProductModel(organization).create({
|
const newProduct = await ProductModel(organization).create({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
productName: productName
|
productName: productName,
|
||||||
|
});
|
||||||
})
|
|
||||||
if (newProduct) {
|
if (newProduct) {
|
||||||
|
|
||||||
if (eventDatas) {
|
if (eventDatas) {
|
||||||
const addEventData = await EventsDataModel(organization).create({
|
await EventsDataModel(organization).create({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
modelUuid: eventDatas?.modelUuid,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
modelName: eventDatas?.modelName,
|
modelName: eventDatas?.modelName,
|
||||||
@@ -77,14 +73,12 @@ export class productFlowservice {
|
|||||||
speed: eventDatas?.speed,
|
speed: eventDatas?.speed,
|
||||||
point: eventDatas?.point,
|
point: eventDatas?.point,
|
||||||
points: eventDatas?.points,
|
points: eventDatas?.points,
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
.status(201)
|
.status(201)
|
||||||
.json({ message: "Product created successfully" });
|
.json({ message: "Product created successfully" });
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to create product" });
|
res.status(500).json({ message: "Failed to create product" });
|
||||||
@@ -92,123 +86,116 @@ export class productFlowservice {
|
|||||||
}
|
}
|
||||||
static async getProductDatas(req: Request, res: Response): Promise<any> {
|
static async getProductDatas(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productId, organization } = req.query
|
const { productId, organization } = req.query;
|
||||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||||
return res.status(400).json({ message: "Missing or invalid query parameters" });
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ message: "Missing or invalid query parameters" });
|
||||||
}
|
}
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
|
const existingEventDatas = await EventsDataModel(organization)
|
||||||
|
.find({ productId: productId })
|
||||||
|
.select("-productId");
|
||||||
|
|
||||||
const existingEventDatas = await EventsDataModel(organization).find({ productId: productId }).select("-productId")
|
return res.status(200).json(existingEventDatas);
|
||||||
|
|
||||||
return res
|
|
||||||
.status(200)
|
|
||||||
.json(existingEventDatas);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
res.status(500).json({ message: "Failed to get product" });
|
res.status(500).json({ message: "Failed to get product" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
static async productDataDelete(req: Request, res: Response): Promise<any> {
|
static async productDataDelete(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productId, organization } = req.query
|
const { productId, organization } = req.query;
|
||||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||||
return res.status(400).json({ message: "Missing or invalid query parameters" });
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ message: "Missing or invalid query parameters" });
|
||||||
}
|
}
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
const productDelete = await ProductModel(organization).findOneAndUpdate(
|
await ProductModel(organization).findOneAndUpdate(
|
||||||
{ productId: productId },
|
{ productId: productId },
|
||||||
{
|
{
|
||||||
isArchive: true,
|
isArchive: true,
|
||||||
}, { new: true }
|
},
|
||||||
|
{ new: true }
|
||||||
)
|
);
|
||||||
const existingEventDatas = await EventsDataModel(organization).find({ productId: productId })
|
const existingEventDatas = await EventsDataModel(organization).find({
|
||||||
|
productId: productId,
|
||||||
|
});
|
||||||
if (existingEventDatas) {
|
if (existingEventDatas) {
|
||||||
for (const event of 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) {
|
||||||
res.status(500).json({ message: "Failed to delete product" });
|
res.status(500).json({ message: "Failed to delete product" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
static async EventDataDelete(req: Request, res: Response): Promise<any> {
|
static async EventDataDelete(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productId, organization, modelUuid } = req.body
|
const { productId, organization, modelUuid } = req.body;
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
const existingEventDatas = await EventsDataModel(organization).findOneAndUpdate(
|
{ productId: productId, modelUuid: modelUuid },
|
||||||
{ productId: productId, modelUuid: modelUuid }, {
|
{
|
||||||
isArchive: true,
|
isArchive: true,
|
||||||
}, { new: true }
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
)
|
return res
|
||||||
|
.status(201)
|
||||||
return res.status(201).json({ message: "EventData deleted successfully" });
|
.json({ message: "EventData deleted successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to delete Eventdata" });
|
res.status(500).json({ message: "Failed to delete Eventdata" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
static async AllProductDatas(req: Request, res: Response): Promise<any> {
|
static async AllProductDatas(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params
|
const { organization } = req.params;
|
||||||
|
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
return res
|
return res.json({ message: "organization not found" });
|
||||||
.json({ message: "organization not found" });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).find({
|
const existingProduct = await ProductModel(organization).find({
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
});
|
||||||
if (!existingProduct) {
|
if (!existingProduct) {
|
||||||
return res.status(404).json({ message: 'No products found' });
|
return res.status(404).json({ message: "No products found" });
|
||||||
}
|
}
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
for (const product of existingProduct) {
|
for (const product of existingProduct) {
|
||||||
|
|
||||||
|
|
||||||
// Fetch events data for each product, excluding productId field
|
|
||||||
const eventDatas = await EventsDataModel(organization)
|
const eventDatas = await EventsDataModel(organization)
|
||||||
.find({ productId: product.productId, isArchive: false })
|
.find({ productId: product.productId, isArchive: false })
|
||||||
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Combine product and event data
|
|
||||||
result.push({
|
result.push({
|
||||||
// product: {
|
// product: {
|
||||||
productName: product.productName,
|
productName: product.productName,
|
||||||
@@ -218,40 +205,34 @@ export class productFlowservice {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return combined data
|
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to get Allproduct" });
|
res.status(500).json({ message: "Failed to get Allproduct" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
static async productRename(req: Request, res: Response): Promise<any> {
|
static async productRename(req: Request, res: Response): Promise<any> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { productId, productName, organization } = req.body
|
const { productId, productName, organization } = req.body;
|
||||||
|
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
const productDelete = 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 res.status(201).json({ message: "product Rename successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to product Rename" });
|
res.status(500).json({ message: "Failed to product Rename" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
95
src/api-server/controller/trash/trashcontrollers.ts
Normal file
95
src/api-server/controller/trash/trashcontrollers.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import {
|
||||||
|
TrashDatas,
|
||||||
|
RestoreTrashData,
|
||||||
|
} from "../../../shared/services/trash/trashService.ts";
|
||||||
|
|
||||||
|
export const GetTrashList = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization } = req.query as { organization: string };
|
||||||
|
if (!organization) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await TrashDatas({ organization });
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "Trash is Empty":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Trash is Empty",
|
||||||
|
TrashDatas: [],
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Success":
|
||||||
|
res.status(200).json({
|
||||||
|
// message: "Project created Successfully",
|
||||||
|
TrashDatas: result.ListDatas,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const RestoreTrash = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const { organization, projectId } = req.query as {
|
||||||
|
organization: string;
|
||||||
|
projectId: string;
|
||||||
|
};
|
||||||
|
console.log("organization: ", organization);
|
||||||
|
if (!organization || !projectId) {
|
||||||
|
res.status(400).json({
|
||||||
|
message: "All fields are required",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await RestoreTrashData({ organization, projectId });
|
||||||
|
|
||||||
|
switch (result.status) {
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project Restore unsuccessfull":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project Restore unsuccessfull",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Project Restored successfully":
|
||||||
|
res.status(200).json({
|
||||||
|
message: "Project Restored successfully",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Internal server error",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({
|
||||||
|
message: "Unknown error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { Server } from 'http';
|
|
||||||
import userModel from "../../shared/model/user-Model.ts";
|
import userModel from "../../shared/model/user-Model.ts";
|
||||||
import { isSharedArrayBuffer } from "util/types";
|
import {hashGenerate,hashValidator} from "../../shared/utils/Hasing.ts"
|
||||||
import {hashGenerate,hashValidator} from "../../shared/security/Hasing.ts"
|
|
||||||
// import {hashGenerate} from '../security/Hasing'
|
|
||||||
|
|
||||||
let serverAlive = true;
|
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;
|
||||||
@@ -43,7 +40,6 @@ export class user {
|
|||||||
try {
|
try {
|
||||||
let role;
|
let role;
|
||||||
const { email, password,organization } = req.body;
|
const { email, password,organization } = req.body;
|
||||||
// console.log(' req.body: ', req.body);
|
|
||||||
|
|
||||||
const existingMail = await userModel(organization).findOne({
|
const existingMail = await userModel(organization).findOne({
|
||||||
email:email
|
email:email
|
||||||
@@ -57,7 +53,6 @@ export class user {
|
|||||||
password,
|
password,
|
||||||
hashedpassword
|
hashedpassword
|
||||||
)
|
)
|
||||||
// console.log('checkpassword: ', checkpassword);
|
|
||||||
if (checkpassword) {
|
if (checkpassword) {
|
||||||
// const tokenValidation=await tokenGenerator(existingMail.email)
|
// const tokenValidation=await tokenGenerator(existingMail.email)
|
||||||
res.status(200).send({
|
res.status(200).send({
|
||||||
@@ -77,27 +72,5 @@ export class user {
|
|||||||
res.status(500).send(error);
|
res.status(500).send(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static async checkserverHealth(server:Server,organization: string){
|
|
||||||
// try {
|
|
||||||
// if (server.listening) {
|
|
||||||
// console.log('Server is running');
|
|
||||||
// serverAlive = true;
|
|
||||||
// // Update all users to online status
|
|
||||||
// } else {
|
|
||||||
// // await userModel(organization).updateMany({}, { activeStatus: "offline" }); // Replace `activeStatus` with your actual field
|
|
||||||
// throw new Error('Server is not running');
|
|
||||||
// }
|
|
||||||
// } catch (error:any) {
|
|
||||||
// console.error('Server health check failed:', error.message);
|
|
||||||
// serverAlive = false;
|
|
||||||
|
|
||||||
// // Update all users to offline status
|
|
||||||
// // await userModel(organization).updateMany({}, { activeStatus: "offline" });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// export const startHealthCheck = (server: Server, organization: string) => {
|
|
||||||
// setInterval(() => user.checkserverHealth(server, organization), 5000);
|
|
||||||
// };
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
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 class widget3dService {
|
export class Widget3dService {
|
||||||
static async add3Dwidget(req: Request, res: Response): Promise<any> {
|
static async add3Dwidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization, widget, zoneId } = req.body;
|
const { organization, widget, zoneId } = req.body;
|
||||||
@@ -129,7 +129,8 @@ export class widget3dService {
|
|||||||
widgetID: id,
|
widgetID: id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!widgetData) return res.status(204).json({ message: "Widget not found" });
|
if (!widgetData)
|
||||||
|
return res.status(204).json({ message: "Widget not found" });
|
||||||
const structureData = {
|
const structureData = {
|
||||||
measurements: widgetData?.Data?.measurements,
|
measurements: widgetData?.Data?.measurements,
|
||||||
duration: widgetData?.Data?.duration,
|
duration: widgetData?.Data?.duration,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
export class floatWidgetService {
|
export class FloatWidgetService {
|
||||||
static async addfloatWidget(req: Request, res: Response): Promise<any> {
|
static async addfloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization, widget, zoneId } = req.body;
|
const { organization, widget, zoneId } = req.body;
|
||||||
@@ -19,9 +19,7 @@ export class floatWidgetService {
|
|||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
await floatWidgetModel(organization).findOneAndUpdate(
|
||||||
organization
|
|
||||||
).findOneAndUpdate(
|
|
||||||
{
|
{
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -141,65 +139,4 @@ export class floatWidgetService {
|
|||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// static async updatewidget(req: Request, res: Response): Promise<any> {
|
|
||||||
// try {
|
|
||||||
// const { organization, widgetID, values } = req.body;
|
|
||||||
// const findwidget = await widgetSchema(organization).findOne({
|
|
||||||
// widgetID: widgetID,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!findwidget)
|
|
||||||
// return res.status(404).send({ message: "Data not found" });
|
|
||||||
// const updateData = {
|
|
||||||
// widgetName: values.widgetName,
|
|
||||||
// widgetSide: values.widgetSide, // Fixed typo from widgetside to widgetSide
|
|
||||||
// elementType: values.type,
|
|
||||||
// Data: {
|
|
||||||
// measurement: values.Data.measurement,
|
|
||||||
// duration: values.Data.duration,
|
|
||||||
// },
|
|
||||||
// elementColor: values.color,
|
|
||||||
// fontFamily: values.fontFamily,
|
|
||||||
// fontStyle: values.fontStyle,
|
|
||||||
// fontWeight: values.fontWeight,
|
|
||||||
// isArchive: false,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const changedWidget = await widgetSchema(organization).findOneAndUpdate(
|
|
||||||
// { widgetID: widgetID, isArchive: false },
|
|
||||||
// updateData,
|
|
||||||
// {
|
|
||||||
// new: true,
|
|
||||||
// upsert: true,
|
|
||||||
// setDefaultsOnInsert: true,
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// return res.status(200).json({
|
|
||||||
// message: "Widget updated successfully",
|
|
||||||
// });
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return res.status(500).send(error.message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static async getDatafromWidget(req: Request, res: Response): Promise<any> {
|
|
||||||
// const { organization, widgetID } = req.params;
|
|
||||||
// try {
|
|
||||||
// const existingWidget = await widgetSchema(organization)
|
|
||||||
// .findOne({
|
|
||||||
// widgetID: widgetID,
|
|
||||||
// isArchive: false,
|
|
||||||
// })
|
|
||||||
// .select("Data -_id");
|
|
||||||
// const Datastructure = {
|
|
||||||
// measurements: existingWidget.Data.measurements || {},
|
|
||||||
// duration: existingWidget.Data.duration || "1h",
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return res.status(500).send(error.message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
|||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
|
|
||||||
export class panelService {
|
export class PanelService {
|
||||||
static async AddPanel(req: Request, res: Response): Promise<any> {
|
static async AddPanel(req: Request, res: Response): Promise<any> {
|
||||||
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 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,
|
||||||
@@ -18,7 +18,7 @@ export class panelService {
|
|||||||
if (!findZone) {
|
if (!findZone) {
|
||||||
return res.status(404).json({ message: "Zone not found" });
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
}
|
}
|
||||||
const updatezone = await zoneSchema(organization).findOneAndUpdate(
|
await zoneSchema(organization).findOneAndUpdate(
|
||||||
{ zoneId: zoneId, isArchive: false },
|
{ zoneId: zoneId, isArchive: false },
|
||||||
{ panelOrder: panelOrder },
|
{ panelOrder: panelOrder },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
@@ -52,10 +52,6 @@ export class panelService {
|
|||||||
message: "No new panels were created. All panels already exist.",
|
message: "No new panels were created. All panels already exist.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// const IDdata = createdPanels.map((ID: any) => {
|
|
||||||
// return ID._id;
|
|
||||||
// });
|
|
||||||
createdPanels;
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
message: "Panels created successfully",
|
message: "Panels created successfully",
|
||||||
panelID: createdPanels,
|
panelID: createdPanels,
|
||||||
@@ -66,7 +62,6 @@ export class panelService {
|
|||||||
}
|
}
|
||||||
static async deletePanel(req: Request, res: Response): Promise<any> {
|
static async deletePanel(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log("req.body: ", req.body);
|
|
||||||
const { organization, panelName, zoneId } = req.body;
|
const { organization, panelName, zoneId } = req.body;
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -81,7 +76,7 @@ export class panelService {
|
|||||||
});
|
});
|
||||||
if (!existingPanel)
|
if (!existingPanel)
|
||||||
return res.status(409).json({ message: "Panel Already Deleted" });
|
return res.status(409).json({ message: "Panel Already Deleted" });
|
||||||
const updatePanel = await panelSchema(organization).findOneAndUpdate(
|
await panelSchema(organization).findOneAndUpdate(
|
||||||
{ _id: existingPanel._id, isArchive: false },
|
{ _id: existingPanel._id, isArchive: false },
|
||||||
{ isArchive: true },
|
{ isArchive: true },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
@@ -96,12 +91,11 @@ export class panelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
||||||
const index1 = existingZone.panelOrder.indexOf(existingPanel.panelName);
|
existingZone.panelOrder.indexOf(existingPanel.panelName);
|
||||||
const zonepanelname = await zoneSchema(organization).updateOne(
|
await zoneSchema(organization).updateOne(
|
||||||
{ _id: existingZone._id },
|
{ _id: existingZone._id },
|
||||||
{ $pull: { panelOrder: existingPanel.panelName } }
|
{ $pull: { panelOrder: existingPanel.panelName } }
|
||||||
);
|
);
|
||||||
console.log("zonepanelname: ", zonepanelname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json({ message: "Panel deleted successfully" });
|
return res.status(200).json({ message: "Panel deleted successfully" });
|
||||||
@@ -111,7 +105,6 @@ export class panelService {
|
|||||||
}
|
}
|
||||||
static async clearPanel(req: Request, res: Response): Promise<any> {
|
static async clearPanel(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log("req.body;: ", req.body);
|
|
||||||
const { organization, panelName, zoneId } = req.body;
|
const { organization, panelName, zoneId } = req.body;
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
|||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
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 {
|
||||||
@@ -18,7 +18,6 @@ export class templateService {
|
|||||||
// snapshot,
|
// snapshot,
|
||||||
// floatWidgets,
|
// floatWidgets,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
// console.log("req.body: ", req.body);
|
|
||||||
const existingTemplate = await templateModel(organization).findOne({
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
templateID: template.id,
|
templateID: template.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -181,7 +180,6 @@ export class templateService {
|
|||||||
}
|
}
|
||||||
static async Deletezone(req: Request, res: Response): Promise<any> {
|
static async Deletezone(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log("req.params: ", req.params);
|
|
||||||
const { organization, templateID } = req.params;
|
const { organization, templateID } = req.params;
|
||||||
const existingTemplate = await templateModel(organization).findOne({
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
templateID: templateID,
|
templateID: templateID,
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ import { Request, Response } from "express";
|
|||||||
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
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 {
|
||||||
// console.log("req.body: ", req.body);
|
|
||||||
console.log("req.body: ", req.body);
|
|
||||||
const {
|
const {
|
||||||
organization,
|
organization,
|
||||||
// panel,
|
// panel,
|
||||||
@@ -34,7 +32,6 @@ export class widgetService {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
// widgetOrder: widget.widgetOrder,
|
// widgetOrder: widget.widgetOrder,
|
||||||
});
|
});
|
||||||
// console.log('existingWidget: ', widget.data.measurements);
|
|
||||||
if (existingWidget) {
|
if (existingWidget) {
|
||||||
const updateWidget = await widgetSchema(
|
const updateWidget = await widgetSchema(
|
||||||
organization
|
organization
|
||||||
@@ -58,16 +55,12 @@ export class widgetService {
|
|||||||
},
|
},
|
||||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
||||||
);
|
);
|
||||||
console.log("updateWidget: ", updateWidget);
|
|
||||||
if (!updateWidget) {
|
if (!updateWidget) {
|
||||||
return res.json({ message: "Widget update unsuccessful" });
|
return res.json({ message: "Widget update unsuccessful" });
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
.status(200)
|
.status(200)
|
||||||
.json({ message: "Widget updated successfully" });
|
.json({ message: "Widget updated successfully" });
|
||||||
// return res
|
|
||||||
// .status(409)
|
|
||||||
// .json({ message: "Widget already exist for the widgetID" });
|
|
||||||
}
|
}
|
||||||
const newWidget = await widgetSchema(organization).create({
|
const newWidget = await widgetSchema(organization).create({
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
@@ -100,7 +93,6 @@ export class widgetService {
|
|||||||
static async deleteWidget(req: Request, res: Response): Promise<any> {
|
static async deleteWidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { widgetID, organization, zoneId } = req.body;
|
const { widgetID, organization, zoneId } = req.body;
|
||||||
console.log(" req.body: ", req.body);
|
|
||||||
const findWidget = await widgetSchema(organization).findOne({
|
const findWidget = await widgetSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
widgetID: widgetID,
|
widgetID: widgetID,
|
||||||
@@ -115,7 +107,7 @@ export class widgetService {
|
|||||||
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
// Find all widgets in the same panel and sort them by widgetOrder
|
// Find all widgets in the same panel and sort them by widgetOrder
|
||||||
const widgets = await widgetSchema(organization).find({
|
await widgetSchema(organization).find({
|
||||||
panelID: findWidget.panelID,
|
panelID: findWidget.panelID,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -146,7 +138,6 @@ export class widgetService {
|
|||||||
|
|
||||||
static async updatewidget(req: Request, res: Response): Promise<any> {
|
static async updatewidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log("req.body: ", req.body);
|
|
||||||
const { organization, widgetID, values } = req.body;
|
const { organization, widgetID, values } = req.body;
|
||||||
const findwidget = await widgetSchema(organization).findOne({
|
const findwidget = await widgetSchema(organization).findOne({
|
||||||
widgetID: widgetID,
|
widgetID: widgetID,
|
||||||
@@ -169,7 +160,7 @@ export class widgetService {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const changedWidget = await widgetSchema(organization).findOneAndUpdate(
|
await widgetSchema(organization).findOneAndUpdate(
|
||||||
{ widgetID: widgetID, isArchive: false },
|
{ widgetID: widgetID, isArchive: false },
|
||||||
updateData,
|
updateData,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import app from './app.ts';
|
import app from './app.ts';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import ip from 'ip';
|
|
||||||
|
|
||||||
// import { startHealthCheck } from './controller/user-Controller';
|
// import { startHealthCheck } from './controller/user-Controller';
|
||||||
import swaggerUi from 'swagger-ui-express';
|
import swaggerUi from 'swagger-ui-express';
|
||||||
import mongoAdminCreation from '../shared/security/mongosecurity.ts';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
@@ -34,6 +32,5 @@ 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`);
|
||||||
// console.log(`Server is also accessible on IP address: ${ip.address()}`);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
24
src/shared/V1Models/Auth/tokenModel.ts
Normal file
24
src/shared/V1Models/Auth/tokenModel.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "./userAuthModel.ts";
|
||||||
|
export interface Token extends Document {
|
||||||
|
userId: User["_id"];
|
||||||
|
isArchive: Boolean;
|
||||||
|
refreshToken: string;
|
||||||
|
resetTokenExpiry?: Date;
|
||||||
|
resetToken: string;
|
||||||
|
}
|
||||||
|
const tokenSchema: Schema = new Schema({
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
token: { type: String },
|
||||||
|
refreshToken: { type: String },
|
||||||
|
tokenCreatedAt: { type: Date },
|
||||||
|
resetToken: { type: String },
|
||||||
|
resetTokenExpiry: { type: Date },
|
||||||
|
});
|
||||||
|
|
||||||
|
const tokenType = (db: any) => {
|
||||||
|
return MainModel(db, "Token", tokenSchema, "Token");
|
||||||
|
};
|
||||||
|
export default tokenType;
|
||||||
49
src/shared/V1Models/Auth/user.ts
Normal file
49
src/shared/V1Models/Auth/user.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "./userAuthModel.ts";
|
||||||
|
export interface UserData extends Document {
|
||||||
|
userId: User["_id"];
|
||||||
|
isShare: Boolean;
|
||||||
|
activeStatus: string;
|
||||||
|
notificationEnable: boolean;
|
||||||
|
About: string;
|
||||||
|
isArchive: boolean;
|
||||||
|
role: string;
|
||||||
|
profilePicture: string;
|
||||||
|
recentlyViewed: string[];
|
||||||
|
}
|
||||||
|
const UserDataSchema: Schema = new Schema({
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
notificationEnable: { type: Boolean, default: false },
|
||||||
|
About: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
role: {
|
||||||
|
type: String,
|
||||||
|
default: "User",
|
||||||
|
enum: ["User", "Admin"],
|
||||||
|
},
|
||||||
|
isShare: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
activeStatus: {
|
||||||
|
type: String,
|
||||||
|
enum: ["online", "offline"],
|
||||||
|
default: "offline",
|
||||||
|
},
|
||||||
|
recentlyViewed: {
|
||||||
|
type: [String],
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
profilePicture: {
|
||||||
|
type: String,
|
||||||
|
// default: "default-profile-picture.jpg"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const UsersDataModel = (db: any) => {
|
||||||
|
return MainModel(db, "UsersData", UserDataSchema, "UsersData");
|
||||||
|
};
|
||||||
|
export default UsersDataModel;
|
||||||
34
src/shared/V1Models/Auth/userAuthModel.ts
Normal file
34
src/shared/V1Models/Auth/userAuthModel.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
export interface User extends Document {
|
||||||
|
userName: string;
|
||||||
|
Email: string;
|
||||||
|
Password: string;
|
||||||
|
isArchive: boolean;
|
||||||
|
visitorBrowserID: string;
|
||||||
|
lastPasswordReset: number;
|
||||||
|
}
|
||||||
|
const AuthSchema: Schema = new Schema({
|
||||||
|
userName: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
Email: {
|
||||||
|
type: String,
|
||||||
|
unique: true,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
Password: {
|
||||||
|
type: String,
|
||||||
|
min: 8,
|
||||||
|
// required: true,
|
||||||
|
},
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
lastPasswordReset: { type: Number },
|
||||||
|
visitorBrowserID: { type: String },
|
||||||
|
});
|
||||||
|
|
||||||
|
const AuthModel = (db: any) => {
|
||||||
|
return MainModel(db, "UserAuth", AuthSchema, "UserAuth");
|
||||||
|
};
|
||||||
|
export default AuthModel;
|
||||||
71
src/shared/V1Models/Builder/assetModel.ts
Normal file
71
src/shared/V1Models/Builder/assetModel.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import { Document, Schema } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
interface ICommonBase {
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
interface IPointsConveyor extends ICommonBase {
|
||||||
|
points?: {
|
||||||
|
Uuid: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
interface IPoint extends ICommonBase {
|
||||||
|
point?: {
|
||||||
|
Uuid: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export interface AssetData extends Document {
|
||||||
|
userId: User["_id"];
|
||||||
|
projectId: Project["_id"];
|
||||||
|
versionId: Version["_id"];
|
||||||
|
modelUuid: string;
|
||||||
|
modelfileID: string;
|
||||||
|
modelName: string;
|
||||||
|
isLocked: boolean;
|
||||||
|
type: string;
|
||||||
|
isVisible: boolean;
|
||||||
|
isArchive: false;
|
||||||
|
// points: [] | {};
|
||||||
|
position: [];
|
||||||
|
rotation: {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
z: number;
|
||||||
|
};
|
||||||
|
speed: number | string;
|
||||||
|
eventData: IPoint | IPointsConveyor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const assetDataSchema: Schema = new Schema({
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
modelUuid: { type: String },
|
||||||
|
modelfileID: { type: String },
|
||||||
|
modelName: { type: String },
|
||||||
|
type: { type: String },
|
||||||
|
position: { type: Array },
|
||||||
|
rotation: {
|
||||||
|
x: { type: Number },
|
||||||
|
y: { type: Number },
|
||||||
|
z: { type: Number },
|
||||||
|
},
|
||||||
|
speed: { type: Schema.Types.Mixed },
|
||||||
|
isLocked: { type: Boolean },
|
||||||
|
isVisible: { type: Boolean },
|
||||||
|
eventData: {
|
||||||
|
type: Schema.Types.Mixed,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const assetModel = (db: string) => {
|
||||||
|
return MainModel(db, "Assets", assetDataSchema, "Assets");
|
||||||
|
};
|
||||||
|
export default assetModel;
|
||||||
51
src/shared/V1Models/Builder/cameraModel.ts
Normal file
51
src/shared/V1Models/Builder/cameraModel.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { Document, Schema } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
export interface Camera extends Document {
|
||||||
|
userId: User["_id"];
|
||||||
|
projectId: Project["_id"];
|
||||||
|
versionId: Version["_id"];
|
||||||
|
position: {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
z: number;
|
||||||
|
};
|
||||||
|
target: {
|
||||||
|
x: { type: Number; required: true };
|
||||||
|
y: { type: Number; required: true };
|
||||||
|
z: { type: Number; required: true };
|
||||||
|
};
|
||||||
|
rotation: {
|
||||||
|
x: { type: Number; required: true };
|
||||||
|
y: { type: Number; required: true };
|
||||||
|
z: { type: Number; required: true };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const cameraSchema: Schema = new Schema({
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
position: {
|
||||||
|
x: { type: Number, required: true },
|
||||||
|
y: { type: Number, required: true },
|
||||||
|
z: { type: Number, required: true },
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
x: { type: Number, required: true },
|
||||||
|
y: { type: Number, required: true },
|
||||||
|
z: { type: Number, required: true },
|
||||||
|
},
|
||||||
|
rotation: {
|
||||||
|
x: { type: Number, required: true },
|
||||||
|
y: { type: Number, required: true },
|
||||||
|
z: { type: Number, required: true },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const cameraModel = (db: string) => {
|
||||||
|
return MainModel(db, "Camera", cameraSchema, "Camera");
|
||||||
|
};
|
||||||
|
export default cameraModel;
|
||||||
29
src/shared/V1Models/Builder/linesModel.ts
Normal file
29
src/shared/V1Models/Builder/linesModel.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import mongoose, { Schema } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
const positionSchema = new mongoose.Schema({
|
||||||
|
x: { type: Number }, // Optional position fields
|
||||||
|
y: { type: Number },
|
||||||
|
z: { type: Number },
|
||||||
|
});
|
||||||
|
|
||||||
|
const Vector3 = new mongoose.Schema({
|
||||||
|
position: { type: positionSchema, required: false }, // Optional position
|
||||||
|
uuid: { type: String, required: false }, // Optional uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
const LineSchema = new mongoose.Schema({
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
layer: { type: Number, required: true }, // Layer is mandatory
|
||||||
|
line: { type: [Vector3], required: true }, // Array of line objects
|
||||||
|
type: { type: String, required: false }, // Optional type
|
||||||
|
});
|
||||||
|
|
||||||
|
const lineModel = (db: string) => {
|
||||||
|
return MainModel(db, "lines", LineSchema, "lines");
|
||||||
|
};
|
||||||
|
export default lineModel;
|
||||||
37
src/shared/V1Models/Builder/wallItemsModel.ts
Normal file
37
src/shared/V1Models/Builder/wallItemsModel.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Document, Schema } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
export interface WallItems extends Document {
|
||||||
|
userId: User["_id"];
|
||||||
|
projectId: Project["_id"];
|
||||||
|
versionId: Version["_id"];
|
||||||
|
modelUuid: string;
|
||||||
|
modelName: string;
|
||||||
|
type: string;
|
||||||
|
csgposition: [];
|
||||||
|
csgscale: [];
|
||||||
|
position: [];
|
||||||
|
quaternion: [];
|
||||||
|
scale: [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const wallItemsSchema: Schema = new Schema({
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
modelUuid: { type: String, unique: true },
|
||||||
|
modelName: { type: String },
|
||||||
|
type: { type: String },
|
||||||
|
csgposition: { type: Array },
|
||||||
|
csgscale: { type: Array },
|
||||||
|
position: { type: Array },
|
||||||
|
quaternion: { type: Array },
|
||||||
|
scale: { type: Array },
|
||||||
|
});
|
||||||
|
|
||||||
|
const wallItemModel = (db: string) => {
|
||||||
|
return MainModel(db, "wallitems", wallItemsSchema, "wallitems");
|
||||||
|
};
|
||||||
|
export default wallItemModel;
|
||||||
50
src/shared/V1Models/Builder/zoneModel.ts
Normal file
50
src/shared/V1Models/Builder/zoneModel.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
export interface Zone extends Document {
|
||||||
|
zoneName: string;
|
||||||
|
zoneId: string;
|
||||||
|
points: [];
|
||||||
|
viewPortCenter: [];
|
||||||
|
viewPortposition: [];
|
||||||
|
isArchive: boolean;
|
||||||
|
panelOrder: string[];
|
||||||
|
lockedPanel: string[];
|
||||||
|
createdBy: User["_id"];
|
||||||
|
projectId: Project["_id"];
|
||||||
|
versionId: Version["_id"];
|
||||||
|
layer: number;
|
||||||
|
}
|
||||||
|
const zoneSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
zoneName: { type: String },
|
||||||
|
zoneId: { type: String },
|
||||||
|
createdBy: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
layer: { type: Number },
|
||||||
|
points: { type: Array },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
panelOrder: {
|
||||||
|
type: [String],
|
||||||
|
enum: ["left", "right", "top", "bottom"],
|
||||||
|
},
|
||||||
|
viewPortCenter: { type: Array, required: true },
|
||||||
|
viewPortposition: { type: Array, required: true },
|
||||||
|
lockedPanel: {
|
||||||
|
type: [String],
|
||||||
|
default: [],
|
||||||
|
enum: ["left", "right", "top", "bottom"],
|
||||||
|
},
|
||||||
|
// createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
|
||||||
|
// sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const zoneModel = (db: any) => {
|
||||||
|
return MainModel(db, "zones", zoneSchema, "zones");
|
||||||
|
};
|
||||||
|
export default zoneModel;
|
||||||
25
src/shared/V1Models/Environment/environments-Model.ts
Normal file
25
src/shared/V1Models/Environment/environments-Model.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Document, Schema } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
export interface Environment extends Document {
|
||||||
|
userId: User["_id"];
|
||||||
|
roofVisibility: boolean;
|
||||||
|
wallVisibility: boolean;
|
||||||
|
renderDistance: number;
|
||||||
|
shadowVisibility: boolean;
|
||||||
|
limitDistance: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const environmentSchema: Schema = new Schema({
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User", unique: true },
|
||||||
|
roofVisibility: { type: Boolean, default: false },
|
||||||
|
wallVisibility: { type: Boolean, default: false },
|
||||||
|
shadowVisibility: { type: Boolean, default: false },
|
||||||
|
renderDistance: { type: Number, default: 40 },
|
||||||
|
limitDistance: { type: Boolean, default: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
const environmentModel = (db: string) => {
|
||||||
|
return MainModel(db, "Environment", environmentSchema, "Environment");
|
||||||
|
};
|
||||||
|
export default environmentModel;
|
||||||
39
src/shared/V1Models/Project/project-model.ts
Normal file
39
src/shared/V1Models/Project/project-model.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
|
||||||
|
export interface Project extends Document {
|
||||||
|
projectUuid: string;
|
||||||
|
projectName: string;
|
||||||
|
createdBy: User["_id"];
|
||||||
|
isArchive: boolean;
|
||||||
|
isDeleted: boolean;
|
||||||
|
thumbnail: string;
|
||||||
|
sharedUsers: [];
|
||||||
|
DeletedAt: Date;
|
||||||
|
isViewed: number;
|
||||||
|
total_versions: string;
|
||||||
|
Present_version: string;
|
||||||
|
}
|
||||||
|
const projectSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
projectUuid: { type: String },
|
||||||
|
projectName: { type: String },
|
||||||
|
thumbnail: { type: String },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
createdBy: { 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 }
|
||||||
|
);
|
||||||
|
|
||||||
|
const projectModel = (db: string) => {
|
||||||
|
return MainModel(db, "Projects", projectSchema, "Projects");
|
||||||
|
};
|
||||||
|
|
||||||
|
export default projectModel;
|
||||||
52
src/shared/V1Models/Project/share-model.ts
Normal file
52
src/shared/V1Models/Project/share-model.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
|
export interface IShare extends Document {
|
||||||
|
Createdby: {
|
||||||
|
userId: mongoose.Types.ObjectId;
|
||||||
|
Email: string;
|
||||||
|
};
|
||||||
|
isActive: boolean;
|
||||||
|
Share_People: [
|
||||||
|
{
|
||||||
|
userId: mongoose.Types.ObjectId;
|
||||||
|
Email: string;
|
||||||
|
AccessPoint: string;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
Description: string;
|
||||||
|
createdAt: number;
|
||||||
|
projectId: mongoose.Types.ObjectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const shareSchema: Schema = new Schema({
|
||||||
|
CreatedBy: {
|
||||||
|
userId: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: "User",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
Email: { type: String, ref: "User", required: true },
|
||||||
|
},
|
||||||
|
isActive: { type: Boolean, default: false },
|
||||||
|
Share_People: [
|
||||||
|
{
|
||||||
|
userId: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
|
||||||
|
Email: { type: String, ref: "User", required: true },
|
||||||
|
AccessPoint: {
|
||||||
|
type: String,
|
||||||
|
default: "Can view",
|
||||||
|
enum: ["Can view", "Can edit", "Can comment"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
createdAt: {
|
||||||
|
type: Number,
|
||||||
|
default: Date.now(),
|
||||||
|
},
|
||||||
|
projectId: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
|
||||||
|
});
|
||||||
|
const shareModel = (db: any) => {
|
||||||
|
return MainModel(db, "Shared", shareSchema, "Shared");
|
||||||
|
};
|
||||||
|
export default shareModel;
|
||||||
182
src/shared/V1Models/Simulation/eventsDataModel.ts
Normal file
182
src/shared/V1Models/Simulation/eventsDataModel.ts
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
// models/Product.ts
|
||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
|
interface AssetEventSchema {
|
||||||
|
modelUuid: string;
|
||||||
|
modelName: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TriggerSchema {
|
||||||
|
triggerUuid: string;
|
||||||
|
triggerName: string;
|
||||||
|
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
||||||
|
delay: number;
|
||||||
|
triggeredAsset: {
|
||||||
|
triggeredModel: { modelName: string; modelUuid: string };
|
||||||
|
triggeredPoint: { pointName: string; pointUuid: string };
|
||||||
|
triggeredAction: { actionName: string; actionUuid: string };
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConveyorPointSchema {
|
||||||
|
uuid: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
action: {
|
||||||
|
actionUuid: string;
|
||||||
|
actionName: string;
|
||||||
|
actionType: "default" | "spawn" | "swap" | "despawn";
|
||||||
|
material: string;
|
||||||
|
delay: number | "inherit";
|
||||||
|
spawnInterval: number | "inherit";
|
||||||
|
spawnCount: number | "inherit";
|
||||||
|
triggers: TriggerSchema[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VehiclePointSchema {
|
||||||
|
uuid: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
action: {
|
||||||
|
actionUuid: string;
|
||||||
|
actionName: string;
|
||||||
|
actionType: "travel";
|
||||||
|
material: string | null;
|
||||||
|
unLoadDuration: number;
|
||||||
|
loadCapacity: number;
|
||||||
|
pickUpPoint: { x: number; y: number; z: number } | null;
|
||||||
|
unLoadPoint: { x: number; y: number; z: number } | null;
|
||||||
|
triggers: TriggerSchema[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RoboticArmPointSchema {
|
||||||
|
uuid: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
actions: {
|
||||||
|
actionUuid: string;
|
||||||
|
actionName: string;
|
||||||
|
actionType: "pickAndPlace";
|
||||||
|
process: {
|
||||||
|
startPoint: [number, number, number];
|
||||||
|
endPoint: [number, number, number];
|
||||||
|
};
|
||||||
|
triggers: TriggerSchema[];
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MachinePointSchema {
|
||||||
|
uuid: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
action: {
|
||||||
|
actionUuid: string;
|
||||||
|
actionName: string;
|
||||||
|
actionType: "process";
|
||||||
|
processTime: number;
|
||||||
|
swapMaterial: string;
|
||||||
|
triggers: TriggerSchema[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StoragePointSchema {
|
||||||
|
uuid: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
action: {
|
||||||
|
actionUuid: string;
|
||||||
|
actionName: string;
|
||||||
|
actionType: "storage";
|
||||||
|
materials: { materialName: string; materialId: string }[];
|
||||||
|
storageCapacity: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConveyorEventSchema extends AssetEventSchema {
|
||||||
|
type: "transfer";
|
||||||
|
speed: number;
|
||||||
|
points: ConveyorPointSchema[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VehicleEventSchema extends AssetEventSchema {
|
||||||
|
type: "vehicle";
|
||||||
|
speed: number;
|
||||||
|
point: VehiclePointSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RoboticArmEventSchema extends AssetEventSchema {
|
||||||
|
type: "roboticArm";
|
||||||
|
speed: number;
|
||||||
|
point: RoboticArmPointSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MachineEventSchema extends AssetEventSchema {
|
||||||
|
type: "machine";
|
||||||
|
// speed: number;
|
||||||
|
point: MachinePointSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StorageEventSchema extends AssetEventSchema {
|
||||||
|
type: "storageUnit";
|
||||||
|
// speed: number;
|
||||||
|
point: StoragePointSchema;
|
||||||
|
}
|
||||||
|
interface IPointModel extends Document {
|
||||||
|
modelUuid: String;
|
||||||
|
modelName: String;
|
||||||
|
position: String;
|
||||||
|
rotation: String;
|
||||||
|
state: String;
|
||||||
|
productId: String;
|
||||||
|
isArchive: boolean;
|
||||||
|
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
||||||
|
speed: number;
|
||||||
|
point:
|
||||||
|
| VehicleEventSchema
|
||||||
|
| RoboticArmEventSchema
|
||||||
|
| MachineEventSchema
|
||||||
|
| StorageEventSchema;
|
||||||
|
points: ConveyorEventSchema[];
|
||||||
|
}
|
||||||
|
// type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;
|
||||||
|
|
||||||
|
const BaseEventSchema = new Schema<IPointModel>(
|
||||||
|
{
|
||||||
|
modelUuid: { type: String, required: true },
|
||||||
|
modelName: { type: String, required: true },
|
||||||
|
position: { type: [Number], required: true },
|
||||||
|
rotation: { type: [Number], required: true },
|
||||||
|
speed: { type: Number },
|
||||||
|
state: {
|
||||||
|
type: String,
|
||||||
|
enum: ["idle", "running", "stopped", "disabled", "error"],
|
||||||
|
default: "idle",
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"],
|
||||||
|
},
|
||||||
|
point: {
|
||||||
|
type: Schema.Types.Mixed,
|
||||||
|
},
|
||||||
|
points: {
|
||||||
|
type: Schema.Types.Mixed,
|
||||||
|
},
|
||||||
|
productId: { type: String, required: true },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
{ discriminatorKey: "type", timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const EventsDataModel = (db: string) => {
|
||||||
|
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EventsDataModel;
|
||||||
26
src/shared/V1Models/Simulation/productModel.ts
Normal file
26
src/shared/V1Models/Simulation/productModel.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
export interface Product extends Document {
|
||||||
|
productName: string;
|
||||||
|
productId: string;
|
||||||
|
projectId: Project["_id"];
|
||||||
|
versionId: Version["_id"];
|
||||||
|
eventsData: [];
|
||||||
|
isArchive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ProductSchema = new Schema({
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
productName: { type: String, required: true },
|
||||||
|
productId: { type: String, required: true },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const ProductModel = (db: string) => {
|
||||||
|
return MainModel(db, "Product", ProductSchema, "Product");
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProductModel;
|
||||||
59
src/shared/V1Models/Thread/thread-Model.ts
Normal file
59
src/shared/V1Models/Thread/thread-Model.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import { Document, Schema } from "mongoose";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
interface IComment {
|
||||||
|
userId: User["_id"];
|
||||||
|
// createdAt: string;
|
||||||
|
comment: string;
|
||||||
|
// lastUpdatedAt: string;
|
||||||
|
timestamp:Number
|
||||||
|
}
|
||||||
|
export interface IThread extends Document {
|
||||||
|
projectId: Project["_id"];
|
||||||
|
versionId: Version["_id"];
|
||||||
|
state: string;
|
||||||
|
commentId: string;
|
||||||
|
createdBy: User["_id"];
|
||||||
|
createdAt: number;
|
||||||
|
lastUpdatedAt: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
rotation: [number, number, number];
|
||||||
|
replies: IComment[];
|
||||||
|
|
||||||
|
}
|
||||||
|
const CommentSchema = new Schema<IComment>(
|
||||||
|
{
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||||
|
// createdAt: { type: String, },
|
||||||
|
comment: { type: String,},
|
||||||
|
// lastUpdatedAt: { type: String, },
|
||||||
|
timestamp:{
|
||||||
|
type: Number,
|
||||||
|
default:Date.now()}
|
||||||
|
},
|
||||||
|
// { _id: false } // Prevent automatic _id for each reply object
|
||||||
|
);
|
||||||
|
const threadSchema = new Schema<IThread>({
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: 'Project', required: true },
|
||||||
|
state: { type: String, enum: ['active', 'inactive'], required: true },
|
||||||
|
commentId: { type: String, },
|
||||||
|
createdBy: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||||
|
createdAt: { type: Number,},
|
||||||
|
lastUpdatedAt: { type: String, },
|
||||||
|
position: {
|
||||||
|
type: [Number],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
rotation: {
|
||||||
|
type: [Number],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
replies: { type: [CommentSchema ], default: [] },
|
||||||
|
});
|
||||||
|
|
||||||
|
const ThreadModel = (db: string) => {
|
||||||
|
return MainModel(db, "Threads", threadSchema, "Threads");
|
||||||
|
};
|
||||||
|
export default ThreadModel;
|
||||||
27
src/shared/V1Models/Version/versionModel.ts
Normal file
27
src/shared/V1Models/Version/versionModel.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
export interface Version extends Document {
|
||||||
|
versionName: string;
|
||||||
|
projectId: Project["_id"];
|
||||||
|
createdBy: User["_id"];
|
||||||
|
isArchive: boolean;
|
||||||
|
version: number;
|
||||||
|
}
|
||||||
|
const versionSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
versionName: { type: String },
|
||||||
|
version: { type: Number },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "project" },
|
||||||
|
createdBy: { type: Schema.Types.ObjectId, ref: "user" },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const versionModel = (db: string) => {
|
||||||
|
return MainModel(db, "Versions", versionSchema, "Versions");
|
||||||
|
};
|
||||||
|
|
||||||
|
export default versionModel;
|
||||||
37
src/shared/V1Models/Vizualization/3dwidget.ts
Normal file
37
src/shared/V1Models/Vizualization/3dwidget.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Schema, Document, model } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { Zone } from "../Builder/zoneModel.ts";
|
||||||
|
export interface Widget3d extends Document {
|
||||||
|
type: string;
|
||||||
|
widgetID: string;
|
||||||
|
widgetName: string;
|
||||||
|
position: [];
|
||||||
|
rotation: [];
|
||||||
|
isArchive: boolean;
|
||||||
|
zoneId: string;
|
||||||
|
Data: {
|
||||||
|
measurements: {};
|
||||||
|
duration: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const Widget3dSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
type: { type: String },
|
||||||
|
widgetID: { type: String },
|
||||||
|
widgetName: { type: String, default: "Widget3D" },
|
||||||
|
position: { type: Array },
|
||||||
|
rotation: { type: Array },
|
||||||
|
zoneId: { type: String },
|
||||||
|
Data: {
|
||||||
|
measurements: { type: Object, default: {} },
|
||||||
|
duration: { type: String, default: "1h" },
|
||||||
|
},
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const widget3dModel = (db: any) => {
|
||||||
|
return MainModel(db, "3dWidget", Widget3dSchema, "3dWidget");
|
||||||
|
};
|
||||||
|
export default widget3dModel;
|
||||||
46
src/shared/V1Models/Vizualization/floatWidget.ts
Normal file
46
src/shared/V1Models/Vizualization/floatWidget.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { Schema, Document, model } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { Zone } from "../Builder/zoneModel.ts";
|
||||||
|
export interface FloatingWidget extends Document {
|
||||||
|
className: string;
|
||||||
|
iconName: string;
|
||||||
|
header: string;
|
||||||
|
floatWidgetID: string;
|
||||||
|
position: {};
|
||||||
|
per: string;
|
||||||
|
value: string;
|
||||||
|
isArchive: boolean;
|
||||||
|
zoneId: string;
|
||||||
|
Data: {
|
||||||
|
measurements: {};
|
||||||
|
duration: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const floatingWidgetSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
className: { type: String },
|
||||||
|
iconName: { type: String },
|
||||||
|
header: { type: String },
|
||||||
|
floatWidgetID: { type: String },
|
||||||
|
position: { type: Object },
|
||||||
|
per: { type: String },
|
||||||
|
value: { type: String },
|
||||||
|
zoneId: { type: String },
|
||||||
|
Data: {
|
||||||
|
measurements: { type: Object, default: {} },
|
||||||
|
duration: { type: String, default: "1h" },
|
||||||
|
},
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const floatWidgetModel = (db: any) => {
|
||||||
|
return MainModel(
|
||||||
|
db,
|
||||||
|
"FloatingWidget",
|
||||||
|
floatingWidgetSchema,
|
||||||
|
"FloatingWidget"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default floatWidgetModel;
|
||||||
23
src/shared/V1Models/Vizualization/panelmodel.ts
Normal file
23
src/shared/V1Models/Vizualization/panelmodel.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { Zone } from "../Builder/zoneModel.ts";
|
||||||
|
export interface Panel extends Document {
|
||||||
|
zoneId: string;
|
||||||
|
panelName: string;
|
||||||
|
widgets: [mongoose.Types.ObjectId];
|
||||||
|
isArchive: boolean;
|
||||||
|
}
|
||||||
|
const panelSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
zoneId: { type: String },
|
||||||
|
panelName: { type: String },
|
||||||
|
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const panelModel = (db: any) => {
|
||||||
|
return MainModel(db, "Panel", panelSchema, "Panel");
|
||||||
|
};
|
||||||
|
export default panelModel;
|
||||||
39
src/shared/V1Models/Vizualization/templatemodel.ts
Normal file
39
src/shared/V1Models/Vizualization/templatemodel.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { User } from "../Auth/userAuthModel.ts";
|
||||||
|
import { Project } from "../Project/project-model.ts";
|
||||||
|
import { Version } from "../Version/versionModel.ts";
|
||||||
|
export interface Template extends Document {
|
||||||
|
userId: User["_id"];
|
||||||
|
projectId: Project["_id"];
|
||||||
|
versionId: Version["_id"];
|
||||||
|
templateName: string;
|
||||||
|
templateID: string;
|
||||||
|
snapshot: string;
|
||||||
|
panelOrder: [];
|
||||||
|
widgets: [];
|
||||||
|
floatWidgets: [];
|
||||||
|
Widgets3D: [];
|
||||||
|
isArchive: boolean;
|
||||||
|
}
|
||||||
|
const templateSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
templateName: { type: String },
|
||||||
|
templateID: { type: String },
|
||||||
|
snapshot: { type: String },
|
||||||
|
panelOrder: { type: Array },
|
||||||
|
widgets: { type: Array },
|
||||||
|
floatWidgets: { type: Array },
|
||||||
|
Widgets3D: { type: Array },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const templateModel = (db: any) => {
|
||||||
|
return MainModel(db, "Template", templateSchema, "Template");
|
||||||
|
};
|
||||||
|
export default templateModel;
|
||||||
47
src/shared/V1Models/Vizualization/widgemodel.ts
Normal file
47
src/shared/V1Models/Vizualization/widgemodel.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
import { Zone } from "../Builder/zoneModel.ts";
|
||||||
|
export interface widget extends Document {
|
||||||
|
widgetName: string;
|
||||||
|
widgetside: string;
|
||||||
|
widgetID: string;
|
||||||
|
widgetOrder: string;
|
||||||
|
elementType: string;
|
||||||
|
elementColor: string;
|
||||||
|
fontFamily: string;
|
||||||
|
fontStyle: string;
|
||||||
|
fontWeight: string;
|
||||||
|
isArchive: boolean;
|
||||||
|
panelID: mongoose.Types.ObjectId;
|
||||||
|
Data: {
|
||||||
|
measurements: {};
|
||||||
|
duration: string;
|
||||||
|
};
|
||||||
|
zoneId: string;
|
||||||
|
}
|
||||||
|
const widgetSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
widgetName: { type: String, default: "Widget" },
|
||||||
|
widgetside: { type: String },
|
||||||
|
widgetID: { type: String },
|
||||||
|
widgetOrder: { type: String },
|
||||||
|
elementType: { type: String },
|
||||||
|
elementColor: { type: String },
|
||||||
|
fontFamily: { type: String },
|
||||||
|
fontStyle: { type: String },
|
||||||
|
Data: {
|
||||||
|
measurements: { type: Object, default: {} },
|
||||||
|
duration: { type: String, default: "1h" },
|
||||||
|
},
|
||||||
|
fontWeight: { type: String },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||||
|
zoneId: { type: String },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const widgetModel = (db: any) => {
|
||||||
|
return MainModel(db, "Widget", widgetSchema, "Widget");
|
||||||
|
};
|
||||||
|
export default widgetModel;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user