panel widget point service and model API completed
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
import zoneRouter from "../API/routes/zoneRoutes.ts";
|
||||
import panelRouter from "../API/routes/panelRoutes.ts";
|
||||
import widgetRouter from "../API/routes/widgetRoute.ts";
|
||||
import swaggerOptions from "./swagger/swagger.ts";
|
||||
import swaggerUi from "swagger-ui-express";
|
||||
import swaggerJSDoc from "swagger-jsdoc";
|
||||
import zoneRouter from "./routes/zoneRoutes.ts";
|
||||
import panelRouter from "./routes/panelRoutes.ts";
|
||||
import widgetRouter from "./routes/widgetRoute.ts";
|
||||
import pointRouter from "./routes/pointroutes.ts";
|
||||
const app = express();
|
||||
const swaggerSpec = swaggerJSDoc(swaggerOptions);
|
||||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
||||
app.use("/api/v1", zoneRouter);
|
||||
app.use("/api/v1", panelRouter);
|
||||
app.use("/api/v1", widgetRouter);
|
||||
app.use("/api/v1", pointRouter);
|
||||
export default app;
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
import ip from "ip";
|
||||
import approutes from "./app.ts";
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use(approutes);
|
||||
app.use(cors());
|
||||
const port = process.env.PORT || 3000;
|
||||
const port = process.env.PORT || 5004;
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running in the port ${port}`);
|
||||
console.log(
|
||||
`Swagger docs available at http://${ip.address()}:${port}/api-docs`
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,140 @@
|
||||
import * as express from "express";
|
||||
import { panelService } from "../service/panelService.ts";
|
||||
const router = express.Router();
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* - name: Panels
|
||||
* description: API operations related to panels
|
||||
*/
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Panel:
|
||||
* type: object
|
||||
* properties:
|
||||
* _id:
|
||||
* type: string
|
||||
* example: "60d0fe4f5311236168a109ca"
|
||||
* zoneID:
|
||||
* type: string
|
||||
* example: "67e3d030ed12ffa47b4eade3"
|
||||
* panelName:
|
||||
* type: string
|
||||
* example: "New Panel"
|
||||
* widgets:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* example: []
|
||||
* isArchive:
|
||||
* type: boolean
|
||||
* example: false
|
||||
* required:
|
||||
* - zoneID
|
||||
* - panelName
|
||||
* - widgets
|
||||
* - isArchive
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /panel/save:
|
||||
* post:
|
||||
* summary: Create new panels for a given zone
|
||||
* tags: [Panels]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* organization:
|
||||
* type: string
|
||||
* example: "NEWORG"
|
||||
* zoneID:
|
||||
* type: string
|
||||
* example: "67e3d030ed12ffa47b4eade3"
|
||||
* panelOrder:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* example: ["up", "right", "left", "down"]
|
||||
* responses:
|
||||
* 201:
|
||||
* description: Panels created successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Panels created successfully"
|
||||
* panelID:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* example: ["60d0fe4f5311236168a109ca", "60d0fe4f5311236168a109cb"]
|
||||
* 200:
|
||||
* description: No new panels were created as they already exist
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "No new panels were created. All panels already exist."
|
||||
* 404:
|
||||
* description: Zone not found
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Zone not found"
|
||||
* 500:
|
||||
* description: Server error
|
||||
*/
|
||||
router.post("/panel/save", panelService.AddPanel);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /panel/delete:
|
||||
* patch:
|
||||
* summary: Delete the panel on the Zone
|
||||
* tags: [Panels]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* organization:
|
||||
* type: string
|
||||
* example: "NEWORG"
|
||||
* zoneID:
|
||||
* type: string
|
||||
* example: "0114-58-064-925"
|
||||
* panelID:
|
||||
* type: string
|
||||
* example: "67e4f754cc778ad6c123394b"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Panel deleted successfully
|
||||
* 409:
|
||||
* description: Panel Already Deleted
|
||||
* 404:
|
||||
* description: Zone not found
|
||||
* 500:
|
||||
* description: Server error
|
||||
*/
|
||||
router.patch("/panel/delete", panelService.deletePanel);
|
||||
// router.get("/zone/:sceneID", Zoneservice.allZones);
|
||||
export default router;
|
||||
|
||||
6
src/API/routes/pointroutes.ts
Normal file
6
src/API/routes/pointroutes.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as express from "express";
|
||||
import { pointService } from "../service/pointservice.ts";
|
||||
const router = express.Router();
|
||||
router.post("/pointcreate/:organization", pointService.pointCreate);
|
||||
router.get("/pointget/:modelfileID/:organization", pointService.GetPoints);
|
||||
export default router;
|
||||
@@ -1,5 +1,143 @@
|
||||
import * as express from "express";
|
||||
import { widgetService } from "../service/widgetService.ts";
|
||||
const router = express.Router();
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* - name: Widgets
|
||||
* description: API operations related to widgets
|
||||
*/
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Widget:
|
||||
* type: object
|
||||
* properties:
|
||||
* _id:
|
||||
* type: string
|
||||
* example: "60d0fe4f5311236168a109cd"
|
||||
* widgetName:
|
||||
* type: string
|
||||
* example: "Temperature Widget"
|
||||
* widgetside:
|
||||
* type: string
|
||||
* example: "right"
|
||||
* widgetID:
|
||||
* type: string
|
||||
* example: "wid-12345"
|
||||
* widgetOrder:
|
||||
* type: string
|
||||
* example: "1"
|
||||
* elementType:
|
||||
* type: string
|
||||
* example: "chart"
|
||||
* elementColor:
|
||||
* type: string
|
||||
* example: "#FF5733"
|
||||
* fontFamily:
|
||||
* type: string
|
||||
* example: "Arial"
|
||||
* fontStyle:
|
||||
* type: string
|
||||
* example: "bold"
|
||||
* fontWeight:
|
||||
* type: string
|
||||
* example: "600"
|
||||
* isArchive:
|
||||
* type: boolean
|
||||
* example: false
|
||||
* panelID:
|
||||
* type: string
|
||||
* example: "67e3d030ed12ffa47b4eade3"
|
||||
* Data:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* example: []
|
||||
* required:
|
||||
* - widgetName
|
||||
* - widgetID
|
||||
* - widgetOrder
|
||||
* - elementType
|
||||
* - panelID
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @swagger
|
||||
* /widget/save:
|
||||
* post:
|
||||
* summary: Create a new widget inside a panel
|
||||
* tags: [Widgets]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* organization:
|
||||
* type: string
|
||||
* example: "NEWORG"
|
||||
* panelID:
|
||||
* type: string
|
||||
* example: "67e3d030ed12ffa47b4eade3"
|
||||
* widgetName:
|
||||
* type: string
|
||||
* example: "Temperature Widget"
|
||||
* widgetOrder:
|
||||
* type: string
|
||||
* example: "1"
|
||||
* type:
|
||||
* type: string
|
||||
* example: "chart"
|
||||
* widgetID:
|
||||
* type: string
|
||||
* example: "wid-12345"
|
||||
* panel:
|
||||
* type: string
|
||||
* example: "right"
|
||||
* responses:
|
||||
* 201:
|
||||
* description: Widget created successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Widget created successfully"
|
||||
* widgetID:
|
||||
* type: string
|
||||
* example: "60d0fe4f5311236168a109cd"
|
||||
* 404:
|
||||
* description: Panel not found
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "PanelID not found"
|
||||
* 409:
|
||||
* description: Widget with the given widgetID already exists
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Widget already exists for the widgetID"
|
||||
* 500:
|
||||
* description: Server error
|
||||
*/
|
||||
router.post("/widget/save", widgetService.addWidget);
|
||||
router.patch("/widget/delete", widgetService.deleteWidget);
|
||||
router.get(
|
||||
"/WidgetData/:widgetID/:organization",
|
||||
widgetService.getDatafromWidget
|
||||
);
|
||||
export default router;
|
||||
|
||||
@@ -1,10 +1,539 @@
|
||||
import * as express from "express";
|
||||
import { Zoneservice } from "../service/zoneService.ts";
|
||||
const router = express.Router();
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Zone:
|
||||
* type: object
|
||||
* required:
|
||||
* - zoneName
|
||||
* - zoneUUID
|
||||
* - sceneID
|
||||
* - createdBy
|
||||
* - layer
|
||||
* - viewPortCenter
|
||||
* - viewPortposition
|
||||
* properties:
|
||||
* zoneName:
|
||||
* type: string
|
||||
* description: Name of the zone
|
||||
* zoneUUID:
|
||||
* type: string
|
||||
* description: Unique identifier for the zone
|
||||
* sceneID:
|
||||
* type: string
|
||||
* description: ID of the scene associated with the zone
|
||||
* createdBy:
|
||||
* type: string
|
||||
* description: User ID who created the zone
|
||||
* layer:
|
||||
* type: integer
|
||||
* description: Layer number in the scene
|
||||
* zonePoints:
|
||||
* type: array
|
||||
* description: List of points defining the zone
|
||||
* items:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* y:
|
||||
* type: number
|
||||
* viewPortCenter:
|
||||
* type: array
|
||||
* description: Center position of the viewport
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* y:
|
||||
* type: number
|
||||
* viewPortposition:
|
||||
* type: array
|
||||
* description: Position of the viewport
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* panelOrder:
|
||||
* type: array
|
||||
* description: Order of panels
|
||||
* items:
|
||||
* type: string
|
||||
* enum: ["left", "right", "up", "down"]
|
||||
* lockedPanel:
|
||||
* type: array
|
||||
* description: Locked panels in the zone
|
||||
* items:
|
||||
* type: string
|
||||
* enum: ["left", "right", "up", "down"]
|
||||
* isArchive:
|
||||
* type: boolean
|
||||
* description: Flag to mark if the zone is archived
|
||||
* createdAt:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* description: Timestamp when the zone was created
|
||||
* updatedAt:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* description: Timestamp when the zone was last updated
|
||||
* example:
|
||||
* zoneName: "Zone 2"
|
||||
* zoneUUID: "0114-58-064-9"
|
||||
* sceneID: "125789632548"
|
||||
* createdBy: "012357894268"
|
||||
* layer: 1
|
||||
* zonePoints: [[{"x":5,"y":5}], [{"x":5,"y":5}], [{"x":5,"y":5}]]
|
||||
* viewPortCenter: [{"x":5, "y":5}]
|
||||
* viewPortposition: [{"x":5}]
|
||||
* panelOrder: ["left", "right"]
|
||||
* lockedPanel: ["up"]
|
||||
* isArchive: false
|
||||
* createdAt: "2025-01-01T00:00:00Z"
|
||||
* updatedAt: "2025-01-01T00:00:00Z"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Zones
|
||||
* description: API for managing zones
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /zone/save:
|
||||
* post:
|
||||
* summary: Create or update a zone
|
||||
* tags: [Zones]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - organization
|
||||
* - zonesdata
|
||||
* properties:
|
||||
* organization:
|
||||
* type: string
|
||||
* description: Organization name
|
||||
* example: "NEWORG"
|
||||
* zonesdata:
|
||||
* type: object
|
||||
* required:
|
||||
* - zonename
|
||||
* - zoneId
|
||||
* - sceneID
|
||||
* - userid
|
||||
* - layer
|
||||
* - points
|
||||
* - viewportPosition
|
||||
* properties:
|
||||
* zonename:
|
||||
* type: string
|
||||
* description: Name of the zone
|
||||
* example: "Zone 2"
|
||||
* zoneId:
|
||||
* type: string
|
||||
* description: Unique identifier for the zone
|
||||
* example: "0114-58-064-9"
|
||||
* sceneID:
|
||||
* type: string
|
||||
* description: ID of the scene associated with the zone
|
||||
* example: "125789632548"
|
||||
* userid:
|
||||
* type: string
|
||||
* description: User ID who created the zone
|
||||
* example: "012357894268"
|
||||
* layer:
|
||||
* type: integer
|
||||
* description: Layer number in the scene
|
||||
* example: 1
|
||||
* points:
|
||||
* type: array
|
||||
* description: List of points defining the zone
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* y:
|
||||
* type: number
|
||||
* example: [{"x":5,"y":5}, {"x":10,"y":10}]
|
||||
* viewportPosition:
|
||||
* type: array
|
||||
* description: Position of the viewport
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* y:
|
||||
* type: number
|
||||
* example: [{"x":5, "y":5}]
|
||||
* viewPortCenter:
|
||||
* type: array
|
||||
* description: Center of the viewport
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* y:
|
||||
* type: number
|
||||
* example: [{"x":10, "y":10}]
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Zone created or updated successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Zone created successfully"
|
||||
* zoneData:
|
||||
* type: object
|
||||
* properties:
|
||||
* zoneName:
|
||||
* type: string
|
||||
* points:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* y:
|
||||
* type: number
|
||||
* viewPortposition:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* viewPortCenter:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* 404:
|
||||
* description: Zone not updated
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Zone not updated"
|
||||
* 500:
|
||||
* description: Server error
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* error:
|
||||
* type: string
|
||||
* example: "Internal server error"
|
||||
*/
|
||||
router.post("/zone/save", Zoneservice.addandUpdateZone); //Zone create and update for the points
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /zones/{sceneID}:
|
||||
* get:
|
||||
* summary: Get all zones for a scene
|
||||
* tags: [Zones]
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: sceneID
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: ID of the scene
|
||||
* - in: query
|
||||
* name: organization
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Organization name
|
||||
* responses:
|
||||
* 200:
|
||||
* description: List of zones retrieved successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* zoneName:
|
||||
* type: string
|
||||
* description: Name of the zone
|
||||
* sceneID:
|
||||
* type: string
|
||||
* description: Scene ID associated with the zone
|
||||
* zoneUUID:
|
||||
* type: string
|
||||
* description: Unique identifier for the zone
|
||||
* 404:
|
||||
* description: No zones found for the given scene ID
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Zone not found for the UUID"
|
||||
* 500:
|
||||
* description: Server error
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* error:
|
||||
* type: string
|
||||
* example: "Internal Server Error"
|
||||
* examples:
|
||||
* Successful Response:
|
||||
* value:
|
||||
* - zoneName: "Zone A"
|
||||
* sceneID: "scene123"
|
||||
* zoneUUID: "UUID-12345"
|
||||
* - zoneName: "Zone B"
|
||||
* sceneID: "scene123"
|
||||
* zoneUUID: "UUID-67890"
|
||||
* Not Found Response:
|
||||
* value:
|
||||
* message: "Zone not found for the UUID"
|
||||
*/
|
||||
router.get("/zones/:sceneID", Zoneservice.allZones);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /ZoneVisualization/{zoneID}:
|
||||
* get:
|
||||
* summary: Get Zone Panel Data
|
||||
* tags: [Zones]
|
||||
* description: Fetches zone panel details including widgets, panel order, locked panels, and points.
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: zoneID
|
||||
* required: true
|
||||
* description: The unique identifier of the zone.
|
||||
* schema:
|
||||
* type: string
|
||||
* - in: query
|
||||
* name: organization
|
||||
* required: true
|
||||
* description: The organization name to filter data.
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Zone panel data retrieved successfully.
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* zoneName:
|
||||
* type: string
|
||||
* activeSides:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* panelOrder:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* lockedPanels:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* points:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* x:
|
||||
* type: number
|
||||
* y:
|
||||
* type: number
|
||||
* widgets:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: string
|
||||
* type:
|
||||
* type: string
|
||||
* title:
|
||||
* type: string
|
||||
* panel:
|
||||
* type: string
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* example:
|
||||
* zoneName: "Zone 2"
|
||||
* activeSides: []
|
||||
* panelOrder: []
|
||||
* lockedPanels: []
|
||||
* points:
|
||||
* - x: 5
|
||||
* y: 5
|
||||
* - x: 10
|
||||
* y: 10
|
||||
* widgets: []
|
||||
* 404:
|
||||
* description: Zone not found
|
||||
* content:
|
||||
* application/json:
|
||||
* example:
|
||||
* message: "Zone not found for the UUID"
|
||||
* 500:
|
||||
* description: Internal Server Error
|
||||
* content:
|
||||
* application/json:
|
||||
* example:
|
||||
* error: "Internal Server Error"
|
||||
*/
|
||||
router.get("/ZoneVisualization/:zoneID", Zoneservice.singleZonePanelDatas);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /A_zone/{zoneID}:
|
||||
* get:
|
||||
* summary: Get a specific zone's data
|
||||
* tags: [Zones]
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: zoneID
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Unique identifier of the zone
|
||||
* - in: query
|
||||
* name: organization
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Organization name
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Zone data retrieved successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* zoneUUID:
|
||||
* type: string
|
||||
* description: Unique identifier of the zone
|
||||
* zoneName:
|
||||
* type: string
|
||||
* description: Name of the zone
|
||||
* isArchive:
|
||||
* type: boolean
|
||||
* description: Indicates if the zone is archived
|
||||
* 404:
|
||||
* description: Zone not found
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Zone not found"
|
||||
* 500:
|
||||
* description: Server error
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* error:
|
||||
* type: string
|
||||
* example: "Internal Server Error"
|
||||
* examples:
|
||||
* Successful Response:
|
||||
* value:
|
||||
* zoneUUID: "abc123"
|
||||
* zoneName: "Zone A"
|
||||
* isArchive: false
|
||||
* otherProperties: {}
|
||||
* Not Found Response:
|
||||
* value:
|
||||
* message: "Zone not found"
|
||||
*/
|
||||
router.get("/A_zone/:zoneID", Zoneservice.ZoneData);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /zone/{zoneID}:
|
||||
* patch:
|
||||
* summary: Soft delete a zone
|
||||
* tags: [Zones]
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: zoneID
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Unique identifier of the zone
|
||||
* - in: query
|
||||
* name: organization
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Organization name
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Zone successfully deleted
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Zone deleted successfully"
|
||||
* 404:
|
||||
* description: Zone not found
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* message:
|
||||
* type: string
|
||||
* example: "Zone not found for the UUID"
|
||||
* 500:
|
||||
* description: Server error
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* error:
|
||||
* type: string
|
||||
* example: "Internal Server Error"
|
||||
*/
|
||||
router.patch("/zone/:zoneID", Zoneservice.deleteAZone); //delete Zone
|
||||
// router.get("/zone/:sceneID", Zoneservice.allZones);
|
||||
export default router;
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { Request, Response } from "express";
|
||||
import panelSchema from "../../shared/model/vizualization/panelmodel.ts";
|
||||
import zoneSchema from "../../shared/model/builder/lines/zone-Model.ts";
|
||||
import widgetSchema from "../../shared/model/vizualization/widgemodel.ts";
|
||||
|
||||
export class panelService {
|
||||
static async AddPanel(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const organization = req.body.organization;
|
||||
const zoneID = req.body.zoneID;
|
||||
const zoneId = req.body.zoneId;
|
||||
const panelName = req.body.panelName;
|
||||
const panelOrder = req.body.panelOrder;
|
||||
const findZone = await zoneSchema(organization).findOne({
|
||||
_id: zoneID,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
@@ -17,12 +19,12 @@ export class panelService {
|
||||
return res.status(404).json({ message: "Zone not found" });
|
||||
}
|
||||
const updatezone = await zoneSchema(organization).findOneAndUpdate(
|
||||
{ _id: findZone._id, isArchive: false },
|
||||
{ zoneId: zoneId, isArchive: false },
|
||||
{ panelOrder: panelOrder },
|
||||
{ new: true }
|
||||
);
|
||||
const existingPanels = await panelSchema(organization).find({
|
||||
zoneID: zoneID,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
@@ -37,7 +39,7 @@ export class panelService {
|
||||
const createdPanels = [];
|
||||
for (const panelName of missingPanels) {
|
||||
const newPanel = await panelSchema(organization).create({
|
||||
zoneID: zoneID,
|
||||
zoneId: zoneId,
|
||||
panelName: panelName,
|
||||
widgets: [],
|
||||
isArchive: false,
|
||||
@@ -64,6 +66,43 @@ export class panelService {
|
||||
}
|
||||
static async deletePanel(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { organization, panelID, zoneId } = req.body;
|
||||
const existingZone = await zoneSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingZone)
|
||||
return res.status(404).json({ message: "Zone not found" });
|
||||
const existingPanel = await panelSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
_id: panelID,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingPanel)
|
||||
return res.status(409).json({ message: "Panel Already Deleted" });
|
||||
const updatePanel = await panelSchema(organization).updateOne(
|
||||
{ _id: panelID, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
const existingWidgets = await widgetSchema(organization).find({
|
||||
panelID: panelID,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
for (const widgetData of existingWidgets) {
|
||||
widgetData.isArchive = true;
|
||||
await widgetData.save();
|
||||
}
|
||||
|
||||
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
||||
existingZone.panelOrder = existingZone.panelOrder.filter(
|
||||
(panel: any) => panel !== existingPanel.panelName
|
||||
);
|
||||
|
||||
await existingZone.save();
|
||||
}
|
||||
|
||||
return res.status(200).json({ message: "Panel deleted successfully" });
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
|
||||
35
src/API/service/pointservice.ts
Normal file
35
src/API/service/pointservice.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Request, Response } from "express";
|
||||
import pointSchema from "../../shared/model/builder/assets/pointSchema.ts";
|
||||
export class pointService {
|
||||
static async pointCreate(req: Request, res: Response): Promise<any> {
|
||||
const organization = req.params.organization;
|
||||
const modelfileID = "6633215057b31fe671145959";
|
||||
try {
|
||||
const existingData = await pointSchema(organization).findOne({
|
||||
modelfileID: modelfileID,
|
||||
});
|
||||
if (existingData) return res.status(409).send("already data exists");
|
||||
const assetData = await pointSchema(organization).create({
|
||||
modelfileID: modelfileID,
|
||||
});
|
||||
return res.status(200).send(assetData);
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async GetPoints(req: Request, res: Response): Promise<any> {
|
||||
const { organization, modelfileID } = req.params;
|
||||
try {
|
||||
const existingPanel = await pointSchema(organization)
|
||||
.findOne({ modelfileID: modelfileID })
|
||||
.select("-_id -__v -points._id");
|
||||
if (existingPanel) {
|
||||
return res.status(200).json(existingPanel);
|
||||
}
|
||||
return res.status(404).json({ message: "No data found" });
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ export class widgetService {
|
||||
type,
|
||||
widgetID,
|
||||
panel,
|
||||
Data,
|
||||
} = req.body;
|
||||
const existingPanel = await panelSchema(organization).findOne({
|
||||
_id: panelID,
|
||||
@@ -19,35 +20,108 @@ export class widgetService {
|
||||
});
|
||||
if (!existingPanel)
|
||||
return res.status(404).json({ message: "PanelID not found" });
|
||||
const existingWidget = await widgetSchema(organization).findOne({
|
||||
panelID: panelID,
|
||||
widgetID: widgetID,
|
||||
isArchive: false,
|
||||
widgetOrder: widgetOrder,
|
||||
});
|
||||
if (existingWidget)
|
||||
return res
|
||||
.status(409)
|
||||
.json({ message: "Widget already exist for the widgetID" });
|
||||
const newWidget = await widgetSchema(organization).create({
|
||||
widgetID: widgetID,
|
||||
elementType: type,
|
||||
widgetOrder: widgetOrder,
|
||||
widgetName: widgetName,
|
||||
panelID: panelID,
|
||||
widgetside: panel,
|
||||
});
|
||||
if (newWidget) {
|
||||
return res.status(201).json({
|
||||
message: "Widget created successfully",
|
||||
widgetID: newWidget._id,
|
||||
|
||||
if (existingPanel.panelName === type) {
|
||||
const existingWidget = await widgetSchema(organization).findOne({
|
||||
panelID: panelID,
|
||||
widgetID: widgetID,
|
||||
isArchive: false,
|
||||
widgetOrder: widgetOrder,
|
||||
});
|
||||
if (existingWidget)
|
||||
return res
|
||||
.status(409)
|
||||
.json({ message: "Widget already exist for the widgetID" });
|
||||
const newWidget = await widgetSchema(organization).create({
|
||||
widgetID: widgetID,
|
||||
elementType: type,
|
||||
widgetOrder: widgetOrder,
|
||||
widgetName: widgetName,
|
||||
panelID: panelID,
|
||||
widgetside: panel,
|
||||
Data: {
|
||||
measurements: Data.measurements || {},
|
||||
duration: Data.duration || "1hr",
|
||||
},
|
||||
});
|
||||
if (newWidget) {
|
||||
existingPanel.widgets.push(newWidget._id);
|
||||
await existingPanel.save();
|
||||
return res.status(201).json({
|
||||
message: "Widget created successfully",
|
||||
widgetID: newWidget._id,
|
||||
});
|
||||
}
|
||||
}
|
||||
return res.json({ message: "Type mismatch" });
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async deleteWidget(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { widgetID, organization } = req.body;
|
||||
const findWidget = await widgetSchema(organization).findOne({
|
||||
_id: widgetID,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!findWidget)
|
||||
return res.status(409).json({ message: "Widget already deleted" });
|
||||
const widgetData = await widgetSchema(organization).updateOne(
|
||||
{ _id: widgetID, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
if (widgetData) {
|
||||
// Find all widgets in the same panel and sort them by widgetOrder
|
||||
const widgets = await widgetSchema(organization)
|
||||
.find({
|
||||
panelID: findWidget.panelID,
|
||||
isArchive: false,
|
||||
})
|
||||
.sort({ widgetOrder: 1 });
|
||||
|
||||
// Reassign widgetOrder values
|
||||
for (let i = 0; i < widgets.length; i++) {
|
||||
widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
||||
await widgets[i].save();
|
||||
}
|
||||
const panelData = await panelSchema(organization).findOne({
|
||||
_id: findWidget.panelID,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
if (panelData.widgets.includes(widgetID)) {
|
||||
panelData.widgets = panelData.widgets.filter(
|
||||
(widget: any) => widget !== findWidget._id
|
||||
);
|
||||
}
|
||||
await panelData.save();
|
||||
}
|
||||
return res.status(200).json({ message: "Widget deleted successfully" });
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async getDatafromWidget(req: Request, res: Response): Promise<any> {
|
||||
const { organization, widgetID } = req.params;
|
||||
try {
|
||||
const existingWidget = await widgetSchema(organization)
|
||||
.findOne({
|
||||
_id: widgetID,
|
||||
isArchive: false,
|
||||
})
|
||||
.select("Data -_id");
|
||||
const Datastructure = {
|
||||
measurements: existingWidget.Data.measurements || {},
|
||||
duration: existingWidget.Data.duration || "1hr",
|
||||
};
|
||||
|
||||
if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
// static async deleteWidget(req: Request, res: Response):Promise<any>{
|
||||
// const findWidget = await widgetSchema(req.body.organization).findOne({_id:req.body.widget})
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -9,15 +9,16 @@ export class Zoneservice {
|
||||
|
||||
try {
|
||||
const existingZone = await zoneSchema(organization).findOne({
|
||||
zoneUUID: zoneDatas.zoneId,
|
||||
zoneId: zoneDatas.zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingZone) {
|
||||
const newZone = await zoneSchema(organization).create({
|
||||
zoneName: zoneDatas.zonename,
|
||||
zoneUUID: zoneDatas.zoneId,
|
||||
zoneId: zoneDatas.zoneId,
|
||||
zonePoints: zoneDatas.points,
|
||||
centerPoints: zoneDatas.viewportPosition,
|
||||
viewPortposition: zoneDatas.viewportPosition,
|
||||
viewPortCenter: zoneDatas.viewPortCenter,
|
||||
createdBy: zoneDatas.userid,
|
||||
layer: zoneDatas.layer,
|
||||
sceneID: zoneDatas.sceneID,
|
||||
@@ -28,15 +29,17 @@ export class Zoneservice {
|
||||
zoneData: {
|
||||
zoneName: newZone.zoneName,
|
||||
points: newZone.zonePoints,
|
||||
centerPoints: newZone.centerPoints,
|
||||
viewPortposition: zoneDatas.viewPortposition,
|
||||
viewPortCenter: zoneDatas.viewPortCenter,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
|
||||
{ zoneUUID: zoneDatas.zoneId, isArchive: false },
|
||||
{ zoneId: zoneDatas.zoneId, isArchive: false },
|
||||
{
|
||||
zonePoints: zoneDatas.points,
|
||||
centerPoints: zoneDatas.viewportPosition,
|
||||
viewPortposition: zoneDatas.viewPortposition,
|
||||
viewPortCenter: zoneDatas.viewPortCenter,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
@@ -48,7 +51,8 @@ export class Zoneservice {
|
||||
zoneData: {
|
||||
zoneName: replaceZone.zoneName,
|
||||
points: replaceZone.zonePoints,
|
||||
centerPoints: replaceZone.centerPoints,
|
||||
viewPortposition: replaceZone.viewPortposition,
|
||||
viewPortCenter: replaceZone.viewPortCenter,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -59,17 +63,17 @@ export class Zoneservice {
|
||||
|
||||
static async deleteAZone(req: Request, res: Response): Promise<any> {
|
||||
const organization = req.query.organization;
|
||||
const zoneUUID = req.params.zoneId;
|
||||
const zoneId = req.params.zoneId;
|
||||
try {
|
||||
const existingZone = await zoneSchema(organization).findOne({
|
||||
zoneUUID: zoneUUID,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingZone) {
|
||||
return res.status(404).json({ message: "Zone not found for the UUID" });
|
||||
} else {
|
||||
const deleteZone = await zoneSchema(organization).findOneAndUpdate(
|
||||
{ zoneUUID: zoneUUID, isArchive: false },
|
||||
{ zoneId: zoneId, isArchive: false },
|
||||
{
|
||||
isArchive: true,
|
||||
},
|
||||
@@ -87,19 +91,21 @@ export class Zoneservice {
|
||||
|
||||
static async singleZonePanelDatas(req: Request, res: Response): Promise<any> {
|
||||
const organization = req.query.organization;
|
||||
const zoneID = req.params.zoneID;
|
||||
const zoneId = req.params.zoneId;
|
||||
|
||||
try {
|
||||
const existingZone = await zoneSchema(organization)
|
||||
.findOne({
|
||||
_id: req.params.zoneID,
|
||||
zoneId: req.params.zoneId,
|
||||
isArchive: false,
|
||||
})
|
||||
.select("panelOrder zoneName zonePoints lockedPanel");
|
||||
if (!existingZone) {
|
||||
return res.send({ message: "Zone not found for the UUID" });
|
||||
} else {
|
||||
const panelData = await panelSchema(organization).find({
|
||||
zoneID: zoneID,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
const zoneName = existingZone.zoneName as string;
|
||||
|
||||
@@ -107,6 +113,7 @@ export class Zoneservice {
|
||||
panelData.map(async (data) => {
|
||||
const widgetDataArray = await widgetSchema(organization).find({
|
||||
panelID: data._id,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
return widgetDataArray.map((widgetData) => ({
|
||||
@@ -130,7 +137,7 @@ export class Zoneservice {
|
||||
widgets: flattenedWidgets,
|
||||
};
|
||||
|
||||
return res.send(objectData);
|
||||
return res.status(200).json(objectData);
|
||||
}
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
@@ -143,10 +150,10 @@ export class Zoneservice {
|
||||
try {
|
||||
const Allzones = await zoneSchema(organization)
|
||||
.find({ sceneID: sceneID, isArchive: false })
|
||||
.select("zoneName sceneID zoneUUID");
|
||||
.select("zoneName sceneID zoneId");
|
||||
|
||||
if (!Allzones || Allzones.length === 0) {
|
||||
return res.status(200).json({ message: "Zone not found for the UUID" });
|
||||
return res.status(404).json({ message: "Zone not found for the UUID" });
|
||||
}
|
||||
return res.status(200).json(Allzones);
|
||||
} catch (error: any) {
|
||||
@@ -158,25 +165,25 @@ export class Zoneservice {
|
||||
try {
|
||||
const organization = req.query.organization;
|
||||
console.log("organization: ", organization);
|
||||
const zoneID = req.params.zoneID;
|
||||
console.log("zoneID: ", zoneID);
|
||||
const findZone = await zoneSchema(organization)
|
||||
.findOne({ _id: zoneID })
|
||||
// .select("zoneName");
|
||||
console.log("findZone: ", findZone);
|
||||
const zoneId = req.params.zoneId;
|
||||
console.log("zoneId: ", zoneId);
|
||||
const findZone = await zoneSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
});
|
||||
// .select("zoneName");
|
||||
if (findZone) return res.status(200).json(findZone);
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// static async ZoneIDgenerate(req: Request, res: Response): Promise<any> {
|
||||
// static async zoneIdgenerate(req: Request, res: Response): Promise<any> {
|
||||
// const organization = req.query.organization;
|
||||
// const sceneID = req.params.sceneID;
|
||||
// try {
|
||||
// const Allzones = await zoneSchema(organization)
|
||||
// .find({ sceneID: sceneID, isArchive: false })
|
||||
// .select("zoneName sceneID zoneUUID");
|
||||
// .select("zoneName sceneID zoneId");
|
||||
|
||||
// if (!Allzones || Allzones.length === 0) {
|
||||
// return res.send({ message: "Zone not found for the UUID" });
|
||||
|
||||
43
src/API/swagger/swagger.ts
Normal file
43
src/API/swagger/swagger.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import swaggerJSDoc from "swagger-jsdoc";
|
||||
import ip from "ip";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
const swaggerPort = process.env.PORT;
|
||||
const swaggerOptions: swaggerJSDoc.Options = {
|
||||
definition: {
|
||||
openapi: "3.0.0",
|
||||
info: {
|
||||
title: "Dwinzo-Beta API",
|
||||
version: "1.0.0",
|
||||
description: "API documentation for BackendIOT",
|
||||
contact: {
|
||||
name: "Backend Developer",
|
||||
email: "nivetha@hexrfactory.com",
|
||||
},
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: `http://192.168.0.102:${swaggerPort}/api/v1`,
|
||||
description: "Server Endpoint",
|
||||
},
|
||||
],
|
||||
components: {
|
||||
securitySchemes: {
|
||||
bearerAuth: {
|
||||
type: "http",
|
||||
scheme: "bearer",
|
||||
bearerFormat: "JWT",
|
||||
},
|
||||
},
|
||||
},
|
||||
security: [
|
||||
{
|
||||
bearerAuth: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
apis: ["./src/API/routes/*.ts"], // Adjust path based on where your routes are located
|
||||
tryItOutEnabled: false,
|
||||
};
|
||||
|
||||
export default swaggerOptions;
|
||||
62
src/shared/model/builder/assets/asset-Model.ts
Normal file
62
src/shared/model/builder/assets/asset-Model.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface assetData extends Document {
|
||||
modeluuid: string;
|
||||
modelfileID: string;
|
||||
modelname: string;
|
||||
isLocked: boolean;
|
||||
isVisible: boolean;
|
||||
position: [];
|
||||
rotation: {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
};
|
||||
points: [
|
||||
{
|
||||
uuid: string;
|
||||
position: [];
|
||||
rotation: [];
|
||||
actions: [mongoose.Types.ObjectId];
|
||||
triggers: [mongoose.Types.ObjectId];
|
||||
// connections:{
|
||||
// source:{
|
||||
// pathuuid:string,pointuuid:string
|
||||
// },
|
||||
// target:[]
|
||||
// }
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const assetDataSchema: Schema = new Schema({
|
||||
modeluuid: { type: String },
|
||||
modelfileID: { type: String },
|
||||
modelname: { type: String },
|
||||
position: { type: Array },
|
||||
points: [
|
||||
{
|
||||
uuid: { type: String },
|
||||
position: { type: Array },
|
||||
rotation: { type: Array },
|
||||
actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||
triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||
},
|
||||
],
|
||||
isLocked: { type: Boolean },
|
||||
isVisible: { type: Boolean },
|
||||
rotation: {
|
||||
x: { type: Number, required: true },
|
||||
y: { type: Number, required: true },
|
||||
z: { type: Number, required: true },
|
||||
},
|
||||
});
|
||||
|
||||
// export default floorItemsModel;
|
||||
const assetModel = (db: string) => {
|
||||
return MainModel(db, "Assets", assetDataSchema, "Assets");
|
||||
};
|
||||
export default assetModel;
|
||||
@@ -1,38 +0,0 @@
|
||||
import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface floorItenms extends Document {
|
||||
modeluuid: string;
|
||||
modelfileID: string;
|
||||
modelname: string;
|
||||
isLocked: boolean;
|
||||
isVisible: boolean;
|
||||
position: [];
|
||||
rotation: {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
};
|
||||
}
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const floorItemsSchema: Schema = new Schema({
|
||||
modeluuid: { type: String },
|
||||
modelfileID: { type: String },
|
||||
modelname: { type: String },
|
||||
position: { type: Array },
|
||||
isLocked: { type: Boolean },
|
||||
isVisible: { type: Boolean },
|
||||
rotation: {
|
||||
x: { type: Number, required: true },
|
||||
y: { type: Number, required: true },
|
||||
z: { type: Number, required: true },
|
||||
},
|
||||
});
|
||||
|
||||
// export default floorItemsModel;
|
||||
const floorItemsModel = (db: string) => {
|
||||
return MainModel(db, "floorItems", floorItemsSchema, "floorItems");
|
||||
};
|
||||
export default floorItemsModel;
|
||||
59
src/shared/model/builder/assets/pointSchema.ts
Normal file
59
src/shared/model/builder/assets/pointSchema.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface Points extends Document {
|
||||
modelfileID: string;
|
||||
points: {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
rotation: number[];
|
||||
actions: string[];
|
||||
triggers: string[];
|
||||
}[];
|
||||
}
|
||||
const defaultPoints = [
|
||||
{
|
||||
uuid: "",
|
||||
position: [0, 1.25, 3.3],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [],
|
||||
triggers: [],
|
||||
},
|
||||
{
|
||||
uuid: "",
|
||||
position: [0, 1.25, 3.3],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [],
|
||||
triggers: [],
|
||||
},
|
||||
{
|
||||
uuid: "",
|
||||
position: [0, 1.25, 3.3],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [],
|
||||
triggers: [],
|
||||
},
|
||||
];
|
||||
// Define the Mongoose Schema
|
||||
const pointSchema: Schema = new Schema({
|
||||
modelfileID: { type: String, required: true },
|
||||
points: {
|
||||
type: [
|
||||
{
|
||||
uuid: { type: String },
|
||||
position: { type: [Number], default: [0, 1.25, 3.3] },
|
||||
rotation: { type: [Number], default: [0, 0, 0] },
|
||||
actions: { type: [String], default: [] },
|
||||
triggers: { type: [String], default: [] },
|
||||
},
|
||||
],
|
||||
default: defaultPoints,
|
||||
},
|
||||
});
|
||||
|
||||
const pointModel = (db: string) => {
|
||||
return MainModel(db, "Points", pointSchema, "Points");
|
||||
};
|
||||
|
||||
export default pointModel;
|
||||
@@ -39,7 +39,7 @@ import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
export interface Zone extends Document {
|
||||
zoneName: string;
|
||||
// zoneUUID: string;
|
||||
zoneId: string;
|
||||
zonePoints: [];
|
||||
viewPortCenter: [];
|
||||
viewPortposition: [];
|
||||
@@ -55,12 +55,11 @@ export interface Zone extends Document {
|
||||
const zoneSchema: Schema = new Schema(
|
||||
{
|
||||
zoneName: { type: String },
|
||||
// zoneUUID: { type: String },
|
||||
zoneId: { type: String },
|
||||
createdBy: { type: String },
|
||||
sceneID: { type: String },
|
||||
layer: { type: Number },
|
||||
centerPoints: { type: Array },
|
||||
zonePoints: { type: Array },
|
||||
points: { type: Array },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
panelOrder: {
|
||||
type: [String],
|
||||
@@ -79,7 +78,7 @@ const zoneSchema: Schema = new Schema(
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const dataModel = (db: any) => {
|
||||
const zoneModel = (db: any) => {
|
||||
return MainModel(db, "zones", zoneSchema, "zones");
|
||||
};
|
||||
export default dataModel;
|
||||
export default zoneModel;
|
||||
|
||||
39
src/shared/model/simulation/actionmodel.ts
Normal file
39
src/shared/model/simulation/actionmodel.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import mongoose, { Schema, Document, model } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
|
||||
export interface Event extends Document {
|
||||
pointsUUID: string;
|
||||
actionUUID: string;
|
||||
isArchive: string;
|
||||
sceneID: string;
|
||||
eventData: {
|
||||
uuid: string;
|
||||
type: string;
|
||||
material: string;
|
||||
delay: number;
|
||||
spawn_Interval: number;
|
||||
};
|
||||
}
|
||||
const eventSchema: Schema = new Schema(
|
||||
{
|
||||
pointsUUID: { type: String },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
actionUUID: { type: String },
|
||||
sceneID: { type: String },
|
||||
eventData: [
|
||||
{
|
||||
uuid: { type: String },
|
||||
type: { type: String },
|
||||
material: { type: String },
|
||||
delay: { type: Number },
|
||||
spawn_Interval: { type: Number },
|
||||
},
|
||||
],
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const actionModel = (db: any) => {
|
||||
return MainModel(db, "Events", eventSchema, "Events");
|
||||
};
|
||||
export default actionModel;
|
||||
@@ -0,0 +1,39 @@
|
||||
import mongoose, { Schema, Document, model } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
|
||||
export interface Trigger extends Document {
|
||||
pointsUUID: string;
|
||||
actionUUID: string;
|
||||
isArchive: string;
|
||||
sceneID: string;
|
||||
triggerData: {
|
||||
uuid: string;
|
||||
type: string;
|
||||
// material: string;
|
||||
// delay: number;
|
||||
// spawn_Interval: number;
|
||||
};
|
||||
}
|
||||
const triggerSchema: Schema = new Schema(
|
||||
{
|
||||
pointsUUID: { type: String },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
actionUUID: { type: String },
|
||||
sceneID: { type: String },
|
||||
triggerData: [
|
||||
{
|
||||
uuid: { type: String },
|
||||
type: { type: String },
|
||||
// material: { type: String },
|
||||
// delay: { type: Number },
|
||||
// spawn_Interval: { type: Number },
|
||||
},
|
||||
],
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const triggerModel = (db: any) => {
|
||||
return MainModel(db, "Triggers", triggerSchema, "Triggers");
|
||||
};
|
||||
export default triggerModel;
|
||||
|
||||
@@ -2,14 +2,16 @@ import mongoose, { Schema, Document, model } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
|
||||
export interface Panel extends Document {
|
||||
zoneID: mongoose.Types.ObjectId;
|
||||
// zoneID: mongoose.Types.ObjectId;
|
||||
zoneId: string;
|
||||
panelName: string;
|
||||
widgets: [mongoose.Types.ObjectId];
|
||||
isArchive: boolean;
|
||||
}
|
||||
const panelSchema: Schema = new Schema(
|
||||
{
|
||||
zoneID: { type: mongoose.Schema.Types.ObjectId, ref: "Zone" },
|
||||
// zoneID: { type: mongoose.Schema.Types.ObjectId, ref: "Zone" },
|
||||
zoneId: { type: String },
|
||||
panelName: { type: String },
|
||||
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||
isArchive: { type: Boolean, default: false },
|
||||
@@ -17,7 +19,7 @@ const panelSchema: Schema = new Schema(
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const dataModel = (db: any) => {
|
||||
const panelModel = (db: any) => {
|
||||
return MainModel(db, "Panel", panelSchema, "Panel");
|
||||
};
|
||||
export default dataModel;
|
||||
export default panelModel;
|
||||
|
||||
@@ -2,17 +2,18 @@ import mongoose, { Schema, Document, model } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
|
||||
export interface Template extends Document {
|
||||
// templateName:;
|
||||
templateName: string;
|
||||
isArchive: boolean;
|
||||
}
|
||||
const templateSchema: Schema = new Schema(
|
||||
{
|
||||
templateName: { type: String },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const dataModel = (db: any) => {
|
||||
return MainModel(db, "template", templateSchema, "template");
|
||||
const templateModel = (db: any) => {
|
||||
return MainModel(db, "Template", templateSchema, "Template");
|
||||
};
|
||||
export default dataModel;
|
||||
export default templateModel;
|
||||
|
||||
@@ -13,7 +13,10 @@ export interface widget extends Document {
|
||||
fontWeight: string;
|
||||
isArchive: boolean;
|
||||
panelID: mongoose.Types.ObjectId;
|
||||
Data: [];
|
||||
Data: {
|
||||
measurement: Record<string, any>;
|
||||
duration: string;
|
||||
};
|
||||
}
|
||||
const widgetSchema: Schema = new Schema(
|
||||
{
|
||||
@@ -25,7 +28,13 @@ const widgetSchema: Schema = new Schema(
|
||||
elementColor: { type: String },
|
||||
fontFamily: { type: String },
|
||||
fontStyle: { type: String },
|
||||
Data: { type: Array },
|
||||
Data: {
|
||||
measurements: {
|
||||
type: Object,
|
||||
default: {},
|
||||
},
|
||||
duration: { type: String, default: "1hr" },
|
||||
},
|
||||
fontWeight: { type: String },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||
@@ -33,7 +42,7 @@ const widgetSchema: Schema = new Schema(
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const dataModel = (db: any) => {
|
||||
const widgetModel = (db: any) => {
|
||||
return MainModel(db, "Widget", widgetSchema, "Widget");
|
||||
};
|
||||
export default dataModel;
|
||||
export default widgetModel;
|
||||
|
||||
Reference in New Issue
Block a user