V2 API for visualization gomathi part completed
This commit is contained in:
16
.env
16
.env
@@ -1,10 +1,10 @@
|
|||||||
MONGO_URI=mongodb://127.0.0.1:27017/
|
# MONGO_URI=mongodb://192.168.0.111/
|
||||||
MONGO_USER=mydata
|
# MONGO_USER=mydata
|
||||||
MONGO_PASSWORD=mongodb@hexr2002
|
# MONGO_PASSWORD=mongodb@hexr2002
|
||||||
MONGO_AUTH_DB=admin
|
|
||||||
# MONGO_USER=admin
|
|
||||||
# MONGO_PASSWORD=admin321
|
|
||||||
# MONGO_AUTH_DB=admin
|
# MONGO_AUTH_DB=admin
|
||||||
# MONGO_URI=mongodb://mongo/
|
MONGO_USER=admin
|
||||||
|
MONGO_PASSWORD=admin321
|
||||||
|
MONGO_AUTH_DB=admin
|
||||||
|
MONGO_URI=mongodb://mongo/
|
||||||
API_PORT=5000
|
API_PORT=5000
|
||||||
SOCKET_PORT=8001
|
SOCKET_PORT=8000
|
||||||
7
src/api-server/Routes/assetfloorRoutes.ts
Normal file
7
src/api-server/Routes/assetfloorRoutes.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import * as express from "express";
|
||||||
|
import { assetsFloorservice } from "../controller/simulation/assetsFloorservice.ts";
|
||||||
|
const router = express.Router();
|
||||||
|
router.post("/setasset", assetsFloorservice.setFloorassets);
|
||||||
|
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
||||||
|
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
||||||
|
export default router;
|
||||||
6
src/api-server/Routes/assetpointRoutes.ts
Normal file
6
src/api-server/Routes/assetpointRoutes.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import * as express from "express";
|
||||||
|
import { pointService } from "../controller/assets/pointService.ts";
|
||||||
|
const router = express.Router();
|
||||||
|
router.post("/pointSchema", pointService.addPoints);
|
||||||
|
router.get("/pointData/:modelfileID/:organization", pointService.gettypePoints);
|
||||||
|
export default router;
|
||||||
@@ -135,6 +135,7 @@ const router = express.Router();
|
|||||||
* 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/delete", widgetService.deleteWidget);
|
router.patch("/widget/delete", widgetService.deleteWidget);
|
||||||
router.get(
|
router.get(
|
||||||
"/WidgetData/:widgetID/:organization",
|
"/WidgetData/:widgetID/:organization",
|
||||||
|
|||||||
@@ -320,6 +320,8 @@ router.post("/zone/save", Zoneservice.addandUpdateZone); //Zone create and updat
|
|||||||
*/
|
*/
|
||||||
router.get("/zones/:sceneID", Zoneservice.allZones);
|
router.get("/zones/:sceneID", Zoneservice.allZones);
|
||||||
|
|
||||||
|
router.get("/pageZodeData", Zoneservice.vizAllDatas);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /ZoneVisualization/{zoneId}:
|
* /ZoneVisualization/{zoneId}:
|
||||||
|
|||||||
@@ -1,41 +1,44 @@
|
|||||||
import express from 'express';
|
import express from "express";
|
||||||
import cors from 'cors';
|
import cors from "cors";
|
||||||
import connectDB from '../shared/connect/mongoose.ts';
|
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";
|
||||||
import linesRoutes from './Routes/lines-Routes.ts'
|
import linesRoutes from "./Routes/lines-Routes.ts";
|
||||||
import flooritemRoutes from './Routes/flooritem-Routes.ts'
|
import flooritemRoutes from "./Routes/flooritem-Routes.ts";
|
||||||
import WallitemRoutes from './Routes/wallItems-Routes.ts'
|
import WallitemRoutes from "./Routes/wallItems-Routes.ts";
|
||||||
import userRoutes from './Routes/user-Routes.ts'
|
import userRoutes from "./Routes/user-Routes.ts";
|
||||||
import shareRoutes from './Routes/share-Routes.ts'
|
import shareRoutes from "./Routes/share-Routes.ts";
|
||||||
import zoneRoutes from './Routes/zone-Routes.ts'
|
import zoneRoutes from "./Routes/zone-Routes.ts";
|
||||||
import zoneRoutes2 from './Routes/zoneRoutes.ts'//update
|
import zoneRoutes2 from "./Routes/zoneRoutes.ts"; //update
|
||||||
import panelRouter from './Routes/panelRoutes.ts'
|
import panelRouter from "./Routes/panelRoutes.ts";
|
||||||
import widgetRouter from './Routes/widgetRoute.ts'
|
import widgetRouter from "./Routes/widgetRoute.ts";
|
||||||
|
import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
||||||
|
import assetfloorRoutes from "./Routes/assetfloorRoutes.ts";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
app.get('/', (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.send('Hello, I am Major-Dwinzo API!');
|
res.send("Hello, I am Major-Dwinzo API!");
|
||||||
});
|
});
|
||||||
// connectDB();
|
// connectDB();
|
||||||
app.get('/health',(req,res)=>{
|
app.get("/health", (req, res) => {
|
||||||
res.status(200).json({ message: 'Server is running' });
|
res.status(200).json({ message: "Server is running" });
|
||||||
})
|
});
|
||||||
app.use('/api/v1', cameraRoutes);
|
app.use("/api/v1", cameraRoutes);
|
||||||
app.use('/api/v1', environmentsRoutes);
|
app.use("/api/v1", environmentsRoutes);
|
||||||
app.use('/api/v1', linesRoutes);
|
app.use("/api/v1", linesRoutes);
|
||||||
app.use('/api/v1', flooritemRoutes);
|
app.use("/api/v1", flooritemRoutes);
|
||||||
app.use('/api/v1', WallitemRoutes);
|
app.use("/api/v1", WallitemRoutes);
|
||||||
app.use('/api/v1', userRoutes);
|
app.use("/api/v1", userRoutes);
|
||||||
app.use('/api/v1', shareRoutes);
|
app.use("/api/v1", shareRoutes);
|
||||||
// app.use('/api/v2', zoneRoutes);
|
// app.use('/api/v2', zoneRoutes);
|
||||||
//update
|
//update
|
||||||
app.use('/api/v2', zoneRoutes2);//updates
|
app.use("/api/v2", zoneRoutes2); //updates
|
||||||
app.use('/api/v2', panelRouter);
|
app.use("/api/v2", panelRouter);
|
||||||
app.use('/api/v2', widgetRouter);
|
app.use("/api/v2", widgetRouter);
|
||||||
|
app.use("/api/v2", assetpointRouter);
|
||||||
|
app.use("/api/v2", assetfloorRoutes);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
137
src/api-server/controller/assets/pointService.ts
Normal file
137
src/api-server/controller/assets/pointService.ts
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||||
|
|
||||||
|
export class pointService {
|
||||||
|
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||||
|
const { type, modelfileID, organization } = req.body;
|
||||||
|
|
||||||
|
if (!["Conveyor", "Vehicle"].includes(type)) {
|
||||||
|
return res.status(400).json({ message: "Invalid type requested" });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (type === "Conveyor") {
|
||||||
|
const pointsData = await pointModel(organization).findOne({
|
||||||
|
modelfileID: modelfileID,
|
||||||
|
type: type,
|
||||||
|
});
|
||||||
|
if (pointsData) return res.send("Data already exists");
|
||||||
|
const createData = await pointModel(organization).create({
|
||||||
|
type: "Conveyor",
|
||||||
|
modelfileID: "672a090f80d91ac979f4d0bd",
|
||||||
|
points: [
|
||||||
|
{
|
||||||
|
uuid: "point1UUID",
|
||||||
|
position: [0, 0.85, 2.2],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
uuid: "randomUUID",
|
||||||
|
name: "Action 1",
|
||||||
|
type: "Inherit",
|
||||||
|
material: "Inherit",
|
||||||
|
delay: "Inherit",
|
||||||
|
spawnInterval: "Inherit",
|
||||||
|
isUsed: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
triggers: [],
|
||||||
|
// connections: {
|
||||||
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
|
// targets: [],
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uuid: "point1UUID",
|
||||||
|
position: [0, 0.85, 0],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
uuid: "randomUUID",
|
||||||
|
name: "Action 1",
|
||||||
|
type: "Inherit",
|
||||||
|
material: "Inherit",
|
||||||
|
delay: "Inherit",
|
||||||
|
spawnInterval: "Inherit",
|
||||||
|
isUsed: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
triggers: [],
|
||||||
|
// connections: {
|
||||||
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
|
// targets: [],
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uuid: "point1UUID",
|
||||||
|
position: [0, 0.85, -2.2],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
uuid: "randomUUID",
|
||||||
|
name: "Action 1",
|
||||||
|
type: "Inherit",
|
||||||
|
material: "Inherit",
|
||||||
|
delay: "Inherit",
|
||||||
|
spawnInterval: "Inherit",
|
||||||
|
isUsed: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
triggers: [],
|
||||||
|
// connections: {
|
||||||
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
|
// targets: [],
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
speed: 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// else if (type === "Vehicle") {
|
||||||
|
// // responseData = {
|
||||||
|
// // type: "Vehicle",
|
||||||
|
// // points: {
|
||||||
|
// // uuid: "point1UUID",
|
||||||
|
// // position: [10, 20, 30],
|
||||||
|
// // rotation: [0, 0, 0],
|
||||||
|
// // actions: [
|
||||||
|
// // {
|
||||||
|
// // uuid: "randomUUID",
|
||||||
|
// // name: "Action 1",
|
||||||
|
// // type: "Inherit",
|
||||||
|
// // material: "Inherit",
|
||||||
|
// // delay: "Inherit",
|
||||||
|
// // spawnInterval: "Inherit",
|
||||||
|
// // isUsed: false,
|
||||||
|
// // },
|
||||||
|
// // ],
|
||||||
|
// // triggers: [],
|
||||||
|
// // connections: {
|
||||||
|
// // source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
|
// // targets: [],
|
||||||
|
// // },
|
||||||
|
// // },
|
||||||
|
// // speed: 1,
|
||||||
|
// // };
|
||||||
|
// }
|
||||||
|
|
||||||
|
res.status(200).json({ message: "point created successfully" });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Server error", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async gettypePoints(req: Request, res: Response): Promise<any> {
|
||||||
|
const { modelfileID, organization } = req.params;
|
||||||
|
try {
|
||||||
|
const getData = await pointModel(organization)
|
||||||
|
.findOne({
|
||||||
|
modelfileID: modelfileID,
|
||||||
|
})
|
||||||
|
.select("-_id -__v -createdAt -updatedAt");
|
||||||
|
res.send(getData);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Server error", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,7 @@ export class Zoneservice {
|
|||||||
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.body.organization;
|
const organization = req.body.organization;
|
||||||
const zoneDatas = req.body.zonesdata;
|
const zoneDatas = req.body.zonesdata;
|
||||||
|
|
||||||
console.log('organization: ', organization);
|
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneDatas.zoneId,
|
zoneId: zoneDatas.zoneId,
|
||||||
@@ -90,6 +89,7 @@ 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;
|
||||||
@@ -97,10 +97,12 @@ export class Zoneservice {
|
|||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization)
|
const existingZone = await zoneSchema(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
zoneId: req.params.zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("panelOrder zoneName zonePoints lockedPanel");
|
.select(
|
||||||
|
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition"
|
||||||
|
);
|
||||||
if (!existingZone) {
|
if (!existingZone) {
|
||||||
return res.send({ message: "Zone not found for the UUID" });
|
return res.send({ message: "Zone not found for the UUID" });
|
||||||
} else {
|
} else {
|
||||||
@@ -131,6 +133,9 @@ export class Zoneservice {
|
|||||||
|
|
||||||
const objectData = {
|
const objectData = {
|
||||||
zoneName,
|
zoneName,
|
||||||
|
viewPortposition: existingZone.viewPortposition,
|
||||||
|
zoneId: existingZone.zoneId,
|
||||||
|
viewPortCenter: existingZone.viewPortCenter,
|
||||||
activeSides: existingZone.panelOrder || [],
|
activeSides: existingZone.panelOrder || [],
|
||||||
panelOrder: existingZone.panelOrder || [],
|
panelOrder: existingZone.panelOrder || [],
|
||||||
lockedPanels: existingZone.lockedPanel || [],
|
lockedPanels: existingZone.lockedPanel || [],
|
||||||
@@ -145,13 +150,75 @@ export class Zoneservice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//page full zone Datas with panel and widget
|
||||||
|
static async vizAllDatas(req: Request, res: Response): Promise<any> {
|
||||||
|
const organization = req.query.organization;
|
||||||
|
try {
|
||||||
|
const existingZones = await zoneSchema(organization)
|
||||||
|
.find({
|
||||||
|
isArchive: false,
|
||||||
|
})
|
||||||
|
.select(
|
||||||
|
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition"
|
||||||
|
);
|
||||||
|
if (!existingZones) {
|
||||||
|
return res.send({ message: "Zone not found for the UUID" });
|
||||||
|
} else {
|
||||||
|
const response = await Promise.all(
|
||||||
|
existingZones.map(async (zone) => {
|
||||||
|
// Fetch all panels associated with the current zone
|
||||||
|
const panelData = await panelSchema(organization).find({
|
||||||
|
zoneId: zone._id,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fetch widgets for each panel
|
||||||
|
const widgets = await Promise.all(
|
||||||
|
panelData.map(async (panel) => {
|
||||||
|
const widgetDataArray = await widgetSchema(organization).find({
|
||||||
|
panelID: panel._id,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
return widgetDataArray.map((widget) => ({
|
||||||
|
id: widget.widgetID,
|
||||||
|
type: widget.elementType,
|
||||||
|
title: widget.widgetName,
|
||||||
|
panel: widget.widgetside,
|
||||||
|
data: widget.Data || [],
|
||||||
|
}));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
zoneName: zone.zoneName,
|
||||||
|
zoneId: zone.zoneId,
|
||||||
|
viewPortposition: zone.viewPortposition,
|
||||||
|
viewPortCenter: zone.viewPortCenter,
|
||||||
|
activeSides: zone.panelOrder || [],
|
||||||
|
panelOrder: zone.panelOrder || [],
|
||||||
|
lockedPanels: zone.lockedPanel || [],
|
||||||
|
points: zone.zonePoints || [],
|
||||||
|
widgets: widgets.flat(),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(response);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//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";
|
||||||
try {
|
try {
|
||||||
const Allzones = await zoneSchema(organization)
|
const Allzones = await zoneSchema(organization)
|
||||||
.find({ sceneID: sceneID, isArchive: false })
|
.find({ sceneID: sceneID, isArchive: false })
|
||||||
.select("zoneName sceneID zoneId");
|
.select("zoneName zoneId");
|
||||||
|
|
||||||
if (!Allzones || Allzones.length === 0) {
|
if (!Allzones || Allzones.length === 0) {
|
||||||
return res.status(404).json({ message: "Zone not found for the UUID" });
|
return res.status(404).json({ message: "Zone not found for the UUID" });
|
||||||
@@ -165,9 +232,7 @@ export class Zoneservice {
|
|||||||
static async ZoneData(req: Request, res: Response): Promise<any> {
|
static async ZoneData(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const organization = req.query.organization;
|
const organization = req.query.organization;
|
||||||
console.log("organization: ", organization);
|
|
||||||
const zoneId = req.params.zoneId;
|
const zoneId = req.params.zoneId;
|
||||||
console.log("zoneId: ", zoneId);
|
|
||||||
const findZone = await zoneSchema(organization).findOne({
|
const findZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
|
|||||||
211
src/api-server/controller/simulation/assetsFloorservice.ts
Normal file
211
src/api-server/controller/simulation/assetsFloorservice.ts
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
|
export class assetsFloorservice {
|
||||||
|
static async setFloorassets(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
modeluuid,
|
||||||
|
modelname,
|
||||||
|
position,
|
||||||
|
modelfileID,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
organization,
|
||||||
|
points,
|
||||||
|
} = req.body;
|
||||||
|
|
||||||
|
const findvalue = await assetModel(organization).findOne({
|
||||||
|
modeluuid: modeluuid,
|
||||||
|
modelname: modelname,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (findvalue) {
|
||||||
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
|
{ modeluuid: modeluuid, modelname: modelname },
|
||||||
|
{
|
||||||
|
position: position,
|
||||||
|
rotation: rotation,
|
||||||
|
isVisible: isVisible,
|
||||||
|
isLocked: isLocked,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
res.status(201).json(updatevalue);
|
||||||
|
} else {
|
||||||
|
// const newValue = await assetModel(organization).create({
|
||||||
|
// modeluuid,
|
||||||
|
// modelfileID,
|
||||||
|
// modelname,
|
||||||
|
// position,
|
||||||
|
// rotation,
|
||||||
|
// isLocked,
|
||||||
|
// isVisible,
|
||||||
|
// points,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// for (const point of points) {
|
||||||
|
// // Create actions if they exist
|
||||||
|
// for (const action of point.actions || []) {
|
||||||
|
// const actionData = await actionModel(organization).create({
|
||||||
|
// pointsUUID: point.uuid,
|
||||||
|
// actionUUID: action.uuid,
|
||||||
|
// eventData: {
|
||||||
|
// uuid: action.uuid,
|
||||||
|
// type: action.type,
|
||||||
|
// material: action.material,
|
||||||
|
// delay: action.delay,
|
||||||
|
// spawn_Interval: action.spawnInterval,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Push action ID to point
|
||||||
|
// newValue.points
|
||||||
|
// .find((p: any) => p.uuid === point.uuid)
|
||||||
|
// ?.actions.push(actionData._id);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Create triggers if they exist
|
||||||
|
// for (const trigger of point.triggers || []) {
|
||||||
|
// const triggerData = await triggerModel(organization).create({
|
||||||
|
// pointsUUID: point.uuid,
|
||||||
|
// actionUUID: trigger.uuid,
|
||||||
|
// triggerData: {
|
||||||
|
// type: trigger.type,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Push trigger ID to point
|
||||||
|
// newValue.points
|
||||||
|
// .find((p: any) => p.uuid === point.uuid)
|
||||||
|
// ?.triggers.push(triggerData._id);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Save the updated document
|
||||||
|
// await newValue.save();
|
||||||
|
|
||||||
|
// res.status(201).json(newValue);
|
||||||
|
|
||||||
|
let pointRefs = [];
|
||||||
|
|
||||||
|
for (const point of points) {
|
||||||
|
let actionRefs = [];
|
||||||
|
let triggerRefs = [];
|
||||||
|
|
||||||
|
// Store Actions (Events)
|
||||||
|
if (point.actions && point.actions.length > 0) {
|
||||||
|
for (const action of point.actions) {
|
||||||
|
const actionDoc = await actionModel(organization).create({
|
||||||
|
pointsUUID: point.uuid,
|
||||||
|
actionUUID: action.uuid,
|
||||||
|
isArchive: false,
|
||||||
|
eventData: [action], // Store the action data
|
||||||
|
});
|
||||||
|
await actionDoc.save();
|
||||||
|
actionRefs.push(actionDoc._id); // Store reference
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store Triggers
|
||||||
|
if (point.triggers && point.triggers.length > 0) {
|
||||||
|
for (const trigger of point.triggers) {
|
||||||
|
const triggerDoc = await triggerModel(organization).create({
|
||||||
|
pointsUUID: point.uuid,
|
||||||
|
actionUUID: trigger.uuid,
|
||||||
|
isArchive: false,
|
||||||
|
triggerData: [trigger], // Store trigger data
|
||||||
|
});
|
||||||
|
await triggerDoc.save();
|
||||||
|
triggerRefs.push(triggerDoc._id); // Store reference
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the Point document
|
||||||
|
pointRefs.push({
|
||||||
|
uuid: point.uuid,
|
||||||
|
position: point.position,
|
||||||
|
rotation: point.rotation,
|
||||||
|
actions: actionRefs,
|
||||||
|
triggers: triggerRefs,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the main asset document
|
||||||
|
const assetDoc = await assetModel(organization).create({
|
||||||
|
modeluuid,
|
||||||
|
modelname,
|
||||||
|
position,
|
||||||
|
modelfileID,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
points: pointRefs,
|
||||||
|
});
|
||||||
|
|
||||||
|
await assetDoc.save();
|
||||||
|
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) {
|
||||||
|
try {
|
||||||
|
const { organization } = req.params;
|
||||||
|
const findValue = await assetModel(organization)
|
||||||
|
.find()
|
||||||
|
.select("-_id -__v")
|
||||||
|
.populate({
|
||||||
|
path: "points.actions",
|
||||||
|
select: "-_id",
|
||||||
|
populate: {
|
||||||
|
path: "eventData",
|
||||||
|
select: "uuid type -_id",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.populate({
|
||||||
|
path: "points.triggers",
|
||||||
|
select: "-_id",
|
||||||
|
populate: {
|
||||||
|
path: "triggerData",
|
||||||
|
select: "uuid type -_id",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!findValue) {
|
||||||
|
res.status(200).json("floorItems 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 deleteFloorItems(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { modeluuid, modelname, organization } = req.body;
|
||||||
|
|
||||||
|
const findValue = await assetModel(organization).findOneAndDelete({
|
||||||
|
modeluuid: modeluuid,
|
||||||
|
modelname: modelname,
|
||||||
|
});
|
||||||
|
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" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,7 @@ 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 {
|
||||||
console.log('req.body: ', req.body);
|
|
||||||
const organization = req.body.organization;
|
const organization = req.body.organization;
|
||||||
console.log('organization: ', organization);
|
|
||||||
const zoneId = req.body.zoneId;
|
const zoneId = req.body.zoneId;
|
||||||
const panelName = req.body.panelName;
|
const panelName = req.body.panelName;
|
||||||
const panelOrder = req.body.panelOrder;
|
const panelOrder = req.body.panelOrder;
|
||||||
@@ -57,8 +55,7 @@ export class panelService {
|
|||||||
// const IDdata = createdPanels.map((ID: any) => {
|
// const IDdata = createdPanels.map((ID: any) => {
|
||||||
// return ID._id;
|
// return ID._id;
|
||||||
// });
|
// });
|
||||||
console.log("IDdata: ", createdPanels);
|
createdPanels;
|
||||||
createdPanels
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
message: "Panels created successfully",
|
message: "Panels created successfully",
|
||||||
panelID: createdPanels,
|
panelID: createdPanels,
|
||||||
@@ -69,7 +66,7 @@ export class panelService {
|
|||||||
}
|
}
|
||||||
static async deletePanel(req: Request, res: Response): Promise<any> {
|
static async deletePanel(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization, panelID, 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,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -78,17 +75,17 @@ export class panelService {
|
|||||||
return res.status(404).json({ message: "Zone not found" });
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
const existingPanel = await panelSchema(organization).findOne({
|
const existingPanel = await panelSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
_id: panelID,
|
panelName: panelName,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
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).updateOne(
|
const updatePanel = await panelSchema(organization).updateOne(
|
||||||
{ _id: panelID, isArchive: false },
|
{ _id: existingPanel._id, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
const existingWidgets = await widgetSchema(organization).find({
|
const existingWidgets = await widgetSchema(organization).find({
|
||||||
panelID: panelID,
|
panelID: existingPanel._id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,50 +6,48 @@ export class widgetService {
|
|||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
organization,
|
organization,
|
||||||
panelID,
|
// panel,
|
||||||
widgetName,
|
zoneId,
|
||||||
widgetOrder,
|
widget,
|
||||||
type,
|
|
||||||
widgetID,
|
|
||||||
panel,
|
|
||||||
Data,
|
|
||||||
} = req.body;
|
} = req.body;
|
||||||
const existingPanel = await panelSchema(organization).findOne({
|
const existingPanel = await panelSchema(organization).findOne({
|
||||||
_id: panelID,
|
panelName: widget.panel,
|
||||||
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingPanel)
|
if (!existingPanel)
|
||||||
return res.status(404).json({ message: "PanelID not found" });
|
return res.status(404).json({ message: "panelName not found" });
|
||||||
|
|
||||||
if (existingPanel.panelName === panel) {
|
if (existingPanel.panelName === widget.panel) {
|
||||||
const existingWidget = await widgetSchema(organization).findOne({
|
const existingWidget = await widgetSchema(organization).findOne({
|
||||||
panelID: panelID,
|
panelID: existingPanel._id,
|
||||||
widgetID: widgetID,
|
widgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
widgetOrder: widgetOrder,
|
// widgetOrder: widget.widgetOrder,
|
||||||
});
|
});
|
||||||
if (existingWidget)
|
if (existingWidget) {
|
||||||
return res
|
return res
|
||||||
.status(409)
|
.status(409)
|
||||||
.json({ message: "Widget already exist for the widgetID" });
|
.json({ message: "Widget already exist for the widgetID" });
|
||||||
|
}
|
||||||
const newWidget = await widgetSchema(organization).create({
|
const newWidget = await widgetSchema(organization).create({
|
||||||
widgetID: widgetID,
|
widgetID: widget.id,
|
||||||
elementType: type,
|
elementType: widget.type,
|
||||||
widgetOrder: widgetOrder,
|
// widgetOrder: widgetOrder,
|
||||||
widgetName: widgetName,
|
widgetName: widget.widgetName,
|
||||||
panelID: panelID,
|
panelID: existingPanel._id,
|
||||||
widgetside: panel,
|
widgetside: widget.panel,
|
||||||
Data: {
|
// Data: {
|
||||||
measurements: Data.measurements || {},
|
// measurements: widget.Data.measurements || {},
|
||||||
duration: Data.duration || "1hr",
|
// duration: widget.Data.duration || "1hr",
|
||||||
},
|
// },
|
||||||
});
|
});
|
||||||
if (newWidget) {
|
if (newWidget) {
|
||||||
existingPanel.widgets.push(newWidget._id);
|
existingPanel.widgets.push(newWidget._id);
|
||||||
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,
|
// widgetID: newWidget._id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,13 +61,13 @@ export class widgetService {
|
|||||||
try {
|
try {
|
||||||
const { widgetID, organization } = req.body;
|
const { widgetID, organization } = req.body;
|
||||||
const findWidget = await widgetSchema(organization).findOne({
|
const findWidget = await widgetSchema(organization).findOne({
|
||||||
_id: widgetID,
|
widgetID: widgetID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findWidget)
|
if (!findWidget)
|
||||||
return res.status(409).json({ message: "Widget already deleted" });
|
return res.status(409).json({ message: "Widget already deleted" });
|
||||||
const widgetData = await widgetSchema(organization).updateOne(
|
const widgetData = await widgetSchema(organization).updateOne(
|
||||||
{ _id: widgetID, isArchive: false },
|
{ _id: findWidget._id, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -92,7 +90,7 @@ export class widgetService {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (panelData.widgets.includes(widgetID)) {
|
if (panelData.widgets.includes(findWidget._id)) {
|
||||||
panelData.widgets = panelData.widgets.filter(
|
panelData.widgets = panelData.widgets.filter(
|
||||||
(widget: any) => widget !== findWidget._id
|
(widget: any) => widget !== findWidget._id
|
||||||
);
|
);
|
||||||
@@ -105,6 +103,48 @@ export class widgetService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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> {
|
static async getDatafromWidget(req: Request, res: Response): Promise<any> {
|
||||||
const { organization, widgetID } = req.params;
|
const { organization, widgetID } = req.params;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const MainModel = <T>(
|
|||||||
const authOptions = {
|
const authOptions = {
|
||||||
user: process.env.MONGO_USER, // Correct username environment variable
|
user: process.env.MONGO_USER, // Correct username environment variable
|
||||||
pass: process.env.MONGO_PASSWORD, // Correct password environment variable
|
pass: process.env.MONGO_PASSWORD, // Correct password environment variable
|
||||||
authSource: process.env.MONGO_AUTH_DB || 'admin', // Default to 'admin' if not provided
|
authSource: process.env.MONGO_AUTH_DB || "admin", // Default to 'admin' if not provided
|
||||||
maxPoolSize: 50,
|
maxPoolSize: 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -24,9 +24,9 @@ const MainModel = <T>(
|
|||||||
if (connections[db]) {
|
if (connections[db]) {
|
||||||
return connections[db].model<T>(modelName, schema, collectionName);
|
return connections[db].model<T>(modelName, schema, collectionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const db1 = mongoose.createConnection(db1_url,authOptions);
|
const db1 = mongoose.createConnection(db1_url, authOptions);
|
||||||
|
|
||||||
// Cache the connection
|
// Cache the connection
|
||||||
connections[db] = db1;
|
connections[db] = db1;
|
||||||
@@ -37,7 +37,10 @@ const MainModel = <T>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
db1.on("error", (err) => {
|
db1.on("error", (err) => {
|
||||||
console.error(`MongoDB connection error for database ${db}:`, err.message);
|
console.error(
|
||||||
|
`MongoDB connection error for database ${db}:`,
|
||||||
|
err.message
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return db1.model<T>(modelName, schema, collectionName);
|
return db1.model<T>(modelName, schema, collectionName);
|
||||||
@@ -48,4 +51,3 @@ const MainModel = <T>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default MainModel;
|
export default MainModel;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
|
interface IAction {
|
||||||
|
uuid: string;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
material: string;
|
||||||
|
delay: string;
|
||||||
|
spawnInterval: string;
|
||||||
|
isUsed: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
// Interface for TypeScript with PascalCase
|
||||||
export interface assetData extends Document {
|
export interface assetData extends Document {
|
||||||
modeluuid: string;
|
modeluuid: string;
|
||||||
@@ -42,16 +52,16 @@ const assetDataSchema: Schema = new Schema({
|
|||||||
uuid: { type: String },
|
uuid: { type: String },
|
||||||
position: { type: Array },
|
position: { type: Array },
|
||||||
rotation: { type: Array },
|
rotation: { type: Array },
|
||||||
actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Actions" }],
|
||||||
triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Triggers" }],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
isLocked: { type: Boolean },
|
isLocked: { type: Boolean },
|
||||||
isVisible: { type: Boolean },
|
isVisible: { type: Boolean },
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number },
|
||||||
z: { type: Number, required: true },
|
z: { type: Number },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
80
src/shared/model/builder/assets/assetPoint-Model.ts
Normal file
80
src/shared/model/builder/assets/assetPoint-Model.ts
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
|
interface IAction {
|
||||||
|
uuid: string;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
material: string;
|
||||||
|
delay: string;
|
||||||
|
spawnInterval: string;
|
||||||
|
isUsed: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// interface IConnection {
|
||||||
|
// source: { pathUUID: string; pointUUID: string };
|
||||||
|
// targets: string[];
|
||||||
|
// }
|
||||||
|
|
||||||
|
interface IPoint {
|
||||||
|
uuid: string;
|
||||||
|
position: number[];
|
||||||
|
rotation: number[];
|
||||||
|
actions: IAction[];
|
||||||
|
triggers: string[];
|
||||||
|
// connections: IConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IBaseModel extends Document {
|
||||||
|
modelfileID: string;
|
||||||
|
type: "Conveyor" | "Vehicle";
|
||||||
|
points: IPoint[] | IPoint;
|
||||||
|
speed: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Base Schema
|
||||||
|
const PointSchema = new Schema<IPoint>({
|
||||||
|
uuid: { type: String, required: true },
|
||||||
|
position: { type: [Number], required: true },
|
||||||
|
rotation: { type: [Number], required: true },
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
uuid: { type: String, default: "" },
|
||||||
|
name: { type: String, required: true },
|
||||||
|
type: { type: String, required: true },
|
||||||
|
material: { type: String, required: true },
|
||||||
|
delay: { type: String, required: true },
|
||||||
|
spawnInterval: { type: String, required: true },
|
||||||
|
isUsed: { type: Boolean, required: true },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
triggers: { type: [String], default: [] },
|
||||||
|
// connections: {
|
||||||
|
// source: {
|
||||||
|
// pathUUID: { type: String, required: true },
|
||||||
|
// pointUUID: { type: String, required: true },
|
||||||
|
// },
|
||||||
|
// targets: { type: [String], default: [] },
|
||||||
|
// },
|
||||||
|
});
|
||||||
|
|
||||||
|
const BaseSchema = new Schema<IBaseModel>(
|
||||||
|
{
|
||||||
|
modelfileID: { type: String },
|
||||||
|
type: { type: String, enum: ["Conveyor", "Vehicle"] },
|
||||||
|
points: {
|
||||||
|
type: Schema.Types.Mixed,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
speed: { type: Number },
|
||||||
|
},
|
||||||
|
{ discriminatorKey: "type", timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const pointModel = (db: string) => {
|
||||||
|
return MainModel(db, "Points", BaseSchema, "Points");
|
||||||
|
};
|
||||||
|
export default pointModel;
|
||||||
|
|
||||||
|
// const pointModel = mongoose.model<IBaseModel>("Points", BaseSchema, "Points");
|
||||||
|
// export default pointModel;
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
import mongoose, { Document, Schema } from "mongoose";
|
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
|
||||||
export interface Points extends Document {
|
|
||||||
modelfileID: string;
|
|
||||||
points: {
|
|
||||||
uuid: string;
|
|
||||||
position: number[];
|
|
||||||
rotation: number[];
|
|
||||||
actions: string[];
|
|
||||||
triggers: string[];
|
|
||||||
}[];
|
|
||||||
}
|
|
||||||
const defaultPoints = [
|
|
||||||
{
|
|
||||||
uuid: "",
|
|
||||||
position: [0, 1.25, 3.3],
|
|
||||||
rotation: [0, 0, 0],
|
|
||||||
actions: [],
|
|
||||||
triggers: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
uuid: "",
|
|
||||||
position: [0, 1.25, 3.3],
|
|
||||||
rotation: [0, 0, 0],
|
|
||||||
actions: [],
|
|
||||||
triggers: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
uuid: "",
|
|
||||||
position: [0, 1.25, 3.3],
|
|
||||||
rotation: [0, 0, 0],
|
|
||||||
actions: [],
|
|
||||||
triggers: [],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const pointSchema: Schema = new Schema({
|
|
||||||
modelfileID: { type: String, required: true },
|
|
||||||
points: {
|
|
||||||
type: [
|
|
||||||
{
|
|
||||||
uuid: { type: String },
|
|
||||||
position: { type: [Number], default: [0, 1.25, 3.3] },
|
|
||||||
rotation: { type: [Number], default: [0, 0, 0] },
|
|
||||||
actions: { type: [String], default: [] },
|
|
||||||
triggers: { type: [String], default: [] },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
default: defaultPoints,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const pointModel = (db: string) => {
|
|
||||||
return MainModel(db, "Points", pointSchema, "Points");
|
|
||||||
};
|
|
||||||
|
|
||||||
export default pointModel;
|
|
||||||
@@ -19,7 +19,6 @@ const eventSchema: Schema = new Schema(
|
|||||||
pointsUUID: { type: String },
|
pointsUUID: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
actionUUID: { type: String },
|
actionUUID: { type: String },
|
||||||
sceneID: { type: String },
|
|
||||||
eventData: [
|
eventData: [
|
||||||
{
|
{
|
||||||
uuid: { type: String },
|
uuid: { type: String },
|
||||||
@@ -34,6 +33,6 @@ const eventSchema: Schema = new Schema(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const actionModel = (db: any) => {
|
const actionModel = (db: any) => {
|
||||||
return MainModel(db, "Events", eventSchema, "Events");
|
return MainModel(db, "Actions", eventSchema, "Actions");
|
||||||
};
|
};
|
||||||
export default actionModel;
|
export default actionModel;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface widget extends Document {
|
|||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
panelID: mongoose.Types.ObjectId;
|
panelID: mongoose.Types.ObjectId;
|
||||||
Data: {
|
Data: {
|
||||||
measurement: Record<string, any>;
|
measurement: [any];
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -29,10 +29,7 @@ const widgetSchema: Schema = new Schema(
|
|||||||
fontFamily: { type: String },
|
fontFamily: { type: String },
|
||||||
fontStyle: { type: String },
|
fontStyle: { type: String },
|
||||||
Data: {
|
Data: {
|
||||||
measurements: {
|
measurements: { type: Array, default: [] },
|
||||||
type: Object,
|
|
||||||
default: {},
|
|
||||||
},
|
|
||||||
duration: { type: String, default: "1hr" },
|
duration: { type: String, default: "1hr" },
|
||||||
},
|
},
|
||||||
fontWeight: { type: String },
|
fontWeight: { type: String },
|
||||||
|
|||||||
Reference in New Issue
Block a user