Compare commits
1 Commits
main
...
Main-dupli
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b15772692 |
10
.env
10
.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
|
||||
|
||||
22
Dwinzo-Backend-OLD.code-workspace
Normal file
22
Dwinzo-Backend-OLD.code-workspace
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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<void> => {
|
||||
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<void> => {
|
||||
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",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
try {
|
||||
const { productId, productName, organization } = req.body;
|
||||
|
||||
const existingProduct = await ProductModel(organization).findOne({
|
||||
productId: productId,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
if (!existingProduct)
|
||||
return res.status(404).json({ message: "Product not found" });
|
||||
|
||||
await ProductModel(organization).findOneAndUpdate(
|
||||
{ productId: productId },
|
||||
{
|
||||
productName: productName,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
return res.status(201).json({ message: "product Rename successfully" });
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Failed to product Rename" });
|
||||
}
|
||||
}
|
||||
}
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
try {
|
||||
const { productId, productName, organization } = req.body;
|
||||
|
||||
const existingProduct = await ProductModel(organization).findOne({
|
||||
productId: productId,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
if (!existingProduct)
|
||||
return res.status(404).json({ message: "Product not found" });
|
||||
|
||||
await ProductModel(organization).findOneAndUpdate(
|
||||
{ productId: productId },
|
||||
{
|
||||
productName: productName,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
return res.status(201).json({ message: "product Rename successfully" });
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Failed to product Rename" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,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;
|
||||
|
||||
@@ -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<IPointModel>(
|
||||
{
|
||||
modelUuid: { type: String, required: true },
|
||||
modelName: { type: String, required: true },
|
||||
position: { type: [Number], required: true },
|
||||
rotation: { type: [Number], required: true },
|
||||
speed: { type: Number },
|
||||
state: {
|
||||
type: String,
|
||||
enum: ["idle", "running", "stopped", "disabled", "error"],
|
||||
default: "idle",
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"],
|
||||
},
|
||||
point: {
|
||||
type: Schema.Types.Mixed,
|
||||
},
|
||||
points: {
|
||||
type: Schema.Types.Mixed,
|
||||
},
|
||||
productId: { type: String, required: true },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
},
|
||||
{ discriminatorKey: "type", timestamps: true }
|
||||
);
|
||||
|
||||
const EventsDataModel = (db: string) => {
|
||||
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
||||
};
|
||||
|
||||
export default EventsDataModel;
|
||||
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<IPointModel>(
|
||||
{
|
||||
modelUuid: { type: String, required: true },
|
||||
modelName: { type: String, required: true },
|
||||
position: { type: [Number], required: true },
|
||||
rotation: { type: [Number], required: true },
|
||||
speed: { type: Number },
|
||||
state: {
|
||||
type: String,
|
||||
enum: ["idle", "running", "stopped", "disabled", "error"],
|
||||
default: "idle",
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"],
|
||||
},
|
||||
point: {
|
||||
type: Schema.Types.Mixed,
|
||||
},
|
||||
points: {
|
||||
type: Schema.Types.Mixed,
|
||||
},
|
||||
productId: { type: String, required: true },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
},
|
||||
{ discriminatorKey: "type", timestamps: true }
|
||||
);
|
||||
|
||||
const EventsDataModel = (db: string) => {
|
||||
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
||||
};
|
||||
|
||||
export default EventsDataModel;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
1886
swagger-output.json
1886
swagger-output.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user