vizualization updates

This commit is contained in:
2025-03-28 12:45:59 +05:30
parent b117c8705c
commit dc5d7c2ebf
59 changed files with 1977 additions and 92 deletions

14
.env
View File

@@ -1,8 +1,10 @@
# MONGO_URI=mongodb://127.0.0.1:27017/
MONGO_USER=admin
MONGO_PASSWORD=admin321
MONGO_URI=mongodb://127.0.0.1:27017/
MONGO_USER=mydata
MONGO_PASSWORD=mongodb@hexr2002
MONGO_AUTH_DB=admin
MONGO_URI=mongodb://mongo/
# MONGO_USER=admin
# MONGO_PASSWORD=admin321
# MONGO_AUTH_DB=admin
# MONGO_URI=mongodb://mongo/
API_PORT=5000
SOCKET_PORT=8000
SOCKET_PORT=8001

View File

@@ -7,7 +7,7 @@
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/.retool_types/**": true,
"**/*tsconfig.json": true,
// "**/*tsconfig.json": true,
".cache": true,
"retool.config.json": true
}

28
package-lock.json generated
View File

@@ -9,10 +9,10 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^4.21.1",
"fs": "^0.0.1-security",
"http": "^0.0.1-security",
"ip": "^2.0.1",
"jsonwebtoken": "^9.0.2",
@@ -22,6 +22,7 @@
"swagger-ui-express": "^5.0.1"
},
"devDependencies": {
"@types/bcryptjs": "^3.0.0",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/ip": "^1.1.3",
@@ -113,6 +114,16 @@
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
"dev": true
},
"node_modules/@types/bcryptjs": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-3.0.0.tgz",
"integrity": "sha512-WRZOuCuaz8UcZZE4R5HXTco2goQSI2XxjGY3hbM/xDvwmqFWd4ivooImsMx65OKM6CtNKbnZ5YL+YwAwK7c1dg==",
"deprecated": "This is a stub types definition. bcryptjs provides its own type definitions, so you do not need this installed.",
"dev": true,
"dependencies": {
"bcryptjs": "*"
}
},
"node_modules/@types/body-parser": {
"version": "1.19.5",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
@@ -339,9 +350,13 @@
}
},
"node_modules/bcryptjs": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
"integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ=="
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-3.0.2.tgz",
"integrity": "sha512-k38b3XOZKv60C4E2hVsXTolJWfkGRMbILBIe2IBITXciy5bOsTKot5kDrf3ZfufQtQOUN5mXceUEpU1rTl9Uog==",
"dev": true,
"bin": {
"bcrypt": "bin/bcrypt"
}
},
"node_modules/binary-extensions": {
"version": "2.3.0",
@@ -799,6 +814,11 @@
"node": ">= 0.6"
}
},
"node_modules/fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",

View File

@@ -3,19 +3,20 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start:api": "nodemon --exec ts-node src/api-server/main.ts",
"start:socket": "nodemon --exec ts-node src/socket-server/index.ts"
"start:api": "nodemon --exec tsx src/api-server/main.ts",
"start:socket": "nodemon --exec tsx src/socket-server/index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^4.21.1",
"fs": "^0.0.1-security",
"http": "^0.0.1-security",
"ip": "^2.0.1",
"jsonwebtoken": "^9.0.2",
@@ -25,6 +26,7 @@
"swagger-ui-express": "^5.0.1"
},
"devDependencies": {
"@types/bcryptjs": "^3.0.0",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/ip": "^1.1.3",

View File

@@ -1,5 +1,5 @@
import express from 'express';
import { camera } from '../controller/camera/camera-Controlle';
import { camera } from '../controller/camera/camera-Services.ts';
const router = express.Router();

View File

@@ -1,5 +1,5 @@
import express from 'express';
import { environment } from '../controller/environments/environments-controller';
import { environment } from '../controller/environments/environments-Services.ts';
const router = express.Router();
router.post('/setEvironments',environment.setEnvironment)

View File

@@ -1,5 +1,5 @@
import express from 'express';
import { floorItems } from '../controller/assets/flooritem-Controller';
import { floorItems } from '../controller/assets/flooritem-Services.ts';
const router = express.Router();
router.post('/setfloorItems',floorItems.setFloorItems)

View File

@@ -1,5 +1,5 @@
import express from 'express';
import { lines } from '../controller/lines/line-Controller';
import { lines } from '../controller/lines/line-Services.ts';
const router = express.Router();

View File

@@ -0,0 +1,140 @@
import * as express from "express";
import { panelService } from "../controller/visualization/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;

View File

@@ -1,5 +1,5 @@
import express from 'express';
import { share } from '../controller/share/share-Controller';
import { share } from '../controller/share/share-Controller.ts';
const router = express.Router();

View File

@@ -1,5 +1,5 @@
import express from 'express';
import { user } from '../controller/user-Controller';
import { user } from '../controller/user-Controller.ts';
const router = express.Router();

View File

@@ -1,5 +1,5 @@
import express from 'express';
import { wallItems } from '../controller/assets/wallitem-Controller';
import { wallItems } from '../controller/assets/wallitem-Services.ts';
const router = express.Router();

View File

@@ -0,0 +1,143 @@
import * as express from "express";
import { widgetService } from "../controller/visualization/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;

View File

@@ -1,13 +1,13 @@
import express from 'express';
import { zone } from '../controller/lines/zone-Controller';
import { zone } from '../controller/lines/zone-Services.ts';
const router = express.Router();
router.post('/setZone',zone.setZone)
router.delete('/deleteZone',zone.deleteZone)
router.get('/findZones/:organization',zone.getZones)
router.get('/A_zone/:zoneID/:organization',zone.ZoneData)
router.get('/A_zone/:zoneId/:organization',zone.ZoneData)

View File

@@ -0,0 +1,539 @@
import * as express from "express";
import { Zoneservice } from "../controller/lines/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;

View File

@@ -1,15 +1,18 @@
import express from 'express';
import cors from 'cors';
import connectDB from '../shared/connect/mongoose';
import connectDB from '../shared/connect/mongoose.ts';
import dotenv from 'dotenv';
import cameraRoutes from './Routes/camera-Routes'
import environmentsRoutes from './Routes/environments-Routes'
import linesRoutes from './Routes/lines-Routes'
import flooritemRoutes from './Routes/flooritem-Routes'
import WallitemRoutes from './Routes/wallItems-Routes'
import userRoutes from './Routes/user-Routes'
import shareRoutes from './Routes/share-Routes'
import zoneRoutes from './Routes/zone-Routes'
import cameraRoutes from './Routes/camera-Routes.ts'
import environmentsRoutes from './Routes/environments-Routes.ts'
import linesRoutes from './Routes/lines-Routes.ts'
import flooritemRoutes from './Routes/flooritem-Routes.ts'
import WallitemRoutes from './Routes/wallItems-Routes.ts'
import userRoutes from './Routes/user-Routes.ts'
import shareRoutes from './Routes/share-Routes.ts'
import zoneRoutes from './Routes/zone-Routes.ts'
import zoneRoutes2 from './Routes/zoneRoutes.ts'//update
import panelRouter from './Routes/panelRoutes.ts'
import widgetRouter from './Routes/widgetRoute.ts'
const app = express();
@@ -30,5 +33,9 @@ app.use('/api/v1', flooritemRoutes);
app.use('/api/v1', WallitemRoutes);
app.use('/api/v1', userRoutes);
app.use('/api/v1', shareRoutes);
app.use('/api/v2', zoneRoutes);
// app.use('/api/v2', zoneRoutes);
//update
app.use('/api/v2', zoneRoutes2);//updates
app.use('/api/v2', panelRouter);
app.use('/api/v2', widgetRouter);
export default app;

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import floorItemsModel from "../../../shared/model/assets/flooritems-Model";
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
export class floorItems {

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import wallItenmModel from "../../../shared/model/assets/wallitems-Model";
import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
export class wallItems {

View File

@@ -1,6 +1,6 @@
import { Request, Response } from "express";
import cameraModel from "../../../shared/model/camera/camera-Model";
import userModel from "../../../shared/model/user-Model";
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
import userModel from "../../../shared/model/user-Model.ts";
export class camera {
static async createCamera(req: Request, res: Response) {
@@ -54,7 +54,7 @@ export class camera {
const findactiveUsers = await userModel(organization).find({activeStatus:"online"})
const cameraDataPromises = findactiveUsers.map(async (activeUser) => {
const cameraDataPromises = findactiveUsers.map(async (activeUser:any) => {
const cameraData = await cameraModel(organization)
.findOne({ userId: activeUser._id })
.select("position target rotation -_id");

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import environmentModel from "../../../shared/model/environments/environments-Model";
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
export class environment {
static async setEnvironment(req: Request, res: Response) {

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import lineModel from "../../../shared/model/lines/lines-Model";
import lineModel from "../../../shared/model/lines/lines-Model.ts";
export class lines {
static async setLines(req: Request, res: Response) {

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import zoneModel from "../../../shared/model/lines/zone-Model";
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
export class zone {
static async setZone(req: Request, res: Response) {
try {
@@ -75,9 +75,9 @@ export class zone {
static async ZoneData(req: Request, res: Response): Promise<any> {
try {
const organization = req.params.organization;
const zoneID = req.params.zoneID;
const zoneId = req.params.zoneId;
const findZone = await zoneModel(organization)
.findOne({ zoneId: zoneID })
.findOne({ zoneId: zoneId })
// .select("zoneName");
console.log("findZone: ", findZone);
if (findZone) return res.status(200).json(findZone);

View File

@@ -0,0 +1,197 @@
import { Request, Response } from "express";
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
export class Zoneservice {
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
const organization = req.body.organization;
const zoneDatas = req.body.zonesdata;
console.log('organization: ', organization);
try {
const existingZone = await zoneSchema(organization).findOne({
zoneId: zoneDatas.zoneId,
isArchive: false,
});
if (!existingZone) {
const newZone = await zoneSchema(organization).create({
zoneName: zoneDatas.zonename,
zoneId: zoneDatas.zoneId,
zonePoints: zoneDatas.points,
viewPortposition: zoneDatas.viewportPosition,
viewPortCenter: zoneDatas.viewPortCenter,
createdBy: zoneDatas.userid,
layer: zoneDatas.layer,
sceneID: zoneDatas.sceneID,
});
if (newZone)
return res.status(200).json({
message: "Zone created successfully",
zoneData: {
zoneName: newZone.zoneName,
points: newZone.zonePoints,
viewPortposition: zoneDatas.viewPortposition,
viewPortCenter: zoneDatas.viewPortCenter,
},
});
} else {
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
{ zoneId: zoneDatas.zoneId, isArchive: false },
{
zonePoints: zoneDatas.points,
viewPortposition: zoneDatas.viewPortposition,
viewPortCenter: zoneDatas.viewPortCenter,
},
{ new: true }
);
if (!replaceZone)
return res.status(404).json({ message: "Zone not updated" });
else
return res.status(200).json({
message: "updated successfully",
zoneData: {
zoneName: replaceZone.zoneName,
points: replaceZone.zonePoints,
viewPortposition: replaceZone.viewPortposition,
viewPortCenter: replaceZone.viewPortCenter,
},
});
}
} catch (error: any) {
return res.status(500).send(error.message);
}
}
static async deleteAZone(req: Request, res: Response): Promise<any> {
const organization = req.query.organization;
const zoneId = req.params.zoneId;
try {
const existingZone = await zoneSchema(organization).findOne({
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(
{ zoneId: zoneId, isArchive: false },
{
isArchive: true,
},
{ new: true }
);
if (deleteZone) {
return res.status(200).json({ message: "Zone deleted successfully" });
}
}
} catch (error: any) {
return res.status(500).send(error.message);
}
}
static async singleZonePanelDatas(req: Request, res: Response): Promise<any> {
const organization = req.query.organization;
const zoneId = req.params.zoneId;
try {
const existingZone = await zoneSchema(organization)
.findOne({
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,
isArchive: false,
});
const zoneName = existingZone.zoneName as string;
const widgets = await Promise.all(
panelData.map(async (data) => {
const widgetDataArray = await widgetSchema(organization).find({
panelID: data._id,
isArchive: false,
});
return widgetDataArray.map((widgetData) => ({
id: widgetData.widgetID,
type: widgetData.elementType,
title: widgetData.widgetName,
panel: widgetData.widgetside,
data: widgetData.Data || [],
}));
})
);
const flattenedWidgets = widgets.flat();
const objectData = {
zoneName,
activeSides: existingZone.panelOrder || [],
panelOrder: existingZone.panelOrder || [],
lockedPanels: existingZone.lockedPanel || [],
points: existingZone.zonePoints || [],
widgets: flattenedWidgets,
};
return res.status(200).json(objectData);
}
} catch (error: any) {
return res.status(500).send(error.message);
}
}
static async allZones(req: Request, res: Response): Promise<any> {
const organization = req.query.organization;
const sceneID = req.params.sceneID || "scene123";
try {
const Allzones = await zoneSchema(organization)
.find({ sceneID: sceneID, isArchive: false })
.select("zoneName sceneID zoneId");
if (!Allzones || Allzones.length === 0) {
return res.status(404).json({ message: "Zone not found for the UUID" });
}
return res.status(200).json(Allzones);
} catch (error: any) {
return res.status(500).send(error.message);
}
}
static async ZoneData(req: Request, res: Response): Promise<any> {
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({
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> {
// const organization = req.query.organization;
// const sceneID = req.params.sceneID;
// try {
// const Allzones = await zoneSchema(organization)
// .find({ sceneID: sceneID, isArchive: false })
// .select("zoneName sceneID zoneId");
// if (!Allzones || Allzones.length === 0) {
// return res.send({ message: "Zone not found for the UUID" });
// }
// return res.send(Allzones);
// } catch (error: any) {
// return res.status(500).send(error.message);
// }
// }
}

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import userModel from "../../../shared/model/user-Model";
import userModel from "../../../shared/model/user-Model.ts";
export class share {

View File

@@ -1,8 +1,8 @@
import { Request, Response } from "express";
import { Server } from 'http';
import userModel from "../../shared/model/user-Model";
import userModel from "../../shared/model/user-Model.ts";
import { isSharedArrayBuffer } from "util/types";
const {hashGenerate,hashValidator} = require("../../shared/security/Hasing.ts")
import {hashGenerate,hashValidator} from "../../shared/security/Hasing.ts"
// import {hashGenerate} from '../security/Hasing'
let serverAlive = true;

View File

@@ -0,0 +1,113 @@
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 {
console.log('req.body: ', req.body);
const organization = req.body.organization;
console.log('organization: ', organization);
const zoneId = req.body.zoneId;
const panelName = req.body.panelName;
const panelOrder = req.body.panelOrder;
const findZone = await zoneSchema(organization).findOne({
zoneId: zoneId,
isArchive: false,
});
if (!findZone) {
return res.status(404).json({ message: "Zone not found" });
}
const updatezone = await zoneSchema(organization).findOneAndUpdate(
{ zoneId: zoneId, isArchive: false },
{ panelOrder: panelOrder },
{ new: true }
);
const existingPanels = await panelSchema(organization).find({
zoneId: zoneId,
isArchive: false,
});
const existingPanelNames = existingPanels.map(
(panel: any) => panel.panelName
);
const missingPanels = panelOrder.filter(
(panelName: string) => !existingPanelNames.includes(panelName)
);
const createdPanels = [];
for (const panelName of missingPanels) {
const newPanel = await panelSchema(organization).create({
zoneId: zoneId,
panelName: panelName,
widgets: [],
isArchive: false,
});
createdPanels.push(newPanel);
}
if (createdPanels.length === 0) {
return res.status(200).json({
message: "No new panels were created. All panels already exist.",
});
}
// const IDdata = createdPanels.map((ID: any) => {
// return ID._id;
// });
console.log("IDdata: ", createdPanels);
createdPanels
return res.status(201).json({
message: "Panels created successfully",
panelID: createdPanels,
});
} catch (error: any) {
return res.status(500).send(error.message);
}
}
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);
}
}
}

View File

@@ -0,0 +1,127 @@
import { Request, Response } from "express";
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
export class widgetService {
static async addWidget(req: Request, res: Response): Promise<any> {
try {
const {
organization,
panelID,
widgetName,
widgetOrder,
type,
widgetID,
panel,
Data,
} = req.body;
const existingPanel = await panelSchema(organization).findOne({
_id: panelID,
isArchive: false,
});
if (!existingPanel)
return res.status(404).json({ message: "PanelID not found" });
if (existingPanel.panelName === panel) {
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);
}
}
}

View File

@@ -1,21 +1,27 @@
import app from './app';
import app from './app.ts';
import http from 'http';
import ip from 'ip';
// import { startHealthCheck } from './controller/user-Controller';
import swaggerUi from 'swagger-ui-express';
import mongoAdminCreation from '../shared/security/mongosecurity';
import mongoAdminCreation from '../shared/security/mongosecurity.ts';
import fs from 'fs';
const server = http.createServer(app);
let swaggerDocument;
try {
let swaggerDocument = {};
// try {
// swaggerDocument = require('../../swagger-output.json');
swaggerDocument = require('../../swagger-output.json');
// } catch (error) {
// console.error('Error loading Swagger JSON:', error);
// swaggerDocument = {}; // Fallback: empty object or some default
// }
try {
swaggerDocument = JSON.parse(fs.readFileSync('swagger-output.json', 'utf-8'));
} catch (error) {
console.error('Error loading Swagger JSON:', error);
swaggerDocument = {}; // Fallback: empty object or some default
}
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
const organization = process.env.ORGANIZATION_NAME || 'defaultOrganization'; // Replace with your logic

View File

@@ -1,5 +1,5 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose';
import MainModel from '../../connect/mongoose.ts';
// Interface for TypeScript with PascalCase
export interface floorItenms extends Document {

View File

@@ -1,5 +1,5 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose';
import MainModel from '../../connect/mongoose.ts';
// Interface for TypeScript with PascalCase
export interface wallitems extends Document {
modeluuid: string;

View 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;

View 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;

View File

@@ -0,0 +1,31 @@
import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
// Interface for TypeScript with PascalCase
export interface wallitems extends Document {
modeluuid: string;
modelname: string;
type: string;
csgposition: [];
csgscale: [];
position: [];
quaternion: [];
scale: [];
}
// Define the Mongoose Schema
const wallItemsSchema: Schema = new Schema({
modeluuid: { type: String, unique: true },
modelname: { type: String },
type: { type: String },
csgposition: { type: Array },
csgscale: { type: Array },
position: { type: Array },
quaternion: { type: Array },
scale: { type: Array },
});
// export default wallItenmModel;
const wallItenmModel = (db: string) => {
return MainModel(db, "wallitems", wallItemsSchema, "wallitems");
};
export default wallItenmModel;

View File

@@ -0,0 +1,48 @@
import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
// Interface for TypeScript with PascalCase
export interface Camera extends Document {
userId: string;
position: {
x: number;
y: number;
z: number;
};
target: {
x: { type: Number; required: true };
y: { type: Number; required: true };
z: { type: Number; required: true };
};
rotation: {
x: { type: Number; required: true };
y: { type: Number; required: true };
z: { type: Number; required: true };
};
}
// Define the Mongoose Schema
const cameraSchema: Schema = new Schema({
userId: { type: String },
position: {
x: { type: Number, required: true },
y: { type: Number, required: true },
z: { type: Number, required: true },
},
target: {
x: { type: Number, required: true },
y: { type: Number, required: true },
z: { type: Number, required: true },
},
rotation: {
x: { type: Number, required: true },
y: { type: Number, required: true },
z: { type: Number, required: true },
},
});
// export default cameraModel
const cameraModel = (db: string) => {
return MainModel(db, "Camera", cameraSchema, "Camera");
};
export default cameraModel;

View File

@@ -0,0 +1,24 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../../connect/mongoose.ts';
// Interface for TypeScript with PascalCase
export interface environment extends Document {
userId: string;
roofVisibility: boolean
wallVisibility: boolean
}
// Define the Mongoose Schema
const environmentSchema: Schema = new Schema({
userId: { type: String, unique: true },
roofVisibility: { type: Boolean, default: false },
wallVisibility: { type: Boolean, default: false },
shadowVisibility: { type: Boolean, default: false },
});
// export default environmentModel;
const environmentModel = (db: string) => {
return MainModel(db, "environments", environmentSchema, "environments")
};
export default environmentModel;

View File

@@ -0,0 +1,26 @@
import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
const positionSchema = new mongoose.Schema({
x: { type: Number }, // Optional position fields
y: { type: Number },
z: { type: Number },
});
// Define a schema for the individual line
const Vector3 = new mongoose.Schema({
position: { type: positionSchema, required: false }, // Optional position
uuid: { type: String, required: false }, // Optional uuid
});
// Define the main schema
const LineSchema = new mongoose.Schema({
layer: { type: Number, required: true }, // Layer is mandatory
line: { type: [Vector3], required: true }, // Array of line objects
type: { type: String, required: false }, // Optional type
});
// export default lineModel;
const lineModel = (db: string) => {
return MainModel(db, "lines", LineSchema, "lines");
};
export default lineModel;

View File

@@ -0,0 +1,84 @@
// import mongoose, { Schema, Document, model } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// export interface Zone extends Document {
// zoneName: string;
// // zoneUUID: string;
// zonePoints: [];
// centerPoints: [];
// isArchive: boolean;
// createdBy: string;
// sceneID: string;
// // createdBy: mongoose.Types.ObjectId;
// // sceneID: mongoose.Types.ObjectId;
// layer: number;
// }
// const zoneSchema: Schema = new Schema(
// {
// zoneName: { type: String },
// // zoneUUID: { type: String },
// createdBy: { type: String },
// sceneID: { type: String },
// layer: { type: Number },
// centerPoints: { type: Array },
// zonePoints: { type: Array },
// isArchive: { type: Boolean, default: false },
// // createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
// // sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
// },
// { timestamps: true }
// );
// const dataModel = (db: any) => {
// return MainModel(db, "Zones", zoneSchema, "Zones");
// };
// export default dataModel;
import mongoose, { Schema, Document, model } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
export interface Zone extends Document {
zoneName: string;
zoneId: string;
zonePoints: [];
viewPortCenter: [];
viewPortposition: [];
isArchive: boolean;
createdBy: string;
sceneID: string;
panelOrder: string[];
lockedPanel: string[];
// createdBy: mongoose.Types.ObjectId;
// sceneID: mongoose.Types.ObjectId;
layer: number;
}
const zoneSchema: Schema = new Schema(
{
zoneName: { type: String },
zoneId: { type: String },
createdBy: { type: String },
sceneID: { type: String },
layer: { type: Number },
points: { type: Array },
isArchive: { type: Boolean, default: false },
panelOrder: {
type: [String],
enum: ["left", "right", "up", "down"],
},
viewPortCenter: { type: Array, required: true },
viewPortposition: { type: Array, required: true },
lockedPanel: {
type: [String],
default: [],
enum: ["left", "right", "up", "down"],
},
// createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
// sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
},
{ timestamps: true }
);
const zoneModel = (db: any) => {
return MainModel(db, "zones", zoneSchema, "zones");
};
export default zoneModel;

View File

@@ -1,5 +1,5 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose';
import MainModel from '../../connect/mongoose.ts';
// Interface for TypeScript with PascalCase
export interface Camera extends Document {

View File

@@ -1,5 +1,5 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose';
import MainModel from '../../connect/mongoose.ts';
// Interface for TypeScript with PascalCase
export interface environment extends Document {
userId: string;

View File

@@ -1,5 +1,5 @@
import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../../connect/mongoose";
import MainModel from "../../connect/mongoose.ts";
const positionSchema = new mongoose.Schema({
x: { type: Number, }, // Optional position fields
y: { type: Number, },

View File

@@ -1,25 +1,27 @@
import mongoose, { Document, ObjectId, Schema } from "mongoose";
import MainModel from "../../connect/mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface zoneSchema extends Document {
zoneId: string;
zoneId: string;//UUID
zoneName: string
createBy: mongoose.Types.ObjectId
points: []
layer: Number
viewPortCenter: []
viewPortposition: []
isArchive:boolean
}
// Define the Mongoose Schema
const zoneSchema: Schema = new Schema({
zoneId: { type: String },
zoneId: { type: String },//UUID
zoneName: { type: String },
createBy: { type: Schema.Types.ObjectId, ref: "Users", },
points: { type: Array },
layer: { type: Number, required: true },
viewPortCenter: { type: Array, required: true },
viewPortposition: { type: Array, required: true },
isArchive:{type:Boolean,default:false}
});

View 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;

View File

@@ -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;

View File

@@ -1,5 +1,5 @@
import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../connect/mongoose";
import MainModel from "../connect/mongoose.ts";
export interface User extends Document {
userName: String;
email: String;

View File

@@ -0,0 +1,25 @@
import mongoose, { Schema, Document, model } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface Panel extends Document {
// 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: String },
panelName: { type: String },
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
isArchive: { type: Boolean, default: false },
},
{ timestamps: true }
);
const panelModel = (db: any) => {
return MainModel(db, "Panel", panelSchema, "Panel");
};
export default panelModel;

View File

@@ -0,0 +1,19 @@
import mongoose, { Schema, Document, model } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface Template extends Document {
templateName: string;
isArchive: boolean;
}
const templateSchema: Schema = new Schema(
{
templateName: { type: String },
isArchive: { type: Boolean, default: false },
},
{ timestamps: true }
);
const templateModel = (db: any) => {
return MainModel(db, "Template", templateSchema, "Template");
};
export default templateModel;

View File

@@ -0,0 +1,48 @@
import mongoose, { Schema, Document, model } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface widget extends Document {
widgetName: string;
widgetside: string;
widgetID: string;
widgetOrder: string;
elementType: string;
elementColor: string;
fontFamily: string;
fontStyle: string;
fontWeight: string;
isArchive: boolean;
panelID: mongoose.Types.ObjectId;
Data: {
measurement: Record<string, any>;
duration: string;
};
}
const widgetSchema: Schema = new Schema(
{
widgetName: { type: String },
widgetside: { type: String },
widgetID: { type: String },
widgetOrder: { type: String },
elementType: { type: String },
elementColor: { type: String },
fontFamily: { type: String },
fontStyle: { type: String },
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" },
},
{ timestamps: true }
);
const widgetModel = (db: any) => {
return MainModel(db, "Widget", widgetSchema, "Widget");
};
export default widgetModel;

View File

@@ -1,16 +1,17 @@
const bcrypt = require("bcryptjs");
import bcrypt from 'bcryptjs';
const saltRounds = 10;
const hashGenerate = async (Password:String) => {
export const hashGenerate = async (Password:string) => {
try {
const salt = await bcrypt.genSalt(saltRounds);
const hash = await bcrypt.hash(Password, salt);
return hash;
} catch (error) {
return error;
}
};
const hashValidator = async (password:String, hashedPassword:String) => {
export const hashValidator = async (password:string, hashedPassword:string) => {
try {
const result = await bcrypt.compare(password, hashedPassword);
@@ -20,5 +21,4 @@ const hashValidator = async (password:String, hashedPassword:String) => {
return false;
}
};
module.exports.hashGenerate = hashGenerate;
module.exports.hashValidator = hashValidator;
;

View File

@@ -6,7 +6,7 @@ import dotenv from "dotenv"; // Import dotenv
dotenv.config();
import { initSocketServer } from "./socket/socketManager";
import { initSocketServer } from "./socket/socketManager.ts";
const app = express();
const PORT = process.env.SOCKET_PORT;

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import floorItemsModel from "../../../shared/model/assets/flooritems-Model";
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
export const setFloorItems = async (data: any) => {
try {

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import wallItenmModel from "../../../shared/model/assets/wallitems-Model";
import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
export const setWallItems = async (data: any) => {

View File

@@ -1,6 +1,6 @@
import { Request, Response } from "express";
import { Socket } from "socket.io";
import cameraModel from "../../../shared/model/camera/camera-Model";
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
export const createCamera = async (data: any,) => {
try {

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import environmentModel from "../../../shared/model/environments/environments-Model";
import environmentModel from "../../../shared/model/environments/environments-Model.ts";

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import lineModel from "../../../shared/model/lines/lines-Model";
import lineModel from "../../../shared/model/lines/lines-Model.ts";
export const createLineItems = async (data: any)=>{

View File

@@ -0,0 +1,80 @@
// import zoneModel from "../../../shared/model/builder/lines/zone-Model.ts";
// export const setZone = async (data: any) => {
// const { organization, userId, zoneData } = data
// // try {
// // console.log('data: ', data);
// // const zoneId = zoneData.zoneId
// // const points = zoneData.points
// // const zoneName = zoneData.zoneName
// // const layer = zoneData.layer
// // const viewPortCenter = zoneData.viewPortCenter
// // const viewPortposition = zoneData.viewPortposition
// // const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
// // } catch (error) {
// // console.log('error: ', error);
// // return { success: false, message: 'Zone not found', error }
// // }
// try {
// console.log('data: ', data);
// const zoneId = zoneData.zoneId
// const points = zoneData.points
// const zoneName = zoneData.zoneName
// const layer = zoneData.layer
// const viewPortCenter = zoneData.viewPortCenter
// const viewPortposition = zoneData.viewPortposition
// const existingZone = await zoneModel(organization).findOne({
// zoneId:zoneId,
// isArchive: false,
// });
// if (!existingZone) {
// const newZone = await zoneModel(organization).create({
// zoneName: zoneName,
// zoneId: zoneId,
// zonePoints: points,
// viewPortposition: viewPortposition,
// viewPortCenter: viewPortCenter,
// createdBy: userId,
// layer: layer,
// sceneID: sceneID,
// });
// if (newZone)
// return res.status(200).json({
// message: "Zone created successfully",
// zoneData: {
// zoneName: newZone.zoneName,
// points: newZone.zonePoints,
// viewPortposition: viewPortposition,
// viewPortCenter: viewPortCenter,
// },
// });
// } else {
// const replaceZone = await zoneModel(organization).findOneAndUpdate(
// { zoneId: zoneId, isArchive: false },
// {
// zonePoints: points,
// viewPortposition: viewPortposition,
// viewPortCenter: viewPortCenter,
// },
// { new: true }
// );
// if (!replaceZone)
// return res.status(404).json({ message: "Zone not updated" });
// else
// return res.status(200).json({
// message: "updated successfully",
// zoneData: {
// zoneName: replaceZone.zoneName,
// points: replaceZone.zonePoints,
// viewPortposition: replaceZone.viewPortposition,
// viewPortCenter: replaceZone.viewPortCenter,
// },
// });
// }
// } catch (error: any) {
// return res.status(500).send(error.message);
// }
// }

View File

@@ -1,4 +1,4 @@
import zoneModel from "../../../shared/model/lines/zone-Model";
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
export const setZone = async (data: any) => {
try {

View File

@@ -1,5 +1,5 @@
import cameraModel from "../../../shared/model/camera/camera-Model"
import userModel from "../../../shared/model/user-Model"
import cameraModel from "../../../shared/model/camera/camera-Model.ts"
import userModel from "../../../shared/model/user-Model.ts"
export const activeUsers = async (data: any) => {
try {

View File

@@ -1,12 +1,12 @@
import { Server, Socket } from 'socket.io';
import { EVENTS } from './events';
import { createCamera } from '../services/camera/camera-Controller';
import { setEnvironment } from '../services/environments/environments-controller';
import { deleteFloorItems, setFloorItems } from '../services/assets/flooritem-Controller';
import { deleteWallItems, setWallItems } from '../services/assets/wallitem-Controller';
import { deleteLineItems, deleteLinPoiteItems, updateLineItems ,createLineItems, deleteLayer} from '../services/lines/line-Controller';
import { activeUserOffline, activeUsers } from '../services/users/user-controller';
import { deleteZone, setZone } from '../services/lines/zone-controller';
import { EVENTS } from './events.ts';
import { createCamera } from '../services/camera/camera-Controller.ts';
import { setEnvironment } from '../services/environments/environments-controller.ts';
import { deleteFloorItems, setFloorItems } from '../services/assets/flooritem-Controller.ts';
import { deleteWallItems, setWallItems } from '../services/assets/wallitem-Controller.ts';
import { deleteLineItems, deleteLinPoiteItems, updateLineItems ,createLineItems, deleteLayer} from '../services/lines/line-Controller.ts';
import { activeUserOffline, activeUsers } from '../services/users/user-controller.ts';
import { deleteZone, setZone } from '../services/lines/zone-controller.ts';

View File

@@ -11,9 +11,10 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "libReplacement": true, /* Enable lib replacement. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
@@ -25,17 +26,18 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "NodeNext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
"typeRoots": ["node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */
"types": ["node"], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
"allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
@@ -55,7 +57,7 @@
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */
"noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
@@ -76,6 +78,7 @@
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */