Testing failer uncomment issue sorted API-Docker updated based on the Failed testcase
This commit is contained in:
5
.env
5
.env
@@ -1,8 +1,3 @@
|
|||||||
# MONGO_URI=mongodb://192.168.0.110/
|
|
||||||
# MONGO_USER=mydata
|
|
||||||
# MONGO_PASSWORD=mongodb@hexr2002
|
|
||||||
# MONGO_AUTH_DB=admin
|
|
||||||
|
|
||||||
MONGO_URI=mongodb://mongo/
|
MONGO_URI=mongodb://mongo/
|
||||||
MONGO_USER=admin
|
MONGO_USER=admin
|
||||||
MONGO_PASSWORD=admin321
|
MONGO_PASSWORD=admin321
|
||||||
|
|||||||
@@ -1,50 +1,56 @@
|
|||||||
let url_Backend_dwinzoMajor = "http://192.168.0.110:3503";
|
let url_Backend_dwinzoMajor = "http://192.168.0.110:3503";
|
||||||
//Login Api
|
|
||||||
export const createCamera = async (userId:string, position:Object) => {
|
export const createCamera = async (userId: string, position: Object) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/createCamera`, {
|
const response = await fetch(
|
||||||
|
`${url_Backend_dwinzoMajor}/api/v1/createCamera`,
|
||||||
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ userId, position }),
|
body: JSON.stringify({ userId, position }),
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error("Failed to create Camera");
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const result = await response.json();
|
if (!response.ok) {
|
||||||
return result;
|
throw new Error("Failed to create Camera");
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error`
|
|
||||||
} else {
|
|
||||||
throw new Error("An unknown error occurred");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
export const getCamera = async (userId:string) => {
|
const result = await response.json();
|
||||||
try {
|
return result;
|
||||||
const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/getCamera/${userId}`, {
|
} catch (error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
} else {
|
||||||
|
throw new Error("An unknown error occurred");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCamera = async (userId: string) => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`${url_Backend_dwinzoMajor}/api/v1/getCamera/${userId}`,
|
||||||
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error("Failed to get Camera");
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const result = await response.json();
|
if (!response.ok) {
|
||||||
return result;
|
throw new Error("Failed to get Camera");
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error`
|
|
||||||
} else {
|
|
||||||
throw new Error("An unknown error occurred");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
const result = await response.json();
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
} else {
|
||||||
|
throw new Error("An unknown error occurred");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -3,24 +3,22 @@ ARG NODE_VERSION=lts
|
|||||||
FROM node:${NODE_VERSION}-alpine AS development
|
FROM node:${NODE_VERSION}-alpine AS development
|
||||||
# Use production node environment by default.
|
# Use production node environment by default.
|
||||||
|
|
||||||
ENV NODE_ENV development
|
ENV NODE_ENV=development
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
RUN npm install -g tsx
|
RUN npm install -g tsx --ignore-scripts
|
||||||
|
|
||||||
COPY package.json /usr/src/app/package.json
|
COPY package.json ./
|
||||||
|
COPY package-lock.json ./
|
||||||
|
RUN npm install --ignore-scripts
|
||||||
|
|
||||||
|
|
||||||
# COPY package-lock.json /usr/src/app/package-lock.json
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
|
RUN chown -R appuser:appgroup /usr/src/app
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
RUN npm install
|
USER appuser
|
||||||
|
|
||||||
# Run the application as a non-root user.
|
|
||||||
USER root
|
|
||||||
|
|
||||||
# Copy the rest of the source files into the image.
|
|
||||||
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
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);
|
|
||||||
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',AssetsFloorService.deleteFloorItems)
|
||||||
router.delete('/deletefloorItem',assetsFloorservice.deleteFloorItems)
|
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
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,7 @@ 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);
|
|
||||||
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,11 @@
|
|||||||
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("/AllProducts/:organization", ProductFlowService.AllProductDatas);
|
||||||
productRouter.patch("/productRename", productFlowservice.productRename);
|
productRouter.patch("/productRename", ProductFlowService.productRename);
|
||||||
export default productRouter;
|
export default productRouter;
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { user } from '../controller/user-Controller.ts';
|
import { User } from '../controller/user-Controller.ts';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.post('/signup',user.signup)
|
router.post('/signup',User.signup)
|
||||||
router.post('/login',user.login)
|
router.post('/login',User.login)
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
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,13 +1,12 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
|
||||||
import { zone } from '../controller/lines/zone-Services.ts';
|
import { Zone } from '../controller/lines/zone-Services.ts';
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post('/setZone',zone.setZone)
|
router.post('/setZone',Zone.setZone)
|
||||||
router.delete('/deleteZone',zone.deleteZone)
|
router.delete('/deleteZone',Zone.deleteZone)
|
||||||
router.get('/findZones/:organization',zone.getZones)
|
router.get('/findZones/:organization',Zone.getZones)
|
||||||
// router.get('/A_zone/:zoneId/:organization',zone.ZoneData)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { Zoneservice } from "../controller/lines/zoneService.ts";
|
import { ZoneService } from "../controller/lines/zoneService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -245,7 +245,7 @@ const router = express.Router();
|
|||||||
* type: string
|
* type: string
|
||||||
* example: "Internal server error"
|
* example: "Internal server error"
|
||||||
*/
|
*/
|
||||||
router.post("/zone/save", Zoneservice.addandUpdateZone); //Zone create and update for the points
|
router.post("/zone/save", ZoneService.addandUpdateZone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -318,9 +318,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 +414,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 +483,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 +536,6 @@ router.get("/A_zone/:zoneId/:organization", Zoneservice.ZoneData);
|
|||||||
* type: string
|
* type: string
|
||||||
* example: "Internal Server Error"
|
* example: "Internal Server Error"
|
||||||
*/
|
*/
|
||||||
router.patch("/zone/:zoneId", Zoneservice.deleteAZone); //delete Zone
|
router.patch("/zone/:zoneId", ZoneService.deleteAZone);
|
||||||
// router.get("/zone/:sceneID", Zoneservice.allZones);
|
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||||
router.patch("/zones/lockedPanels", Zoneservice.lockedPanel);
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -10,7 +9,7 @@ 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/zone-Routes.ts";
|
||||||
import zoneRoutes2 from "./Routes/zoneRoutes.ts"; //update
|
import zoneRoutes2 from "./Routes/zoneRoutes.ts";
|
||||||
import panelRouter from "./Routes/panelRoutes.ts";
|
import panelRouter from "./Routes/panelRoutes.ts";
|
||||||
import widgetRouter from "./Routes/widgetRoute.ts";
|
import widgetRouter from "./Routes/widgetRoute.ts";
|
||||||
import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
||||||
@@ -20,48 +19,43 @@ 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 productFlowRoutes from "./Routes/productFlowRouts.ts";
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors());
|
app.disable("x-powered-by");
|
||||||
// const allowedOriginsDev = [
|
|
||||||
// "http://localhost:3000",
|
|
||||||
// "http://192.168.0.183:8200",
|
|
||||||
// "http://192.168.0.101:8200",
|
|
||||||
// "http://192.168.0.105:8200",
|
|
||||||
// "http://192.168.0.134:8200"
|
|
||||||
// ];
|
|
||||||
// const allowedOrigin =
|
|
||||||
// process.env.NODE_ENV === "production"
|
|
||||||
// ? process.env.FRONTEND_ORIGIN_PROD
|
|
||||||
// : allowedOriginsDev;
|
|
||||||
// app.use(cors({
|
|
||||||
// origin: (origin, callback) => {
|
|
||||||
// if (!origin) return callback(null, true);
|
|
||||||
// if (
|
|
||||||
// Array.isArray(allowedOrigin) &&
|
|
||||||
// allowedOrigin.includes(origin)
|
|
||||||
// ) {
|
|
||||||
// return callback(null, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (typeof allowedOrigin === "string" && origin === allowedOrigin) {
|
|
||||||
// return callback(null, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return callback(new Error("Not allowed by CORS"));
|
|
||||||
// },
|
|
||||||
// credentials: true
|
|
||||||
// }));
|
|
||||||
app.use(express.json());
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
const allowedOriginsDev = [
|
||||||
|
"http://localhost:3000",
|
||||||
|
"http://192.168.0.183:8200",
|
||||||
|
"http://192.168.0.101:8200",
|
||||||
|
"http://192.168.0.105:8200",
|
||||||
|
"http://192.168.0.134:8200",
|
||||||
|
];
|
||||||
|
const allowedOrigin =
|
||||||
|
process.env.NODE_ENV === "production"
|
||||||
|
? process.env.FRONTEND_ORIGIN_PROD
|
||||||
|
: allowedOriginsDev;
|
||||||
|
app.use(
|
||||||
|
cors({
|
||||||
|
origin: (origin, callback) => {
|
||||||
|
if (!origin) return callback(null, true);
|
||||||
|
if (Array.isArray(allowedOrigin) && allowedOrigin.includes(origin)) {
|
||||||
|
return callback(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof allowedOrigin === "string" && origin === allowedOrigin) {
|
||||||
|
return callback(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback(new Error("Not allowed by CORS"));
|
||||||
|
},
|
||||||
|
credentials: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
app.use(express.json());
|
||||||
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) => {
|
|
||||||
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);
|
||||||
@@ -70,8 +64,8 @@ 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);
|
app.use("/api/v2", zoneRoutes);
|
||||||
//update
|
|
||||||
app.use("/api/v2", zoneRoutes2); //updates
|
app.use("/api/v2", zoneRoutes2);
|
||||||
app.use("/api/v2", panelRouter);
|
app.use("/api/v2", panelRouter);
|
||||||
app.use("/api/v2", widgetRouter);
|
app.use("/api/v2", widgetRouter);
|
||||||
app.use("/api/v2", assetpointRouter);
|
app.use("/api/v2", assetpointRouter);
|
||||||
@@ -80,6 +74,5 @@ app.use("/api/v2", floadWidgetRoutes);
|
|||||||
app.use("/api/v2", templateRoutes);
|
app.use("/api/v2", templateRoutes);
|
||||||
app.use("/api/v2", widget3dRoutes);
|
app.use("/api/v2", widget3dRoutes);
|
||||||
app.use("/api/v2", productRouter);
|
app.use("/api/v2", productRouter);
|
||||||
// app.use("/api/v2", productFlowRoutes);
|
app.use("/api/v1", projectRouter);
|
||||||
app.use("/api/v1",projectRouter)
|
|
||||||
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 {
|
||||||
@@ -48,16 +48,13 @@ export class floorItems {
|
|||||||
res.status(201).json(newValue);
|
res.status(201).json(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating flooritems:", error);
|
|
||||||
res.status(500).json({ message: "Failed to create flooritems" });
|
res.status(500).json({ message: "Failed to create flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) {
|
||||||
@@ -66,7 +63,6 @@ export class floorItems {
|
|||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get flooritems:", error);
|
|
||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,7 +80,6 @@ export class floorItems {
|
|||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get flooritems:", error);
|
|
||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,11 +74,9 @@ 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;
|
||||||
|
|
||||||
// Validate type
|
|
||||||
if (!["Conveyor", "Vehicle", "ArmBot", "StaticMachine"].includes(type)) {
|
if (!["Conveyor", "Vehicle", "ArmBot", "StaticMachine"].includes(type)) {
|
||||||
return res.status(400).json({ message: "Invalid type requested" });
|
return res.status(400).json({ message: "Invalid type requested" });
|
||||||
}
|
}
|
||||||
@@ -92,7 +90,6 @@ export class pointService {
|
|||||||
|
|
||||||
if (type === "Conveyor") {
|
if (type === "Conveyor") {
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "672a090f80d91ac979f4d0bd",
|
|
||||||
modelfileID: "7dc04e36882e4debbc1a8e3d",
|
modelfileID: "7dc04e36882e4debbc1a8e3d",
|
||||||
type: "Conveyor",
|
type: "Conveyor",
|
||||||
};
|
};
|
||||||
@@ -118,8 +115,6 @@ export class pointService {
|
|||||||
name: "trigger 1",
|
name: "trigger 1",
|
||||||
type: "triggerType",
|
type: "triggerType",
|
||||||
bufferTime: 0,
|
bufferTime: 0,
|
||||||
// delay: "Inherit",
|
|
||||||
// spawnInterval: "Inherit",
|
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -195,7 +190,6 @@ export class pointService {
|
|||||||
} else if (type === "Vehicle") {
|
} else if (type === "Vehicle") {
|
||||||
console.log("vehcile data");
|
console.log("vehcile data");
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "67e3da19c2e8f37134526e6a",
|
|
||||||
modelfileID: "a1ee92554935007b10b3eb05",
|
modelfileID: "a1ee92554935007b10b3eb05",
|
||||||
type: "Vehicle",
|
type: "Vehicle",
|
||||||
};
|
};
|
||||||
@@ -231,7 +225,6 @@ export class pointService {
|
|||||||
} else if (type === "ArmBot") {
|
} else if (type === "ArmBot") {
|
||||||
console.log("ArmBot data");
|
console.log("ArmBot data");
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "67eb7904c2e8f37134527eae",
|
|
||||||
modelfileID: "52e6681fbb743a890d96c914",
|
modelfileID: "52e6681fbb743a890d96c914",
|
||||||
type: "ArmBot",
|
type: "ArmBot",
|
||||||
};
|
};
|
||||||
@@ -269,7 +262,6 @@ export class pointService {
|
|||||||
} else if (type === "StaticMachine") {
|
} else if (type === "StaticMachine") {
|
||||||
console.log("StaticMachine data");
|
console.log("StaticMachine data");
|
||||||
const baseData = {
|
const baseData = {
|
||||||
// modelfileID: "67e3db5ac2e8f37134526f40",
|
|
||||||
modelfileID: "ca164ffdfa74f6622536bb0f",
|
modelfileID: "ca164ffdfa74f6622536bb0f",
|
||||||
type: "StaticMachine",
|
type: "StaticMachine",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,80 +1,90 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
|
import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
|
||||||
|
|
||||||
|
export class WallItems {
|
||||||
|
static async setWallItems(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
organization,
|
||||||
|
} = req.body;
|
||||||
|
|
||||||
export class wallItems {
|
const findvalue = await wallItenmModel(organization).findOne({
|
||||||
static async setWallItems(req: Request, res: Response) {
|
modelUuid: modelUuid,
|
||||||
try {
|
});
|
||||||
const { modelUuid, modelName, position, type, csgposition,csgscale,quaternion,scale,organization } = req.body
|
|
||||||
|
|
||||||
|
if (findvalue) {
|
||||||
|
const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
|
||||||
|
{ modelUuid: modelUuid },
|
||||||
|
{
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
res.status(201).json(updatevalue);
|
||||||
|
} else {
|
||||||
|
const newValue = await wallItenmModel(organization).create({
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
});
|
||||||
|
|
||||||
const findvalue = await wallItenmModel(organization).findOne({ modelUuid: modelUuid})
|
res.status(201).json(newValue);
|
||||||
|
}
|
||||||
if (findvalue) {
|
} catch (error) {
|
||||||
const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
|
console.error("Error creating wallitems:", error);
|
||||||
{ modelUuid: modelUuid },
|
res.status(500).json({ message: "Failed to create wallitems" });
|
||||||
{
|
|
||||||
modelName,
|
|
||||||
position,
|
|
||||||
type,
|
|
||||||
csgposition,
|
|
||||||
csgscale,
|
|
||||||
quaternion,
|
|
||||||
scale,
|
|
||||||
},
|
|
||||||
{ new: true } // Return the updated document
|
|
||||||
);
|
|
||||||
res.status(201).json(updatevalue);
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
const newValue = await wallItenmModel(organization).create({ modelUuid,modelName, position, type, csgposition,csgscale,quaternion,scale });
|
|
||||||
|
|
||||||
|
|
||||||
res.status(201).json(newValue);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating wallitems:', error);
|
|
||||||
res.status(500).json({ message: "Failed to create wallitems" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
static async getWallItems(req: Request, res: Response) {
|
}
|
||||||
try {
|
static async getWallItems(req: Request, res: Response) {
|
||||||
const { organization } = req.params;
|
try {
|
||||||
|
const { organization } = req.params;
|
||||||
|
|
||||||
|
const findValue = await wallItenmModel(organization).find();
|
||||||
const findValue = await wallItenmModel
|
if (!findValue) {
|
||||||
(organization).find()
|
res.status(200).json("wallitems not found");
|
||||||
if (!findValue) {
|
} else {
|
||||||
res.status(200).json("wallitems not found");
|
res.status(201).json(findValue);
|
||||||
} else {
|
}
|
||||||
|
} catch (error) {
|
||||||
res.status(201).json(findValue);
|
console.error("Error get wallitems:", error);
|
||||||
}
|
res.status(500).json({ error: "Failed to get wallitems" });
|
||||||
} catch (error) {
|
|
||||||
console.error('Error get wallitems:', error);
|
|
||||||
res.status(500).json({ error: "Failed to get wallitems" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
static async deleteWallItems(req: Request, res: Response) {
|
}
|
||||||
try {
|
static async deleteWallItems(req: Request, res: Response) {
|
||||||
const { modelUuid,modelName,organization } = req.body;
|
try {
|
||||||
|
const { modelUuid, modelName, organization } = req.body;
|
||||||
|
|
||||||
|
const findValue = await wallItenmModel(organization).findOneAndDelete({
|
||||||
const findValue = await wallItenmModel
|
modelUuid: modelUuid,
|
||||||
(organization).findOneAndDelete({modelUuid:modelUuid,modelName:modelName})
|
modelName: modelName,
|
||||||
if (!findValue) {
|
});
|
||||||
res.status(200).json("user not found");
|
if (!findValue) {
|
||||||
} else {
|
res.status(200).json("user not found");
|
||||||
|
} 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,88 +2,91 @@ 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({
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
|
||||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
if (findCamera) {
|
||||||
|
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
||||||
if (findCamera) {
|
{ userId: userId },
|
||||||
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
{ position: position, target: target, rotation: rotation },
|
||||||
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
|
{ 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,
|
||||||
res.status(201).json(newCamera);
|
position,
|
||||||
|
target,
|
||||||
}
|
rotation,
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating camera:', error);
|
|
||||||
res.status(500).json({message:"Failed to create camera"});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static async getCamera(req: Request, res: Response) {
|
|
||||||
try {
|
|
||||||
const { userId, organization } = req.params;
|
|
||||||
|
|
||||||
// if (!userId) {
|
|
||||||
// res.status(201).json("User data is insufficient");
|
|
||||||
// }
|
|
||||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
|
||||||
if (!findCamera) {
|
|
||||||
res.status(200).json("user not found");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
res.status(201).json(findCamera);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error get camera:', error);
|
|
||||||
res.status(500).json({ error: "Failed to get camera" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static async onlineActiveDatas(req: Request, res: Response) {
|
|
||||||
const {organization } = req.params;
|
|
||||||
try {
|
|
||||||
const findactiveUsers = await userModel(organization).find({activeStatus:"online"})
|
|
||||||
|
|
||||||
|
|
||||||
const cameraDataPromises = findactiveUsers.map(async (activeUser:any) => {
|
|
||||||
const cameraData = await cameraModel(organization)
|
|
||||||
.findOne({ userId: activeUser._id })
|
|
||||||
.select("position target rotation -_id");
|
|
||||||
|
|
||||||
if (cameraData) {
|
|
||||||
return {
|
|
||||||
position: cameraData.position,
|
|
||||||
target: cameraData.target,
|
|
||||||
rotation:cameraData.rotation,
|
|
||||||
userData: {
|
|
||||||
_id: activeUser._id,
|
|
||||||
userName: activeUser.userName,
|
|
||||||
email: activeUser.email,
|
|
||||||
activeStatus: activeUser.activeStatus,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return null if no camera data is found for the user
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const cameraDatas = (await Promise.all(cameraDataPromises)).filter((singledata:any) => singledata !== null);
|
res.status(201).json(newCamera);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
res.status(200).send({ cameraDatas });
|
console.error("Error creating camera:", error);
|
||||||
|
res.status(500).json({ message: "Failed to create camera" });
|
||||||
} catch (error:any) {
|
|
||||||
res.status(500).send(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
static async getCamera(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { userId, organization } = req.params;
|
||||||
|
const findCamera = await cameraModel(organization).findOne({
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
if (!findCamera) {
|
||||||
|
res.status(200).json("user not found");
|
||||||
|
} else {
|
||||||
|
res.status(201).json(findCamera);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get camera:", error);
|
||||||
|
res.status(500).json({ error: "Failed to get camera" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async onlineActiveDatas(req: Request, res: Response) {
|
||||||
|
const { organization } = req.params;
|
||||||
|
try {
|
||||||
|
const findactiveUsers = await userModel(organization).find({
|
||||||
|
activeStatus: "online",
|
||||||
|
});
|
||||||
|
|
||||||
|
const cameraDataPromises = findactiveUsers.map(
|
||||||
|
async (activeUser: any) => {
|
||||||
|
const cameraData = await cameraModel(organization)
|
||||||
|
.findOne({ userId: activeUser._id })
|
||||||
|
.select("position target rotation -_id");
|
||||||
|
|
||||||
|
if (cameraData) {
|
||||||
|
return {
|
||||||
|
position: cameraData.position,
|
||||||
|
target: cameraData.target,
|
||||||
|
rotation: cameraData.rotation,
|
||||||
|
userData: {
|
||||||
|
_id: activeUser._id,
|
||||||
|
userName: activeUser.userName,
|
||||||
|
email: activeUser.email,
|
||||||
|
activeStatus: activeUser.activeStatus,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const cameraDatas = (await Promise.all(cameraDataPromises)).filter(
|
||||||
|
(singledata: any) => singledata !== null
|
||||||
|
);
|
||||||
|
|
||||||
|
res.status(200).send({ cameraDatas });
|
||||||
|
} catch (error: any) {
|
||||||
|
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 {
|
||||||
@@ -46,7 +46,6 @@ export class environment {
|
|||||||
res.status(201).json(newValue);
|
res.status(201).json(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating environments:", error);
|
console.error("Error creating environments:", error);
|
||||||
res.status(500).json({ message: "Failed to create environments" });
|
res.status(500).json({ message: "Failed to create environments" });
|
||||||
|
|||||||
@@ -1,125 +1,111 @@
|
|||||||
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);
|
} catch (error) {
|
||||||
|
console.error("Error creating Lines:", error);
|
||||||
// Send response with the created document
|
res.status(500).json({ message: "Failed to create Lines" });
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating Lines:', error);
|
|
||||||
res.status(500).json({message:"Failed to create Lines"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
static async updateLines(req: Request, res: Response) {
|
}
|
||||||
try {
|
static async updateLines(req: Request, res: Response) {
|
||||||
const {organization,uuid,position,}=req.body
|
try {
|
||||||
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
const { organization, uuid, position } = req.body;
|
||||||
// Update the position of the line matching the uuid
|
const updateResult = await lineModel(organization).updateMany(
|
||||||
|
{ "line.uuid": uuid },
|
||||||
|
{ $set: { "line.$.position": position } }
|
||||||
|
);
|
||||||
|
|
||||||
|
res.status(201).json(updateResult);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating Lines:", error);
|
||||||
|
res.status(500).json({ message: "Failed to create Lines" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async getLines(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization } = req.params;
|
||||||
|
|
||||||
|
const findValue = await lineModel(organization).find();
|
||||||
|
if (!findValue) {
|
||||||
|
res.status(200).json("user not found");
|
||||||
|
} else {
|
||||||
|
res.status(201).json(findValue);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get Lines:", error);
|
||||||
|
res.status(500).json({ error: "Failed to get Lines" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async deleteLineItems(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization, line } = req.body;
|
||||||
|
|
||||||
|
const inputUuids = line.map((item: any) => item.uuid);
|
||||||
|
|
||||||
|
const findValue = await lineModel(organization).findOneAndDelete({
|
||||||
|
"line.uuid": { $all: inputUuids },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!findValue) {
|
||||||
|
res.status(200).json("data not found");
|
||||||
|
} else {
|
||||||
|
res.status(201).json(findValue);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error delete Lines:", error);
|
||||||
|
res.status(500).json({ error: "Failed to delete Lines" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async deleteLinPoiteItems(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization, uuid } = req.body;
|
||||||
|
|
||||||
|
const findValue = await lineModel(organization).deleteMany({
|
||||||
|
"line.uuid": uuid,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!findValue) {
|
||||||
|
res.status(200).json("data not found");
|
||||||
|
} else {
|
||||||
|
res.status(201).json(findValue);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error delete Lines:", error);
|
||||||
|
res.status(500).json({ error: "Failed to delete Lines" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async deleteLayer(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization, layer } = req.body;
|
||||||
|
|
||||||
|
const findValue = await lineModel(organization).find({ layer: layer });
|
||||||
|
|
||||||
|
if (!findValue) {
|
||||||
|
res.status(200).json("data not found");
|
||||||
|
} else {
|
||||||
|
await lineModel(organization).deleteMany({ layer: layer });
|
||||||
|
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
const updateResult = await lineModel(organization).updateMany(
|
||||||
{ 'line.uuid': uuid }, // Filter: Find the line with the given uuid
|
{ layer: { $gt: layer } },
|
||||||
{ $set: { 'line.$.position': position } } // Update the position and type
|
{ $inc: { layer: -1 } }
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(201).json(updateResult);
|
res.status(201).json(updateResult);
|
||||||
|
}
|
||||||
// Send response with the created document
|
} catch (error) {
|
||||||
} catch (error) {
|
console.error("Error delete Lines:", error);
|
||||||
console.error('Error creating Lines:', error);
|
res.status(500).json({ error: "Failed to delete Lines" });
|
||||||
res.status(500).json({message:"Failed to create Lines"});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static async getLines(req: Request, res: Response) {
|
|
||||||
try {
|
|
||||||
const { organization } = req.params;
|
|
||||||
|
|
||||||
|
|
||||||
const findValue = await lineModel(organization).find()
|
|
||||||
if (!findValue) {
|
|
||||||
res.status(200).json("user not found");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error get Lines:', error);
|
|
||||||
res.status(500).json({ error: "Failed to get Lines" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static async deleteLineItems(req: Request, res: Response) {
|
|
||||||
try {
|
|
||||||
const {organization,layer,line,type}=req.body
|
|
||||||
|
|
||||||
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({
|
|
||||||
"line.uuid": { $all: inputUuids } // Ensure all UUIDs are present in the `line` key
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!findValue) {
|
|
||||||
res.status(200).json("data not found");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error delete Lines:', error);
|
|
||||||
res.status(500).json({ error: "Failed to delete Lines" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static async deleteLinPoiteItems(req: Request, res: Response) {
|
|
||||||
try {
|
|
||||||
const {organization,layer,uuid,type}=req.body
|
|
||||||
|
|
||||||
const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid })
|
|
||||||
|
|
||||||
if (!findValue) {
|
|
||||||
res.status(200).json("data not found");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
res.status(201).json(findValue);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error delete Lines:', error);
|
|
||||||
res.status(500).json({ error: "Failed to delete Lines" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static async deleteLayer(req: Request, res: Response) {
|
|
||||||
try {
|
|
||||||
const {organization,layer}=req.body
|
|
||||||
|
|
||||||
// Fetch the documents with the specified layer value
|
|
||||||
const findValue = await lineModel(organization).find({ layer: layer });
|
|
||||||
|
|
||||||
if (!findValue) {
|
|
||||||
res.status(200).json("data not found");
|
|
||||||
} else {
|
|
||||||
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(
|
|
||||||
{ layer: { $gt:layer} },
|
|
||||||
{ $inc: { layer: -1 } } // Example operation: decrementing layer by 1
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
res.status(201).json(updateResult);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error delete Lines:', error);
|
|
||||||
res.status(500).json({ error: "Failed to delete Lines" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,88 +1,121 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
||||||
export class zone {
|
export class Zone {
|
||||||
static async setZone(req: Request, res: Response) {
|
static async setZone(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, zoneData } = req.body
|
const { organization, userId, zoneData } = req.body;
|
||||||
// console.log('req.body: ', req.body);
|
const zoneId = zoneData.zoneId;
|
||||||
const zoneId = zoneData.zoneId
|
const points = zoneData.points;
|
||||||
const points = zoneData.points
|
const zoneName = zoneData.zoneName;
|
||||||
const zoneName = zoneData.zoneName
|
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({
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
zoneId: zoneId,
|
||||||
if (findZoneId) {
|
});
|
||||||
const updateZone = await zoneModel(organization).findOneAndUpdate(
|
if (findZoneId) {
|
||||||
{ zoneId: zoneId }, { points: points, viewPortposition: viewPortposition, viewPortCenter: viewPortCenter }, { new: true }
|
const updateZone = await zoneModel(organization)
|
||||||
).select("-_id -__v")
|
.findOneAndUpdate(
|
||||||
res.status(201).json({ message: 'zone updated', data: updateZone, organization: organization })
|
{ zoneId: zoneId },
|
||||||
} else {
|
{
|
||||||
const zoneCreate = await zoneModel(organization).create({
|
points: points,
|
||||||
zoneId, createBy: userId, zoneName: zoneName, points, layer, viewPortCenter, viewPortposition
|
viewPortposition: viewPortposition,
|
||||||
})
|
viewPortCenter: viewPortCenter,
|
||||||
const createdZone = await zoneModel(organization)
|
},
|
||||||
.findById(zoneCreate._id)
|
{ new: true }
|
||||||
.select('-_id -__v')
|
)
|
||||||
.lean();
|
.select("-_id -__v");
|
||||||
res.status(201).json({ message: 'zone created', data: createdZone, organization: organization })
|
res
|
||||||
}
|
.status(201)
|
||||||
} catch (error) {
|
.json({
|
||||||
console.log('error: ', error);
|
message: "zone updated",
|
||||||
res.status(500).json({ message: 'Zone not found', error })
|
data: updateZone,
|
||||||
}
|
organization: organization,
|
||||||
}
|
});
|
||||||
static async deleteZone(req: Request, res: Response) {
|
} else {
|
||||||
try {
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
const { organization, userId, zoneId } = req.body
|
zoneId,
|
||||||
|
createBy: userId,
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
zoneName: zoneName,
|
||||||
if (findZoneId) {
|
points,
|
||||||
const deleteZone = await zoneModel(organization).findOneAndDelete(
|
layer,
|
||||||
{ zoneId: zoneId, createBy: userId }
|
viewPortCenter,
|
||||||
).select("-_id -__v")
|
viewPortposition,
|
||||||
res.status(201).json({ message: 'zone deleted', data: deleteZone, organization: organization })
|
});
|
||||||
} else {
|
const createdZone = await zoneModel(organization)
|
||||||
|
.findById(zoneCreate._id)
|
||||||
res.status(500).json({ message: 'Invalid zone ID' })
|
.select("-_id -__v")
|
||||||
|
.lean();
|
||||||
}
|
res
|
||||||
} catch (error) {
|
.status(201)
|
||||||
console.log('error: ', error);
|
.json({
|
||||||
res.status(500).json({ message: 'Zone not found', error })
|
message: "zone created",
|
||||||
}
|
data: createdZone,
|
||||||
}
|
organization: organization,
|
||||||
static async getZones(req: Request, res: Response) {
|
});
|
||||||
try {
|
|
||||||
const { organization, userId } = req.params
|
|
||||||
|
|
||||||
|
|
||||||
const findZoneId = await zoneModel(organization)
|
|
||||||
.find()
|
|
||||||
.select("zoneId zoneName layer points viewPortCenter viewPortposition -_id");
|
|
||||||
|
|
||||||
if (!findZoneId) {
|
|
||||||
res.status(500).json({ message: 'Invalid zone' })
|
|
||||||
|
|
||||||
}
|
|
||||||
res.status(201).json({ data: findZoneId, organization: organization })
|
|
||||||
} catch (error) {
|
|
||||||
console.log('error: ', error);
|
|
||||||
res.status(500).json({ message: 'Zone not found', error })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static async ZoneData(req: Request, res: Response): Promise<any> {
|
|
||||||
try {
|
|
||||||
const organization = req.params.organization;
|
|
||||||
const zoneId = req.params.zoneId;
|
|
||||||
const findZone = await zoneModel(organization)
|
|
||||||
.findOne({ zoneId: zoneId })
|
|
||||||
// .select("zoneName");
|
|
||||||
console.log("findZone: ", findZone);
|
|
||||||
if (findZone) return res.status(200).json(findZone);
|
|
||||||
} catch (error: any) {
|
|
||||||
return res.status(500).send(error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async deleteZone(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization, userId, zoneId } = req.body;
|
||||||
|
|
||||||
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
if (findZoneId) {
|
||||||
|
const deleteZone = await zoneModel(organization)
|
||||||
|
.findOneAndDelete({ zoneId: zoneId, createBy: userId })
|
||||||
|
.select("-_id -__v");
|
||||||
|
res
|
||||||
|
.status(201)
|
||||||
|
.json({
|
||||||
|
message: "zone deleted",
|
||||||
|
data: deleteZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.status(500).json({ message: "Invalid zone ID" });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async getZones(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization } = req.params;
|
||||||
|
|
||||||
|
const findZoneId = await zoneModel(organization)
|
||||||
|
.find()
|
||||||
|
.select(
|
||||||
|
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!findZoneId) {
|
||||||
|
res.status(500).json({ message: "Invalid zone" });
|
||||||
|
}
|
||||||
|
res.status(201).json({ data: findZoneId, organization: organization });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async ZoneData(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
const organization = req.params.organization;
|
||||||
|
const zoneId = req.params.zoneId;
|
||||||
|
const findZone = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
console.log("findZone: ", findZone);
|
||||||
|
if (findZone) return res.status(200).json(findZone);
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -33,13 +33,6 @@ export class Zoneservice {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// const existingZoneName = await zoneSchema(organization).find({
|
|
||||||
// zoneName: zoneDatas.zoneName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (existingZoneName.length > 0) {
|
|
||||||
// return res.json({ message: "Zone name already exists" });
|
|
||||||
// }
|
|
||||||
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
|
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
|
||||||
{ zoneId: zoneDatas.zoneId, isArchive: false },
|
{ zoneId: zoneDatas.zoneId, isArchive: false },
|
||||||
{
|
{
|
||||||
@@ -96,7 +89,6 @@ export class Zoneservice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//single zode panel and widget data
|
|
||||||
static async singleZonePanelDatas(req: Request, res: Response): Promise<any> {
|
static async singleZonePanelDatas(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.query.organization;
|
const organization = req.query.organization;
|
||||||
const zoneId = req.params.zoneId;
|
const zoneId = req.params.zoneId;
|
||||||
@@ -157,7 +149,6 @@ export class Zoneservice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//page full zone Datas with panel and widget
|
|
||||||
static async vizAllDatas(req: Request, res: Response): Promise<any> {
|
static async vizAllDatas(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.query.organization;
|
const organization = req.query.organization;
|
||||||
try {
|
try {
|
||||||
@@ -173,13 +164,11 @@ export class Zoneservice {
|
|||||||
} else {
|
} else {
|
||||||
const response = await Promise.all(
|
const response = await Promise.all(
|
||||||
existingZones.map(async (zone) => {
|
existingZones.map(async (zone) => {
|
||||||
// Fetch all panels associated with the current zone
|
|
||||||
const panelData = await panelSchema(organization).find({
|
const panelData = await panelSchema(organization).find({
|
||||||
zoneId: zone._id,
|
zoneId: zone._id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch widgets for each panel
|
|
||||||
const widgets = await Promise.all(
|
const widgets = await Promise.all(
|
||||||
panelData.map(async (panel) => {
|
panelData.map(async (panel) => {
|
||||||
const widgetDataArray = await widgetSchema(organization).find({
|
const widgetDataArray = await widgetSchema(organization).find({
|
||||||
@@ -218,7 +207,6 @@ export class Zoneservice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//only for the name and zoneID
|
|
||||||
static async allZones(req: Request, res: Response): Promise<any> {
|
static async allZones(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.query.organization;
|
const organization = req.query.organization;
|
||||||
const sceneID = req.params.sceneID || "scene123";
|
const sceneID = req.params.sceneID || "scene123";
|
||||||
@@ -244,7 +232,7 @@ export class Zoneservice {
|
|||||||
const findZone = await zoneSchema(organization).findOne({
|
const findZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
// .select("zoneName");
|
|
||||||
if (findZone) return res.status(200).json(findZone);
|
if (findZone) return res.status(200).json(findZone);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
@@ -284,21 +272,4 @@ export class Zoneservice {
|
|||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static async zoneIdgenerate(req: Request, res: Response): Promise<any> {
|
|
||||||
// const organization = req.query.organization;
|
|
||||||
// const sceneID = req.params.sceneID;
|
|
||||||
// try {
|
|
||||||
// const Allzones = await zoneSchema(organization)
|
|
||||||
// .find({ sceneID: sceneID, isArchive: false })
|
|
||||||
// .select("zoneName sceneID zoneId");
|
|
||||||
|
|
||||||
// if (!Allzones || Allzones.length === 0) {
|
|
||||||
// return res.send({ message: "Zone not found for the UUID" });
|
|
||||||
// }
|
|
||||||
// return res.send(Allzones);
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return res.status(500).send(error.message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { createProject } from "../../../shared/services/project/project-Serivice
|
|||||||
export const createProjectController = async (req: Request, res: Response): Promise<void> => {
|
export const createProjectController = async (req: Request, res: Response): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
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":
|
||||||
|
|||||||
@@ -1,43 +1,44 @@
|
|||||||
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 {
|
||||||
|
static async shareUser(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { email, isShare, organization } = req.body;
|
||||||
|
|
||||||
export class share {
|
const findValue = await userModel(organization).findOneAndUpdate(
|
||||||
static async shareUser(req: Request, res: Response) {
|
{ email: email },
|
||||||
try {
|
{ isShare: isShare },
|
||||||
const { email, isShare, organization } = req.body
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
res
|
||||||
const findValue = await userModel(organization).findOneAndUpdate({email:email},{isShare:isShare},{new:true})
|
.status(201)
|
||||||
|
.json({ message: "scene shared successfully", data: findValue });
|
||||||
res.status(201).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"})
|
}
|
||||||
}
|
} catch (error) {
|
||||||
// Send response with the created document
|
console.error("Error creating Share:", error);
|
||||||
} catch (error) {
|
res.status(500).json({ message: "Failed to create Share" });
|
||||||
console.error('Error creating Share:', error);
|
|
||||||
res.status(500).json({message:"Failed to create Share"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async findshareUser(req: Request, res: Response) {
|
static async findshareUser(req: Request, res: Response) {
|
||||||
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);
|
if (!findValue) {
|
||||||
|
res.status(404).json({ message: "Not found" });
|
||||||
res.status(201).json({message:"scene shared datas",data:findValue});
|
}
|
||||||
if (!findValue) {
|
} catch (error) {
|
||||||
res.status(404).json({message:"Not found"})
|
console.error("Error Share:", error);
|
||||||
}
|
res.status(500).json({ message: "Failed to Share datas " });
|
||||||
// Send response with the created document
|
}
|
||||||
} catch (error) {
|
}
|
||||||
console.error('Error Share:', error);
|
|
||||||
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,12 +13,10 @@ export class assetsFloorservice {
|
|||||||
modelUuid,
|
modelUuid,
|
||||||
modelName,
|
modelName,
|
||||||
position,
|
position,
|
||||||
modelfileID,
|
|
||||||
rotation,
|
rotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
organization,
|
organization,
|
||||||
// eventData, // Optional
|
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
const existingAsset = await assetModel(organization).findOne({
|
const existingAsset = await assetModel(organization).findOne({
|
||||||
@@ -244,7 +69,7 @@ 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 {
|
||||||
@@ -258,14 +83,12 @@ export class assetsFloorservice {
|
|||||||
organization,
|
organization,
|
||||||
eventData,
|
eventData,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
console.log("req.body: ", req.body);
|
|
||||||
|
|
||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modelUuid,
|
modelUuid,
|
||||||
// modelName,
|
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
const checkpointType = await pointModel(organization).findOne({
|
await pointModel(organization).findOne({
|
||||||
modelfileID: modelfileID,
|
modelfileID: modelfileID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
@@ -292,10 +115,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,11 +128,6 @@ 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({
|
||||||
@@ -318,11 +135,6 @@ export class assetsFloorservice {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 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 +164,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 +174,10 @@ 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,
|
||||||
@@ -426,14 +207,11 @@ export class assetsFloorservice {
|
|||||||
return res.status(500).json({ message: "Failed to archive asset" });
|
return res.status(500).json({ message: "Failed to archive asset" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
await EventsDataModel(organization).updateMany(
|
||||||
{ modelUuid },
|
{ modelUuid },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("Archived asset:", archivedAsset);
|
|
||||||
console.log("Updated events:", updatedEvents.modifiedCount);
|
|
||||||
|
|
||||||
return res.status(200).json({ message: "delete Asset successfully" });
|
return res.status(200).json({ message: "delete Asset successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error deleting floor items:", error);
|
console.error("Error deleting floor items:", error);
|
||||||
|
|||||||
@@ -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,256 +2,233 @@ import { Request, Response } from "express";
|
|||||||
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
||||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||||
|
|
||||||
export class productFlowservice {
|
export class ProductFlowService {
|
||||||
|
static async productAdd(req: Request, res: Response): Promise<any> {
|
||||||
static async productAdd(req: Request, res: Response): Promise<any> {
|
try {
|
||||||
try {
|
const { productName, productId, eventDatas, organization } = req.body;
|
||||||
const { productName, productId, eventDatas, organization } = req.body;
|
if (!organization) {
|
||||||
if (!organization) {
|
return res.json({ message: "organization not found" });
|
||||||
return res
|
}
|
||||||
.json({ message: "organization not found" });
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingProduct) {
|
||||||
|
const existingEventData = await EventsDataModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
modelUuid: eventDatas.modelUuid,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingEventData) {
|
||||||
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
|
{
|
||||||
|
modelUuid: eventDatas.modelUuid,
|
||||||
|
productId: productId,
|
||||||
|
isArchive: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
modelUuid: eventDatas?.modelUuid,
|
||||||
|
modelName: eventDatas?.modelName,
|
||||||
|
position: eventDatas?.position,
|
||||||
|
rotation: eventDatas?.rotation,
|
||||||
|
type: eventDatas?.type,
|
||||||
|
speed: eventDatas?.speed,
|
||||||
|
point: eventDatas?.point,
|
||||||
|
points: eventDatas?.points,
|
||||||
}
|
}
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
);
|
||||||
productId: productId,
|
return res
|
||||||
isArchive: false,
|
.status(200)
|
||||||
})
|
.json({ message: "EventData updated successfully" });
|
||||||
if (existingProduct) {
|
} else {
|
||||||
const existingEventData = await EventsDataModel(organization).findOne(
|
await EventsDataModel(organization).create({
|
||||||
{
|
productId: productId,
|
||||||
productId: productId,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
modelUuid: eventDatas.modelUuid,
|
modelName: eventDatas?.modelName,
|
||||||
isArchive: false,
|
position: eventDatas?.position,
|
||||||
})
|
rotation: eventDatas?.rotation,
|
||||||
if (existingEventData) {
|
type: eventDatas?.type,
|
||||||
const updateEventData = await EventsDataModel(organization).findOneAndUpdate(
|
speed: eventDatas?.speed,
|
||||||
{
|
point: eventDatas?.point,
|
||||||
modelUuid: eventDatas.modelUuid,
|
points: eventDatas?.points,
|
||||||
productId: productId,
|
});
|
||||||
isArchive: false,
|
return res
|
||||||
}
|
.status(201)
|
||||||
, {
|
.json({ message: "EventData add successfully" });
|
||||||
modelUuid: eventDatas?.modelUuid,
|
|
||||||
modelName: eventDatas?.modelName,
|
|
||||||
position: eventDatas?.position,
|
|
||||||
rotation: eventDatas?.rotation,
|
|
||||||
type: eventDatas?.type,
|
|
||||||
speed: eventDatas?.speed,
|
|
||||||
point: eventDatas?.point,
|
|
||||||
points: eventDatas?.points,
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
.status(200)
|
|
||||||
.json({ message: "EventData updated successfully" });
|
|
||||||
} else {
|
|
||||||
const addEventData = await EventsDataModel(organization).create({
|
|
||||||
productId: productId,
|
|
||||||
modelUuid: eventDatas?.modelUuid,
|
|
||||||
modelName: eventDatas?.modelName,
|
|
||||||
position: eventDatas?.position,
|
|
||||||
rotation: eventDatas?.rotation,
|
|
||||||
type: eventDatas?.type,
|
|
||||||
speed: eventDatas?.speed,
|
|
||||||
point: eventDatas?.point,
|
|
||||||
points: eventDatas?.points
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
.status(201)
|
|
||||||
.json({ message: "EventData add successfully" });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const newProduct = await ProductModel(organization).create({
|
|
||||||
productId: productId,
|
|
||||||
productName: productName
|
|
||||||
|
|
||||||
})
|
|
||||||
if (newProduct) {
|
|
||||||
|
|
||||||
if (eventDatas) {
|
|
||||||
const addEventData = await EventsDataModel(organization).create({
|
|
||||||
productId: productId,
|
|
||||||
modelUuid: eventDatas?.modelUuid,
|
|
||||||
modelName: eventDatas?.modelName,
|
|
||||||
position: eventDatas?.position,
|
|
||||||
rotation: eventDatas?.rotation,
|
|
||||||
type: eventDatas?.type,
|
|
||||||
speed: eventDatas?.speed,
|
|
||||||
point: eventDatas?.point,
|
|
||||||
points: eventDatas?.points,
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
.status(201)
|
|
||||||
.json({ message: "Product created successfully" });
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ message: "Failed to create product" });
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
static async getProductDatas(req: Request, res: Response): Promise<any> {
|
const newProduct = await ProductModel(organization).create({
|
||||||
try {
|
productId: productId,
|
||||||
const { productId, organization } = req.query
|
productName: productName,
|
||||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
});
|
||||||
return res.status(400).json({ message: "Missing or invalid query parameters" });
|
if (newProduct) {
|
||||||
}
|
if (eventDatas) {
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
await EventsDataModel(organization).create({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
})
|
modelName: eventDatas?.modelName,
|
||||||
|
position: eventDatas?.position,
|
||||||
if (!existingProduct)
|
rotation: eventDatas?.rotation,
|
||||||
return res.status(404).json({ message: "Product not found" });
|
type: eventDatas?.type,
|
||||||
|
speed: eventDatas?.speed,
|
||||||
|
point: eventDatas?.point,
|
||||||
const existingEventDatas = await EventsDataModel(organization).find({ productId: productId }).select("-productId")
|
points: eventDatas?.points,
|
||||||
|
});
|
||||||
return res
|
}
|
||||||
.status(200)
|
|
||||||
.json(existingEventDatas);
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
res.status(500).json({ message: "Failed to get product" });
|
|
||||||
}
|
}
|
||||||
|
return res
|
||||||
|
.status(201)
|
||||||
|
.json({ message: "Product created successfully" });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Failed to create product" });
|
||||||
}
|
}
|
||||||
static async productDataDelete(req: Request, res: Response): Promise<any> {
|
}
|
||||||
try {
|
static async getProductDatas(req: Request, res: Response): Promise<any> {
|
||||||
const { productId, organization } = req.query
|
try {
|
||||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
const { productId, organization } = req.query;
|
||||||
return res.status(400).json({ message: "Missing or invalid query parameters" });
|
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||||
}
|
return res
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
.status(400)
|
||||||
productId: productId,
|
.json({ message: "Missing or invalid query parameters" });
|
||||||
isArchive: false,
|
}
|
||||||
})
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
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(
|
const existingEventDatas = await EventsDataModel(organization)
|
||||||
{ productId: productId },
|
.find({ productId: productId })
|
||||||
{
|
.select("-productId");
|
||||||
isArchive: true,
|
|
||||||
}, { new: true }
|
|
||||||
|
|
||||||
)
|
|
||||||
const existingEventDatas = await EventsDataModel(organization).find({ productId: productId })
|
|
||||||
if (existingEventDatas) {
|
|
||||||
for (const event of existingEventDatas) {
|
|
||||||
|
|
||||||
await EventsDataModel(organization).updateMany(
|
|
||||||
{ productId },
|
|
||||||
{ $set: { isArchive: true } }
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res.status(201).json({ message: "product deleted successfully" });
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ message: "Failed to delete product" });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return res.status(200).json(existingEventDatas);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Failed to get product" });
|
||||||
}
|
}
|
||||||
static async EventDataDelete(req: Request, res: Response): Promise<any> {
|
}
|
||||||
try {
|
static async productDataDelete(req: Request, res: Response): Promise<any> {
|
||||||
const { productId, organization, modelUuid } = req.body
|
try {
|
||||||
|
const { productId, organization } = req.query;
|
||||||
|
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||||
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ message: "Missing or invalid query parameters" });
|
||||||
|
}
|
||||||
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
if (!existingProduct)
|
||||||
productId: productId,
|
return res.status(404).json({ message: "Product not found" });
|
||||||
isArchive: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!existingProduct)
|
|
||||||
return res.status(404).json({ message: "Product not found" });
|
|
||||||
|
|
||||||
|
|
||||||
const existingEventDatas = await EventsDataModel(organization).findOneAndUpdate(
|
|
||||||
{ productId: productId, modelUuid: modelUuid }, {
|
|
||||||
isArchive: true,
|
|
||||||
}, { new: true }
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
return res.status(201).json({ message: "EventData deleted successfully" });
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ message: "Failed to delete Eventdata" });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
await ProductModel(organization).findOneAndUpdate(
|
||||||
|
{ productId: productId },
|
||||||
|
{
|
||||||
|
isArchive: true,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
const existingEventDatas = await EventsDataModel(organization).find({
|
||||||
|
productId: productId,
|
||||||
|
});
|
||||||
|
if (existingEventDatas) {
|
||||||
|
await EventsDataModel(organization).updateMany(
|
||||||
|
{ productId },
|
||||||
|
{ $set: { isArchive: true } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return res.status(201).json({ message: "product deleted successfully" });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Failed to delete product" });
|
||||||
}
|
}
|
||||||
static async AllProductDatas(req: Request, res: Response): Promise<any> {
|
}
|
||||||
try {
|
static async EventDataDelete(req: Request, res: Response): Promise<any> {
|
||||||
const { organization } = req.params
|
try {
|
||||||
|
const { productId, organization, modelUuid } = req.body;
|
||||||
|
|
||||||
if (!organization) {
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
return res
|
productId: productId,
|
||||||
.json({ message: "organization not found" });
|
isArchive: false,
|
||||||
}
|
});
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).find({
|
if (!existingProduct)
|
||||||
isArchive: false,
|
return res.status(404).json({ message: "Product not found" });
|
||||||
})
|
|
||||||
if (!existingProduct) {
|
|
||||||
return res.status(404).json({ message: 'No products found' });
|
|
||||||
}
|
|
||||||
const result = [];
|
|
||||||
|
|
||||||
for (const product of existingProduct) {
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
|
{ productId: productId, modelUuid: modelUuid },
|
||||||
|
{
|
||||||
// Fetch events data for each product, excluding productId field
|
isArchive: true,
|
||||||
const eventDatas = await EventsDataModel(organization)
|
},
|
||||||
.find({ productId: product.productId, isArchive: false })
|
{ new: true }
|
||||||
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Combine product and event data
|
|
||||||
result.push({
|
|
||||||
// product: {
|
|
||||||
productName: product.productName,
|
|
||||||
productId: product.productId,
|
|
||||||
eventDatas,
|
|
||||||
// },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return combined data
|
|
||||||
return res.status(200).json(result);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ message: "Failed to get Allproduct" });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return res
|
||||||
|
.status(201)
|
||||||
|
.json({ message: "EventData deleted successfully" });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Failed to delete Eventdata" });
|
||||||
}
|
}
|
||||||
static async productRename(req: Request, res: Response): Promise<any> {
|
}
|
||||||
|
static async AllProductDatas(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
const { organization } = req.params;
|
||||||
|
|
||||||
try {
|
if (!organization) {
|
||||||
const { productId, productName, organization } = req.body
|
return res.json({ message: "organization not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingProduct = await ProductModel(organization).find({
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingProduct) {
|
||||||
|
return res.status(404).json({ message: "No products found" });
|
||||||
|
}
|
||||||
|
const result = [];
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
for (const product of existingProduct) {
|
||||||
productId: productId,
|
const eventDatas = await EventsDataModel(organization)
|
||||||
isArchive: false,
|
.find({ productId: product.productId, isArchive: false })
|
||||||
})
|
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
||||||
|
|
||||||
if (!existingProduct)
|
result.push({
|
||||||
return res.status(404).json({ message: "Product not found" });
|
productName: product.productName,
|
||||||
|
productId: product.productId,
|
||||||
const productDelete = await ProductModel(organization).findOneAndUpdate(
|
eventDatas,
|
||||||
{ productId: productId },
|
});
|
||||||
{
|
}
|
||||||
productName: productName,
|
|
||||||
}, { new: true }
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
return res.status(201).json({ message: "product Rename successfully" });
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ message: "Failed to product Rename" });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Failed to get Allproduct" });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
static async productRename(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
const { productId, productName, organization } = req.body;
|
||||||
|
|
||||||
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
|
productId: productId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!existingProduct)
|
||||||
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
|
await ProductModel(organization).findOneAndUpdate(
|
||||||
|
{ productId: productId },
|
||||||
|
{
|
||||||
|
productName: productName,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(201).json({ message: "product Rename successfully" });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Failed to product Rename" });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,103 +1,72 @@
|
|||||||
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/security/Hasing.ts";
|
||||||
import {hashGenerate,hashValidator} from "../../shared/security/Hasing.ts"
|
|
||||||
// import {hashGenerate} from '../security/Hasing'
|
|
||||||
|
|
||||||
let serverAlive = true;
|
export class User {
|
||||||
export class user {
|
static async signup(req: Request, res: Response) {
|
||||||
static async signup(req: Request, res: Response) {
|
try {
|
||||||
try {
|
let role;
|
||||||
let role;
|
const { userName, email, password, organization, profilePicture } =
|
||||||
const { userName, email, password,organization,profilePicture } = req.body;
|
req.body;
|
||||||
const caseChange = email.toLowerCase();
|
const caseChange = email.toLowerCase();
|
||||||
const emailcheck = await userModel(organization).findOne({ email: caseChange });
|
const emailcheck = await userModel(organization).findOne({
|
||||||
if (emailcheck!==null) {
|
email: caseChange,
|
||||||
res.json({
|
});
|
||||||
message:"User already exists"
|
if (emailcheck !== null) {
|
||||||
});
|
res.json({
|
||||||
} else {
|
message: "User already exists",
|
||||||
const hashpassword=await hashGenerate(password)
|
});
|
||||||
const userCount = await userModel(organization).countDocuments({});
|
} else {
|
||||||
role = userCount === 0 ? "Admin" : "User";
|
const hashpassword = await hashGenerate(password);
|
||||||
const isShare = "true";
|
const userCount = await userModel(organization).countDocuments({});
|
||||||
const newuser = await userModel(organization).create({
|
role = userCount === 0 ? "Admin" : "User";
|
||||||
userName: userName,
|
const isShare = "true";
|
||||||
email: caseChange,
|
const newuser = await userModel(organization).create({
|
||||||
isShare:isShare,
|
userName: userName,
|
||||||
password: hashpassword,
|
email: caseChange,
|
||||||
role:role,
|
isShare: isShare,
|
||||||
profilePicture:profilePicture
|
password: hashpassword,
|
||||||
});
|
role: role,
|
||||||
newuser.save();
|
profilePicture: profilePicture,
|
||||||
res.status(200).json({
|
});
|
||||||
message:"New User created"
|
newuser.save();
|
||||||
});
|
res.status(200).json({
|
||||||
}
|
message: "New User created",
|
||||||
} catch (error:any) {
|
});
|
||||||
res.status(500).send(error);
|
}
|
||||||
}
|
} catch (error: any) {
|
||||||
|
res.status(500).send(error);
|
||||||
}
|
}
|
||||||
static async login(req: Request, res: Response) {
|
}
|
||||||
try {
|
static async login(req: Request, res: Response) {
|
||||||
let role;
|
try {
|
||||||
const { email, password,organization } = req.body;
|
let role;
|
||||||
// console.log(' req.body: ', req.body);
|
const { email, password, organization } = req.body;
|
||||||
|
const existingMail = await userModel(organization).findOne({
|
||||||
|
email: email,
|
||||||
|
});
|
||||||
|
|
||||||
const existingMail = await userModel(organization).findOne({
|
if (existingMail === null || !existingMail) {
|
||||||
email:email
|
res.status(401).json({ message: "User Not Found!!! Kindly signup..." });
|
||||||
});
|
} else {
|
||||||
|
const hashedpassword = existingMail.password;
|
||||||
if (existingMail === null || !existingMail) {
|
const checkpassword = await hashValidator(password, hashedpassword);
|
||||||
res.status(401).json({ message: "User Not Found!!! Kindly signup..." });
|
if (checkpassword) {
|
||||||
} else {
|
res.status(200).send({
|
||||||
const hashedpassword= existingMail.password
|
message: "login successfull",
|
||||||
const checkpassword = await hashValidator(
|
email: existingMail.email,
|
||||||
password,
|
name: existingMail.userName,
|
||||||
hashedpassword
|
userId: existingMail._id,
|
||||||
)
|
isShare: existingMail.isShare,
|
||||||
// console.log('checkpassword: ', checkpassword);
|
});
|
||||||
if (checkpassword) {
|
} else {
|
||||||
// const tokenValidation=await tokenGenerator(existingMail.email)
|
res.status(404).json({
|
||||||
res.status(200).send({
|
message: "email & password is invalid...Check the credentials",
|
||||||
message: "login successfull",
|
});
|
||||||
email: existingMail.email,
|
}
|
||||||
name: existingMail.userName,
|
}
|
||||||
userId: existingMail._id,
|
} catch (error: any) {
|
||||||
isShare:existingMail.isShare,
|
res.status(500).send(error);
|
||||||
// token:tokenValidation
|
|
||||||
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
res.status(404).json({message:"email & password is invalid...Check the credentials"})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error:any) {
|
|
||||||
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;
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -141,65 +141,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,11 @@ 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 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 +17,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 +51,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 +61,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 +75,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 +90,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 +104,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,20 +5,10 @@ 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 { organization, template } = req.body;
|
||||||
organization,
|
|
||||||
template,
|
|
||||||
// id,
|
|
||||||
// name,
|
|
||||||
// panelOrder,
|
|
||||||
// widgets,
|
|
||||||
// snapshot,
|
|
||||||
// floatWidgets,
|
|
||||||
} = 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,
|
||||||
@@ -84,7 +74,6 @@ export class templateService {
|
|||||||
if (existingZone.panelOrder.length > 0) {
|
if (existingZone.panelOrder.length > 0) {
|
||||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||||
await existingZone.save();
|
await existingZone.save();
|
||||||
// Clear existing data before adding new data
|
|
||||||
const archivePanelDatas = await panelSchema(organization).find({
|
const archivePanelDatas = await panelSchema(organization).find({
|
||||||
zoneId,
|
zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
|
|||||||
@@ -2,17 +2,10 @@ 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);
|
const { organization, zoneId, widget } = req.body;
|
||||||
console.log("req.body: ", req.body);
|
|
||||||
const {
|
|
||||||
organization,
|
|
||||||
// panel,
|
|
||||||
zoneId,
|
|
||||||
widget,
|
|
||||||
} = req.body;
|
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -32,9 +25,7 @@ export class widgetService {
|
|||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
// widgetOrder: widget.widgetOrder,
|
|
||||||
});
|
});
|
||||||
// console.log('existingWidget: ', widget.data.measurements);
|
|
||||||
if (existingWidget) {
|
if (existingWidget) {
|
||||||
const updateWidget = await widgetSchema(
|
const updateWidget = await widgetSchema(
|
||||||
organization
|
organization
|
||||||
@@ -46,8 +37,6 @@ export class widgetService {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
// panelID: existingPanel._id,
|
|
||||||
// widgetID: widget.id,
|
|
||||||
widgetName: widget?.widgetName,
|
widgetName: widget?.widgetName,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements || {},
|
measurements: widget?.Data?.measurements || {},
|
||||||
@@ -56,23 +45,18 @@ export class widgetService {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
{ upsert: true, new: true }
|
||||||
);
|
);
|
||||||
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,
|
||||||
elementType: widget.type,
|
elementType: widget.type,
|
||||||
// widgetOrder: widgetOrder,
|
|
||||||
zoneId,
|
zoneId,
|
||||||
widgetName: widget.title,
|
widgetName: widget.title,
|
||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
@@ -87,7 +71,6 @@ export class widgetService {
|
|||||||
await existingPanel.save();
|
await existingPanel.save();
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
message: "Widget created successfully",
|
message: "Widget created successfully",
|
||||||
// widgetID: newWidget._id,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +83,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,
|
||||||
@@ -114,19 +96,11 @@ export class widgetService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
// Find all widgets in the same panel and sort them by widgetOrder
|
await widgetSchema(organization).find({
|
||||||
const widgets = await widgetSchema(organization).find({
|
|
||||||
panelID: findWidget.panelID,
|
panelID: findWidget.panelID,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
// .sort({ widgetOrder: 1 });
|
|
||||||
|
|
||||||
// Reassign widgetOrder values
|
|
||||||
// for (let i = 0; i < widgets.length; i++) {
|
|
||||||
// widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
|
||||||
// await widgets[i].save();
|
|
||||||
// }
|
|
||||||
const panelData = await panelSchema(organization).findOne({
|
const panelData = await panelSchema(organization).findOne({
|
||||||
_id: findWidget.panelID,
|
_id: findWidget.panelID,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -146,7 +120,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,
|
||||||
@@ -156,7 +129,7 @@ export class widgetService {
|
|||||||
return res.status(404).send({ message: "Data not found" });
|
return res.status(404).send({ message: "Data not found" });
|
||||||
const updateData = {
|
const updateData = {
|
||||||
widgetName: values.widgetName,
|
widgetName: values.widgetName,
|
||||||
widgetSide: values.widgetSide, // Fixed typo from widgetside to widgetSide
|
widgetSide: values.widgetSide,
|
||||||
elementType: values.type,
|
elementType: values.type,
|
||||||
Data: {
|
Data: {
|
||||||
measurement: values.Data.measurement,
|
measurement: values.Data.measurement,
|
||||||
@@ -169,7 +142,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,39 +1,25 @@
|
|||||||
import app from './app.ts';
|
import app from "./app.ts";
|
||||||
import http from 'http';
|
import http from "http";
|
||||||
import ip from 'ip';
|
import swaggerUi from "swagger-ui-express";
|
||||||
|
import fs from "fs";
|
||||||
// import { startHealthCheck } from './controller/user-Controller';
|
|
||||||
import swaggerUi from 'swagger-ui-express';
|
|
||||||
import mongoAdminCreation from '../shared/security/mongosecurity.ts';
|
|
||||||
import fs from 'fs';
|
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
|
|
||||||
let swaggerDocument = {};
|
let swaggerDocument = {};
|
||||||
// try {
|
|
||||||
// swaggerDocument = require('../../swagger-output.json');
|
|
||||||
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('Error loading Swagger JSON:', error);
|
|
||||||
// swaggerDocument = {}; // Fallback: empty object or some default
|
|
||||||
// }
|
|
||||||
try {
|
try {
|
||||||
swaggerDocument = JSON.parse(fs.readFileSync('swagger-output.json', 'utf-8'));
|
swaggerDocument = JSON.parse(fs.readFileSync("swagger-output.json", "utf-8"));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading Swagger JSON:', error);
|
console.error("Error loading Swagger JSON:", error);
|
||||||
}
|
}
|
||||||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||||
const organization = process.env.ORGANIZATION_NAME || 'defaultOrganization'; // Replace with your logic
|
const organization = process.env.ORGANIZATION_NAME || "defaultOrganization";
|
||||||
|
|
||||||
// mongoAdminCreation()
|
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
throw new Error('ORGANIZATION_NAME is not defined in the environment');
|
throw new Error("ORGANIZATION_NAME is not defined in the environment");
|
||||||
}
|
}
|
||||||
|
|
||||||
const PORT = process.env.API_PORT
|
const PORT = process.env.API_PORT;
|
||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
console.log(`API-Server running on http://localhost:${PORT}`);
|
console.log(`API-Server running on http://localhost:${PORT}`);
|
||||||
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
|
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
|
||||||
// console.log(`Server is also accessible on IP address: ${ip.address()}`);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,13 +14,12 @@ const MainModel = <T>(
|
|||||||
): Model<T> => {
|
): Model<T> => {
|
||||||
const db1_url = `${process.env.MONGO_URI}${db}`;
|
const db1_url = `${process.env.MONGO_URI}${db}`;
|
||||||
const authOptions = {
|
const authOptions = {
|
||||||
user: process.env.MONGO_USER, // Correct username environment variable
|
user: process.env.MONGO_USER,
|
||||||
pass: process.env.MONGO_PASSWORD, // Correct password environment variable
|
pass: process.env.MONGO_PASSWORD,
|
||||||
authSource: process.env.MONGO_AUTH_DB || "admin", // Default to 'admin' if not provided
|
authSource: process.env.MONGO_AUTH_DB || "admin",
|
||||||
maxPoolSize: 50,
|
maxPoolSize: 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if the connection already exists
|
|
||||||
if (connections[db]) {
|
if (connections[db]) {
|
||||||
return connections[db].model<T>(modelName, schema, collectionName);
|
return connections[db].model<T>(modelName, schema, collectionName);
|
||||||
}
|
}
|
||||||
@@ -28,10 +27,8 @@ const MainModel = <T>(
|
|||||||
try {
|
try {
|
||||||
const db1 = mongoose.createConnection(db1_url, authOptions);
|
const db1 = mongoose.createConnection(db1_url, authOptions);
|
||||||
|
|
||||||
// Cache the connection
|
|
||||||
connections[db] = db1;
|
connections[db] = db1;
|
||||||
|
|
||||||
// Log connection success or handle errors
|
|
||||||
db1.on("connected", () => {
|
db1.on("connected", () => {
|
||||||
console.log(`Connected to MongoDB database: ${db}`);
|
console.log(`Connected to MongoDB database: ${db}`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,57 +1,35 @@
|
|||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from '../../connect/mongoose.ts';
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
export interface FloorItenms extends Document {
|
||||||
export interface floorItenms extends Document {
|
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
modelName: string
|
modelName: string;
|
||||||
isLocked:boolean
|
isLocked: boolean;
|
||||||
isVisible:boolean
|
isVisible: boolean;
|
||||||
position: []
|
position: [];
|
||||||
rotation: {
|
rotation: {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
z: number;
|
z: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const floorItemsSchema: Schema = new Schema({
|
const floorItemsSchema: Schema = new Schema({
|
||||||
modelUuid: { type: String },
|
modelUuid: { type: String },
|
||||||
modelfileID: { type: String },
|
modelfileID: { type: String },
|
||||||
modelName: { type: String },
|
modelName: { type: String },
|
||||||
position: { type: Array},
|
position: { type: Array },
|
||||||
isLocked:{type:Boolean},
|
isLocked: { type: Boolean },
|
||||||
isVisible:{type:Boolean},
|
isVisible: { type: Boolean },
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Model for MongoDB collection
|
const floorItemsModel = (db: string) => {
|
||||||
// const cameraModel = model<Camera>("Camera", cameraSchema);
|
return MainModel(db, "floorItems", floorItemsSchema, "floorItems");
|
||||||
|
|
||||||
// export default cameraModel;
|
|
||||||
// const floorItemsModel = (db: string) => {
|
|
||||||
// const mongoUrl = process.env.MONGO_URI || '';
|
|
||||||
// if (!mongoUrl) {
|
|
||||||
// throw new Error('MONGO_URI environment variable is not set');
|
|
||||||
// }
|
|
||||||
// // Connect to the database
|
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
||||||
// dbName: db, // Specify the database name here
|
|
||||||
// serverSelectionTimeoutMS: 30000,
|
|
||||||
// });
|
|
||||||
// return dbConnection.model<floorItenms>('floorItenms', floorItenmsSchema,`floorItenms`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export default floorItemsModel;
|
|
||||||
const floorItemsModel = (db:string) => {
|
|
||||||
return MainModel(db, "floorItems", floorItemsSchema, "floorItems")
|
|
||||||
};
|
};
|
||||||
export default floorItemsModel;
|
export default floorItemsModel;
|
||||||
@@ -1,48 +1,30 @@
|
|||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from '../../connect/mongoose.ts';
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
// Interface for TypeScript with PascalCase
|
export interface WallItems extends Document {
|
||||||
export interface wallitems extends Document {
|
modelUuid: string;
|
||||||
modelUuid: string;
|
modelName: string;
|
||||||
modelName: string
|
modelfileID: string;
|
||||||
modelfileID: string;
|
type: string;
|
||||||
type: string
|
csgposition: [];
|
||||||
csgposition: []
|
csgscale: [];
|
||||||
csgscale: []
|
position: [];
|
||||||
position: []
|
quaternion: [];
|
||||||
quaternion: []
|
scale: [];
|
||||||
scale: []
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const wallItemsSchema: Schema = new Schema({
|
const wallItemsSchema: Schema = new Schema({
|
||||||
modelUuid: { type: String},
|
modelUuid: { type: String },
|
||||||
modelfileID: { type: String},
|
modelfileID: { type: String },
|
||||||
modelName: { type: String},
|
modelName: { type: String },
|
||||||
type: { type: String },
|
type: { type: String },
|
||||||
csgposition: { type: Array},
|
csgposition: { type: Array },
|
||||||
csgscale: { type: Array,},
|
csgscale: { type: Array },
|
||||||
position: { type: Array },
|
position: { type: Array },
|
||||||
quaternion: { type: Array},
|
quaternion: { type: Array },
|
||||||
scale: { type: Array}
|
scale: { type: Array },
|
||||||
});
|
});
|
||||||
|
|
||||||
// const wallItenmModel = (db: string) => {
|
const wallItenmModel = (db: string) => {
|
||||||
// const mongoUrl = process.env.MONGO_URI || '';
|
return MainModel(db, "wallitems", wallItemsSchema, "wallitems");
|
||||||
// if (!mongoUrl) {
|
};
|
||||||
// throw new Error('MONGO_URI environment variable is not set');
|
export default wallItenmModel;
|
||||||
// }
|
|
||||||
// // Connect to the database
|
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
||||||
// dbName: db, // Specify the database name here
|
|
||||||
// serverSelectionTimeoutMS: 30000,
|
|
||||||
// });
|
|
||||||
// return dbConnection.model<wallitenms>('wallitenms', wallItenmsSchema, `wallitenms`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export default wallItenmModel;
|
|
||||||
const wallItenmModel = (db:string) => {
|
|
||||||
return MainModel(db, "wallitems", wallItemsSchema, "wallitems")
|
|
||||||
};
|
|
||||||
export default wallItenmModel;
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
interface ICommonBase {
|
interface ICommonBase {
|
||||||
@@ -26,7 +26,6 @@ export interface assetData extends Document {
|
|||||||
type: string;
|
type: string;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
isArchive: false;
|
isArchive: false;
|
||||||
// points: [] | {};
|
|
||||||
position: [];
|
position: [];
|
||||||
rotation: {
|
rotation: {
|
||||||
x: number;
|
x: number;
|
||||||
@@ -43,7 +42,6 @@ const assetDataSchema: Schema = new Schema({
|
|||||||
modelfileID: { type: String },
|
modelfileID: { type: String },
|
||||||
modelName: { type: String },
|
modelName: { type: String },
|
||||||
type: { type: String },
|
type: { type: String },
|
||||||
// points: { type: Schema.Types.Mixed },
|
|
||||||
position: { type: Array },
|
position: { type: Array },
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number },
|
x: { type: Number },
|
||||||
@@ -58,101 +56,7 @@ const assetDataSchema: Schema = new Schema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default floorItemsModel;
|
|
||||||
const assetModel = (db: string) => {
|
const assetModel = (db: string) => {
|
||||||
return MainModel(db, "Assets", assetDataSchema, "Assets");
|
return MainModel(db, "Assets", assetDataSchema, "Assets");
|
||||||
};
|
};
|
||||||
export default assetModel;
|
export default assetModel;
|
||||||
|
|
||||||
// import mongoose, { Document, Schema } from "mongoose";
|
|
||||||
// import MainModel from "../../../connect/mongoose.ts";
|
|
||||||
|
|
||||||
// export interface assetData extends Document {
|
|
||||||
// modelUuid: string;
|
|
||||||
// modelfileID: string;
|
|
||||||
// modelName: string;
|
|
||||||
// isLocked: boolean;
|
|
||||||
// type: string;
|
|
||||||
// isVisible: boolean;
|
|
||||||
// isArchive: false;
|
|
||||||
// // position: [];
|
|
||||||
// // rotation: {
|
|
||||||
// // x: number;
|
|
||||||
// // y: number;
|
|
||||||
// // z: number;
|
|
||||||
// // };
|
|
||||||
// points: {
|
|
||||||
// uuid: string;
|
|
||||||
// position: [];
|
|
||||||
// rotation: [];
|
|
||||||
// actions: [mongoose.Types.ObjectId];
|
|
||||||
// triggers: [mongoose.Types.ObjectId];
|
|
||||||
// connections: {
|
|
||||||
// source: {
|
|
||||||
// modelUUID: string;
|
|
||||||
// pointUUID: string;
|
|
||||||
// };
|
|
||||||
// targets: [
|
|
||||||
// {
|
|
||||||
// modelUUID: string;
|
|
||||||
// pointUUID: string;
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
// }[];
|
|
||||||
// }[];
|
|
||||||
// position: [];
|
|
||||||
// // rotation: [];
|
|
||||||
// rotation: {
|
|
||||||
// x: number;
|
|
||||||
// y: number;
|
|
||||||
// z: number;
|
|
||||||
// };
|
|
||||||
// speed: number | string;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Define the Mongoose Schema
|
|
||||||
// const assetDataSchema: Schema = new Schema({
|
|
||||||
// isArchive: { type: Boolean, default: false },
|
|
||||||
// modelUuid: { type: String },
|
|
||||||
// modelfileID: { type: String },
|
|
||||||
// modelName: { type: String },
|
|
||||||
// type: { type: String },
|
|
||||||
// // assetPosition: { type: Array },
|
|
||||||
// points: [
|
|
||||||
// {
|
|
||||||
// uuid: { type: String },
|
|
||||||
// position: { type: Array },
|
|
||||||
// rotation: { type: Array },
|
|
||||||
// actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Actions" }],
|
|
||||||
// triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Triggers" }],
|
|
||||||
// connections: {
|
|
||||||
// source: {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// targets: [
|
|
||||||
// {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// position: { type: Array },
|
|
||||||
// // rotation: { type: Array},
|
|
||||||
// rotation: {
|
|
||||||
// x: { type: Number },
|
|
||||||
// y: { type: Number },
|
|
||||||
// z: { type: Number },
|
|
||||||
// },
|
|
||||||
// speed: { type: Schema.Types.Mixed },
|
|
||||||
// isLocked: { type: Boolean },
|
|
||||||
// isVisible: { type: Boolean },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // export default floorItemsModel;
|
|
||||||
// const assetModel = (db: string) => {
|
|
||||||
// return MainModel(db, "Assets", assetDataSchema, "Assets");
|
|
||||||
// };
|
|
||||||
// export default assetModel;
|
|
||||||
|
|||||||
@@ -1,31 +1,6 @@
|
|||||||
import mongoose, { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
// Common Interfaces
|
|
||||||
// interface ITriggerConveyor {
|
|
||||||
// uuid: string;
|
|
||||||
// name: string;
|
|
||||||
// type: string;
|
|
||||||
// isUsed: boolean;
|
|
||||||
// bufferTime: number;
|
|
||||||
// }
|
|
||||||
// interface ITriggerVehicle {
|
|
||||||
// uuid: string;
|
|
||||||
// name: string;
|
|
||||||
// type: string;
|
|
||||||
// isUsed: boolean;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// interface IConnectionConveyor {
|
|
||||||
// source: { modelUUID: string; pointUUID: string };
|
|
||||||
// targets: { modelUUID: string; pointUUID: string }[];
|
|
||||||
// }
|
|
||||||
// interface IConnectionVehicle {
|
|
||||||
// source: { modelUUID: string; pointUUID: string };
|
|
||||||
// targets: { modelUUID: string; pointUUID: string }[];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Point Types
|
|
||||||
interface IPointBase {
|
interface IPointBase {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: number[];
|
position: number[];
|
||||||
@@ -127,322 +102,10 @@ const PointSchema = new Schema<IPointModel>(
|
|||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
// Model Creation
|
|
||||||
const pointModel = (db: string) => {
|
const pointModel = (db: string) => {
|
||||||
return MainModel(db, "Points", PointSchema, "Points");
|
return MainModel(db, "Points", PointSchema, "Points");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default pointModel;
|
export default pointModel;
|
||||||
|
|
||||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
|
|
||||||
// import mongoose, { Schema, Document } from "mongoose";
|
|
||||||
// import MainModel from "../../../connect/mongoose.ts";
|
|
||||||
|
|
||||||
// interface IActionConveyor {
|
|
||||||
// uuid: string;
|
|
||||||
// name: string;
|
|
||||||
// type: string;
|
|
||||||
// material: string;
|
|
||||||
// delay: number | string;
|
|
||||||
// spawnInterval: number | string;
|
|
||||||
// spawnMaterial: string;
|
|
||||||
// isUsed: boolean;
|
|
||||||
// hitCount: number;
|
|
||||||
// start: string;
|
|
||||||
// end: string;
|
|
||||||
// buffer: number;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// interface ITriggers {
|
|
||||||
// uuid: string;
|
|
||||||
// name: string;
|
|
||||||
// type: string;
|
|
||||||
// isUsed: boolean;
|
|
||||||
// bufferTime: number;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// interface IConnection {
|
|
||||||
// source: { modelUUID: string; pointUUID: string };
|
|
||||||
// targets: { modelUUID: string; pointUUID: string }[];
|
|
||||||
// }
|
|
||||||
// interface IActionVehicle {
|
|
||||||
// uuid: string;
|
|
||||||
// name: string;
|
|
||||||
// type: string;
|
|
||||||
// isUsed: boolean;
|
|
||||||
// hitCount: number;
|
|
||||||
// start: string;
|
|
||||||
// end: string;
|
|
||||||
// buffer: number;
|
|
||||||
// }
|
|
||||||
// interface IPointConveyor {
|
|
||||||
// uuid: string;
|
|
||||||
// position: number[];
|
|
||||||
// rotation: number[];
|
|
||||||
// actions: IActionConveyor[];
|
|
||||||
// triggers: ITriggers[];
|
|
||||||
// connections: IConnection;
|
|
||||||
// }
|
|
||||||
// interface IPointVehicle {
|
|
||||||
// uuid: string;
|
|
||||||
// position: number[];
|
|
||||||
// actions: IActionVehicle[];
|
|
||||||
// triggers: ITriggers[];
|
|
||||||
// connections: IConnection;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// interface IBaseModel extends Document {
|
|
||||||
// modelfileID: string;
|
|
||||||
// type: "Conveyor" | "Vehicle";
|
|
||||||
// points: IPointConveyor[] | IPointVehicle;
|
|
||||||
// }
|
|
||||||
// const PointconveyorSchema = new Schema<IPointConveyor>({
|
|
||||||
// uuid: { type: String, required: true },
|
|
||||||
// position: { type: [Number] },
|
|
||||||
// rotation: { type: [Number] },
|
|
||||||
// actions: [
|
|
||||||
// {
|
|
||||||
// uuid: { type: String, default: "" },
|
|
||||||
// name: { type: String },
|
|
||||||
// type: { type: String },
|
|
||||||
// material: { type: String },
|
|
||||||
// delay: { type: Schema.Types.Mixed },
|
|
||||||
// spawnInterval: { type: Schema.Types.Mixed },
|
|
||||||
// spawnMaterial: { type: String },
|
|
||||||
// isUsed: { type: Boolean },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// triggers: [
|
|
||||||
// {
|
|
||||||
// uuid: { type: String, default: "" },
|
|
||||||
// name: { type: String },
|
|
||||||
// type: { type: String },
|
|
||||||
// bufferTime: { type: Number },
|
|
||||||
// isUsed: { type: Boolean },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// connections: {
|
|
||||||
// source: {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// targets: [
|
|
||||||
// {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// const PointvehicleSchema = new Schema<IPointVehicle>({
|
|
||||||
// uuid: { type: String, required: true },
|
|
||||||
// position: { type: [Number] },
|
|
||||||
// actions: [
|
|
||||||
// {
|
|
||||||
// uuid: { type: String, default: "" },
|
|
||||||
// name: { type: String },
|
|
||||||
// type: { type: String },
|
|
||||||
// isUsed: { type: Boolean },
|
|
||||||
// hitCount: { type: String },
|
|
||||||
// start: { type: String },
|
|
||||||
// end: { type: String },
|
|
||||||
// buffer: { type: String },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// triggers: [
|
|
||||||
// {
|
|
||||||
// uuid: { type: String, default: "" },
|
|
||||||
// name: { type: String },
|
|
||||||
// type: { type: String },
|
|
||||||
// bufferTime: { type: Number },
|
|
||||||
// isUsed: { type: Boolean },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// connections: {
|
|
||||||
// source: {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// targets: [
|
|
||||||
// {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const BaseSchema = new Schema<IBaseModel>(
|
|
||||||
// {
|
|
||||||
// modelfileID: { type: String },
|
|
||||||
// type: { type: String, enum: ["Conveyor", "Vehicle"] },
|
|
||||||
// points: {
|
|
||||||
// type: Schema.Types.Mixed,
|
|
||||||
// required: true,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// { discriminatorKey: "type", timestamps: true }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const pointModel = (db: string) => {
|
|
||||||
// const BasePointModel = MainModel(db, "Points", BaseSchema, "Points");
|
|
||||||
|
|
||||||
// const ConveyorModel = BasePointModel.discriminator(
|
|
||||||
// "Conveyor",
|
|
||||||
// new Schema({
|
|
||||||
// points: [PointconveyorSchema],
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const VehicleModel = BasePointModel.discriminator(
|
|
||||||
// "Vehicle",
|
|
||||||
// new Schema({
|
|
||||||
// points: PointvehicleSchema,
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
|
|
||||||
// return { ConveyorModel, VehicleModel };
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export default pointModel;
|
|
||||||
|
|
||||||
// ===
|
|
||||||
// const pointModel = (db: string) => {
|
|
||||||
// const BasePointModel =
|
|
||||||
// mongoose.models.Points || MainModel(db, "Points", BaseSchema, "Points");
|
|
||||||
|
|
||||||
// if (!BasePointModel.discriminators?.Conveyor) {
|
|
||||||
// BasePointModel.discriminator(
|
|
||||||
// "Conveyor",
|
|
||||||
// new Schema({
|
|
||||||
// points: [PointconveyorSchema],
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!BasePointModel.discriminators?.Vehicle) {
|
|
||||||
// BasePointModel.discriminator(
|
|
||||||
// "Vehicle",
|
|
||||||
// new Schema({
|
|
||||||
// points: PointvehicleSchema,
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const ConveyorModel =
|
|
||||||
// mongoose.models.Conveyor || BasePointModel.discriminators?.Conveyor;
|
|
||||||
// const VehicleModel =
|
|
||||||
// mongoose.models.Vehicle || BasePointModel.discriminators?.Vehicle;
|
|
||||||
|
|
||||||
// return { ConveyorModel, VehicleModel, BasePointModel };
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export default pointModel;
|
|
||||||
// ===========================================
|
|
||||||
// ===
|
|
||||||
// import mongoose, { Schema, Document } from "mongoose";
|
|
||||||
// import MainModel from "../../../connect/mongoose.ts";
|
|
||||||
|
|
||||||
// interface IAction {
|
|
||||||
// uuid: string;
|
|
||||||
// name: string;
|
|
||||||
// type: string;
|
|
||||||
// material: string;
|
|
||||||
// delay: number | string;
|
|
||||||
// spawnInterval: number | string;
|
|
||||||
// spawnMaterial: string;
|
|
||||||
// isUsed: boolean;
|
|
||||||
// hitCount: number;
|
|
||||||
// start: string;
|
|
||||||
// end: string;
|
|
||||||
// buffer: number;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// interface ITriggers {
|
|
||||||
// uuid: string;
|
|
||||||
// name: string;
|
|
||||||
// type: string;
|
|
||||||
// isUsed: boolean;
|
|
||||||
// bufferTime: number;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// interface IConnection {
|
|
||||||
// source: { modelUUID: string; pointUUID: string };
|
|
||||||
// targets: { modelUUID: string; pointUUID: string }[];
|
|
||||||
// }
|
|
||||||
// interface IPoint {
|
|
||||||
// uuid: string;
|
|
||||||
// position: number[];
|
|
||||||
// rotation: number[];
|
|
||||||
// actions: IAction[];
|
|
||||||
// triggers: ITriggers[];
|
|
||||||
// connections: IConnection;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// interface IBaseModel extends Document {
|
|
||||||
// modelfileID: string;
|
|
||||||
// type: "Conveyor" | "Vehicle";
|
|
||||||
// points: IPoint[] | IPoint;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const PointSchema = new Schema<IPoint>({
|
|
||||||
// uuid: { type: String, required: true },
|
|
||||||
// position: { type: [Number] },
|
|
||||||
// rotation: { type: [Number] },
|
|
||||||
// actions: [
|
|
||||||
// {
|
|
||||||
// uuid: { type: String, default: "" },
|
|
||||||
// name: { type: String },
|
|
||||||
// type: { type: String },
|
|
||||||
// material: { type: String },
|
|
||||||
// delay: { type: String },
|
|
||||||
// spawnInterval: { type: String },
|
|
||||||
// spawnMaterial: { type: String },
|
|
||||||
// isUsed: { type: Boolean },
|
|
||||||
// hitCount: { type: String },
|
|
||||||
// start: { type: String },
|
|
||||||
// end: { type: String },
|
|
||||||
// buffer: { type: String },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// triggers: [
|
|
||||||
// {
|
|
||||||
// uuid: { type: String, default: "" },
|
|
||||||
// name: { type: String },
|
|
||||||
// type: { type: String },
|
|
||||||
// bufferTime: { type: Number },
|
|
||||||
// isUsed: { type: Boolean },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// connections: {
|
|
||||||
// source: {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// targets: [
|
|
||||||
// {
|
|
||||||
// modelUUID: { type: String },
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// // Base Schema
|
|
||||||
|
|
||||||
// const BaseSchema = new Schema<IBaseModel>(
|
|
||||||
// {
|
|
||||||
// modelfileID: { type: String },
|
|
||||||
// type: { type: String, enum: ["Conveyor", "Vehicle"] },
|
|
||||||
// points: {
|
|
||||||
// type: Schema.Types.Mixed,
|
|
||||||
// required: true,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// { discriminatorKey: "type", timestamps: true }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const pointModel = (db: string) => {
|
|
||||||
// return MainModel(db, "Points", BaseSchema, "Points");
|
|
||||||
// };
|
|
||||||
// export default pointModel;
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
// Interface for TypeScript with PascalCase
|
export interface WallItems extends Document {
|
||||||
export interface wallitems extends Document {
|
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -12,7 +11,6 @@ export interface wallitems extends Document {
|
|||||||
scale: [];
|
scale: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const wallItemsSchema: Schema = new Schema({
|
const wallItemsSchema: Schema = new Schema({
|
||||||
modelUuid: { type: String, unique: true },
|
modelUuid: { type: String, unique: true },
|
||||||
modelName: { type: String },
|
modelName: { type: String },
|
||||||
@@ -24,7 +22,6 @@ const wallItemsSchema: Schema = new Schema({
|
|||||||
scale: { type: Array },
|
scale: { type: Array },
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default wallItenmModel;
|
|
||||||
const wallItenmModel = (db: string) => {
|
const wallItenmModel = (db: string) => {
|
||||||
return MainModel(db, "wallitems", wallItemsSchema, "wallitems");
|
return MainModel(db, "wallitems", wallItemsSchema, "wallitems");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
|
||||||
export interface Camera extends Document {
|
export interface Camera extends Document {
|
||||||
userId: string;
|
userId: string;
|
||||||
position: {
|
position: {
|
||||||
@@ -21,7 +20,6 @@ export interface Camera extends Document {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const cameraSchema: Schema = new Schema({
|
const cameraSchema: Schema = new Schema({
|
||||||
userId: { type: String },
|
userId: { type: String },
|
||||||
position: {
|
position: {
|
||||||
@@ -41,7 +39,6 @@ const cameraSchema: Schema = new Schema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default cameraModel
|
|
||||||
const cameraModel = (db: string) => {
|
const cameraModel = (db: string) => {
|
||||||
return MainModel(db, "Camera", cameraSchema, "Camera");
|
return MainModel(db, "Camera", cameraSchema, "Camera");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from '../../../connect/mongoose.ts';
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
// Interface for TypeScript with PascalCase
|
export interface Environment extends Document {
|
||||||
export interface environment extends Document {
|
|
||||||
userId: string;
|
userId: string;
|
||||||
roofVisibility: boolean
|
roofVisibility: boolean;
|
||||||
wallVisibility: boolean
|
wallVisibility: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const environmentSchema: Schema = new Schema({
|
const environmentSchema: Schema = new Schema({
|
||||||
userId: { type: String, unique: true },
|
userId: { type: String, unique: true },
|
||||||
roofVisibility: { type: Boolean, default: false },
|
roofVisibility: { type: Boolean, default: false },
|
||||||
@@ -15,10 +13,7 @@ const environmentSchema: Schema = new Schema({
|
|||||||
shadowVisibility: { type: Boolean, default: false },
|
shadowVisibility: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// export default environmentModel;
|
|
||||||
const environmentModel = (db: string) => {
|
const environmentModel = (db: string) => {
|
||||||
return MainModel(db, "environments", environmentSchema, "environments")
|
return MainModel(db, "environments", environmentSchema, "environments");
|
||||||
};
|
};
|
||||||
export default environmentModel;
|
export default environmentModel;
|
||||||
@@ -1,25 +1,22 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
const positionSchema = new mongoose.Schema({
|
const positionSchema = new mongoose.Schema({
|
||||||
x: { type: Number }, // Optional position fields
|
x: { type: Number },
|
||||||
y: { type: Number },
|
y: { type: Number },
|
||||||
z: { type: Number },
|
z: { type: Number },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define a schema for the individual line
|
|
||||||
const Vector3 = new mongoose.Schema({
|
const Vector3 = new mongoose.Schema({
|
||||||
position: { type: positionSchema, required: false }, // Optional position
|
position: { type: positionSchema, required: false },
|
||||||
uuid: { type: String, required: false }, // Optional uuid
|
uuid: { type: String, required: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define the main schema
|
|
||||||
const LineSchema = new mongoose.Schema({
|
const LineSchema = new mongoose.Schema({
|
||||||
layer: { type: Number, required: true }, // Layer is mandatory
|
layer: { type: Number, required: true },
|
||||||
line: { type: [Vector3], required: true }, // Array of line objects
|
line: { type: [Vector3], required: true },
|
||||||
type: { type: String, required: false }, // Optional type
|
type: { type: String, required: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default lineModel;
|
|
||||||
const lineModel = (db: string) => {
|
const lineModel = (db: string) => {
|
||||||
return MainModel(db, "lines", LineSchema, "lines");
|
return MainModel(db, "lines", LineSchema, "lines");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,40 +1,4 @@
|
|||||||
// import mongoose, { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
// import MainModel from "../../../connect/mongoose.ts";
|
|
||||||
|
|
||||||
// export interface Zone extends Document {
|
|
||||||
// zoneName: string;
|
|
||||||
// // zoneUUID: string;
|
|
||||||
// zonePoints: [];
|
|
||||||
// centerPoints: [];
|
|
||||||
// isArchive: boolean;
|
|
||||||
// createdBy: string;
|
|
||||||
// sceneID: string;
|
|
||||||
// // createdBy: mongoose.Types.ObjectId;
|
|
||||||
// // sceneID: mongoose.Types.ObjectId;
|
|
||||||
// layer: number;
|
|
||||||
// }
|
|
||||||
// const zoneSchema: Schema = new Schema(
|
|
||||||
// {
|
|
||||||
// zoneName: { type: String },
|
|
||||||
// // zoneUUID: { type: String },
|
|
||||||
// createdBy: { type: String },
|
|
||||||
// sceneID: { type: String },
|
|
||||||
// layer: { type: Number },
|
|
||||||
// centerPoints: { type: Array },
|
|
||||||
// zonePoints: { type: Array },
|
|
||||||
// isArchive: { type: Boolean, default: false },
|
|
||||||
// // createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
|
|
||||||
// // sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
|
|
||||||
// },
|
|
||||||
// { timestamps: true }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const dataModel = (db: any) => {
|
|
||||||
// return MainModel(db, "Zones", zoneSchema, "Zones");
|
|
||||||
// };
|
|
||||||
// export default dataModel;
|
|
||||||
|
|
||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Zone extends Document {
|
export interface Zone extends Document {
|
||||||
@@ -48,8 +12,6 @@ export interface Zone extends Document {
|
|||||||
sceneID: string;
|
sceneID: string;
|
||||||
panelOrder: string[];
|
panelOrder: string[];
|
||||||
lockedPanel: string[];
|
lockedPanel: string[];
|
||||||
// createdBy: mongoose.Types.ObjectId;
|
|
||||||
// sceneID: mongoose.Types.ObjectId;
|
|
||||||
layer: number;
|
layer: number;
|
||||||
}
|
}
|
||||||
const zoneSchema: Schema = new Schema(
|
const zoneSchema: Schema = new Schema(
|
||||||
@@ -72,8 +34,6 @@ const zoneSchema: Schema = new Schema(
|
|||||||
default: [],
|
default: [],
|
||||||
enum: ["left", "right", "top", "bottom"],
|
enum: ["left", "right", "top", "bottom"],
|
||||||
},
|
},
|
||||||
// createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
|
|
||||||
// sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
|
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,87 +1,45 @@
|
|||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from '../../connect/mongoose.ts';
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
|
||||||
export interface Camera extends Document {
|
export interface Camera extends Document {
|
||||||
userId: string;
|
userId: string;
|
||||||
position: {
|
position: {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
z: number;
|
z: number;
|
||||||
}
|
};
|
||||||
target: {
|
target: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number; required: true };
|
||||||
y: { type: Number, required: true },
|
y: { type: Number; required: true };
|
||||||
z: { type: Number, required: true }
|
z: { type: Number; required: true };
|
||||||
}
|
};
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number; required: true };
|
||||||
y: { type: Number, required: true },
|
y: { type: Number; required: true };
|
||||||
z: { type: Number, required: true }
|
z: { type: Number; required: true };
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const cameraSchema: Schema = new Schema({
|
const cameraSchema: Schema = new Schema({
|
||||||
userId: { type: String },
|
userId: { type: String },
|
||||||
position: {
|
position: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
},
|
},
|
||||||
target: {
|
target: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
},
|
},
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Model for MongoDB collection
|
const cameraModel = (db: string) => {
|
||||||
// const cameraModel = model<Camera>("Camera", cameraSchema);
|
return MainModel(db, "Camera", cameraSchema, "Camera");
|
||||||
|
|
||||||
// export default cameraModel;
|
|
||||||
// const cameraModel = (db: string) => {
|
|
||||||
// const mongoUrl = process.env.MONGO_URI || '';
|
|
||||||
// if (!mongoUrl) {
|
|
||||||
// throw new Error('MONGO_URI environment variable is not set');
|
|
||||||
// }
|
|
||||||
// // Connect to the database
|
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
||||||
// dbName: db, // Specify the database name here
|
|
||||||
// serverSelectionTimeoutMS: 30000,
|
|
||||||
// });
|
|
||||||
// return dbConnection.model<Camera>('Camera', cameraSchema,`Camera`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export default cameraModel;
|
|
||||||
// const cameraModel = (db: string) => {
|
|
||||||
// const mongoUrl = process.env.MONGO_URI || '';
|
|
||||||
// if (!mongoUrl) {
|
|
||||||
// throw new Error('MONGO_URI environment variable is not set');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
||||||
// dbName: db,
|
|
||||||
// serverSelectionTimeoutMS: 60000, // Increased timeout
|
|
||||||
// });
|
|
||||||
|
|
||||||
// dbConnection.on('error', (err) => {
|
|
||||||
// console.error(`MongoDB connection error for database ${db}:`, err);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// dbConnection.once('open', () => {
|
|
||||||
// console.log(`Connected to MongoDB database: ${db}`);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return dbConnection.model<Camera>('Camera', cameraSchema, 'Camera');
|
|
||||||
// };
|
|
||||||
// export default cameraModel
|
|
||||||
const cameraModel = (db:string) => {
|
|
||||||
return MainModel(db, "Camera", cameraSchema, "Camera")
|
|
||||||
};
|
};
|
||||||
export default cameraModel;
|
export default cameraModel;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
// Interface for TypeScript with PascalCase
|
|
||||||
export interface environment extends Document {
|
export interface Environment extends Document {
|
||||||
userId: string;
|
userId: string;
|
||||||
roofVisibility: boolean;
|
roofVisibility: boolean;
|
||||||
wallVisibility: boolean;
|
wallVisibility: boolean;
|
||||||
@@ -10,7 +10,6 @@ export interface environment extends Document {
|
|||||||
limitDistance: boolean;
|
limitDistance: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const environmentSchema: Schema = new Schema({
|
const environmentSchema: Schema = new Schema({
|
||||||
userId: { type: String, unique: true },
|
userId: { type: String, unique: true },
|
||||||
roofVisibility: { type: Boolean, default: false },
|
roofVisibility: { type: Boolean, default: false },
|
||||||
@@ -20,24 +19,6 @@ const environmentSchema: Schema = new Schema({
|
|||||||
limitDistance: { type: Boolean, default: true },
|
limitDistance: { type: Boolean, default: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Model for MongoDB collection
|
|
||||||
// const cameraModel = model<Camera>("Camera", cameraSchema);
|
|
||||||
|
|
||||||
// export default cameraModel;
|
|
||||||
// const environmentModel = (db: string) => {
|
|
||||||
// const mongoUrl = process.env.MONGO_URI || '';
|
|
||||||
// if (!mongoUrl) {
|
|
||||||
// throw new Error('MONGO_URI environment variable is not set');
|
|
||||||
// }
|
|
||||||
// // Connect to the database
|
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
||||||
// dbName: db, // Specify the database name here
|
|
||||||
// serverSelectionTimeoutMS: 30000,
|
|
||||||
// });
|
|
||||||
// return dbConnection.model<environment>('environments', environmentSchema,`environments`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export default environmentModel;
|
|
||||||
const environmentModel = (db: string) => {
|
const environmentModel = (db: string) => {
|
||||||
return MainModel(db, "environments", environmentSchema, "environments");
|
return MainModel(db, "environments", environmentSchema, "environments");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,43 +1,23 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
const positionSchema = new mongoose.Schema({
|
const positionSchema = new mongoose.Schema({
|
||||||
x: { type: Number, }, // Optional position fields
|
x: { type: Number },
|
||||||
y: { type: Number, },
|
y: { type: Number },
|
||||||
z: { type: Number},
|
z: { type: Number },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define a schema for the individual line
|
const Vector3 = new mongoose.Schema({
|
||||||
const Vector3 = new mongoose.Schema({
|
position: { type: positionSchema, required: false },
|
||||||
position: { type: positionSchema, required: false }, // Optional position
|
uuid: { type: String, required: false },
|
||||||
uuid: { type: String, required: false }, // Optional uuid
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Define the main schema
|
const LineSchema = new mongoose.Schema({
|
||||||
const LineSchema = new mongoose.Schema({
|
layer: { type: Number, required: true },
|
||||||
layer: { type: Number, required: true }, // Layer is mandatory
|
line: { type: [Vector3], required: true },
|
||||||
line: { type: [Vector3], required: true }, // Array of line objects
|
type: { type: String, required: false },
|
||||||
type: { type: String, required: false }, // Optional type
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Database connection and model creation
|
const lineModel = (db: string) => {
|
||||||
// const lineModel = (db: string) => {
|
return MainModel(db, "lines", LineSchema, "lines");
|
||||||
// const mongoUrl = process.env.MONGO_URI || "";
|
|
||||||
// if (!mongoUrl) {
|
|
||||||
// throw new Error("MONGO_URI environment variable is not set");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Connect to the database
|
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
||||||
// dbName: db, // Specify the database name here
|
|
||||||
// serverSelectionTimeoutMS: 30000,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Return the model
|
|
||||||
// return dbConnection.model("lines", LineSchema, "lines");
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export default lineModel;
|
|
||||||
const lineModel = (db:string) => {
|
|
||||||
return MainModel(db, "lines", LineSchema, "lines")
|
|
||||||
};
|
};
|
||||||
export default lineModel;
|
export default lineModel;
|
||||||
@@ -1,32 +1,28 @@
|
|||||||
import mongoose, { Document, ObjectId, Schema } from "mongoose";
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
export interface zoneSchema extends Document {
|
export interface ZoneSchema extends Document {
|
||||||
zoneId: string;//UUID
|
zoneId: string;
|
||||||
zoneName: string
|
zoneName: string;
|
||||||
createBy: mongoose.Types.ObjectId
|
createBy: mongoose.Types.ObjectId;
|
||||||
points: []
|
points: [];
|
||||||
layer: Number
|
layer: Number;
|
||||||
viewPortCenter: []
|
viewPortCenter: [];
|
||||||
viewPortposition: []
|
viewPortposition: [];
|
||||||
isArchive:boolean
|
isArchive: boolean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const zoneSchema: Schema = new Schema({
|
const zoneSchema: Schema = new Schema({
|
||||||
zoneId: { type: String },//UUID
|
zoneId: { type: String },
|
||||||
zoneName: { type: String },
|
zoneName: { type: String },
|
||||||
createBy: { type: Schema.Types.ObjectId, ref: "Users", },
|
createBy: { type: Schema.Types.ObjectId, ref: "Users" },
|
||||||
points: { type: Array },
|
points: { type: Array },
|
||||||
layer: { type: Number, required: true },
|
layer: { type: Number, required: true },
|
||||||
viewPortCenter: { type: Array, required: true },
|
viewPortCenter: { type: Array, required: true },
|
||||||
viewPortposition: { type: Array, required: true },
|
viewPortposition: { type: Array, required: true },
|
||||||
isArchive:{type:Boolean,default:false}
|
isArchive: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// export default zoneModel;
|
|
||||||
const zoneModel = (db: string) => {
|
const zoneModel = (db: string) => {
|
||||||
return MainModel(db, "zones", zoneSchema, "zones")
|
return MainModel(db, "zones", zoneSchema, "zones");
|
||||||
};
|
};
|
||||||
export default zoneModel;
|
export default zoneModel;
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
import { Schema, Document, Types } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
import {User} from "../user-Model.ts";
|
import { User } from "../user-Model.ts";
|
||||||
|
|
||||||
export interface Project extends Document {
|
export interface Project extends Document {
|
||||||
projectUuid: string;
|
projectUuid: string;
|
||||||
projectName: string;
|
projectName: string;
|
||||||
createdBy: User["_id"];
|
createdBy: User["_id"];
|
||||||
isArchive: boolean
|
isArchive: boolean;
|
||||||
thumbnail: string
|
thumbnail: string;
|
||||||
sharedUsers: []
|
sharedUsers: [];
|
||||||
|
|
||||||
}
|
}
|
||||||
const projectSchema:Schema = new Schema({
|
const projectSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
projectUuid: { type: String, required: true },
|
projectUuid: { type: String, required: true },
|
||||||
projectName: { type: String },
|
projectName: { type: String },
|
||||||
thumbnail: { type: String },
|
thumbnail: { type: String },
|
||||||
isArchive: { type: Boolean,default:false },
|
isArchive: { type: Boolean, default: false },
|
||||||
createdBy: { type: Schema.Types.ObjectId, ref: "user" },
|
createdBy: { type: Schema.Types.ObjectId, ref: "user" },
|
||||||
sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }],
|
sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }],
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
}, { timestamps: true })
|
);
|
||||||
|
|
||||||
const projectModel = (db: string) => {
|
const projectModel = (db: string) => {
|
||||||
return MainModel(db, "Projects", projectSchema, "Projects");
|
return MainModel(db, "Projects", projectSchema, "Projects");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default projectModel;
|
export default projectModel;
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Action extends Document {
|
export interface Action extends Document {
|
||||||
pointsUUID: string;
|
pointsUUID: string;
|
||||||
// actionUUID: string;
|
|
||||||
isArchive: string;
|
isArchive: string;
|
||||||
// sceneID: string;
|
|
||||||
// eventData: {
|
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -19,13 +16,11 @@ export interface Action extends Document {
|
|||||||
start: string;
|
start: string;
|
||||||
end: string;
|
end: string;
|
||||||
buffer: number;
|
buffer: number;
|
||||||
// };
|
|
||||||
}
|
}
|
||||||
const actionSchema: Schema = new Schema(
|
const actionSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
pointsUUID: { type: String },
|
pointsUUID: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
// actionUUID: { type: String },
|
|
||||||
uuid: { type: String, default: "" },
|
uuid: { type: String, default: "" },
|
||||||
name: { type: String },
|
name: { type: String },
|
||||||
type: { type: String },
|
type: { type: String },
|
||||||
|
|||||||
@@ -1,179 +1,178 @@
|
|||||||
// models/Product.ts
|
import { Schema, Document } from "mongoose";
|
||||||
import mongoose, { Schema, Document, Types } from "mongoose";
|
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
interface AssetEventSchema {
|
interface AssetEventSchema {
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
||||||
};
|
}
|
||||||
|
|
||||||
interface TriggerSchema {
|
interface TriggerSchema {
|
||||||
triggerUuid: string;
|
triggerUuid: string;
|
||||||
triggerName: string;
|
triggerName: string;
|
||||||
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
||||||
delay: number;
|
delay: number;
|
||||||
triggeredAsset: {
|
triggeredAsset: {
|
||||||
triggeredModel: { modelName: string, modelUuid: string };
|
triggeredModel: { modelName: string; modelUuid: string };
|
||||||
triggeredPoint: { pointName: string, pointUuid: string };
|
triggeredPoint: { pointName: string; pointUuid: string };
|
||||||
triggeredAction: { actionName: string, actionUuid: string };
|
triggeredAction: { actionName: string; actionUuid: string };
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConveyorPointSchema {
|
interface ConveyorPointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "default" | "spawn" | "swap" | "despawn";
|
actionType: "default" | "spawn" | "swap" | "despawn";
|
||||||
material: string;
|
material: string;
|
||||||
delay: number | "inherit";
|
delay: number | "inherit";
|
||||||
spawnInterval: number | "inherit";
|
spawnInterval: number | "inherit";
|
||||||
spawnCount: number | "inherit";
|
spawnCount: number | "inherit";
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VehiclePointSchema {
|
interface VehiclePointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "travel";
|
actionType: "travel";
|
||||||
material: string | null;
|
material: string | null;
|
||||||
unLoadDuration: number;
|
unLoadDuration: number;
|
||||||
loadCapacity: number;
|
loadCapacity: number;
|
||||||
pickUpPoint: { x: number; y: number, z: number } | null;
|
pickUpPoint: { x: number; y: number; z: number } | null;
|
||||||
unLoadPoint: { x: number; y: number, z: number } | null;
|
unLoadPoint: { x: number; y: number; z: number } | null;
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RoboticArmPointSchema {
|
interface RoboticArmPointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
actions: {
|
actions: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "pickAndPlace";
|
actionType: "pickAndPlace";
|
||||||
process: { startPoint: [number, number, number]; endPoint: [number, number, number] };
|
process: {
|
||||||
triggers: TriggerSchema[];
|
startPoint: [number, number, number];
|
||||||
}[];
|
endPoint: [number, number, number];
|
||||||
|
};
|
||||||
|
triggers: TriggerSchema[];
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MachinePointSchema {
|
interface MachinePointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "process";
|
actionType: "process";
|
||||||
processTime: number;
|
processTime: number;
|
||||||
swapMaterial: string;
|
swapMaterial: string;
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StoragePointSchema {
|
interface StoragePointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "storage";
|
actionType: "storage";
|
||||||
materials: { materialName: string; materialId: string; }[];
|
materials: { materialName: string; materialId: string }[];
|
||||||
storageCapacity: number;
|
storageCapacity: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConveyorEventSchema extends AssetEventSchema {
|
interface ConveyorEventSchema extends AssetEventSchema {
|
||||||
type: "transfer";
|
type: "transfer";
|
||||||
speed: number;
|
speed: number;
|
||||||
points: ConveyorPointSchema[];
|
points: ConveyorPointSchema[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VehicleEventSchema extends AssetEventSchema {
|
interface VehicleEventSchema extends AssetEventSchema {
|
||||||
type: "vehicle";
|
type: "vehicle";
|
||||||
speed: number;
|
speed: number;
|
||||||
point: VehiclePointSchema;
|
point: VehiclePointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RoboticArmEventSchema extends AssetEventSchema {
|
interface RoboticArmEventSchema extends AssetEventSchema {
|
||||||
type: "roboticArm";
|
type: "roboticArm";
|
||||||
speed: number;
|
speed: number;
|
||||||
point: RoboticArmPointSchema;
|
point: RoboticArmPointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MachineEventSchema extends AssetEventSchema {
|
interface MachineEventSchema extends AssetEventSchema {
|
||||||
type: "machine";
|
type: "machine";
|
||||||
// speed: number;
|
point: MachinePointSchema;
|
||||||
point: MachinePointSchema;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StorageEventSchema extends AssetEventSchema {
|
interface StorageEventSchema extends AssetEventSchema {
|
||||||
type: "storageUnit";
|
type: "storageUnit";
|
||||||
// speed: number;
|
point: StoragePointSchema;
|
||||||
point: StoragePointSchema;
|
|
||||||
}
|
}
|
||||||
interface IPointModel extends Document {
|
interface IPointModel extends Document {
|
||||||
modelUuid:String,
|
modelUuid: String;
|
||||||
modelName:String,
|
modelName: String;
|
||||||
position:String,
|
position: String;
|
||||||
rotation:String,
|
rotation: String;
|
||||||
state:String,
|
state: String;
|
||||||
productId:String,
|
productId: String;
|
||||||
isArchive:boolean,
|
isArchive: boolean;
|
||||||
type: "transfer" | "vehicle" | "roboticArm" | "machine" |"storageUnit";
|
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
||||||
speed: number;
|
speed: number;
|
||||||
point: VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema
|
point:
|
||||||
points: ConveyorEventSchema[]
|
| VehicleEventSchema
|
||||||
|
| RoboticArmEventSchema
|
||||||
|
| MachineEventSchema
|
||||||
|
| StorageEventSchema;
|
||||||
|
points: ConveyorEventSchema[];
|
||||||
}
|
}
|
||||||
// type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;
|
|
||||||
|
|
||||||
|
|
||||||
const BaseEventSchema = new Schema<IPointModel>(
|
const BaseEventSchema = new Schema<IPointModel>(
|
||||||
{
|
{
|
||||||
modelUuid: { type: String, required: true },
|
modelUuid: { type: String, required: true },
|
||||||
modelName: { type: String, required: true },
|
modelName: { type: String, required: true },
|
||||||
position: { type: [Number], required: true },
|
position: { type: [Number], required: true },
|
||||||
rotation: { type: [Number], required: true },
|
rotation: { type: [Number], required: true },
|
||||||
speed: { type: Number,},
|
speed: { type: Number },
|
||||||
state: {
|
state: {
|
||||||
type: String,
|
type: String,
|
||||||
enum: ["idle", "running", "stopped", "disabled", "error"],
|
enum: ["idle", "running", "stopped", "disabled", "error"],
|
||||||
default: "idle"
|
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 }
|
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) => {
|
const EventsDataModel = (db: string) => {
|
||||||
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EventsDataModel;
|
export default EventsDataModel;
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
// import mongoose, { Schema, Document, model } from "mongoose";
|
|
||||||
// import MainModel from "../../connect/mongoose.ts";
|
|
||||||
|
|
||||||
// export interface ProductFlow extends Document {
|
|
||||||
// productName: string;
|
|
||||||
// ProductData: [
|
|
||||||
// {
|
|
||||||
// AssetName: string;
|
|
||||||
// Assetuuid: string;
|
|
||||||
// paths: {
|
|
||||||
// Points: [
|
|
||||||
// {
|
|
||||||
// pointuuid: string;
|
|
||||||
// actions: [mongoose.Types.ObjectId];
|
|
||||||
// triggers: [mongoose.Types.ObjectId];
|
|
||||||
// position: [];
|
|
||||||
// rotation: [number];
|
|
||||||
// connections: {
|
|
||||||
// source: {
|
|
||||||
// // modelUUID: { type: String };
|
|
||||||
// pointUUID: string;
|
|
||||||
// };
|
|
||||||
// targets: [
|
|
||||||
// {
|
|
||||||
// // modelUUID: { type: String };
|
|
||||||
// pointUUID: string;
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
// // endPoint: {
|
|
||||||
// // pointuuid: string;
|
|
||||||
// // actions: [mongoose.Types.ObjectId];
|
|
||||||
// // triggers: [mongoose.Types.ObjectId];
|
|
||||||
// // position: [];
|
|
||||||
// // rotation: [];
|
|
||||||
// // };
|
|
||||||
// };
|
|
||||||
// isArchive: false;
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
// isArchive: false;
|
|
||||||
// }
|
|
||||||
// const productFlowSchema: Schema = new Schema(
|
|
||||||
// {
|
|
||||||
// productName: { type: String },
|
|
||||||
// ProductData: [
|
|
||||||
// {
|
|
||||||
// AssetName: { type: String },
|
|
||||||
// Assetuuid: { type: String },
|
|
||||||
// paths: {
|
|
||||||
// Points: [
|
|
||||||
// {
|
|
||||||
// pointuuid: { type: String },
|
|
||||||
// actions: [
|
|
||||||
// { type: mongoose.Schema.Types.ObjectId, ref: "Actions" },
|
|
||||||
// ],
|
|
||||||
// triggers: [
|
|
||||||
// { type: mongoose.Schema.Types.ObjectId, ref: "Triggers" },
|
|
||||||
// ],
|
|
||||||
// connections: {
|
|
||||||
// source: {
|
|
||||||
// // modelUUID: { type: String };
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// targets: [
|
|
||||||
// {
|
|
||||||
// // modelUUID: { type: String };
|
|
||||||
// pointUUID: { type: String },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// position: { type: Array },
|
|
||||||
// rotation: {
|
|
||||||
// type: [Number],
|
|
||||||
// validate: {
|
|
||||||
// validator: function (value: number[]) {
|
|
||||||
// return value && value.length > 0; // Ensures it's only stored if it has values
|
|
||||||
// },
|
|
||||||
// message: "Rotation array should not be empty",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// isArchive: { type: Boolean, default: false },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// { timestamps: true }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const productFlowModel = (db: any) => {
|
|
||||||
// return MainModel(db, "ProductFlow", productFlowSchema, "ProductFlow");
|
|
||||||
// };
|
|
||||||
// export default productFlowModel;
|
|
||||||
@@ -1,22 +1,18 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
export interface product extends Document {
|
export interface Product extends Document {
|
||||||
productName: string;
|
productName: string;
|
||||||
productId: string;
|
productId: string;
|
||||||
eventsData: [];
|
eventsData: [];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Product Schema
|
|
||||||
const ProductSchema = new Schema({
|
const ProductSchema = new Schema({
|
||||||
productName: { type: String, required: true },
|
productName: { type: String, required: true },
|
||||||
productId: { type: String, required: true },
|
productId: { type: String, required: true },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const ProductModel = (db: string) => {
|
const ProductModel = (db: string) => {
|
||||||
return MainModel(db, "Product", ProductSchema, "Product");
|
return MainModel(db, "Product", ProductSchema, "Product");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Trigger extends Document {
|
export interface Trigger extends Document {
|
||||||
pointsUUID: string;
|
pointsUUID: string;
|
||||||
// triggerUUID: string;
|
|
||||||
isArchive: string;
|
isArchive: string;
|
||||||
// sceneID: string;
|
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -16,7 +14,6 @@ const triggerSchema: Schema = new Schema(
|
|||||||
{
|
{
|
||||||
pointsUUID: { type: String },
|
pointsUUID: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
// triggerUUID: { type: String },
|
|
||||||
uuid: { type: String, default: "" },
|
uuid: { type: String, default: "" },
|
||||||
name: { type: String },
|
name: { type: String },
|
||||||
type: { type: String },
|
type: { type: String },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../connect/mongoose.ts";
|
import MainModel from "../connect/mongoose.ts";
|
||||||
export interface User extends Document {
|
export interface User extends Document {
|
||||||
userName: String;
|
userName: String;
|
||||||
@@ -7,9 +7,8 @@ export interface User extends Document {
|
|||||||
|
|
||||||
role: String;
|
role: String;
|
||||||
profilePicture: String;
|
profilePicture: String;
|
||||||
isShare:Boolean,
|
isShare: Boolean;
|
||||||
activeStatus:string
|
activeStatus: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
const signupschema: Schema = new Schema({
|
const signupschema: Schema = new Schema({
|
||||||
userName: {
|
userName: {
|
||||||
@@ -33,37 +32,19 @@ const signupschema: Schema = new Schema({
|
|||||||
},
|
},
|
||||||
profilePicture: {
|
profilePicture: {
|
||||||
type: String,
|
type: String,
|
||||||
// default: "default-profile-picture.jpg"
|
|
||||||
},
|
},
|
||||||
isShare:{
|
isShare: {
|
||||||
type:Boolean,
|
type: Boolean,
|
||||||
default:false
|
default: false,
|
||||||
},
|
},
|
||||||
activeStatus:{
|
activeStatus: {
|
||||||
type:String,
|
type: String,
|
||||||
enum: ["online", "offline"],
|
enum: ["online", "offline"],
|
||||||
default: "offline"
|
default: "offline",
|
||||||
}
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
// const userModel = (db: string) => {
|
|
||||||
// const mongoUrl = process.env.MONGO_URI || "";
|
|
||||||
// if (!mongoUrl) {
|
|
||||||
// throw new Error("MONGO_URI environment variable is not set");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Connect to the database
|
const userModel = (db: string) => {
|
||||||
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
return MainModel(db, "Users", signupschema, "Users");
|
||||||
// dbName: db, // Specify the database name here
|
|
||||||
// serverSelectionTimeoutMS: 30000,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Return the model
|
|
||||||
// return dbConnection.model("Users", signupschema, "Users");
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export default userModel;
|
|
||||||
const userModel = (db:string) => {
|
|
||||||
return MainModel(db, "Users", signupschema, "Users")
|
|
||||||
};
|
};
|
||||||
export default userModel;
|
export default userModel;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Widget3d extends Document {
|
export interface Widget3d extends Document {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface floatingWidget extends Document {
|
export interface FloatingWidget extends Document {
|
||||||
className: string;
|
className: string;
|
||||||
iconName: string;
|
iconName: string;
|
||||||
header: string;
|
header: string;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Panel extends Document {
|
export interface Panel extends Document {
|
||||||
// zoneId: mongoose.Types.ObjectId;
|
|
||||||
zoneId: string;
|
zoneId: string;
|
||||||
panelName: string;
|
panelName: string;
|
||||||
widgets: [mongoose.Types.ObjectId];
|
widgets: [mongoose.Types.ObjectId];
|
||||||
@@ -10,8 +9,7 @@ export interface Panel extends Document {
|
|||||||
}
|
}
|
||||||
const panelSchema: Schema = new Schema(
|
const panelSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
// zoneId: { type: mongoose.Schema.Types.ObjectId, ref: "Zone" },
|
zoneId: { type: String },
|
||||||
zoneId: { type: String },
|
|
||||||
panelName: { type: String },
|
panelName: { type: String },
|
||||||
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface Template extends Document {
|
export interface Template extends Document {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface widget extends Document {
|
export interface Widget extends Document {
|
||||||
widgetName: string;
|
widgetName: string;
|
||||||
widgetside: string;
|
widgetside: string;
|
||||||
widgetID: string;
|
widgetID: string;
|
||||||
@@ -17,7 +17,7 @@ export interface widget extends Document {
|
|||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
zoneId:string
|
zoneId: string;
|
||||||
}
|
}
|
||||||
const widgetSchema: Schema = new Schema(
|
const widgetSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
@@ -36,7 +36,7 @@ const widgetSchema: Schema = new Schema(
|
|||||||
fontWeight: { type: String },
|
fontWeight: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||||
zoneId:{ type: String }
|
zoneId: { type: String },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
import { MongoClient } from 'mongodb'
|
import { MongoClient } from "mongodb";
|
||||||
export default async function mongoAdminCreation() {
|
export default async function mongoAdminCreation() {
|
||||||
const uri = process.env.MONGO_URI!; // Replace with your MongoDB URI
|
const uri = process.env.MONGO_URI!;
|
||||||
const client = new MongoClient(uri);
|
const client = new MongoClient(uri);
|
||||||
const user = {
|
const user = {
|
||||||
user:"admin",
|
user: "admin",
|
||||||
pwd: process.env.MONGO_PASSWORD!,
|
pwd: process.env.MONGO_PASSWORD!,
|
||||||
roles: [{ role: "root", db: process.env.MONGO_AUTH_DB || "admin" }],
|
roles: [{ role: "root", db: process.env.MONGO_AUTH_DB || "admin" }],
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
const db = client.db('admin'); // Specify the actual database where the user should be created
|
const db = client.db("admin");
|
||||||
|
|
||||||
// Check if the user already exists
|
const userExists = await db
|
||||||
const userExists = await db.collection('system.users').findOne({ user: user.user});
|
.collection("system.users")
|
||||||
|
.findOne({ user: user.user });
|
||||||
|
|
||||||
if (userExists) {
|
if (userExists) {
|
||||||
console.log(`User ${user} already exists`);
|
console.log(`User ${user} already exists`);
|
||||||
return; // Exit if the user already exists
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create the user
|
|
||||||
await db.command({ createUser: user.user, pwd: user.pwd, roles: user.roles });
|
|
||||||
console.log("User created successfully!")
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error creating user:",error);
|
|
||||||
} finally {
|
|
||||||
await client.close();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// mongoAdminCreation
|
await db.command({
|
||||||
|
createUser: user.user,
|
||||||
|
pwd: user.pwd,
|
||||||
|
roles: user.roles,
|
||||||
|
});
|
||||||
|
console.log("User created successfully!");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating user:", error);
|
||||||
|
} finally {
|
||||||
|
await client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,31 +1,33 @@
|
|||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from "express";
|
||||||
import * as Jwt from 'jsonwebtoken'; // Correct way to import jsonwebtoken
|
import * as Jwt from "jsonwebtoken";
|
||||||
|
|
||||||
// Define a new interface extending Request
|
|
||||||
interface AuthenticatedRequest extends Request {
|
interface AuthenticatedRequest extends Request {
|
||||||
user?: {
|
user?: {
|
||||||
email: string;
|
email: string;
|
||||||
// Add more fields as needed based on your JWT payload
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const tokenGenerator = (email: string) => {
|
const tokenGenerator = (email: string) => {
|
||||||
const token = Jwt.sign({ email: email }, "Milestone", {
|
const token = Jwt.sign({ email: email }, "Milestone", {
|
||||||
expiresIn: "3hours",
|
expiresIn: "3hours",
|
||||||
});
|
});
|
||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
const tokenValidator = (req: AuthenticatedRequest, res: Response, next: NextFunction): void => {
|
const tokenValidator = (
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): void => {
|
||||||
const token: string | undefined = req.headers.token as string | undefined;
|
const token: string | undefined = req.headers.token as string | undefined;
|
||||||
if (!token) {
|
if (!token) {
|
||||||
res.status(403).json({
|
res.status(403).json({
|
||||||
msg: "No token present",
|
msg: "No token present",
|
||||||
});
|
});
|
||||||
return; // Make sure to return after sending a response
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const decoded = Jwt.verify(token,"Milestone") as { email: string }; // adjust if your JWT payload has more fields
|
const decoded = Jwt.verify(token, "Milestone") as { email: string };
|
||||||
req.user = decoded;
|
req.user = decoded;
|
||||||
next();
|
next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -35,4 +37,4 @@ const tokenValidator = (req: AuthenticatedRequest, res: Response, next: NextFunc
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { tokenValidator,tokenGenerator };
|
export { tokenValidator, tokenGenerator };
|
||||||
|
|||||||
@@ -1,80 +1,87 @@
|
|||||||
import projectModel from "../../model/project/project-model.ts";
|
import projectModel from "../../model/project/project-model.ts";
|
||||||
import userModel from "../../model/user-Model.ts";
|
import userModel from "../../model/user-Model.ts";
|
||||||
import { Types } from 'mongoose';
|
import { Types } from "mongoose";
|
||||||
interface CreateProjectInput {
|
interface CreateProjectInput {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectUuid: string;
|
projectUuid: string;
|
||||||
createdBy: string; // user ID
|
createdBy: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization:string
|
organization: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createProject = async (data: CreateProjectInput) => {
|
export const createProject = async (data: CreateProjectInput) => {
|
||||||
console.log('data: ', data);
|
try {
|
||||||
try {
|
const {
|
||||||
const{projectName,projectUuid,createdBy,thumbnail,sharedUsers,organization}=data
|
projectName,
|
||||||
console.log('createdBy: ', typeof createdBy);
|
projectUuid,
|
||||||
const userExisting =await existingUser(createdBy,organization)
|
createdBy,
|
||||||
if (!userExisting)
|
thumbnail,
|
||||||
{
|
sharedUsers,
|
||||||
return {
|
organization,
|
||||||
status: "user_not_found",
|
} = data;
|
||||||
};
|
const userExisting = await existingUser(createdBy, organization);
|
||||||
|
if (!userExisting) {
|
||||||
|
return {
|
||||||
|
status: "user_not_found",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const projectExisting = await existingProject(projectUuid, organization);
|
||||||
|
|
||||||
}
|
if (projectExisting) {
|
||||||
const projectExisting = await existingProject(projectUuid, organization);
|
return {
|
||||||
console.log('projectExisting: ', projectExisting);
|
status: "project_exists",
|
||||||
|
project: projectExisting,
|
||||||
if (projectExisting) {
|
};
|
||||||
return {
|
|
||||||
status: "project_exists",
|
|
||||||
project: projectExisting,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const project = await projectModel(organization).create({
|
|
||||||
projectName: projectName,
|
|
||||||
projectUuid: projectUuid,
|
|
||||||
createdBy: createdBy,
|
|
||||||
thumbnail: thumbnail || "",
|
|
||||||
sharedUsers: sharedUsers || [],
|
|
||||||
isArchive: false,
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
status: "success",
|
|
||||||
project: project,
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.log('error: ', error);
|
|
||||||
return {
|
|
||||||
exists: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const project = await projectModel(organization).create({
|
||||||
|
projectName: projectName,
|
||||||
|
projectUuid: projectUuid,
|
||||||
|
createdBy: createdBy,
|
||||||
|
thumbnail: thumbnail || "",
|
||||||
|
sharedUsers: sharedUsers || [],
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
status: "success",
|
||||||
|
project: project,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
exists: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const existingProject = async (projectUuid: string,organization:string) => {
|
export const existingProject = async (
|
||||||
console.log("projectUuid",typeof projectUuid);
|
projectUuid: string,
|
||||||
const projectData= await projectModel(organization).findOne({projectUuid:projectUuid,isArchive:false})
|
organization: string
|
||||||
console.log('projectData: ', projectData);
|
) => {
|
||||||
return projectData
|
const projectData = await projectModel(organization).findOne({
|
||||||
|
projectUuid: projectUuid,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
return projectData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const existingUser = async (createdBy: string, organization: string) => {
|
export const existingUser = async (createdBy: string, organization: string) => {
|
||||||
console.log('createdBy: ', typeof createdBy);
|
if (!Types.ObjectId.isValid(createdBy)) {
|
||||||
if (!Types.ObjectId.isValid(createdBy)) {
|
return null;
|
||||||
console.log('Invalid ObjectId format');
|
}
|
||||||
return null;
|
const userData = await userModel(organization).findOne({
|
||||||
}
|
_id: createdBy,
|
||||||
const userData = await userModel(organization).findOne({
|
});
|
||||||
_id: createdBy,
|
return userData;
|
||||||
});
|
};
|
||||||
console.log('userData:', userData);
|
|
||||||
return userData; // ✅ Make sure you return it
|
export const archiveProject = async (
|
||||||
};
|
projectId: string,
|
||||||
|
organization: string
|
||||||
|
) => {
|
||||||
export const archiveProject = async (projectId: string,organization:string) => {
|
return await projectModel(organization).findByIdAndUpdate(
|
||||||
return await projectModel(organization).findByIdAndUpdate(projectId, { isArchive: true }, { new: true });
|
projectId,
|
||||||
|
{ isArchive: true },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ const doc = {
|
|||||||
description: "Description",
|
description: "Description",
|
||||||
},
|
},
|
||||||
host: "185.100.212.76:5000",
|
host: "185.100.212.76:5000",
|
||||||
// host: "192.168.0.102:5000",
|
|
||||||
// basePath: "/api/v1",
|
|
||||||
schemes: ["http"],
|
schemes: ["http"],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ ARG NODE_VERSION=lts
|
|||||||
FROM node:${NODE_VERSION}-alpine AS development
|
FROM node:${NODE_VERSION}-alpine AS development
|
||||||
# Use production node environment by default.
|
# Use production node environment by default.
|
||||||
|
|
||||||
ENV NODE_ENV development
|
ENV NODE_ENV = development
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
RUN npm install -g tsx
|
RUN npm install -g tsx --ignore-scripts
|
||||||
|
|
||||||
COPY package.json /usr/src/app/package.json
|
COPY package.json /usr/src/app/package.json
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ COPY package.json /usr/src/app/package.json
|
|||||||
# COPY package-lock.json /usr/src/app/package-lock.json
|
# COPY package-lock.json /usr/src/app/package-lock.json
|
||||||
|
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install --ignore-scripts
|
||||||
|
|
||||||
# Run the application as a non-root user.
|
# Run the application as a non-root user.
|
||||||
USER root
|
USER root
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
|
import express from "express";
|
||||||
import express from "express"
|
|
||||||
import { Response, Request } from "express";
|
import { Response, Request } from "express";
|
||||||
import http from "http";
|
import http from "http";
|
||||||
import dotenv from "dotenv"; // Import dotenv
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@@ -12,8 +11,8 @@ const app = express();
|
|||||||
const PORT = process.env.SOCKET_PORT;
|
const PORT = process.env.SOCKET_PORT;
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
app.get('/', (req: Request, res: Response) => {
|
app.get("/", (req: Request, res: Response) => {
|
||||||
res.send('Hello, I am Major-Dwinzo RealTime!');
|
res.send("Hello, I am Major-Dwinzo RealTime!");
|
||||||
});
|
});
|
||||||
|
|
||||||
initSocketServer(server);
|
initSocketServer(server);
|
||||||
|
|||||||
@@ -1,208 +1,6 @@
|
|||||||
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||||
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
|
||||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
|
||||||
|
|
||||||
// export const setAssetModel = async (data: any) => {
|
|
||||||
// const {
|
|
||||||
// modelUuid,
|
|
||||||
// modelName,
|
|
||||||
// position,
|
|
||||||
// rotation,
|
|
||||||
// eventData,
|
|
||||||
// modelfileID,
|
|
||||||
// isLocked,
|
|
||||||
// isVisible,
|
|
||||||
// organization,
|
|
||||||
// } = data;
|
|
||||||
// try {
|
|
||||||
// const findvalue = await assetModel(organization).findOne({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// // modelName: modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (findvalue) {
|
|
||||||
// const updatevalue = await assetModel(organization).findOneAndUpdate(
|
|
||||||
// { modelUuid: modelUuid, isArchive: false },
|
|
||||||
// {
|
|
||||||
// modelName: modelName,
|
|
||||||
// position: position,
|
|
||||||
// rotation: rotation,
|
|
||||||
// isVisible: isVisible,
|
|
||||||
// isLocked: isLocked,
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model updated successfully",
|
|
||||||
// data: updatevalue,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// let assetData: any = {
|
|
||||||
// modelUuid,
|
|
||||||
// modelName,
|
|
||||||
// position,
|
|
||||||
// modelfileID,
|
|
||||||
// rotation,
|
|
||||||
// isLocked,
|
|
||||||
// isVisible,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if (eventData) {
|
|
||||||
// if (eventData.type === "Conveyor") {
|
|
||||||
// assetData.speed = eventData.speed;
|
|
||||||
// } else if (eventData.type === "Vehicle") {
|
|
||||||
// assetData.speed = eventData.points.speed;
|
|
||||||
// if (!eventData.points) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "Vehicle points must be a single object",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// // if (eventData.points.rotation) {
|
|
||||||
// // return {
|
|
||||||
// // success: false,
|
|
||||||
// // message: "Rotation is not allowed for Vehicle points",
|
|
||||||
// // organization: organization,
|
|
||||||
// // };
|
|
||||||
// // }
|
|
||||||
// if (eventData.points.triggers) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "triggers is not allowed for Vehicle points",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// assetData.points = eventData.points;
|
|
||||||
// assetData.type = eventData.type;
|
|
||||||
// }
|
|
||||||
// const assetDoc = await assetModel(organization).create(assetData);
|
|
||||||
// await assetDoc.save();
|
|
||||||
// let assetDatas;
|
|
||||||
// if (assetDoc.type === "Conveyor") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// speed: assetDoc.speed,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else if (assetDoc.type === "Vehicle") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else if (assetDoc.type === "ArmBot") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else if (assetDoc.type === "StaticMachine") {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// eventData: {
|
|
||||||
// points: assetDoc.points,
|
|
||||||
// type: assetDoc.type,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// assetDatas = {
|
|
||||||
// modelUuid: assetDoc.modelUuid,
|
|
||||||
// modelName: assetDoc.modelName,
|
|
||||||
// modelfileID: assetDoc.modelfileID,
|
|
||||||
// position: assetDoc.position,
|
|
||||||
// rotation: assetDoc.rotation,
|
|
||||||
// isLocked: assetDoc.isLocked,
|
|
||||||
// isVisible: assetDoc.isVisible,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model created successfully",
|
|
||||||
// data: assetDatas,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// } catch (error: any) {
|
|
||||||
// // console.error("Error creating flooritems:", error);
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: error?.message || "Error occurred while ModelAsset",
|
|
||||||
// error,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const deleteAssetModel = async (data: any) => {
|
|
||||||
// const { modelUuid, modelName, organization } = data;
|
|
||||||
// try {
|
|
||||||
// const findValue = await assetModel(organization).findOneAndDelete({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// modelName: modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!findValue) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "model not found",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// return {
|
|
||||||
// success: true,
|
|
||||||
// message: "Model deleted successfully",
|
|
||||||
// data: findValue,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// // console.error('Error get flooritems:', error);
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "Failed to delete asset",
|
|
||||||
// error,
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//update 30/4..//setAssetModel//deleteAssetModel...........
|
|
||||||
export const setAssetModel = async (data: any) => {
|
export const setAssetModel = async (data: any) => {
|
||||||
const {
|
const {
|
||||||
modelUuid,
|
modelUuid,
|
||||||
@@ -218,7 +16,6 @@ export const setAssetModel = async (data: any) => {
|
|||||||
try {
|
try {
|
||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modelUuid: modelUuid,
|
modelUuid: modelUuid,
|
||||||
// modelName: modelName,
|
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -256,49 +53,16 @@ export const setAssetModel = async (data: any) => {
|
|||||||
if (eventData?.type === "Conveyor") {
|
if (eventData?.type === "Conveyor") {
|
||||||
assetData.eventData = {
|
assetData.eventData = {
|
||||||
type: eventData.type,
|
type: eventData.type,
|
||||||
// point:undefined,
|
|
||||||
points: eventData.points,
|
points: eventData.points,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
assetData.eventData = {
|
assetData.eventData = {
|
||||||
type: eventData.type,
|
type: eventData.type,
|
||||||
point: eventData.point,
|
point: eventData.point,
|
||||||
// points: undefined
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (eventData) {
|
|
||||||
|
|
||||||
// if (eventData.type === "Conveyor") {
|
|
||||||
// assetData.speed = eventData.speed;
|
|
||||||
// } else if (eventData.type === "Vehicle") {
|
|
||||||
// assetData.speed = eventData.points.speed;
|
|
||||||
// if (!eventData.points) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "Vehicle points must be a single object",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// // if (eventData.points.rotation) {
|
|
||||||
// // return {
|
|
||||||
// // success: false,
|
|
||||||
// // message: "Rotation is not allowed for Vehicle points",
|
|
||||||
// // organization: organization,
|
|
||||||
// // };
|
|
||||||
// // }
|
|
||||||
// if (eventData.points.triggers) {
|
|
||||||
// return {
|
|
||||||
// success: false,
|
|
||||||
// message: "triggers is not allowed for Vehicle points",
|
|
||||||
// organization: organization,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// assetData.points = eventData.points;
|
|
||||||
// assetData.type = eventData.type;
|
|
||||||
// }
|
|
||||||
const assetDoc = await assetModel(organization).create(assetData);
|
const assetDoc = await assetModel(organization).create(assetData);
|
||||||
await assetDoc.save();
|
await assetDoc.save();
|
||||||
let assetDatas;
|
let assetDatas;
|
||||||
@@ -374,7 +138,6 @@ export const setAssetModel = async (data: any) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// console.error("Error creating flooritems:", error);
|
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while ModelAsset",
|
message: error?.message || "Error occurred while ModelAsset",
|
||||||
@@ -392,11 +155,7 @@ export const deleteAssetModel = async (data: any) => {
|
|||||||
modelName,
|
modelName,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
// const findmodelValue = await assetModel(organization).findOne({
|
|
||||||
// modelUuid: modelUuid,
|
|
||||||
// modelName: modelName,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
if (!asset) {
|
if (!asset) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -416,22 +175,11 @@ export const deleteAssetModel = async (data: any) => {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
await EventsDataModel(organization).updateMany(
|
||||||
{ modelUuid },
|
{ modelUuid },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
// const findProductEventData = await EventsDataModel(organization).find(modelUuid)
|
|
||||||
// console.log('findProductEventData: ', findProductEventData);
|
|
||||||
// if (findProductEventData) {
|
|
||||||
// for (const event of findProductEventData) {
|
|
||||||
// console.log("Event ID:", event);
|
|
||||||
// await EventsDataModel(organization).updateMany(
|
|
||||||
// { modelUuid },
|
|
||||||
// { $set: { isArchive: true } }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Model deleted successfully",
|
message: "Model deleted successfully",
|
||||||
@@ -439,7 +187,6 @@ export const deleteAssetModel = async (data: any) => {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.error('Error get flooritems:', error);
|
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Failed to delete asset",
|
message: "Failed to delete asset",
|
||||||
@@ -466,14 +213,11 @@ export const replaceEventDatas = async (data: any) => {
|
|||||||
if (existingModel.type === "Conveyor") {
|
if (existingModel.type === "Conveyor") {
|
||||||
speed = eventData?.speed;
|
speed = eventData?.speed;
|
||||||
}
|
}
|
||||||
// if (existingModel.type === "Vehicle") {
|
|
||||||
// speed = eventData?.points?.speed;
|
|
||||||
// }
|
|
||||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modelUuid, isArchive: false },
|
{ modelUuid, isArchive: false },
|
||||||
{
|
{
|
||||||
points: eventData?.points,
|
points: eventData?.points,
|
||||||
// speed: speed,
|
|
||||||
type: eventData?.type || existingModel?.type,
|
type: eventData?.type || existingModel?.type,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
|
|||||||
@@ -1,53 +1,94 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
|
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||||
|
|
||||||
export const setFloorItems = async (data: any) => {
|
export const setFloorItems = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
const { modelfileID,modelUuid, modelName, position, rotation,isLocked,isVisible, organization } = data
|
const {
|
||||||
|
modelfileID,
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
organization,
|
||||||
|
} = data;
|
||||||
|
|
||||||
|
const findvalue = await floorItemsModel(organization).findOne({
|
||||||
|
modelUuid: modelUuid,
|
||||||
|
modelName: modelName,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (findvalue) {
|
||||||
|
const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
|
||||||
|
{ modelUuid: modelUuid, modelName: modelName },
|
||||||
|
{
|
||||||
|
position: position,
|
||||||
|
rotation: rotation,
|
||||||
|
isVisible: isVisible,
|
||||||
|
isLocked: isLocked,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "flooritems updated",
|
||||||
|
data: updatevalue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const newValue = await floorItemsModel(organization).create({
|
||||||
|
modelUuid,
|
||||||
|
modelName,
|
||||||
|
modelfileID,
|
||||||
|
position,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
});
|
||||||
|
|
||||||
const findvalue = await floorItemsModel(organization).findOne({ modelUuid: modelUuid, modelName: modelName })
|
return {
|
||||||
|
success: true,
|
||||||
if (findvalue) {
|
message: "flooritem created",
|
||||||
|
data: newValue,
|
||||||
const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
|
organization: organization,
|
||||||
{ modelUuid: modelUuid, modelName: modelName }, { position: position, rotation: rotation ,isVisible:isVisible,isLocked:isLocked}, { new: true });
|
};
|
||||||
return { success: true, message: 'flooritems updated', data: updatevalue,organization:organization }
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
const newValue = await floorItemsModel(organization).create({ modelUuid, modelName, modelfileID,position, rotation,isLocked,isVisible });
|
|
||||||
|
|
||||||
|
|
||||||
return { success: true, message: 'flooritem created', data: newValue,organization:organization }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating flooritems:', error);
|
|
||||||
return { success: false, message: 'Error creating or updating camera', error }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const deleteFloorItems = async (data: any)=>{
|
|
||||||
try {
|
|
||||||
const { modelUuid,modelName,organization } = data;
|
|
||||||
|
|
||||||
const findValue = await floorItemsModel(organization).findOneAndDelete({modelUuid:modelUuid,modelName:modelName})
|
|
||||||
if (!findValue) {
|
|
||||||
return { success: false, message: 'model not found',organization:organization }
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return { success: true, message: 'flooritem deleted', data: findValue,organization:organization }
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error get flooritems:', error);
|
|
||||||
return { success: false, message: 'Failed to delete flooritems', error }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating flooritems:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error creating or updating camera",
|
||||||
|
error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteFloorItems = async (data: any) => {
|
||||||
|
try {
|
||||||
|
const { modelUuid, modelName, organization } = data;
|
||||||
|
|
||||||
|
const findValue = await floorItemsModel(organization).findOneAndDelete({
|
||||||
|
modelUuid: modelUuid,
|
||||||
|
modelName: modelName,
|
||||||
|
});
|
||||||
|
if (!findValue) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "model not found",
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "flooritem deleted",
|
||||||
|
data: findValue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get flooritems:", error);
|
||||||
|
return { success: false, message: "Failed to delete flooritems", error };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,60 +1,96 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
|
import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
|
||||||
|
|
||||||
|
|
||||||
export const setWallItems = async (data: any) => {
|
export const setWallItems = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
const { modelUuid,modelfileID, modelName, position, type, csgposition, csgscale, quaternion, scale, organization } = data
|
const {
|
||||||
|
modelUuid,
|
||||||
|
modelfileID,
|
||||||
|
modelName,
|
||||||
|
position,
|
||||||
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
organization,
|
||||||
|
} = data;
|
||||||
|
|
||||||
|
const findvalue = await wallItenmModel(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 wallItenmModel(organization).findOneAndUpdate(
|
||||||
{ modelUuid: modelUuid },
|
{ modelUuid: modelUuid },
|
||||||
{
|
{
|
||||||
modelName,
|
modelName,
|
||||||
position,
|
position,
|
||||||
type,
|
type,
|
||||||
csgposition,
|
csgposition,
|
||||||
csgscale,
|
csgscale,
|
||||||
quaternion,
|
quaternion,
|
||||||
scale,
|
scale,
|
||||||
},
|
},
|
||||||
{ new: true } // Return the updated document
|
{ new: true }
|
||||||
);
|
);
|
||||||
return { success: true, message: 'wallIitem updated', data: updatevalue, organization: organization }
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "wallIitem updated",
|
||||||
} else {
|
data: updatevalue,
|
||||||
|
organization: organization,
|
||||||
const newValue = await wallItenmModel(organization).create({ modelUuid,modelfileID, modelName, position, type, csgposition, csgscale, quaternion, scale });
|
};
|
||||||
return { success: true, message: 'wallIitem created', data: newValue, organization: organization }
|
} else {
|
||||||
}
|
const newValue = await wallItenmModel(organization).create({
|
||||||
|
modelUuid,
|
||||||
// Send response with the created document
|
modelfileID,
|
||||||
} catch (error) {
|
modelName,
|
||||||
console.error('Error creating wallIitem:', error);
|
position,
|
||||||
return { success: false, message: 'Error creating or updating camera', error }
|
type,
|
||||||
|
csgposition,
|
||||||
|
csgscale,
|
||||||
|
quaternion,
|
||||||
|
scale,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "wallIitem created",
|
||||||
|
data: newValue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.error("Error creating wallIitem:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error creating or updating camera",
|
||||||
|
error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const deleteWallItems = async (data: any) => {
|
export const deleteWallItems = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
const { modelUuid, modelName, organization } = data;
|
const { modelUuid, modelName, organization } = data;
|
||||||
|
|
||||||
|
|
||||||
const findValue = await wallItenmModel(organization).findOneAndDelete({ modelUuid: modelUuid, modelName: modelName })
|
|
||||||
if (!findValue) {
|
|
||||||
return { success: false, message: 'model not found', organization: organization }
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return { success: true, message: 'wallitem deleted', data: findValue, organization: organization }
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error get wallitem:', error);
|
|
||||||
return { success: false, message: 'Failed to delete wallitem', error }
|
|
||||||
|
|
||||||
|
const findValue = await wallItenmModel(organization).findOneAndDelete({
|
||||||
|
modelUuid: modelUuid,
|
||||||
|
modelName: modelName,
|
||||||
|
});
|
||||||
|
if (!findValue) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "model not found",
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "wallitem deleted",
|
||||||
|
data: findValue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.error("Error get wallitem:", error);
|
||||||
|
return { success: false, message: "Failed to delete wallitem", error };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,31 +1,45 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import { Socket } from "socket.io";
|
|
||||||
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
||||||
|
|
||||||
export const createCamera = async (data: any,) => {
|
export const createCamera = async (data: any) => {
|
||||||
const { userId, position, target, organization,rotation } = data
|
const { userId, position, target, organization, rotation } = data;
|
||||||
try {
|
try {
|
||||||
|
const findCamera = await cameraModel(organization).findOne({
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
if (findCamera) {
|
||||||
|
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
||||||
|
{ userId: userId },
|
||||||
|
{ position: position, target: target, rotation: rotation },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Camera updated",
|
||||||
|
data: updateCamera,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const newCamera = await cameraModel(organization).create({
|
||||||
|
userId,
|
||||||
|
position,
|
||||||
|
target,
|
||||||
|
rotation,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
success: true,
|
||||||
if (findCamera) {
|
message: "Camera created",
|
||||||
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
data: newCamera,
|
||||||
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
|
organization: organization,
|
||||||
// io.emit('cameraUpdateResponse', { success: true, message: 'Camera updated', data: updateCamera });
|
};
|
||||||
return { success: true, message: 'Camera updated', data: updateCamera,organization:organization}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation })
|
|
||||||
|
|
||||||
return { success: true, message: 'Camera created' ,data:newCamera,organization:organization}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating camera:', error);
|
|
||||||
return { success: false, message: 'Error creating or updating camera', error, organization:organization}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.error("Error creating camera:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error creating or updating camera",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,33 +1,55 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
||||||
|
|
||||||
|
export const setEnvironment = async (data: any) => {
|
||||||
|
const {
|
||||||
|
userId,
|
||||||
|
roofVisibility,
|
||||||
|
wallVisibility,
|
||||||
|
shadowVisibility,
|
||||||
|
organization,
|
||||||
|
} = data;
|
||||||
|
try {
|
||||||
|
const findvalue = await environmentModel(organization).findOne({
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
if (findvalue) {
|
||||||
|
const updatevalue = await environmentModel(organization).findOneAndUpdate(
|
||||||
|
{ userId: userId },
|
||||||
|
{
|
||||||
|
roofVisibility: roofVisibility,
|
||||||
|
wallVisibility: wallVisibility,
|
||||||
|
shadowVisibility: shadowVisibility,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "evironments updated",
|
||||||
|
data: updatevalue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const newValue = await environmentModel(organization).create({
|
||||||
|
userId,
|
||||||
|
roofVisibility,
|
||||||
|
wallVisibility,
|
||||||
|
shadowVisibility,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
export const setEnvironment = async (data: any,) => {
|
success: true,
|
||||||
const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = data
|
message: "evironments created",
|
||||||
try {
|
data: newValue,
|
||||||
|
organization: organization,
|
||||||
const findvalue = await environmentModel(organization).findOne({ userId: userId })
|
};
|
||||||
if (findvalue) {
|
|
||||||
const updatevalue = await environmentModel(organization).findOneAndUpdate(
|
|
||||||
{ userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility,shadowVisibility:shadowVisibility }, { new: true });
|
|
||||||
// res.status(201).json(updatevalue);
|
|
||||||
return { success: true, message: 'evironments updated', data: updatevalue,organization:organization }
|
|
||||||
|
|
||||||
} else {
|
|
||||||
const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility,shadowVisibility });
|
|
||||||
|
|
||||||
return { success: true, message: 'evironments created', data: newValue,organization:organization }
|
|
||||||
// res.status(201).json(newValue);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Send response with the created document
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating evironments:', error);
|
|
||||||
return { success: false, message: 'Error creating or updating evironments', error ,organization:organization}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.error("Error creating evironments:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error creating or updating evironments",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,100 +1,140 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import lineModel from "../../../shared/model/lines/lines-Model.ts";
|
import lineModel from "../../../shared/model/lines/lines-Model.ts";
|
||||||
|
|
||||||
|
export const createLineItems = async (data: any) => {
|
||||||
|
const { organization, layer, line, type } = data;
|
||||||
|
try {
|
||||||
|
const newLine = await lineModel(organization).create({ layer, line, type });
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "line create",
|
||||||
|
data: newLine,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error create line",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const updateLineItems = async (data: any) => {
|
||||||
|
const { organization, uuid, position } = data;
|
||||||
|
try {
|
||||||
|
const updateResult = await lineModel(organization).updateMany(
|
||||||
|
{ "line.uuid": uuid },
|
||||||
|
{ $set: { "line.$.position": position } }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "line updated",
|
||||||
|
data: { uuid: uuid, position: position },
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating Lines:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Error updating line",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const createLineItems = async (data: any)=>{
|
export const deleteLineItems = async (data: any) => {
|
||||||
const {organization,layer,line,type}=data
|
const { organization, line } = data;
|
||||||
try {
|
try {
|
||||||
const newLine = await lineModel(organization).create({ layer,line,type });
|
const inputUuids = line.map((item: any) => item.uuid);
|
||||||
return { success: true, message: 'line create', data: newLine,organization:organization }
|
|
||||||
|
|
||||||
// Send response with the created document
|
const findValue = await lineModel(organization).findOneAndDelete({
|
||||||
} catch (error) {
|
"line.uuid": { $all: inputUuids },
|
||||||
|
});
|
||||||
|
|
||||||
return { success: false, message: 'Error create line', error,organization:organization }
|
if (!findValue) {
|
||||||
|
return {
|
||||||
}
|
success: false,
|
||||||
|
message: "line not found",
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "line deleted",
|
||||||
|
data: findValue,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
export const updateLineItems = async (data: any)=>{
|
} catch (error) {
|
||||||
const {organization,uuid,position,}=data
|
console.error("Error delete Lines:", error);
|
||||||
try {
|
return {
|
||||||
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
success: false,
|
||||||
// Update the position of the line matching the uuid
|
message: "Failed to delete line",
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
error,
|
||||||
{ 'line.uuid': uuid }, // Filter: Find the line with the given uuid
|
organization: organization,
|
||||||
{ $set: { 'line.$.position': position } } // Update the position and type
|
};
|
||||||
);
|
}
|
||||||
return { success: true, message: 'line updated', data: {uuid:uuid,position:position},organization:organization }
|
};
|
||||||
|
export const deleteLayer = async (data: any) => {
|
||||||
|
const { organization, layer } = data;
|
||||||
|
try {
|
||||||
|
const findValue = await lineModel(organization).find({ layer: layer });
|
||||||
|
|
||||||
// Send response with the created document
|
if (!findValue) {
|
||||||
} catch (error) {
|
return { success: false, message: "layer not found" };
|
||||||
console.error('Error creating Lines:', error);
|
} else {
|
||||||
return { success: false, message: 'Error updating line', error,organization:organization }
|
await lineModel(organization).deleteMany({ layer: layer });
|
||||||
}
|
|
||||||
|
const updateResult = await lineModel(organization).updateMany(
|
||||||
|
{ layer: { $gt: layer } },
|
||||||
|
{ $inc: { layer: -1 } }
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "layer deleted",
|
||||||
|
data: layer,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error delete layer:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Failed to delete layer",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const deleteLinPoiteItems = async (data: any) => {
|
||||||
|
const { organization, uuid } = data;
|
||||||
|
try {
|
||||||
|
const findValue = await lineModel(organization).deleteMany({
|
||||||
|
"line.uuid": uuid,
|
||||||
|
});
|
||||||
|
|
||||||
export const deleteLineItems = async (data: any)=>{
|
if (!findValue) {
|
||||||
const {organization,line}=data
|
return {
|
||||||
try {
|
success: false,
|
||||||
|
message: "line not found",
|
||||||
const inputUuids = line.map((item: any) => item.uuid);
|
organization: organization,
|
||||||
|
};
|
||||||
// const findValue = await lineModel(organization).findOneAndDelete({
|
} else {
|
||||||
|
return {
|
||||||
// line: { $elemMatch: { uuid: { $in: inputUuids } } },
|
success: true,
|
||||||
// });
|
message: "point deleted",
|
||||||
const findValue = await lineModel(organization).findOneAndDelete({
|
data: uuid,
|
||||||
"line.uuid": { $all: inputUuids } // Ensure all UUIDs are present in the `line` key
|
organization: organization,
|
||||||
});
|
};
|
||||||
|
|
||||||
if (!findValue) {
|
|
||||||
return { success: false, message: 'line not found',organization:organization }
|
|
||||||
} else {
|
|
||||||
return { success: true, message: 'line deleted', data: findValue,organization:organization }
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error delete Lines:', error);
|
|
||||||
return { success: false, message: 'Failed to delete line', error ,organization:organization}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export const deleteLayer = async (data: any)=>{
|
|
||||||
const {organization,layer}=data
|
|
||||||
try {
|
|
||||||
|
|
||||||
const findValue = await lineModel(organization).find({ layer: layer });
|
|
||||||
|
|
||||||
if (!findValue) {
|
|
||||||
return { success: false, message: 'layer not found' }
|
|
||||||
} else {
|
|
||||||
await lineModel(organization).deleteMany({ layer: layer });
|
|
||||||
|
|
||||||
// Update documents with layer greater than -1
|
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
|
||||||
{ layer: { $gt:layer} },
|
|
||||||
{ $inc: { layer: -1 } } // Example operation: decrementing layer by 1
|
|
||||||
);
|
|
||||||
return { success: true, message: 'layer deleted', data: layer,organization:organization }
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error delete layer:', error);
|
|
||||||
return { success: false, message: 'Failed to delete layer', error ,organization:organization}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export const deleteLinPoiteItems = async (data: any)=>{
|
|
||||||
const {organization,uuid}=data
|
|
||||||
try {
|
|
||||||
|
|
||||||
|
|
||||||
const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid })
|
|
||||||
|
|
||||||
if (!findValue) {
|
|
||||||
return { success: false, message: 'line not found',organization:organization }
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return { success: true, message: 'point deleted', data: uuid ,organization:organization}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error delete Lines:', error);
|
|
||||||
return { success: false, message: 'Failed to delete point', error ,organization:organization}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error delete Lines:", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Failed to delete point",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
import zoneModel from "../../../shared/model/builder/lines/zone-Model.ts";
|
|
||||||
|
|
||||||
// export const setZone = async (data: any) => {
|
|
||||||
// const { organization, userId, zoneData } = data
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// console.log('data: ', data);
|
|
||||||
// const zoneId = zoneData.zoneId
|
|
||||||
// const points = zoneData.points
|
|
||||||
// const zoneName = zoneData.zoneName
|
|
||||||
// const layer = zoneData.layer
|
|
||||||
// const viewPortCenter = zoneData.viewPortCenter
|
|
||||||
// const viewPortposition = zoneData.viewPortposition
|
|
||||||
// const sceneID = zoneData.sceneID
|
|
||||||
|
|
||||||
// const existingZone = await zoneModel(organization).findOne({
|
|
||||||
// zoneId: zoneId,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!existingZone) {
|
|
||||||
// const newZone = await zoneModel(organization).create({
|
|
||||||
// zoneName: zoneName,
|
|
||||||
// zoneId: zoneId,
|
|
||||||
// zonePoints: points,
|
|
||||||
// viewPortposition: viewPortposition,
|
|
||||||
// viewPortCenter: viewPortCenter,
|
|
||||||
// createdBy: userId,
|
|
||||||
// layer: layer,
|
|
||||||
// sceneID: sceneID,
|
|
||||||
// });
|
|
||||||
// if (newZone)
|
|
||||||
// return { success: true, message: 'zone created', data: newZone, organization: organization }
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// const replaceZone = await zoneModel(organization).findOneAndUpdate(
|
|
||||||
// { zoneId: zoneId, isArchive: false },
|
|
||||||
// {
|
|
||||||
// zonePoints: points,
|
|
||||||
// viewPortposition: viewPortposition,
|
|
||||||
// viewPortCenter: viewPortCenter,
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
// if (!replaceZone)
|
|
||||||
// return { success: false, message: 'Zone not updated',organization: organization }
|
|
||||||
// else
|
|
||||||
// return { success: true, message: 'zone updated', data: replaceZone, organization: organization }
|
|
||||||
|
|
||||||
// }
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return { success: false, message: 'Zone not found', error,organization: organization }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// export const deleteZone = async (data: any) => {
|
|
||||||
// const { organization, userId, zoneId } = data
|
|
||||||
// try {
|
|
||||||
// const existingZone = await zoneModel(organization).findOne({
|
|
||||||
// zoneId: zoneId,
|
|
||||||
// isArchive: false,
|
|
||||||
// });
|
|
||||||
// if (!existingZone) {
|
|
||||||
// return { success: true, message: 'Invalid zone ID', organization: organization }
|
|
||||||
// } else {
|
|
||||||
// const deleteZone = await zoneModel(organization).findOneAndUpdate(
|
|
||||||
// { zoneId: zoneId, isArchive: false },
|
|
||||||
// {
|
|
||||||
// isArchive: true,
|
|
||||||
// },
|
|
||||||
// { new: true }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (deleteZone) {
|
|
||||||
// return { success: true, message: 'zone deleted', data: deleteZone, organization: organization }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (error: any) {
|
|
||||||
// return { success: false, message: 'Zone not found', error,organization: organization }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -5,137 +5,131 @@ import panelModel from "../../../shared/model/vizualization/panelmodel.ts";
|
|||||||
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
||||||
import widgetModel from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetModel from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
export const setZone = async (data: any) => {
|
export const setZone = async (data: any) => {
|
||||||
const { organization, userId, zoneData } = data
|
const { organization, userId, zoneData } = data;
|
||||||
try {
|
try {
|
||||||
const zoneId = zoneData.zoneId
|
const zoneId = zoneData.zoneId;
|
||||||
const points = zoneData.points
|
const points = zoneData.points;
|
||||||
const zoneName = zoneData.zoneName
|
const zoneName = zoneData.zoneName;
|
||||||
const layer = zoneData.layer
|
const layer = zoneData.layer;
|
||||||
const viewPortCenter = zoneData.viewPortCenter
|
const viewPortCenter = zoneData.viewPortCenter;
|
||||||
const viewPortposition = zoneData.viewPortposition
|
const viewPortposition = zoneData.viewPortposition;
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
if (findZoneId) {
|
zoneId: zoneId,
|
||||||
const updateZone = await zoneModel(organization).findOneAndUpdate(
|
});
|
||||||
{ zoneId: zoneId }, { points: points, viewPortposition: viewPortposition, viewPortCenter: viewPortCenter }, { new: true }
|
if (findZoneId) {
|
||||||
).select("-_id -__v")
|
const updateZone = await zoneModel(organization)
|
||||||
return { success: true, message: 'zone updated', data: updateZone, organization: organization }
|
.findOneAndUpdate(
|
||||||
} else {
|
{ zoneId: zoneId },
|
||||||
const zoneCreate = await zoneModel(organization).create({
|
{
|
||||||
zoneId, createdBy: userId, zoneName: zoneName, points, layer, viewPortCenter, viewPortposition
|
points: points,
|
||||||
})
|
viewPortposition: viewPortposition,
|
||||||
const createdZone = await zoneModel(organization)
|
viewPortCenter: viewPortCenter,
|
||||||
.findById(zoneCreate._id)
|
},
|
||||||
.select('-_id -__v')
|
{ new: true }
|
||||||
.lean();
|
)
|
||||||
return { success: true, message: 'zone created', data: createdZone, organization: organization }
|
.select("-_id -__v");
|
||||||
}
|
return {
|
||||||
} catch (error) {
|
success: true,
|
||||||
console.log('error: ', error);
|
message: "zone updated",
|
||||||
return { success: false, message: 'Zone not found', error , organization: organization}
|
data: updateZone,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
|
zoneId,
|
||||||
|
createdBy: userId,
|
||||||
|
zoneName: zoneName,
|
||||||
|
points,
|
||||||
|
layer,
|
||||||
|
viewPortCenter,
|
||||||
|
viewPortposition,
|
||||||
|
});
|
||||||
|
const createdZone = await zoneModel(organization)
|
||||||
|
.findById(zoneCreate._id)
|
||||||
|
.select("-_id -__v")
|
||||||
|
.lean();
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "zone created",
|
||||||
|
data: createdZone,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Zone not found",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const deleteZone = async (data: any) => {
|
export const deleteZone = async (data: any) => {
|
||||||
const { organization, userId, zoneId } = data
|
const { organization, userId, zoneId } = data;
|
||||||
try {
|
try {
|
||||||
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
if (findZoneId) {
|
||||||
|
const deleteZone = await zoneModel(organization)
|
||||||
|
.findOneAndDelete({ zoneId: zoneId, createdBy: userId })
|
||||||
|
.select("-_id -__v");
|
||||||
|
if (deleteZone) {
|
||||||
|
const panels = await panelModel(organization).find({ zoneId });
|
||||||
|
console.log("panels: ", panels);
|
||||||
|
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
const allWidgetIds = panels.reduce((ids: string[], panel: any) => {
|
||||||
if (findZoneId) {
|
return ids.concat(panel.widgets || []);
|
||||||
const deleteZone = await zoneModel(organization).findOneAndDelete(
|
}, []);
|
||||||
{ zoneId: zoneId, createdBy: userId }
|
|
||||||
).select("-_id -__v")
|
|
||||||
if (deleteZone) {
|
|
||||||
const panels = await panelModel(organization).find({ zoneId });
|
|
||||||
console.log('panels: ', panels);
|
|
||||||
|
|
||||||
// Collect all widget IDs from all panels
|
await widgetModel(organization).updateMany(
|
||||||
const allWidgetIds = panels.reduce((ids: string[], panel: any) => {
|
{ _id: { $in: allWidgetIds } },
|
||||||
return ids.concat(panel.widgets || []);
|
{ $set: { isArchive: true } }
|
||||||
}, []);
|
);
|
||||||
|
|
||||||
// Soft delete all widgets
|
await panelModel(organization).updateMany(
|
||||||
await widgetModel(organization).updateMany(
|
{ zoneId },
|
||||||
{ _id: { $in: allWidgetIds } },
|
{ $set: { isArchive: true } }
|
||||||
{ $set: { isArchive: true } }
|
);
|
||||||
);
|
|
||||||
|
|
||||||
// Soft delete all panels for the zone
|
await Promise.all([
|
||||||
await panelModel(organization).updateMany(
|
widget3dModel(organization).updateMany(
|
||||||
{ zoneId },
|
{ zoneId },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
),
|
||||||
|
templateModel(organization).updateMany(
|
||||||
|
{ zoneId },
|
||||||
|
{ $set: { isArchive: true } }
|
||||||
|
),
|
||||||
|
floatWidgetModel(organization).updateMany(
|
||||||
|
{ zoneId },
|
||||||
|
{ $set: { isArchive: true } }
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Soft delete from other models
|
return {
|
||||||
await Promise.all([
|
success: true,
|
||||||
widget3dModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
message: "zone deleted",
|
||||||
templateModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
data: deleteZone,
|
||||||
floatWidgetModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
organization: organization,
|
||||||
]);
|
};
|
||||||
}
|
} else {
|
||||||
|
return {
|
||||||
return { success: true, message: 'zone deleted', data: deleteZone, organization: organization }
|
success: true,
|
||||||
} else {
|
message: "Invalid zone ID",
|
||||||
|
organization: organization,
|
||||||
return { success: true, message: 'Invalid zone ID', organization: organization }
|
};
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log('error: ', error);
|
|
||||||
return { success: false, message: 'Zone not found', error, organization: organization }
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
// export const zoneDatasDeleted = async (data: { organization: string; userId: string; zoneId: string }) => {
|
console.log("error: ", error);
|
||||||
// const { organization, userId, zoneId } = data;
|
return {
|
||||||
// console.log('data: ', data);
|
success: false,
|
||||||
|
message: "Zone not found",
|
||||||
// try {
|
error,
|
||||||
// const findZone = await zoneModel(organization).findOne({ zoneId });
|
organization: organization,
|
||||||
|
};
|
||||||
// if (!findZone) {
|
}
|
||||||
// return { success: false, message: 'Invalid zone ID', organization };
|
};
|
||||||
// }
|
|
||||||
|
|
||||||
// // Soft delete the zone
|
|
||||||
// const deleteZone = await zoneModel(organization).findOneAndDelete(
|
|
||||||
// { zoneId, createdBy: userId },
|
|
||||||
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (deleteZone) {
|
|
||||||
// const panels = await panelModel(organization).find({ zoneId });
|
|
||||||
// console.log('panels: ', panels);
|
|
||||||
|
|
||||||
// // Collect all widget IDs from all panels
|
|
||||||
// const allWidgetIds = panels.reduce((ids: string[], panel: any) => {
|
|
||||||
// return ids.concat(panel.widgets || []);
|
|
||||||
// }, []);
|
|
||||||
// console.log('allWidgetIds: ', allWidgetIds);
|
|
||||||
|
|
||||||
// // Soft delete all widgets
|
|
||||||
// await widgetModel(organization).updateMany(
|
|
||||||
// { _id: { $in: allWidgetIds } },
|
|
||||||
// { $set: { isArchive: true } }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Soft delete all panels for the zone
|
|
||||||
// await panelModel(organization).updateMany(
|
|
||||||
// { zoneId },
|
|
||||||
// { $set: { isArchive: true } }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Soft delete from other models
|
|
||||||
// await Promise.all([
|
|
||||||
// widget3dModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
|
||||||
// templateModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
|
||||||
// floatWidgetModel(organization).updateMany({ zoneId }, { $set: { isArchive: true } }),
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log("Zone and associated data archived");
|
|
||||||
// return { success: true, message: 'Zone and associated data archived', data: deleteZone, organization };
|
|
||||||
|
|
||||||
// return { success: true, message: 'Zone and associated data deleted', data: deleteZone, organization };
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('Zone deletion error:', error);
|
|
||||||
// return { success: false, message: 'An error occurred while deleting the zone', error, organization };
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|||||||
@@ -1,137 +1,109 @@
|
|||||||
import cameraModel from "../../../shared/model/camera/camera-Model.ts"
|
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
||||||
import userModel from "../../../shared/model/user-Model.ts"
|
import userModel from "../../../shared/model/user-Model.ts";
|
||||||
|
|
||||||
export const activeUsers = async (data: any) => {
|
export const activeUsers = async (data: any) => {
|
||||||
const {organization}=data
|
const { organization } = data;
|
||||||
// console.log('data: ', data);
|
try {
|
||||||
try {
|
if (data && data.email) {
|
||||||
if (data && data.email) {
|
const email = data.email;
|
||||||
|
const organization = email.split("@")[1].split(".")[0];
|
||||||
|
|
||||||
const email = data.email
|
const findUser = await userModel(organization).findOne({ email });
|
||||||
const organization = email.split("@")[1].split(".")[0]
|
|
||||||
|
|
||||||
const findUser = await userModel(organization).findOne({email})
|
if (findUser) {
|
||||||
|
const updateActiveStatus = await userModel(
|
||||||
|
organization
|
||||||
|
).findOneAndUpdate(
|
||||||
|
{ email: findUser.email },
|
||||||
|
{ activeStatus: "online" },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
if (findUser) {
|
if (updateActiveStatus) {
|
||||||
const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:findUser.email},{activeStatus:"online"},{new:true})
|
const cameraDatas = await cameraModel(organization)
|
||||||
|
.findOne({ userId: updateActiveStatus._id })
|
||||||
|
.select("position target rotation -_id");
|
||||||
|
|
||||||
if (updateActiveStatus) {
|
if (cameraDatas) {
|
||||||
const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id})
|
const result = {
|
||||||
.select("position target rotation -_id");
|
position: cameraDatas.position,
|
||||||
|
target: cameraDatas.target,
|
||||||
|
rotation: cameraDatas.rotation,
|
||||||
|
userData: {
|
||||||
|
_id: updateActiveStatus._id,
|
||||||
|
userName: updateActiveStatus.userName,
|
||||||
|
email: updateActiveStatus.email,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if (cameraDatas) {
|
return {
|
||||||
const result = {
|
success: true,
|
||||||
position: cameraDatas.position,
|
message: "user connect ",
|
||||||
target: cameraDatas.target,
|
data: result,
|
||||||
rotation: cameraDatas.rotation,
|
organization: organization,
|
||||||
userData: {
|
};
|
||||||
_id: updateActiveStatus._id,
|
}
|
||||||
userName: updateActiveStatus.userName,
|
|
||||||
email: updateActiveStatus.email,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { success: true, message: 'user connect ', data: result,organization:organization }
|
|
||||||
// return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
// console.error('Invalid data or missing email:', data);
|
|
||||||
// Handle the error or return a default value
|
|
||||||
// Example: Return an error response if the email is invalid
|
|
||||||
|
|
||||||
return { success: false, message: 'Email is missing or invalid', organization:organization }
|
|
||||||
// return res.status(400).send({ message: 'Email is missing or invalid' });
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// // return [];
|
return {
|
||||||
} catch (error:any) {
|
success: false,
|
||||||
return { success: false, message: error?.message || "Error occurred while activeUser", error, organization: organization }
|
message: "Email is missing or invalid",
|
||||||
|
organization: organization,
|
||||||
// return { success: false, message:error}
|
};
|
||||||
}
|
}
|
||||||
}
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: error?.message || "Error occurred while activeUser",
|
||||||
|
error,
|
||||||
|
organization: organization,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const activeUserOffline = async (data: any) => {
|
export const activeUserOffline = async (data: any) => {
|
||||||
|
const email = data.email;
|
||||||
|
const organization = email.split("@")[1].split(".")[0];
|
||||||
|
try {
|
||||||
|
const findUsers = await userModel(organization).findOne({ email });
|
||||||
|
if (findUsers) {
|
||||||
|
const updateActiveStatus = await userModel(organization).findOneAndUpdate(
|
||||||
|
{ email: email },
|
||||||
|
{ activeStatus: "offline" },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
if (updateActiveStatus) {
|
||||||
|
const cameraDatas = await cameraModel(organization)
|
||||||
|
.findOne({ userId: updateActiveStatus._id })
|
||||||
|
.select("position target rotation -_id");
|
||||||
|
if (cameraDatas) {
|
||||||
|
const result = {
|
||||||
|
position: cameraDatas.position,
|
||||||
|
target: cameraDatas.target,
|
||||||
|
rotation: cameraDatas.rotation,
|
||||||
|
userData: {
|
||||||
|
_id: updateActiveStatus._id,
|
||||||
|
userName: updateActiveStatus.userName,
|
||||||
|
email: updateActiveStatus.email,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
const email = data.email
|
success: true,
|
||||||
const organization = email.split("@")[1].split(".")[0]
|
message: "user disconnect",
|
||||||
try {
|
data: result,
|
||||||
|
organization: organization,
|
||||||
const findUsers = await userModel(organization).findOne({email})
|
};
|
||||||
// console.log('findUsers: ', findUsers);
|
|
||||||
if (findUsers) {
|
|
||||||
const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:email},{activeStatus:"offline"},{new:true})
|
|
||||||
// console.log('updateActiveStatus: ',updateActiveStatus);
|
|
||||||
if (updateActiveStatus) {
|
|
||||||
const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id})
|
|
||||||
.select("position target rotation -_id");
|
|
||||||
// console.log('cameraDatas: ', cameraDatas);
|
|
||||||
if (cameraDatas) {
|
|
||||||
const result = {
|
|
||||||
position: cameraDatas.position,
|
|
||||||
target: cameraDatas.target,
|
|
||||||
rotation: cameraDatas.rotation,
|
|
||||||
userData: {
|
|
||||||
_id: updateActiveStatus._id,
|
|
||||||
userName: updateActiveStatus.userName,
|
|
||||||
email: updateActiveStatus.email,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// console.log("Formatted Result:", result);
|
|
||||||
|
|
||||||
|
|
||||||
// return result;
|
|
||||||
return { success: true, message: 'user disconnect', data: result,organization:organization }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// // return [];
|
}
|
||||||
} catch (error:any) {
|
|
||||||
return { success: false, message: error?.message || "Error occurred while activeUser", error, organization: organization }
|
|
||||||
|
|
||||||
// return { success: false, message: error}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (error: any) {
|
||||||
type OnlineUsersMap = Map<string, Set<string>>;
|
return {
|
||||||
|
success: false,
|
||||||
// export const addUserToOnlineList = async (
|
message: error?.message || "Error occurred while activeUser",
|
||||||
// organization: string,
|
error,
|
||||||
// email: string,
|
organization: organization,
|
||||||
// onlineUsers: OnlineUsersMap,
|
};
|
||||||
// socket: any,
|
}
|
||||||
// namespace: string
|
};
|
||||||
// ) => {
|
|
||||||
// if (!organization || !email) return;
|
|
||||||
// console.log('organization: ', organization);
|
|
||||||
|
|
||||||
// // Ensure the organization entry exists
|
|
||||||
// if (!onlineUsers.has(organization)) {
|
|
||||||
// onlineUsers.set(organization, new Set());
|
|
||||||
// }
|
|
||||||
// const findUser = await userModel(organization).findOne({email})
|
|
||||||
// if (!findUser) {
|
|
||||||
// return { success: false, message: "User not found", organization };
|
|
||||||
// }
|
|
||||||
// const userId = findUser._id;
|
|
||||||
// console.log(`🔍 Found user with ID: ${userId}`);
|
|
||||||
// // Add user to the online set
|
|
||||||
// onlineUsers.get(organization)!.add(userId);
|
|
||||||
|
|
||||||
// console.log(`✅ User ${userId} is online (Org: ${organization})`);
|
|
||||||
|
|
||||||
// // Emit updated online users list
|
|
||||||
// socket.emit("users:online", {
|
|
||||||
// organization,
|
|
||||||
// users: [...onlineUsers.get(organization)!],
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
|||||||
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
|
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
|
||||||
export const add3Dwidget = async (data: any,callback:any) => {
|
export const add3Dwidget = async (data: any,callback:any) => {
|
||||||
const { organization, widget, zoneId } = data;
|
const { organization, widget, zoneId } = data;
|
||||||
// console.log("data: ", data);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
|||||||
@@ -143,12 +143,11 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: "FloatWidget update unsuccessfull",
|
message: "FloatWidget update unsuccessfull",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "FloatWidget update unsuccessfull",
|
message: "FloatWidget update unsuccessfull",
|
||||||
// data: updateWidget,
|
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -162,7 +161,7 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget updated successfully",
|
message: "Widget updated successfully",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -203,7 +202,7 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "duplicate FloatWidget created successfully",
|
message: "duplicate FloatWidget created successfully",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -217,7 +216,7 @@ export const duplicatefloat = async (data: any, callback: any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while float",
|
message: error?.message || "Error occurred while float",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -256,9 +255,7 @@ export const deletefloat = async (data: any) => {
|
|||||||
{ isArchive: true },
|
{ isArchive: true },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
// if(!widgetData) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
const floatDeleteData = {
|
const floatDeleteData = {
|
||||||
floatWidgetID: findfloatWidget.floatWidgetID,
|
floatWidgetID: findfloatWidget.floatWidgetID,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const addPanel = async (data: any) => {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
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,14 +52,10 @@ export const addPanel = async (data: any) => {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// const IDdata = createdPanels.map((ID: any) => {
|
|
||||||
// return ID._id;
|
|
||||||
// });
|
|
||||||
// console.log("IDdata: ", createdPanels);
|
|
||||||
createdPanels;
|
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
return zoneAndPanelData; // If the zone and panel data retrieval fails, return the error.
|
return zoneAndPanelData;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -101,7 +97,7 @@ export const panelDelete = async (data: any) => {
|
|||||||
message: "Panel Already Deleted",
|
message: "Panel Already Deleted",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
const updatePanel = await panelSchema(organization).updateOne(
|
await panelSchema(organization).updateOne(
|
||||||
{ _id: existingPanel._id, isArchive: false },
|
{ _id: existingPanel._id, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
@@ -116,17 +112,15 @@ export const panelDelete = async (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 } }
|
||||||
);
|
);
|
||||||
|
|
||||||
// const panelDeleteDatas = await existingZone.save();
|
|
||||||
// console.log('panelDeleteDatas: ', panelDeleteDatas);
|
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
return zoneAndPanelData; // If the zone and panel data retrieval fails, return the error.
|
return zoneAndPanelData;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -146,7 +140,6 @@ export const panelDelete = async (data: any) => {
|
|||||||
};
|
};
|
||||||
export const panelClear = async (data: any) => {
|
export const panelClear = async (data: any) => {
|
||||||
const { organization, panelName, zoneId } = data;
|
const { organization, panelName, zoneId } = data;
|
||||||
console.log("data: ", data);
|
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -201,7 +194,7 @@ export const panelClear = async (data: any) => {
|
|||||||
|
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
return zoneAndPanelData; // If the zone and panel data retrieval fails, return the error.
|
return zoneAndPanelData;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -220,7 +213,6 @@ export const panelClear = async (data: any) => {
|
|||||||
};
|
};
|
||||||
export const panelLocked = async (data: any) => {
|
export const panelLocked = async (data: any) => {
|
||||||
const { organization, lockedPanel, zoneId } = data;
|
const { organization, lockedPanel, zoneId } = data;
|
||||||
console.log("data: ", data);
|
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -242,7 +234,7 @@ export const panelLocked = async (data: any) => {
|
|||||||
);
|
);
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
return zoneAndPanelData; // If the zone and panel data retrieval fails, return the error.
|
return zoneAndPanelData;
|
||||||
}
|
}
|
||||||
if (updateLockedPanel) {
|
if (updateLockedPanel) {
|
||||||
return {
|
return {
|
||||||
@@ -263,9 +255,6 @@ export const panelLocked = async (data: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const getZoneAndPanelData = async (organization: string, zoneId: string) => {
|
const getZoneAndPanelData = async (organization: string, zoneId: string) => {
|
||||||
// const { organization, zoneId, } = data
|
|
||||||
// console.log('data: ', data);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization)
|
const existingZone = await zoneSchema(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ 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 const addTemplate = async (data: any) => {
|
export const addTemplate = async (data: any) => {
|
||||||
const { organization, template, name, panelOrder, widgets, snapshot } = data;
|
const { organization, template } = data;
|
||||||
console.log("data: ", data);
|
|
||||||
try {
|
try {
|
||||||
// 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,
|
||||||
@@ -88,7 +86,6 @@ export const addTemplateZone = async (data: any) => {
|
|||||||
if (existingZone.panelOrder.length > 0) {
|
if (existingZone.panelOrder.length > 0) {
|
||||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||||
await existingZone.save();
|
await existingZone.save();
|
||||||
// Clear existing data before adding new data
|
|
||||||
const archivePanelDatas = await panelSchema(organization).find({
|
const archivePanelDatas = await panelSchema(organization).find({
|
||||||
zoneId,
|
zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -121,7 +118,7 @@ export const addTemplateZone = async (data: any) => {
|
|||||||
const missingPanels = existingTemplate.panelOrder.filter(
|
const missingPanels = existingTemplate.panelOrder.filter(
|
||||||
(panelName: string) => !existingPanelNames.includes(panelName)
|
(panelName: string) => !existingPanelNames.includes(panelName)
|
||||||
);
|
);
|
||||||
const createdPanels = await Promise.all(
|
await Promise.all(
|
||||||
missingPanels.map((panelName: any) =>
|
missingPanels.map((panelName: any) =>
|
||||||
panelSchema(organization).create({
|
panelSchema(organization).create({
|
||||||
zoneId,
|
zoneId,
|
||||||
@@ -206,7 +203,7 @@ export const addTemplateZone = async (data: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const TemplateZoneDelete = async (data: any) => {
|
export const TemplateZoneDelete = async (data: any) => {
|
||||||
const { zoneId, templateID, organization } = data;
|
const { templateID, organization } = data;
|
||||||
try {
|
try {
|
||||||
const existingTemplate = await templateModel(organization).findOne({
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
templateID: templateID,
|
templateID: templateID,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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";
|
||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
export const addWidget = async (data: any,callback:any) => {
|
export const addWidget = async (data: any, callback: any) => {
|
||||||
const { organization, panel, zoneId, widget } = data;
|
const { organization, zoneId, widget } = data;
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -32,7 +32,6 @@ export const addWidget = async (data: any,callback:any) => {
|
|||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
// widgetOrder: widget.widgetOrder,
|
|
||||||
});
|
});
|
||||||
if (existingWidget) {
|
if (existingWidget) {
|
||||||
const updateWidget = await widgetSchema(organization).findOneAndUpdate(
|
const updateWidget = await widgetSchema(organization).findOneAndUpdate(
|
||||||
@@ -52,19 +51,18 @@ export const addWidget = async (data: any,callback:any) => {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
{ upsert: true, new: true }
|
||||||
);
|
);
|
||||||
if (!updateWidget) {
|
if (!updateWidget) {
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: "Widget update unsuccessfull",
|
message: "Widget update unsuccessfull",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Widget update unsuccessfull",
|
message: "Widget update unsuccessfull",
|
||||||
// data: updateWidget,
|
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -78,7 +76,6 @@ export const addWidget = async (data: any,callback:any) => {
|
|||||||
const newWidget = await widgetSchema(organization).create({
|
const newWidget = await widgetSchema(organization).create({
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
elementType: widget.type,
|
elementType: widget.type,
|
||||||
// widgetOrder: widgetOrder,
|
|
||||||
widgetName: widget.title,
|
widgetName: widget.title,
|
||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
widgetside: widget.panel,
|
widgetside: widget.panel,
|
||||||
@@ -106,7 +103,7 @@ export const addWidget = async (data: any,callback:any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget created successfully",
|
message: "Widget created successfully",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -114,7 +111,6 @@ export const addWidget = async (data: any,callback:any) => {
|
|||||||
data: finaldata,
|
data: finaldata,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -126,7 +122,7 @@ export const addWidget = async (data: any,callback:any) => {
|
|||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: "widge not found",
|
message: "widge not found",
|
||||||
})
|
});
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "widge not found",
|
message: "widge not found",
|
||||||
@@ -165,20 +161,12 @@ export const Widgetdelete = async (data: any) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
// Find all widgets in the same panel and sort them by widgetOrder
|
await widgetSchema(organization).find({
|
||||||
const widgets = await widgetSchema(organization).find({
|
|
||||||
panelID: findWidget.panelID,
|
panelID: findWidget.panelID,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
// console.log('widgets: ', widgets);
|
|
||||||
// .sort({ widgetOrder: 1 });
|
|
||||||
|
|
||||||
// Reassign widgetOrder values
|
|
||||||
// for (let i = 0; i < widgets.length; i++) {
|
|
||||||
// widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
|
||||||
// await widgets[i].save();
|
|
||||||
// }
|
|
||||||
const panelData = await panelSchema(organization).findOne({
|
const panelData = await panelSchema(organization).findOne({
|
||||||
_id: findWidget.panelID,
|
_id: findWidget.panelID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -188,33 +176,21 @@ export const Widgetdelete = async (data: any) => {
|
|||||||
const index1 = panelData.widgets.indexOf(findWidget._id);
|
const index1 = panelData.widgets.indexOf(findWidget._id);
|
||||||
panelData.widgets.splice(index1, 1);
|
panelData.widgets.splice(index1, 1);
|
||||||
}
|
}
|
||||||
const panelDeletedata = await panelData.save();
|
await panelData.save();
|
||||||
|
|
||||||
// console.log('Widget deleted successfully: ',panelDeletedata);
|
|
||||||
// if (panelData?.widgets.includes(findWidget._id)) {
|
|
||||||
// panelData.widgets = panelData.widgets.filter(
|
|
||||||
// (id: any) => id.toString() !== findWidget._id.toString()
|
|
||||||
// );
|
|
||||||
// await panelData.save();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Fetch active widgets after deletion
|
|
||||||
const activeWidgets = await widgetSchema(organization).find({
|
const activeWidgets = await widgetSchema(organization).find({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log('activeWidgets: ', activeWidgets);
|
|
||||||
|
|
||||||
// // Format data
|
|
||||||
const formattedWidgets = activeWidgets.map((widget) => ({
|
const formattedWidgets = activeWidgets.map((widget) => ({
|
||||||
id: widget.widgetID,
|
id: widget.widgetID,
|
||||||
type: widget.elementType, // Ensure this field exists
|
type: widget.elementType,
|
||||||
title: widget.widgetName,
|
title: widget.widgetName,
|
||||||
panel: widget.widgetside,
|
panel: widget.widgetside,
|
||||||
data: {
|
data: {
|
||||||
duration: "1h",
|
duration: "1h",
|
||||||
measurements: {}, // Add actual data if available
|
measurements: {},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
const widgetData1 = {
|
const widgetData1 = {
|
||||||
|
|||||||
@@ -1,101 +1,91 @@
|
|||||||
export const EVENTS = {
|
export const EVENTS = {
|
||||||
connection: "connection",
|
connection: "connection",
|
||||||
disconnect:"disconnect",
|
disconnect: "disconnect",
|
||||||
//userActiveStatus
|
|
||||||
userConnect:"userConnectResponse",
|
|
||||||
userDisConnect:"userDisConnectResponse",
|
|
||||||
// Room management events
|
|
||||||
joinRoom: 'joinRoom',
|
|
||||||
createroom: "createRoom", // When a client joins a room
|
|
||||||
leaveRoom: 'leaveRoom', // When a client leaves a room
|
|
||||||
roomCreated: 'roomCreated', // When a new room is created
|
|
||||||
roomDeleted: 'roomDeleted', // When a room is deleted
|
|
||||||
|
|
||||||
// Camera //response
|
userConnect: "userConnectResponse",
|
||||||
setCamera: 'v1:Camera:set',
|
userDisConnect: "userDisConnectResponse",
|
||||||
cameraCreateResponse: "cameraCreateResponse", // Response for camera creation
|
|
||||||
cameraUpdateResponse: "cameraUpdateResponse", // Response for camera update
|
|
||||||
cameraError: "cameraError",
|
|
||||||
//Environment
|
|
||||||
setenvironment: "v1:Environment:set",
|
|
||||||
EnvironmentUpdateResponse: "EnvironmentUpdateResponse",
|
|
||||||
//FloorItems
|
|
||||||
setFloorItems: "v1:FloorItems:set",
|
|
||||||
FloorItemsUpdateResponse: "FloorItemsUpdateResponse",
|
|
||||||
deleteFloorItems: "v1:FloorItems:delete",
|
|
||||||
FloorItemsDeleteResponse: "FloorItemsDeleteResponse",
|
|
||||||
floorItemError: "floorItemError",
|
|
||||||
//WALLItems
|
|
||||||
setWallItems: "v1:wallItems:set",
|
|
||||||
wallItemsUpdateResponse: "wallItemsUpdateResponse",
|
|
||||||
deleteWallItems: "v1:wallItems:delete",
|
|
||||||
wallItemsDeleteResponse: "wallItemsDeleteResponse",
|
|
||||||
wallItemError: "wallItemError",
|
|
||||||
//Lines
|
|
||||||
createLine:"v1:Line:create",
|
|
||||||
createLineResponse:"Line:response:create",
|
|
||||||
updateLine:"v1:Line:update",
|
|
||||||
updateLineResponse:"Line:response:update",
|
|
||||||
deleteLine:"v1:Line:delete",
|
|
||||||
deleteLineResponse:"Line:response:delete",
|
|
||||||
deletePoint:"v1:Line:delete:point",
|
|
||||||
deletePointResponse:"Line:response:delete:point",
|
|
||||||
deleteLineLayer:"v1:Line:delete:layer",
|
|
||||||
deleteLineLayerResponse:"Line:response:delete:layer",
|
|
||||||
//zone
|
|
||||||
setZone:"v2:zone:set",
|
|
||||||
zoneUpdateResponse:"zone:response:updates",
|
|
||||||
deleteZone:"v2:zone:delete",
|
|
||||||
ZoneDeleteResponse:"zone:response:delete",
|
|
||||||
|
|
||||||
//visualization
|
joinRoom: "joinRoom",
|
||||||
//panel
|
createroom: "createRoom",
|
||||||
addPanel:"v2:viz-panel:add",
|
leaveRoom: "leaveRoom",
|
||||||
panelUpdateResponse:"viz-panel:response:updates",
|
roomCreated: "roomCreated",
|
||||||
deletePanel:"v2:viz-panel:delete",
|
roomDeleted: "roomDeleted",
|
||||||
PanelDeleteResponse:"viz-panel:response:delete",
|
|
||||||
clearPanel:"v2:viz-panel:clear",
|
|
||||||
PanelClearResponse:"viz-panel:response:clear",
|
|
||||||
lockedPanel:"v2:viz-panel:locked",
|
|
||||||
PanelLockedResponse:"viz-panel:response:locked",
|
|
||||||
|
|
||||||
//widget
|
setCamera: "v1:Camera:set",
|
||||||
addWidget:"v2:viz-widget:add",
|
cameraCreateResponse: "cameraCreateResponse",
|
||||||
widgetUpdateResponse:"viz-widget:response:updates",
|
cameraUpdateResponse: "cameraUpdateResponse",
|
||||||
deleteWidget:"v2:viz-widget:delete",
|
cameraError: "cameraError",
|
||||||
widgetDeleteResponse:"viz-widget:response:delete",
|
|
||||||
|
|
||||||
//float
|
setenvironment: "v1:Environment:set",
|
||||||
addFloat: "v2:viz-float:add",
|
EnvironmentUpdateResponse: "EnvironmentUpdateResponse",
|
||||||
floatUpdateResponse: "viz-float:response:updates",
|
|
||||||
deleteFloat: "v2:viz-float:delete",
|
|
||||||
floatDeleteResponse: "viz-float:response:delete",
|
|
||||||
duplicatefloat:"v2:viz-float:addDuplicate",
|
|
||||||
duplicatefloatUpdateResponse:"viz-float:response:addDuplicate",
|
|
||||||
|
|
||||||
//template
|
setFloorItems: "v1:FloorItems:set",
|
||||||
addTemplate:"v2:viz-template:add",
|
FloorItemsUpdateResponse: "FloorItemsUpdateResponse",
|
||||||
templateUpdateResponse:"viz-template:response:add",
|
deleteFloorItems: "v1:FloorItems:delete",
|
||||||
addTemplateZone:"v2:viz-template:addToZone",
|
FloorItemsDeleteResponse: "FloorItemsDeleteResponse",
|
||||||
addTemplateZoneResponse:"viz-template:response:addTemplateZone",
|
floorItemError: "floorItemError",
|
||||||
deleteTemplate:"v2:viz-template:deleteTemplate",
|
|
||||||
TemplateDeleteResponse:"viz-template:response:delete",
|
|
||||||
|
|
||||||
|
setWallItems: "v1:wallItems:set",
|
||||||
|
wallItemsUpdateResponse: "wallItemsUpdateResponse",
|
||||||
|
deleteWallItems: "v1:wallItems:delete",
|
||||||
|
wallItemsDeleteResponse: "wallItemsDeleteResponse",
|
||||||
|
wallItemError: "wallItemError",
|
||||||
|
|
||||||
//model-asset
|
createLine: "v1:Line:create",
|
||||||
setAssetModel: "v2:model-asset:add",
|
createLineResponse: "Line:response:create",
|
||||||
assetUpdateResponse: "model-asset:response:updates",
|
updateLine: "v1:Line:update",
|
||||||
deleteAssetModel:"v2:model-asset:delete",
|
updateLineResponse: "Line:response:update",
|
||||||
assetDeleteResponse: "model-asset:response:updates",
|
deleteLine: "v1:Line:delete",
|
||||||
assetEventData:"v2:model-asset:updateEventData",
|
deleteLineResponse: "Line:response:delete",
|
||||||
assetEventDataResponse: "model-asset:response:updateEventData",
|
deletePoint: "v1:Line:delete:point",
|
||||||
|
deletePointResponse: "Line:response:delete:point",
|
||||||
|
deleteLineLayer: "v1:Line:delete:layer",
|
||||||
|
deleteLineLayerResponse: "Line:response:delete:layer",
|
||||||
|
|
||||||
|
setZone: "v2:zone:set",
|
||||||
|
zoneUpdateResponse: "zone:response:updates",
|
||||||
|
deleteZone: "v2:zone:delete",
|
||||||
|
ZoneDeleteResponse: "zone:response:delete",
|
||||||
|
|
||||||
//3Dwidget
|
addPanel: "v2:viz-panel:add",
|
||||||
add3DWidget:"v2:viz-3D-widget:add",
|
panelUpdateResponse: "viz-panel:response:updates",
|
||||||
widget3DUpdateResponse:"viz-widget3D:response:updates",
|
deletePanel: "v2:viz-panel:delete",
|
||||||
update3dPosition:"v2:viz-3D-widget:modifyPositionRotation",
|
PanelDeleteResponse: "viz-panel:response:delete",
|
||||||
update3dPositionResponse:"viz-widget3D:response:modifyPositionRotation",
|
clearPanel: "v2:viz-panel:clear",
|
||||||
delete3DWidget:"v2:viz-3D-widget:delete",
|
PanelClearResponse: "viz-panel:response:clear",
|
||||||
widget3DDeleteResponse:"viz-widget3D:response:delete",
|
lockedPanel: "v2:viz-panel:locked",
|
||||||
}
|
PanelLockedResponse: "viz-panel:response:locked",
|
||||||
|
|
||||||
|
addWidget: "v2:viz-widget:add",
|
||||||
|
widgetUpdateResponse: "viz-widget:response:updates",
|
||||||
|
deleteWidget: "v2:viz-widget:delete",
|
||||||
|
widgetDeleteResponse: "viz-widget:response:delete",
|
||||||
|
|
||||||
|
addFloat: "v2:viz-float:add",
|
||||||
|
floatUpdateResponse: "viz-float:response:updates",
|
||||||
|
deleteFloat: "v2:viz-float:delete",
|
||||||
|
floatDeleteResponse: "viz-float:response:delete",
|
||||||
|
duplicatefloat: "v2:viz-float:addDuplicate",
|
||||||
|
duplicatefloatUpdateResponse: "viz-float:response:addDuplicate",
|
||||||
|
|
||||||
|
addTemplate: "v2:viz-template:add",
|
||||||
|
templateUpdateResponse: "viz-template:response:add",
|
||||||
|
addTemplateZone: "v2:viz-template:addToZone",
|
||||||
|
addTemplateZoneResponse: "viz-template:response:addTemplateZone",
|
||||||
|
deleteTemplate: "v2:viz-template:deleteTemplate",
|
||||||
|
TemplateDeleteResponse: "viz-template:response:delete",
|
||||||
|
|
||||||
|
setAssetModel: "v2:model-asset:add",
|
||||||
|
assetUpdateResponse: "model-asset:response:updates",
|
||||||
|
deleteAssetModel: "v2:model-asset:delete",
|
||||||
|
assetDeleteResponse: "model-asset:response:updates",
|
||||||
|
assetEventData: "v2:model-asset:updateEventData",
|
||||||
|
assetEventDataResponse: "model-asset:response:updateEventData",
|
||||||
|
|
||||||
|
add3DWidget: "v2:viz-3D-widget:add",
|
||||||
|
widget3DUpdateResponse: "viz-widget3D:response:updates",
|
||||||
|
update3dPosition: "v2:viz-3D-widget:modifyPositionRotation",
|
||||||
|
update3dPositionResponse: "viz-widget3D:response:modifyPositionRotation",
|
||||||
|
delete3DWidget: "v2:viz-3D-widget:delete",
|
||||||
|
widget3DDeleteResponse: "viz-widget3D:response:delete",
|
||||||
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user