From 3b157726921b7cd94e46d6662c3c0941d365eb52 Mon Sep 17 00:00:00 2001 From: sabarinathan Date: Tue, 10 Jun 2025 15:12:30 +0530 Subject: [PATCH] first commit --- .env | 10 +- Dwinzo-Backend-OLD.code-workspace | 22 + src/api-server/Routes/productRoutes.ts | 22 +- src/api-server/Routes/projectRoutes.ts | 10 +- .../controller/project/projectController.ts | 90 +- .../controller/simulation/productService.ts | 468 ++-- src/shared/model/project/project-model.ts | 58 +- .../model/simulation/eventsDataModel.ts | 356 ++-- src/shared/model/simulation/productModel.ts | 40 +- .../services/project/project-Serivices.ts | 174 +- .../visualization/3dWidget-Service.ts | 420 ++-- .../visualization/floatWidget-Service.ts | 560 ++--- swagger-output.json | 1886 ++++++++--------- 13 files changed, 2071 insertions(+), 2045 deletions(-) create mode 100644 Dwinzo-Backend-OLD.code-workspace diff --git a/.env b/.env index 019da68..5ee800b 100644 --- a/.env +++ b/.env @@ -1,8 +1,12 @@ -MONGO_URI=mongodb://mongo/ -MONGO_USER=admin -MONGO_PASSWORD=admin321 +# MONGO_URI=mongodb://mongo/ +# MONGO_USER=admin +# MONGO_PASSWORD=admin321 MONGO_AUTH_DB=admin +MONGO_URI=mongodb://192.168.0.110/ +MONGO_USER=mydata +MONGO_PASSWORD=mongodb@hexr2002 +MONGO_AUTH_DB=admin API_PORT=5000 SOCKET_PORT=8000 NODE_ENV=development diff --git a/Dwinzo-Backend-OLD.code-workspace b/Dwinzo-Backend-OLD.code-workspace new file mode 100644 index 0000000..047c172 --- /dev/null +++ b/Dwinzo-Backend-OLD.code-workspace @@ -0,0 +1,22 @@ +{ + "folders": [ + { + "name": "Dwinzo-Backend", + "path": "." + } + ], + "settings": { + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + "**/.retool_types/**": true, + "**/*tsconfig.json": true, + ".cache": true, + "retool.config.json": true + } + } +} \ No newline at end of file diff --git a/src/api-server/Routes/productRoutes.ts b/src/api-server/Routes/productRoutes.ts index debc383..a0852f3 100644 --- a/src/api-server/Routes/productRoutes.ts +++ b/src/api-server/Routes/productRoutes.ts @@ -1,11 +1,11 @@ -import * as express from "express"; -import { ProductFlowService } from "../controller/simulation/productService.ts"; -const productRouter = express.Router(); -productRouter.post("/UpsertProductOrEvent", ProductFlowService.productAdd); -productRouter.get("/productData", ProductFlowService.getProductDatas); -productRouter.patch("/EventDataDelete", ProductFlowService.EventDataDelete); -productRouter.patch("/productDataDelete", ProductFlowService.productDataDelete); -productRouter.get("/AllProducts/:organization", ProductFlowService.AllProductDatas); -productRouter.patch("/productRename", ProductFlowService.productRename); -export default productRouter; - +import * as express from "express"; +import { ProductFlowService } from "../controller/simulation/productService.ts"; +const productRouter = express.Router(); +productRouter.post("/UpsertProductOrEvent", ProductFlowService.productAdd); +productRouter.get("/productData", ProductFlowService.getProductDatas); +productRouter.patch("/EventDataDelete", ProductFlowService.EventDataDelete); +productRouter.patch("/productDataDelete", ProductFlowService.productDataDelete); +productRouter.get("/AllProducts/:organization", ProductFlowService.AllProductDatas); +productRouter.patch("/productRename", ProductFlowService.productRename); +export default productRouter; + diff --git a/src/api-server/Routes/projectRoutes.ts b/src/api-server/Routes/projectRoutes.ts index 92a3862..2429693 100644 --- a/src/api-server/Routes/projectRoutes.ts +++ b/src/api-server/Routes/projectRoutes.ts @@ -1,6 +1,6 @@ -import * as express from "express"; -import { createProjectController } from "../controller/project/projectController.ts"; - -const projectRouter = express.Router(); -projectRouter.post("/upsertProject",createProjectController) +import * as express from "express"; +import { createProjectController } from "../controller/project/projectController.ts"; + +const projectRouter = express.Router(); +projectRouter.post("/upsertProject",createProjectController) export default projectRouter \ No newline at end of file diff --git a/src/api-server/controller/project/projectController.ts b/src/api-server/controller/project/projectController.ts index a0590b0..064d298 100644 --- a/src/api-server/controller/project/projectController.ts +++ b/src/api-server/controller/project/projectController.ts @@ -1,45 +1,45 @@ -import { Request, Response } from "express"; -import { createProject } from "../../../shared/services/project/project-Serivices.ts"; - -export const createProjectController = async (req: Request, res: Response): Promise => { - try { - const result = await createProject(req.body); - - switch (result.status) { - case "project_exists": - res.status(409).json({ - success: false, - message: "Project already exists", - }); - break; - - case "user_not_found": - res.status(404).json({ - success: false, - message: "User not found", - }); - break; - - case "success": - res.status(201).json({ - success: true, - message: "Project created successfully", - data: result.project, - }); - break; - - default: - res.status(500).json({ - success: false, - message: "Internal server error", - }); - break; - } - } catch (error) { - console.error("Error in controller:", error); - res.status(500).json({ - success: false, - message: "Internal server error", - }); - } -}; +import { Request, Response } from "express"; +import { createProject } from "../../../shared/services/project/project-Serivices.ts"; + +export const createProjectController = async (req: Request, res: Response): Promise => { + try { + const result = await createProject(req.body); + + switch (result.status) { + case "project_exists": + res.status(409).json({ + success: false, + message: "Project already exists", + }); + break; + + case "user_not_found": + res.status(404).json({ + success: false, + message: "User not found", + }); + break; + + case "success": + res.status(201).json({ + success: true, + message: "Project created successfully", + data: result.project, + }); + break; + + default: + res.status(500).json({ + success: false, + message: "Internal server error", + }); + break; + } + } catch (error) { + console.error("Error in controller:", error); + res.status(500).json({ + success: false, + message: "Internal server error", + }); + } +}; diff --git a/src/api-server/controller/simulation/productService.ts b/src/api-server/controller/simulation/productService.ts index 6341756..55d791c 100644 --- a/src/api-server/controller/simulation/productService.ts +++ b/src/api-server/controller/simulation/productService.ts @@ -1,234 +1,234 @@ -import { Request, Response } from "express"; -import ProductModel from "../../../shared/model/simulation/productModel.ts"; -import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts"; - -export class ProductFlowService { - static async productAdd(req: Request, res: Response): Promise { - try { - const { productName, productId, eventDatas, organization } = req.body; - if (!organization) { - 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, - } - ); - return res - .status(200) - .json({ message: "EventData updated successfully" }); - } else { - await EventsDataModel(organization).create({ - productId: productId, - modelUuid: eventDatas?.modelUuid, - modelName: eventDatas?.modelName, - position: eventDatas?.position, - rotation: eventDatas?.rotation, - type: eventDatas?.type, - speed: eventDatas?.speed, - point: eventDatas?.point, - points: eventDatas?.points, - }); - return res - .status(201) - .json({ message: "EventData add successfully" }); - } - } else { - const newProduct = await ProductModel(organization).create({ - productId: productId, - productName: productName, - }); - if (newProduct) { - if (eventDatas) { - await EventsDataModel(organization).create({ - productId: productId, - modelUuid: eventDatas?.modelUuid, - modelName: eventDatas?.modelName, - position: eventDatas?.position, - rotation: eventDatas?.rotation, - type: eventDatas?.type, - speed: eventDatas?.speed, - point: eventDatas?.point, - points: eventDatas?.points, - }); - } - } - return res - .status(201) - .json({ message: "Product created successfully" }); - } - } catch (error) { - res.status(500).json({ message: "Failed to create product" }); - } - } - static async getProductDatas(req: Request, res: Response): Promise { - 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, - }); - - if (!existingProduct) - return res.status(404).json({ message: "Product not found" }); - - const existingEventDatas = await EventsDataModel(organization) - .find({ productId: productId }) - .select("-productId"); - - return res.status(200).json(existingEventDatas); - } catch (error) { - res.status(500).json({ message: "Failed to get product" }); - } - } - static async productDataDelete(req: Request, res: Response): Promise { - 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, - }); - - if (!existingProduct) - return res.status(404).json({ message: "Product not found" }); - - 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 EventDataDelete(req: Request, res: Response): Promise { - try { - const { productId, organization, modelUuid } = req.body; - - const existingProduct = await ProductModel(organization).findOne({ - productId: productId, - isArchive: false, - }); - - if (!existingProduct) - return res.status(404).json({ message: "Product not found" }); - - 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" }); - } - } - static async AllProductDatas(req: Request, res: Response): Promise { - try { - const { organization } = req.params; - - if (!organization) { - 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 = []; - - for (const product of existingProduct) { - const eventDatas = await EventsDataModel(organization) - .find({ productId: product.productId, isArchive: false }) - .select("-productId -isArchive -createdAt -updatedAt -__v -_id"); - - result.push({ - productName: product.productName, - productId: product.productId, - eventDatas, - }); - } - - 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 { - 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" }); - } - } -} +import { Request, Response } from "express"; +import ProductModel from "../../../shared/model/simulation/productModel.ts"; +import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts"; + +export class ProductFlowService { + static async productAdd(req: Request, res: Response): Promise { + try { + const { productName, productId, eventDatas, organization } = req.body; + if (!organization) { + 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, + } + ); + return res + .status(200) + .json({ message: "EventData updated successfully" }); + } else { + await EventsDataModel(organization).create({ + productId: productId, + modelUuid: eventDatas?.modelUuid, + modelName: eventDatas?.modelName, + position: eventDatas?.position, + rotation: eventDatas?.rotation, + type: eventDatas?.type, + speed: eventDatas?.speed, + point: eventDatas?.point, + points: eventDatas?.points, + }); + return res + .status(201) + .json({ message: "EventData add successfully" }); + } + } else { + const newProduct = await ProductModel(organization).create({ + productId: productId, + productName: productName, + }); + if (newProduct) { + if (eventDatas) { + await EventsDataModel(organization).create({ + productId: productId, + modelUuid: eventDatas?.modelUuid, + modelName: eventDatas?.modelName, + position: eventDatas?.position, + rotation: eventDatas?.rotation, + type: eventDatas?.type, + speed: eventDatas?.speed, + point: eventDatas?.point, + points: eventDatas?.points, + }); + } + } + return res + .status(201) + .json({ message: "Product created successfully" }); + } + } catch (error) { + res.status(500).json({ message: "Failed to create product" }); + } + } + static async getProductDatas(req: Request, res: Response): Promise { + 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, + }); + + if (!existingProduct) + return res.status(404).json({ message: "Product not found" }); + + const existingEventDatas = await EventsDataModel(organization) + .find({ productId: productId }) + .select("-productId"); + + return res.status(200).json(existingEventDatas); + } catch (error) { + res.status(500).json({ message: "Failed to get product" }); + } + } + static async productDataDelete(req: Request, res: Response): Promise { + 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, + }); + + if (!existingProduct) + return res.status(404).json({ message: "Product not found" }); + + 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 EventDataDelete(req: Request, res: Response): Promise { + try { + const { productId, organization, modelUuid } = req.body; + + const existingProduct = await ProductModel(organization).findOne({ + productId: productId, + isArchive: false, + }); + + if (!existingProduct) + return res.status(404).json({ message: "Product not found" }); + + 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" }); + } + } + static async AllProductDatas(req: Request, res: Response): Promise { + try { + const { organization } = req.params; + + if (!organization) { + 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 = []; + + for (const product of existingProduct) { + const eventDatas = await EventsDataModel(organization) + .find({ productId: product.productId, isArchive: false }) + .select("-productId -isArchive -createdAt -updatedAt -__v -_id"); + + result.push({ + productName: product.productName, + productId: product.productId, + eventDatas, + }); + } + + 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 { + 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" }); + } + } +} diff --git a/src/shared/model/project/project-model.ts b/src/shared/model/project/project-model.ts index a754853..16c722a 100644 --- a/src/shared/model/project/project-model.ts +++ b/src/shared/model/project/project-model.ts @@ -1,29 +1,29 @@ -import { Schema, Document } from "mongoose"; -import MainModel from "../../connect/mongoose.ts"; -import { User } from "../user-Model.ts"; - -export interface Project extends Document { - projectUuid: string; - projectName: string; - createdBy: User["_id"]; - isArchive: boolean; - thumbnail: string; - sharedUsers: []; -} -const projectSchema: Schema = new Schema( - { - projectUuid: { type: String, required: true }, - projectName: { type: String }, - thumbnail: { type: String }, - isArchive: { type: Boolean, default: false }, - createdBy: { type: Schema.Types.ObjectId, ref: "user" }, - sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }], - }, - { timestamps: true } -); - -const projectModel = (db: string) => { - return MainModel(db, "Projects", projectSchema, "Projects"); -}; - -export default projectModel; +import { Schema, Document } from "mongoose"; +import MainModel from "../../connect/mongoose.ts"; +import { User } from "../user-Model.ts"; + +export interface Project extends Document { + projectUuid: string; + projectName: string; + createdBy: User["_id"]; + isArchive: boolean; + thumbnail: string; + sharedUsers: []; +} +const projectSchema: Schema = new Schema( + { + projectUuid: { type: String, required: true }, + projectName: { type: String }, + thumbnail: { type: String }, + isArchive: { type: Boolean, default: false }, + createdBy: { type: Schema.Types.ObjectId, ref: "user" }, + sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }], + }, + { timestamps: true } +); + +const projectModel = (db: string) => { + return MainModel(db, "Projects", projectSchema, "Projects"); +}; + +export default projectModel; diff --git a/src/shared/model/simulation/eventsDataModel.ts b/src/shared/model/simulation/eventsDataModel.ts index 24d5739..2c64ba7 100644 --- a/src/shared/model/simulation/eventsDataModel.ts +++ b/src/shared/model/simulation/eventsDataModel.ts @@ -1,178 +1,178 @@ -import { Schema, Document } from "mongoose"; -import MainModel from "../../connect/mongoose.ts"; - -interface AssetEventSchema { - modelUuid: string; - modelName: string; - position: [number, number, number]; - rotation: [number, number, number]; - state: "idle" | "running" | "stopped" | "disabled" | "error"; -} - -interface TriggerSchema { - triggerUuid: string; - triggerName: string; - triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError"; - delay: number; - triggeredAsset: { - triggeredModel: { modelName: string; modelUuid: string }; - triggeredPoint: { pointName: string; pointUuid: string }; - triggeredAction: { actionName: string; actionUuid: string }; - } | null; -} - -interface ConveyorPointSchema { - uuid: string; - position: [number, number, number]; - rotation: [number, number, number]; - action: { - actionUuid: string; - actionName: string; - actionType: "default" | "spawn" | "swap" | "despawn"; - material: string; - delay: number | "inherit"; - spawnInterval: number | "inherit"; - spawnCount: number | "inherit"; - triggers: TriggerSchema[]; - }; -} - -interface VehiclePointSchema { - uuid: string; - position: [number, number, number]; - rotation: [number, number, number]; - action: { - actionUuid: string; - actionName: string; - actionType: "travel"; - material: string | null; - unLoadDuration: number; - loadCapacity: number; - pickUpPoint: { x: number; y: number; z: number } | null; - unLoadPoint: { x: number; y: number; z: number } | null; - triggers: TriggerSchema[]; - }; -} - -interface RoboticArmPointSchema { - uuid: string; - position: [number, number, number]; - rotation: [number, number, number]; - actions: { - actionUuid: string; - actionName: string; - actionType: "pickAndPlace"; - process: { - startPoint: [number, number, number]; - endPoint: [number, number, number]; - }; - triggers: TriggerSchema[]; - }[]; -} - -interface MachinePointSchema { - uuid: string; - position: [number, number, number]; - rotation: [number, number, number]; - action: { - actionUuid: string; - actionName: string; - actionType: "process"; - processTime: number; - swapMaterial: string; - triggers: TriggerSchema[]; - }; -} - -interface StoragePointSchema { - uuid: string; - position: [number, number, number]; - rotation: [number, number, number]; - action: { - actionUuid: string; - actionName: string; - actionType: "storage"; - materials: { materialName: string; materialId: string }[]; - storageCapacity: number; - }; -} - -interface ConveyorEventSchema extends AssetEventSchema { - type: "transfer"; - speed: number; - points: ConveyorPointSchema[]; -} - -interface VehicleEventSchema extends AssetEventSchema { - type: "vehicle"; - speed: number; - point: VehiclePointSchema; -} - -interface RoboticArmEventSchema extends AssetEventSchema { - type: "roboticArm"; - speed: number; - point: RoboticArmPointSchema; -} - -interface MachineEventSchema extends AssetEventSchema { - type: "machine"; - point: MachinePointSchema; -} - -interface StorageEventSchema extends AssetEventSchema { - type: "storageUnit"; - point: StoragePointSchema; -} -interface IPointModel extends Document { - modelUuid: string; - modelName: string; - position: [number]; - rotation: [number]; - state: string; - productId: string; - isArchive: boolean; - type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit"; - speed: number; - point: - | VehicleEventSchema - | RoboticArmEventSchema - | MachineEventSchema - | StorageEventSchema; - points: ConveyorEventSchema[]; -} - -const BaseEventSchema = new Schema( - { - modelUuid: { type: String, required: true }, - modelName: { type: String, required: true }, - position: { type: [Number], required: true }, - rotation: { type: [Number], required: true }, - speed: { type: Number }, - state: { - type: String, - enum: ["idle", "running", "stopped", "disabled", "error"], - default: "idle", - }, - type: { - type: String, - required: true, - enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"], - }, - point: { - type: Schema.Types.Mixed, - }, - points: { - type: Schema.Types.Mixed, - }, - productId: { type: String, required: true }, - isArchive: { type: Boolean, default: false }, - }, - { discriminatorKey: "type", timestamps: true } -); - -const EventsDataModel = (db: string) => { - return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas"); -}; - -export default EventsDataModel; +import { Schema, Document } from "mongoose"; +import MainModel from "../../connect/mongoose.ts"; + +interface AssetEventSchema { + modelUuid: string; + modelName: string; + position: [number, number, number]; + rotation: [number, number, number]; + state: "idle" | "running" | "stopped" | "disabled" | "error"; +} + +interface TriggerSchema { + triggerUuid: string; + triggerName: string; + triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError"; + delay: number; + triggeredAsset: { + triggeredModel: { modelName: string; modelUuid: string }; + triggeredPoint: { pointName: string; pointUuid: string }; + triggeredAction: { actionName: string; actionUuid: string }; + } | null; +} + +interface ConveyorPointSchema { + uuid: string; + position: [number, number, number]; + rotation: [number, number, number]; + action: { + actionUuid: string; + actionName: string; + actionType: "default" | "spawn" | "swap" | "despawn"; + material: string; + delay: number | "inherit"; + spawnInterval: number | "inherit"; + spawnCount: number | "inherit"; + triggers: TriggerSchema[]; + }; +} + +interface VehiclePointSchema { + uuid: string; + position: [number, number, number]; + rotation: [number, number, number]; + action: { + actionUuid: string; + actionName: string; + actionType: "travel"; + material: string | null; + unLoadDuration: number; + loadCapacity: number; + pickUpPoint: { x: number; y: number; z: number } | null; + unLoadPoint: { x: number; y: number; z: number } | null; + triggers: TriggerSchema[]; + }; +} + +interface RoboticArmPointSchema { + uuid: string; + position: [number, number, number]; + rotation: [number, number, number]; + actions: { + actionUuid: string; + actionName: string; + actionType: "pickAndPlace"; + process: { + startPoint: [number, number, number]; + endPoint: [number, number, number]; + }; + triggers: TriggerSchema[]; + }[]; +} + +interface MachinePointSchema { + uuid: string; + position: [number, number, number]; + rotation: [number, number, number]; + action: { + actionUuid: string; + actionName: string; + actionType: "process"; + processTime: number; + swapMaterial: string; + triggers: TriggerSchema[]; + }; +} + +interface StoragePointSchema { + uuid: string; + position: [number, number, number]; + rotation: [number, number, number]; + action: { + actionUuid: string; + actionName: string; + actionType: "storage"; + materials: { materialName: string; materialId: string }[]; + storageCapacity: number; + }; +} + +interface ConveyorEventSchema extends AssetEventSchema { + type: "transfer"; + speed: number; + points: ConveyorPointSchema[]; +} + +interface VehicleEventSchema extends AssetEventSchema { + type: "vehicle"; + speed: number; + point: VehiclePointSchema; +} + +interface RoboticArmEventSchema extends AssetEventSchema { + type: "roboticArm"; + speed: number; + point: RoboticArmPointSchema; +} + +interface MachineEventSchema extends AssetEventSchema { + type: "machine"; + point: MachinePointSchema; +} + +interface StorageEventSchema extends AssetEventSchema { + type: "storageUnit"; + point: StoragePointSchema; +} +interface IPointModel extends Document { + modelUuid: string; + modelName: string; + position: [number]; + rotation: [number]; + state: string; + productId: string; + isArchive: boolean; + type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit"; + speed: number; + point: + | VehicleEventSchema + | RoboticArmEventSchema + | MachineEventSchema + | StorageEventSchema; + points: ConveyorEventSchema[]; +} + +const BaseEventSchema = new Schema( + { + modelUuid: { type: String, required: true }, + modelName: { type: String, required: true }, + position: { type: [Number], required: true }, + rotation: { type: [Number], required: true }, + speed: { type: Number }, + state: { + type: String, + enum: ["idle", "running", "stopped", "disabled", "error"], + default: "idle", + }, + type: { + type: String, + required: true, + enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"], + }, + point: { + type: Schema.Types.Mixed, + }, + points: { + type: Schema.Types.Mixed, + }, + productId: { type: String, required: true }, + isArchive: { type: Boolean, default: false }, + }, + { discriminatorKey: "type", timestamps: true } +); + +const EventsDataModel = (db: string) => { + return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas"); +}; + +export default EventsDataModel; diff --git a/src/shared/model/simulation/productModel.ts b/src/shared/model/simulation/productModel.ts index 4be6b9b..dab2089 100644 --- a/src/shared/model/simulation/productModel.ts +++ b/src/shared/model/simulation/productModel.ts @@ -1,20 +1,20 @@ -import { Schema, Document } from "mongoose"; -import MainModel from "../../connect/mongoose.ts"; -export interface Product extends Document { - productName: string; - productId: string; - eventsData: []; - isArchive: boolean; -} - -const ProductSchema = new Schema({ - productName: { type: String, required: true }, - productId: { type: String, required: true }, - isArchive: { type: Boolean, default: false }, -}); - -const ProductModel = (db: string) => { - return MainModel(db, "Product", ProductSchema, "Product"); -}; - -export default ProductModel; +import { Schema, Document } from "mongoose"; +import MainModel from "../../connect/mongoose.ts"; +export interface Product extends Document { + productName: string; + productId: string; + eventsData: []; + isArchive: boolean; +} + +const ProductSchema = new Schema({ + productName: { type: String, required: true }, + productId: { type: String, required: true }, + isArchive: { type: Boolean, default: false }, +}); + +const ProductModel = (db: string) => { + return MainModel(db, "Product", ProductSchema, "Product"); +}; + +export default ProductModel; diff --git a/src/shared/services/project/project-Serivices.ts b/src/shared/services/project/project-Serivices.ts index ffc2252..a5b85d9 100644 --- a/src/shared/services/project/project-Serivices.ts +++ b/src/shared/services/project/project-Serivices.ts @@ -1,87 +1,87 @@ -import projectModel from "../../model/project/project-model.ts"; -import userModel from "../../model/user-Model.ts"; -import { Types } from "mongoose"; -interface CreateProjectInput { - projectName: string; - projectUuid: string; - createdBy: string; - thumbnail?: string; - sharedUsers?: string[]; - organization: string; -} - -export const createProject = async (data: CreateProjectInput) => { - try { - const { - projectName, - projectUuid, - createdBy, - thumbnail, - sharedUsers, - organization, - } = data; - const userExisting = await existingUser(createdBy, organization); - if (!userExisting) { - return { - status: "user_not_found", - }; - } - const projectExisting = await existingProject(projectUuid, organization); - - 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) { - return { - exists: false, - }; - } -}; - -export const existingProject = async ( - projectUuid: string, - organization: string -) => { - const projectData = await projectModel(organization).findOne({ - projectUuid: projectUuid, - isArchive: false, - }); - return projectData; -}; - -export const existingUser = async (createdBy: string, organization: string) => { - if (!Types.ObjectId.isValid(createdBy)) { - return null; - } - const userData = await userModel(organization).findOne({ - _id: createdBy, - }); - return userData; -}; - -export const archiveProject = async ( - projectId: string, - organization: string -) => { - return await projectModel(organization).findByIdAndUpdate( - projectId, - { isArchive: true }, - { new: true } - ); -}; +import projectModel from "../../model/project/project-model.ts"; +import userModel from "../../model/user-Model.ts"; +import { Types } from "mongoose"; +interface CreateProjectInput { + projectName: string; + projectUuid: string; + createdBy: string; + thumbnail?: string; + sharedUsers?: string[]; + organization: string; +} + +export const createProject = async (data: CreateProjectInput) => { + try { + const { + projectName, + projectUuid, + createdBy, + thumbnail, + sharedUsers, + organization, + } = data; + const userExisting = await existingUser(createdBy, organization); + if (!userExisting) { + return { + status: "user_not_found", + }; + } + const projectExisting = await existingProject(projectUuid, organization); + + 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) { + return { + exists: false, + }; + } +}; + +export const existingProject = async ( + projectUuid: string, + organization: string +) => { + const projectData = await projectModel(organization).findOne({ + projectUuid: projectUuid, + isArchive: false, + }); + return projectData; +}; + +export const existingUser = async (createdBy: string, organization: string) => { + if (!Types.ObjectId.isValid(createdBy)) { + return null; + } + const userData = await userModel(organization).findOne({ + _id: createdBy, + }); + return userData; +}; + +export const archiveProject = async ( + projectId: string, + organization: string +) => { + return await projectModel(organization).findByIdAndUpdate( + projectId, + { isArchive: true }, + { new: true } + ); +}; diff --git a/src/socket-server/services/visualization/3dWidget-Service.ts b/src/socket-server/services/visualization/3dWidget-Service.ts index fab3afa..d71a341 100644 --- a/src/socket-server/services/visualization/3dWidget-Service.ts +++ b/src/socket-server/services/visualization/3dWidget-Service.ts @@ -1,210 +1,210 @@ -import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts"; -import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts"; -export const add3Dwidget = async (data: any,callback:any) => { - const { organization, widget, zoneId } = data; - - try { - const existingZone = await zoneSchema(organization).findOne({ - zoneId: zoneId, - isArchive: false, - }); - if (!existingZone) - return { - success: false, - message: "Zone not found for the zoneId", - organization: organization, - }; - const existing3Dwidget = await widget3dModel(organization).findOne({ - widgetID: widget.id, - isArchive: false, - }); - if (existing3Dwidget) { - const update3dwidget = await widget3dModel(organization).findOneAndUpdate( - { - widgetID: widget.id, - zoneId: zoneId, - isArchive: false, - }, - { position: widget.position }, - { upsert: true, new: true } - ); - if (update3dwidget){ - if (callback !== undefined) { - callback({ - success: true, - message: "widget update successfully", - }) - } - return { - success: true, - message: "widget update successfully", - organization: organization, - }; - - } - else - return { - success: false, - message: "Widget not updated", - organization: organization, - }; - } - const newWidget3d = await widget3dModel(organization).create({ - type: widget.type, - widgetID: widget.id, - position: widget.position, - zoneId, - Data: { - measurements: widget?.Data?.measurements || {}, - duration: widget?.Data?.duration || "1h", - }, - }); - if (newWidget3d) { - const widgemodel3D_Datas = { - widget: { - id: newWidget3d.widgetID, - type: newWidget3d.type, - position: newWidget3d.position, - }, - Data: newWidget3d.Data, - zoneId: zoneId, - }; - if (callback !== undefined) { - callback({ - success: true, - message: "Widget created successfully", - })} - return { - success: true, - message: "Widget created successfully", - data: widgemodel3D_Datas, - organization: organization, - }; - } - } catch (error: any) { - return { - success: false, - message: error?.message || "Error occurred while 3Dwidget", - error, - organization: organization, - }; - } -}; -export const update3D = async (data: any) => { - const { organization, id, position, rotation, zoneId } = data; - try { - const existingZone = await zoneSchema(organization).findOne({ - zoneId: zoneId, - isArchive: false, - }); - if (!existingZone) - return { - success: false, - message: "Zone not found", - organization: organization, - }; - const existing3Dwidget = await widget3dModel(organization).findOne({ - widgetID: id, - zoneId: zoneId, - isArchive: false, - }); - if (existing3Dwidget) { - const update3dwidget = await widget3dModel(organization).findOneAndUpdate( - { - widgetID: id, - zoneId: zoneId, - isArchive: false, - }, - { position: position, rotation: rotation }, - { upsert: true, new: true } - ); - if (update3dwidget) { - const updateDatas = { - widget: { - id: update3dwidget.widgetID, - type: update3dwidget.type, - position: update3dwidget.position, - rotation: update3dwidget.rotation, - }, - zoneId: zoneId, - }; - return { - success: true, - message: "widget update successfully", - data: updateDatas, - organization: organization, - }; - } - } else { - return { - success: false, - message: "widget not found", - - organization: organization, - }; - } - } catch (error: any) { - return { - success: false, - message: error?.message || "Error occurred while 3Dwidget", - error, - organization: organization, - }; - } -}; -export const delete3Dwidget = async (data: any) => { - const { organization, id, zoneId } = data; - try { - const existingZone = await zoneSchema(organization).findOne({ - zoneId: zoneId, - isArchive: false, - }); - if (!existingZone) - return { - success: false, - message: "Zone not found", - organization: organization, - }; - const existing3Dwidget = await widget3dModel(organization).findOne({ - widgetID: id, - isArchive: false, - zoneId: zoneId, - }); - if (!existing3Dwidget) { - return { - success: false, - message: "3D widget not found for the ID", - organization: organization, - }; - } - const updateWidget = await widget3dModel(organization).findOneAndUpdate( - { - widgetID: id, - zoneId: zoneId, - isArchive: false, - }, - { isArchive: true }, - { new: true } - ); - if (updateWidget) { - const delete_Datas = { - zoneId: zoneId, - id: existing3Dwidget.widgetID, - }; - - return { - success: true, - data: delete_Datas, - message: "3DWidget delete successfull", - organization: organization, - }; - } - } catch (error: any) { - return { - success: false, - message: error?.message || "Error occurred while 3Dwidget", - error, - organization: organization, - }; - } -}; +import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts"; +import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts"; +export const add3Dwidget = async (data: any,callback:any) => { + const { organization, widget, zoneId } = data; + + try { + const existingZone = await zoneSchema(organization).findOne({ + zoneId: zoneId, + isArchive: false, + }); + if (!existingZone) + return { + success: false, + message: "Zone not found for the zoneId", + organization: organization, + }; + const existing3Dwidget = await widget3dModel(organization).findOne({ + widgetID: widget.id, + isArchive: false, + }); + if (existing3Dwidget) { + const update3dwidget = await widget3dModel(organization).findOneAndUpdate( + { + widgetID: widget.id, + zoneId: zoneId, + isArchive: false, + }, + { position: widget.position }, + { upsert: true, new: true } + ); + if (update3dwidget){ + if (callback !== undefined) { + callback({ + success: true, + message: "widget update successfully", + }) + } + return { + success: true, + message: "widget update successfully", + organization: organization, + }; + + } + else + return { + success: false, + message: "Widget not updated", + organization: organization, + }; + } + const newWidget3d = await widget3dModel(organization).create({ + type: widget.type, + widgetID: widget.id, + position: widget.position, + zoneId, + Data: { + measurements: widget?.Data?.measurements || {}, + duration: widget?.Data?.duration || "1h", + }, + }); + if (newWidget3d) { + const widgemodel3D_Datas = { + widget: { + id: newWidget3d.widgetID, + type: newWidget3d.type, + position: newWidget3d.position, + }, + Data: newWidget3d.Data, + zoneId: zoneId, + }; + if (callback !== undefined) { + callback({ + success: true, + message: "Widget created successfully", + })} + return { + success: true, + message: "Widget created successfully", + data: widgemodel3D_Datas, + organization: organization, + }; + } + } catch (error: any) { + return { + success: false, + message: error?.message || "Error occurred while 3Dwidget", + error, + organization: organization, + }; + } +}; +export const update3D = async (data: any) => { + const { organization, id, position, rotation, zoneId } = data; + try { + const existingZone = await zoneSchema(organization).findOne({ + zoneId: zoneId, + isArchive: false, + }); + if (!existingZone) + return { + success: false, + message: "Zone not found", + organization: organization, + }; + const existing3Dwidget = await widget3dModel(organization).findOne({ + widgetID: id, + zoneId: zoneId, + isArchive: false, + }); + if (existing3Dwidget) { + const update3dwidget = await widget3dModel(organization).findOneAndUpdate( + { + widgetID: id, + zoneId: zoneId, + isArchive: false, + }, + { position: position, rotation: rotation }, + { upsert: true, new: true } + ); + if (update3dwidget) { + const updateDatas = { + widget: { + id: update3dwidget.widgetID, + type: update3dwidget.type, + position: update3dwidget.position, + rotation: update3dwidget.rotation, + }, + zoneId: zoneId, + }; + return { + success: true, + message: "widget update successfully", + data: updateDatas, + organization: organization, + }; + } + } else { + return { + success: false, + message: "widget not found", + + organization: organization, + }; + } + } catch (error: any) { + return { + success: false, + message: error?.message || "Error occurred while 3Dwidget", + error, + organization: organization, + }; + } +}; +export const delete3Dwidget = async (data: any) => { + const { organization, id, zoneId } = data; + try { + const existingZone = await zoneSchema(organization).findOne({ + zoneId: zoneId, + isArchive: false, + }); + if (!existingZone) + return { + success: false, + message: "Zone not found", + organization: organization, + }; + const existing3Dwidget = await widget3dModel(organization).findOne({ + widgetID: id, + isArchive: false, + zoneId: zoneId, + }); + if (!existing3Dwidget) { + return { + success: false, + message: "3D widget not found for the ID", + organization: organization, + }; + } + const updateWidget = await widget3dModel(organization).findOneAndUpdate( + { + widgetID: id, + zoneId: zoneId, + isArchive: false, + }, + { isArchive: true }, + { new: true } + ); + if (updateWidget) { + const delete_Datas = { + zoneId: zoneId, + id: existing3Dwidget.widgetID, + }; + + return { + success: true, + data: delete_Datas, + message: "3DWidget delete successfull", + organization: organization, + }; + } + } catch (error: any) { + return { + success: false, + message: error?.message || "Error occurred while 3Dwidget", + error, + organization: organization, + }; + } +}; diff --git a/src/socket-server/services/visualization/floatWidget-Service.ts b/src/socket-server/services/visualization/floatWidget-Service.ts index f443b38..abad9d5 100644 --- a/src/socket-server/services/visualization/floatWidget-Service.ts +++ b/src/socket-server/services/visualization/floatWidget-Service.ts @@ -1,280 +1,280 @@ -import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts"; -import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts"; - -export const addfloat = async (data: any) => { - const { organization, widget, zoneId, index } = data; - try { - const existingZone = await zoneSchema(organization).findOne({ - zoneId: zoneId, - isArchive: false, - }); - if (!existingZone) - return { - success: false, - message: "Zone not found for the zoneId", - organization: organization, - }; - - const existingFloatWidget = await floatWidgetModel(organization).findOne({ - floatWidgetID: widget.id, - isArchive: false, - zoneId: zoneId, - }); - if (existingFloatWidget) { - const updateFloatWidget = await floatWidgetModel( - organization - ).findOneAndUpdate( - { - floatWidgetID: widget.id, - isArchive: false, - }, - { - $set: { - Data: { - measurements: widget?.Data?.measurements, - duration: widget?.Data?.duration, - }, - header: widget?.header, - position: widget?.position, - }, - }, - { - upsert: true, - new: true, - } - ); - const floatUpdateDatas = { - position: updateFloatWidget.position, - index: index, - zoneId: zoneId, - zoneName: existingZone.zoneName, - }; - return { - success: true, - message: "Widget updated successfully", - data: floatUpdateDatas, - organization: organization, - }; - } else { - const newFloadWidget = await floatWidgetModel(organization).create({ - className: widget.className, - iconName: widget.iconName, - header: widget.header, - floatWidgetID: widget.id, - position: widget.position, - per: widget.per, - value: widget.value, - zoneId: zoneId, - }); - if (newFloadWidget) { - const floatDatas = { - widget: { - position: newFloadWidget.position, - header: newFloadWidget.header, - value: newFloadWidget.value, - per: newFloadWidget.per, - className: newFloadWidget.className, - id: newFloadWidget.floatWidgetID, - }, - zoneId: zoneId, - zoneName: existingZone.zoneName, - }; - return { - success: true, - message: "FloatWidget created successfully", - data: floatDatas, - organization: organization, - }; - } - } - } catch (error: any) { - return { - success: false, - message: error?.message || "Error occurred while float", - error, - organization: organization, - }; - } -}; -export const duplicatefloat = async (data: any, callback: any) => { - const { organization, widget, zoneId, index } = data; - try { - const existingZone = await zoneSchema(organization).findOne({ - zoneId: zoneId, - isArchive: false, - }); - if (!existingZone) - return { - success: false, - message: "Zone not found for the zoneId", - organization: organization, - }; - - const existingFloatWidget = await floatWidgetModel(organization).findOne({ - floatWidgetID: widget.id, - isArchive: false, - zoneId: zoneId, - }); - if (existingFloatWidget) { - const updateFloatWidget = await floatWidgetModel( - organization - ).findOneAndUpdate( - { - floatWidgetID: widget.id, - isArchive: false, - }, - { - $set: { - Data: { - measurements: widget?.Data?.measurements, - duration: widget?.Data?.duration, - }, - header: widget?.header, - position: widget?.position, - }, - }, - { - upsert: true, - new: true, - } - ); - if (!updateFloatWidget) { - if (callback !== undefined) { - callback({ - success: false, - message: "FloatWidget update unsuccessfull", - }); - } - return { - success: false, - message: "FloatWidget update unsuccessfull", - organization: organization, - }; - } - const floatUpdateDatas = { - position: updateFloatWidget.position, - index: index, - zoneId: zoneId, - zoneName: existingZone.zoneName, - }; - if (callback !== undefined) { - callback({ - success: true, - message: "Widget updated successfully", - }); - } - return { - success: true, - message: "Widget updated successfully", - data: floatUpdateDatas, - organization: organization, - }; - } - - const newFloadWidget = await floatWidgetModel(organization).create({ - className: widget.className, - header: widget.header, - floatWidgetID: widget.id, - position: widget.position, - per: widget.per, - value: widget.value, - zoneId: zoneId, - Data: { - measurements: widget?.Data?.measurements, - duration: widget?.Data?.duration, - }, - }); - if (newFloadWidget) { - const floatDatas = { - widget: { - position: newFloadWidget.position, - header: newFloadWidget.header, - value: newFloadWidget.value, - per: newFloadWidget.per, - className: newFloadWidget.className, - id: newFloadWidget.floatWidgetID, - }, - zoneId: zoneId, - zoneName: existingZone.zoneName, - index: index, - }; - if (callback !== undefined) { - callback({ - success: true, - message: "duplicate FloatWidget created successfully", - }); - } - return { - success: true, - message: "duplicate FloatWidget created successfully", - data: floatDatas, - organization: organization, - }; - } - } catch (error: any) { - if (callback !== undefined) { - callback({ - success: false, - message: error?.message || "Error occurred while float", - }); - } - return { - success: false, - message: error?.message || "Error occurred while float", - error, - organization: organization, - }; - } -}; -export const deletefloat = async (data: any) => { - const { floatWidgetID, zoneId, organization } = data; - try { - const existingZone = await zoneSchema(organization).findOne({ - zoneId: zoneId, - isArchive: false, - }); - if (!existingZone) - return { - success: false, - message: "Zone not found for the zoneId", - organization: organization, - }; - - const findfloatWidget = await floatWidgetModel(organization).findOne({ - floatWidgetID: floatWidgetID, - isArchive: false, - }); - if (!findfloatWidget) - return { - success: false, - message: "Zone not found for the zoneId", - organization: organization, - }; - const widgetData = await floatWidgetModel(organization).findByIdAndUpdate( - { _id: findfloatWidget._id, isArchive: false }, - { isArchive: true }, - { new: true } - ); - - if (widgetData) { - const floatDeleteData = { - floatWidgetID: findfloatWidget.floatWidgetID, - zoneId: findfloatWidget.zoneId, - zoneName: existingZone.zoneName, - }; - return { - success: true, - message: "FloatingWidget deleted successfully", - data: floatDeleteData, - organization: organization, - }; - } - } catch (error: any) { - return { - success: false, - message: error?.message || "Error occurred while float", - error, - organization: organization, - }; - } -}; +import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts"; +import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts"; + +export const addfloat = async (data: any) => { + const { organization, widget, zoneId, index } = data; + try { + const existingZone = await zoneSchema(organization).findOne({ + zoneId: zoneId, + isArchive: false, + }); + if (!existingZone) + return { + success: false, + message: "Zone not found for the zoneId", + organization: organization, + }; + + const existingFloatWidget = await floatWidgetModel(organization).findOne({ + floatWidgetID: widget.id, + isArchive: false, + zoneId: zoneId, + }); + if (existingFloatWidget) { + const updateFloatWidget = await floatWidgetModel( + organization + ).findOneAndUpdate( + { + floatWidgetID: widget.id, + isArchive: false, + }, + { + $set: { + Data: { + measurements: widget?.Data?.measurements, + duration: widget?.Data?.duration, + }, + header: widget?.header, + position: widget?.position, + }, + }, + { + upsert: true, + new: true, + } + ); + const floatUpdateDatas = { + position: updateFloatWidget.position, + index: index, + zoneId: zoneId, + zoneName: existingZone.zoneName, + }; + return { + success: true, + message: "Widget updated successfully", + data: floatUpdateDatas, + organization: organization, + }; + } else { + const newFloadWidget = await floatWidgetModel(organization).create({ + className: widget.className, + iconName: widget.iconName, + header: widget.header, + floatWidgetID: widget.id, + position: widget.position, + per: widget.per, + value: widget.value, + zoneId: zoneId, + }); + if (newFloadWidget) { + const floatDatas = { + widget: { + position: newFloadWidget.position, + header: newFloadWidget.header, + value: newFloadWidget.value, + per: newFloadWidget.per, + className: newFloadWidget.className, + id: newFloadWidget.floatWidgetID, + }, + zoneId: zoneId, + zoneName: existingZone.zoneName, + }; + return { + success: true, + message: "FloatWidget created successfully", + data: floatDatas, + organization: organization, + }; + } + } + } catch (error: any) { + return { + success: false, + message: error?.message || "Error occurred while float", + error, + organization: organization, + }; + } +}; +export const duplicatefloat = async (data: any, callback: any) => { + const { organization, widget, zoneId, index } = data; + try { + const existingZone = await zoneSchema(organization).findOne({ + zoneId: zoneId, + isArchive: false, + }); + if (!existingZone) + return { + success: false, + message: "Zone not found for the zoneId", + organization: organization, + }; + + const existingFloatWidget = await floatWidgetModel(organization).findOne({ + floatWidgetID: widget.id, + isArchive: false, + zoneId: zoneId, + }); + if (existingFloatWidget) { + const updateFloatWidget = await floatWidgetModel( + organization + ).findOneAndUpdate( + { + floatWidgetID: widget.id, + isArchive: false, + }, + { + $set: { + Data: { + measurements: widget?.Data?.measurements, + duration: widget?.Data?.duration, + }, + header: widget?.header, + position: widget?.position, + }, + }, + { + upsert: true, + new: true, + } + ); + if (!updateFloatWidget) { + if (callback !== undefined) { + callback({ + success: false, + message: "FloatWidget update unsuccessfull", + }); + } + return { + success: false, + message: "FloatWidget update unsuccessfull", + organization: organization, + }; + } + const floatUpdateDatas = { + position: updateFloatWidget.position, + index: index, + zoneId: zoneId, + zoneName: existingZone.zoneName, + }; + if (callback !== undefined) { + callback({ + success: true, + message: "Widget updated successfully", + }); + } + return { + success: true, + message: "Widget updated successfully", + data: floatUpdateDatas, + organization: organization, + }; + } + + const newFloadWidget = await floatWidgetModel(organization).create({ + className: widget.className, + header: widget.header, + floatWidgetID: widget.id, + position: widget.position, + per: widget.per, + value: widget.value, + zoneId: zoneId, + Data: { + measurements: widget?.Data?.measurements, + duration: widget?.Data?.duration, + }, + }); + if (newFloadWidget) { + const floatDatas = { + widget: { + position: newFloadWidget.position, + header: newFloadWidget.header, + value: newFloadWidget.value, + per: newFloadWidget.per, + className: newFloadWidget.className, + id: newFloadWidget.floatWidgetID, + }, + zoneId: zoneId, + zoneName: existingZone.zoneName, + index: index, + }; + if (callback !== undefined) { + callback({ + success: true, + message: "duplicate FloatWidget created successfully", + }); + } + return { + success: true, + message: "duplicate FloatWidget created successfully", + data: floatDatas, + organization: organization, + }; + } + } catch (error: any) { + if (callback !== undefined) { + callback({ + success: false, + message: error?.message || "Error occurred while float", + }); + } + return { + success: false, + message: error?.message || "Error occurred while float", + error, + organization: organization, + }; + } +}; +export const deletefloat = async (data: any) => { + const { floatWidgetID, zoneId, organization } = data; + try { + const existingZone = await zoneSchema(organization).findOne({ + zoneId: zoneId, + isArchive: false, + }); + if (!existingZone) + return { + success: false, + message: "Zone not found for the zoneId", + organization: organization, + }; + + const findfloatWidget = await floatWidgetModel(organization).findOne({ + floatWidgetID: floatWidgetID, + isArchive: false, + }); + if (!findfloatWidget) + return { + success: false, + message: "Zone not found for the zoneId", + organization: organization, + }; + const widgetData = await floatWidgetModel(organization).findByIdAndUpdate( + { _id: findfloatWidget._id, isArchive: false }, + { isArchive: true }, + { new: true } + ); + + if (widgetData) { + const floatDeleteData = { + floatWidgetID: findfloatWidget.floatWidgetID, + zoneId: findfloatWidget.zoneId, + zoneName: existingZone.zoneName, + }; + return { + success: true, + message: "FloatingWidget deleted successfully", + data: floatDeleteData, + organization: organization, + }; + } + } catch (error: any) { + return { + success: false, + message: error?.message || "Error occurred while float", + error, + organization: organization, + }; + } +}; diff --git a/swagger-output.json b/swagger-output.json index d924d14..6ddffd2 100644 --- a/swagger-output.json +++ b/swagger-output.json @@ -1,943 +1,943 @@ -{ - "swagger": "2.0", - "info": { - "title": "dwinzo documentation", - "description": "Description", - "version": "1.0.0" - }, - "host": "185.100.212.76:5000", - "schemes": ["http"], - "tags": [ - { - "name": "Authentication", - "description": "User authentication endpoints" - }, - { - "name": "Camera", - "description": "Camera management endpoints" - }, - { - "name": "Environment", - "description": "Environment configuration" - }, - { - "name": "Floor Items", - "description": "Floor items management" - }, - { - "name": "Lines", - "description": "Line drawing operations" - }, - { - "name": "Walls", - "description": "Wall items management" - }, - { - "name": "Zones", - "description": "Zone operations" - }, - { - "name": "Users Management", - "description": "User sharing and permissions" - }, - { - "name": "3D widgets", - "description": "3D widgets operations" - }, - { - "name": "Panels", - "description": "Panels operations" - }, - { - "name": "Floating Widgets", - "description": "Floating widgets operations" - }, - { - "name": "Assets", - "description": "ModelAssets operations" - }, - { - "name": "Asset Points", - "description": "Asset based structure Points" - } - ], - "paths": { - "/api/v1/signup": { - "post": { - "tags": ["Authentication"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "userName": { - "example": "any" - }, - "email": { - "example": "any" - }, - "password": { - "example": "any" - }, - "organization": { - "example": "any" - }, - "profilePicture": { - "example": "any" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/login": { - "post": { - "tags": ["Authentication"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "email": { - "example": "any" - }, - "password": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/setCamera": { - "post": { - "tags": ["Camera"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "userId": { - "example": "any" - }, - "position": { - "example": "any" - }, - "target": { - "example": "any" - }, - "rotation": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/getCamera/{organization}/{userId}": { - "get": { - "tags": ["Camera"], - "description": "", - "parameters": [ - { - "name": "organization", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "userId", - "in": "path", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/activeCameras/{organization}": { - "get": { - "tags": ["Camera"], - "description": "", - "parameters": [ - { - "name": "organization", - "in": "path", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/setEvironments": { - "post": { - "tags": ["Environment"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "userId": { - "example": "any" - }, - "roofVisibility": { - "example": "any" - }, - "wallVisibility": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/findEnvironments/{organization}/{userId}": { - "get": { - "tags": ["Environment"], - "description": "", - "parameters": [ - { - "name": "organization", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "userId", - "in": "path", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/setfloorItems": { - "post": { - "tags": ["Floor Items"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "modelUuid": { - "example": "any" - }, - "modelName": { - "example": "any" - }, - "position": { - "example": "any" - }, - "modelfileID": { - "example": "any" - }, - "rotation": { - "example": "any" - }, - "isLocked": { - "example": "any" - }, - "isVisible": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/findfloorItems/{organization}": { - "get": { - "tags": ["Floor Items"], - "description": "", - "parameters": [ - { - "name": "organization", - "in": "path", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/deletefloorItem": { - "delete": { - "tags": ["Floor Items"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "modelUuid": { - "example": "any" - }, - "modelName": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/setLine": { - "post": { - "tags": ["Lines"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "organization": { - "example": "any" - }, - "layer": { - "example": "any" - }, - "line": { - "example": "any" - }, - "type": { - "example": "any" - } - } - } - } - ], - "responses": { - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/updatePoint": { - "post": { - "tags": ["Lines"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "organization": { - "example": "any" - }, - "uuid": { - "example": "any" - }, - "position": { - "example": "any" - } - } - } - } - ], - "responses": { - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/findLines/{organization}": { - "get": { - "tags": ["Lines"], - "description": "", - "parameters": [ - { - "name": "organization", - "in": "path", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/deleteLine": { - "delete": { - "tags": ["Lines"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "organization": { - "example": "any" - }, - "layer": { - "example": "any" - }, - "line": { - "example": "any" - }, - "type": { - "example": "any" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/deletePoint": { - "delete": { - "tags": ["Lines"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "organization": { - "example": "any" - }, - "layer": { - "example": "any" - }, - "uuid": { - "example": "any" - }, - "type": { - "example": "any" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/deleteLayer": { - "post": { - "tags": ["Lines"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "organization": { - "example": "any" - }, - "layer": { - "example": "any" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/shareUser": { - "post": { - "tags": ["Users Management"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "email": { - "example": "any" - }, - "isShare": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "201": { - "description": "Created" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/findshareUsers": { - "get": { - "tags": ["Users Management"], - "description": "", - "parameters": [ - { - "name": "organization", - "in": "query", - "type": "string" - } - ], - "responses": { - "201": { - "description": "Created" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/setWallItems": { - "post": { - "tags": ["Walls"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "modelUuid": { - "example": "any" - }, - "modelName": { - "example": "any" - }, - "position": { - "example": "any" - }, - "type": { - "example": "any" - }, - "csgposition": { - "example": "any" - }, - "csgscale": { - "example": "any" - }, - "quaternion": { - "example": "any" - }, - "scale": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/findWallItems/{organization}": { - "get": { - "tags": ["Walls"], - "description": "", - "parameters": [ - { - "name": "organization", - "in": "path", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v1/deleteWallItem": { - "delete": { - "tags": ["Walls"], - "description": "", - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "modelUuid": { - "example": "any" - }, - "modelName": { - "example": "any" - }, - "organization": { - "example": "any" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK" - }, - "201": { - "description": "Created" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/api/v2/zone/save": { - "post": { - "tags": ["Zones"], - "description": "Create or update a zone", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "organization": { - "type": "string", - "example": "NEWORG" - }, - "zonesdata": { - "type": "object", - "properties": { - "zonename": { - "type": "string", - "example": "Zone 2" - }, - "zoneId": { - "type": "string", - "example": "576-65-6-659" - }, - "points": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "object", - "properties": { - "x": { "type": "number" }, - "y": { "type": "number" } - } - } - }, - "example": [ - [{ "x": 5, "y": 5 }], - [{ "x": 5, "y": 5 }], - [{ "x": 0, "y": 0 }] - ] - }, - "viewportPosition": { - "type": "array", - "items": { - "type": "object", - "properties": { - "x": { "type": "number" } - } - }, - "example": [{ "x": 0 }] - }, - "viewPortCenter": { - "type": "object", - "properties": { - "x": { "type": "number" }, - "y": { "type": "number" } - } - }, - "userid": { - "type": "string" - }, - "layer": { - "type": "number", - "example": 1 - }, - "sceneID": { - "type": "string" - } - }, - "required": [ - "zonename", - "zoneId", - "points", - "viewportPosition", - "layer" - ] - } - }, - "required": ["organization", "zonesdata"] - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "message": { "type": "string" }, - "zoneData": { - "type": "object", - "properties": { - "zoneName": { "type": "string" }, - "points": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "object", - "properties": { - "x": { "type": "number" }, - "y": { "type": "number" } - } - } - } - }, - "viewPortposition": { - "type": "array", - "items": { - "type": "object", - "properties": { - "x": { "type": "number" } - } - } - }, - "viewPortCenter": { - "type": "object", - "properties": { - "x": { "type": "number" }, - "y": { "type": "number" } - } - } - } - } - } - } - }, - "201": { - "description": "Created" - }, - "404": { - "description": "Zone not updated" - }, - "500": { - "description": "Internal Server Error" - } - } - } - } - } -} +{ + "swagger": "2.0", + "info": { + "title": "dwinzo documentation", + "description": "Description", + "version": "1.0.0" + }, + "host": "185.100.212.76:5000", + "schemes": ["http"], + "tags": [ + { + "name": "Authentication", + "description": "User authentication endpoints" + }, + { + "name": "Camera", + "description": "Camera management endpoints" + }, + { + "name": "Environment", + "description": "Environment configuration" + }, + { + "name": "Floor Items", + "description": "Floor items management" + }, + { + "name": "Lines", + "description": "Line drawing operations" + }, + { + "name": "Walls", + "description": "Wall items management" + }, + { + "name": "Zones", + "description": "Zone operations" + }, + { + "name": "Users Management", + "description": "User sharing and permissions" + }, + { + "name": "3D widgets", + "description": "3D widgets operations" + }, + { + "name": "Panels", + "description": "Panels operations" + }, + { + "name": "Floating Widgets", + "description": "Floating widgets operations" + }, + { + "name": "Assets", + "description": "ModelAssets operations" + }, + { + "name": "Asset Points", + "description": "Asset based structure Points" + } + ], + "paths": { + "/api/v1/signup": { + "post": { + "tags": ["Authentication"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "userName": { + "example": "any" + }, + "email": { + "example": "any" + }, + "password": { + "example": "any" + }, + "organization": { + "example": "any" + }, + "profilePicture": { + "example": "any" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/login": { + "post": { + "tags": ["Authentication"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "email": { + "example": "any" + }, + "password": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/setCamera": { + "post": { + "tags": ["Camera"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "userId": { + "example": "any" + }, + "position": { + "example": "any" + }, + "target": { + "example": "any" + }, + "rotation": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/getCamera/{organization}/{userId}": { + "get": { + "tags": ["Camera"], + "description": "", + "parameters": [ + { + "name": "organization", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "userId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/activeCameras/{organization}": { + "get": { + "tags": ["Camera"], + "description": "", + "parameters": [ + { + "name": "organization", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/setEvironments": { + "post": { + "tags": ["Environment"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "userId": { + "example": "any" + }, + "roofVisibility": { + "example": "any" + }, + "wallVisibility": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/findEnvironments/{organization}/{userId}": { + "get": { + "tags": ["Environment"], + "description": "", + "parameters": [ + { + "name": "organization", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "userId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/setfloorItems": { + "post": { + "tags": ["Floor Items"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "modelUuid": { + "example": "any" + }, + "modelName": { + "example": "any" + }, + "position": { + "example": "any" + }, + "modelfileID": { + "example": "any" + }, + "rotation": { + "example": "any" + }, + "isLocked": { + "example": "any" + }, + "isVisible": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/findfloorItems/{organization}": { + "get": { + "tags": ["Floor Items"], + "description": "", + "parameters": [ + { + "name": "organization", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/deletefloorItem": { + "delete": { + "tags": ["Floor Items"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "modelUuid": { + "example": "any" + }, + "modelName": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/setLine": { + "post": { + "tags": ["Lines"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "organization": { + "example": "any" + }, + "layer": { + "example": "any" + }, + "line": { + "example": "any" + }, + "type": { + "example": "any" + } + } + } + } + ], + "responses": { + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/updatePoint": { + "post": { + "tags": ["Lines"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "organization": { + "example": "any" + }, + "uuid": { + "example": "any" + }, + "position": { + "example": "any" + } + } + } + } + ], + "responses": { + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/findLines/{organization}": { + "get": { + "tags": ["Lines"], + "description": "", + "parameters": [ + { + "name": "organization", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/deleteLine": { + "delete": { + "tags": ["Lines"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "organization": { + "example": "any" + }, + "layer": { + "example": "any" + }, + "line": { + "example": "any" + }, + "type": { + "example": "any" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/deletePoint": { + "delete": { + "tags": ["Lines"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "organization": { + "example": "any" + }, + "layer": { + "example": "any" + }, + "uuid": { + "example": "any" + }, + "type": { + "example": "any" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/deleteLayer": { + "post": { + "tags": ["Lines"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "organization": { + "example": "any" + }, + "layer": { + "example": "any" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/shareUser": { + "post": { + "tags": ["Users Management"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "email": { + "example": "any" + }, + "isShare": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "201": { + "description": "Created" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/findshareUsers": { + "get": { + "tags": ["Users Management"], + "description": "", + "parameters": [ + { + "name": "organization", + "in": "query", + "type": "string" + } + ], + "responses": { + "201": { + "description": "Created" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/setWallItems": { + "post": { + "tags": ["Walls"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "modelUuid": { + "example": "any" + }, + "modelName": { + "example": "any" + }, + "position": { + "example": "any" + }, + "type": { + "example": "any" + }, + "csgposition": { + "example": "any" + }, + "csgscale": { + "example": "any" + }, + "quaternion": { + "example": "any" + }, + "scale": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/findWallItems/{organization}": { + "get": { + "tags": ["Walls"], + "description": "", + "parameters": [ + { + "name": "organization", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v1/deleteWallItem": { + "delete": { + "tags": ["Walls"], + "description": "", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "modelUuid": { + "example": "any" + }, + "modelName": { + "example": "any" + }, + "organization": { + "example": "any" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "201": { + "description": "Created" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/api/v2/zone/save": { + "post": { + "tags": ["Zones"], + "description": "Create or update a zone", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "organization": { + "type": "string", + "example": "NEWORG" + }, + "zonesdata": { + "type": "object", + "properties": { + "zonename": { + "type": "string", + "example": "Zone 2" + }, + "zoneId": { + "type": "string", + "example": "576-65-6-659" + }, + "points": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "x": { "type": "number" }, + "y": { "type": "number" } + } + } + }, + "example": [ + [{ "x": 5, "y": 5 }], + [{ "x": 5, "y": 5 }], + [{ "x": 0, "y": 0 }] + ] + }, + "viewportPosition": { + "type": "array", + "items": { + "type": "object", + "properties": { + "x": { "type": "number" } + } + }, + "example": [{ "x": 0 }] + }, + "viewPortCenter": { + "type": "object", + "properties": { + "x": { "type": "number" }, + "y": { "type": "number" } + } + }, + "userid": { + "type": "string" + }, + "layer": { + "type": "number", + "example": 1 + }, + "sceneID": { + "type": "string" + } + }, + "required": [ + "zonename", + "zoneId", + "points", + "viewportPosition", + "layer" + ] + } + }, + "required": ["organization", "zonesdata"] + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "message": { "type": "string" }, + "zoneData": { + "type": "object", + "properties": { + "zoneName": { "type": "string" }, + "points": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "x": { "type": "number" }, + "y": { "type": "number" } + } + } + } + }, + "viewPortposition": { + "type": "array", + "items": { + "type": "object", + "properties": { + "x": { "type": "number" } + } + } + }, + "viewPortCenter": { + "type": "object", + "properties": { + "x": { "type": "number" }, + "y": { "type": "number" } + } + } + } + } + } + } + }, + "201": { + "description": "Created" + }, + "404": { + "description": "Zone not updated" + }, + "500": { + "description": "Internal Server Error" + } + } + } + } + } +}