merged with main branch to clear the testing commits
This commit is contained in:
@@ -7,20 +7,19 @@ ENV NODE_ENV = development
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
RUN npm install -g tsx
|
||||
RUN npm install -g tsx --ignore-scripts
|
||||
|
||||
COPY package.json /usr/src/app/package.json
|
||||
COPY package.json ./
|
||||
COPY package-lock.json ./
|
||||
RUN npm install --ignore-scripts
|
||||
|
||||
|
||||
# COPY package-lock.json /usr/src/app/package-lock.json
|
||||
RUN addgroup -S appgroup && \
|
||||
adduser -S appuser -G appgroup && \
|
||||
chown -R appuser:appgroup /usr/src/app
|
||||
|
||||
|
||||
RUN npm install
|
||||
|
||||
# Run the application as a non-root user.
|
||||
USER root
|
||||
|
||||
# Copy the rest of the source files into the image.
|
||||
# Switch to non-root user
|
||||
USER appuser
|
||||
|
||||
|
||||
COPY . .
|
||||
|
||||
@@ -8,5 +8,4 @@ router.patch(
|
||||
AssetsFloorService.updateAssetPositionRotation
|
||||
);
|
||||
router.patch("/eventDataUpdate", AssetsFloorService.replaceEventDatas);
|
||||
// router.get("/pointData/:modelfileID/:organization", AssetsFloorService.gettypePoints);
|
||||
export default router;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import express from "express";
|
||||
import { FloorItems } from "../controller/assets/flooritem-Services.ts";
|
||||
import { AssetsFloorService } from "../controller/simulation/assetsFloorservice.ts";
|
||||
import express from 'express';
|
||||
import { FloorItems } from '../controller/assets/flooritem-Services.ts';
|
||||
import { AssetsFloorService } from '../controller/simulation/assetsFloorservice.ts';
|
||||
|
||||
const router = express.Router();
|
||||
router.post("/setfloorItems", FloorItems.setFloorItems);
|
||||
router.get("/findfloorItems/:organization", FloorItems.getFloorItems);
|
||||
// router.delete('/deletefloorItem',floorItems.deleteFloorItems)
|
||||
router.delete("/deletefloorItem", AssetsFloorService.deleteFloorItems);
|
||||
router.post('/setfloorItems',FloorItems.setFloorItems)
|
||||
router.get('/findfloorItems/:organization',FloorItems.getFloorItems)
|
||||
router.delete('/deletefloorItem',AssetsFloorService.deleteFloorItems)
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import express from "express";
|
||||
import { Lines } from "../controller/lines/line-Services.ts";
|
||||
import express from 'express';
|
||||
import { Lines } from '../controller/lines/line-Services.ts';
|
||||
|
||||
|
||||
const router = express.Router();
|
||||
router.post("/setLine", Lines.setLines);
|
||||
router.post("/updatePoint", Lines.updateLines);
|
||||
router.get("/findLines/:organization", Lines.getLines);
|
||||
router.delete("/deleteLine", Lines.deleteLineItems);
|
||||
router.delete("/deletePoint", Lines.deleteLinPoiteItems);
|
||||
router.post("/deleteLayer", Lines.deleteLayer);
|
||||
router.post('/setLine',Lines.setLines)
|
||||
router.post('/updatePoint',Lines.updateLines)
|
||||
router.get('/findLines/:organization',Lines.getLines)
|
||||
router.delete('/deleteLine',Lines.deleteLineItems)
|
||||
router.delete('/deletePoint',Lines.deleteLinPoiteItems)
|
||||
router.post('/deleteLayer',Lines.deleteLayer)
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -138,5 +138,4 @@ router.post("/panel/save", PanelService.AddPanel);
|
||||
router.patch("/panel/delete", PanelService.deletePanel);
|
||||
router.patch("/clearpanel", PanelService.clearPanel);
|
||||
|
||||
// router.get("/zone/:sceneID", Zoneservice.allZones);
|
||||
export default router;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import * as express from "express";
|
||||
import { ProductFlowservice } from "../controller/simulation/productService.ts";
|
||||
import { ProductFlowService } from "../controller/simulation/productService.ts";
|
||||
const productRouter = express.Router();
|
||||
productRouter.post("/UpsertProductOrEvent", ProductFlowservice.productAdd);
|
||||
productRouter.get("/productData", ProductFlowservice.getProductDatas);
|
||||
productRouter.patch("/EventDataDelete", ProductFlowservice.EventDataDelete);
|
||||
productRouter.patch("/productDataDelete", ProductFlowservice.productDataDelete);
|
||||
productRouter.get(
|
||||
"/AllProducts/:organization",
|
||||
ProductFlowservice.AllProductDatas
|
||||
);
|
||||
productRouter.patch("/productRename", ProductFlowservice.productRename);
|
||||
productRouter.post("/UpsertProductOrEvent", ProductFlowService.productAdd);
|
||||
productRouter.get("/productData", ProductFlowService.getProductDatas);
|
||||
productRouter.patch("/EventDataDelete", ProductFlowService.EventDataDelete);
|
||||
productRouter.patch("/productDataDelete", ProductFlowService.productDataDelete);
|
||||
productRouter.get("/AllProducts/:organization", ProductFlowService.AllProductDatas);
|
||||
productRouter.patch("/productRename", ProductFlowService.productRename);
|
||||
export default productRouter;
|
||||
|
||||
@@ -7,6 +7,6 @@ router.post("/TemplatetoZone", TemplateService.AddToZone);
|
||||
router.patch(
|
||||
"/TemplateDelete/:templateID/:organization",
|
||||
TemplateService.Deletezone
|
||||
); //delete zone
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import express from "express";
|
||||
import { User } from "../controller/user-Controller.ts";
|
||||
import express from 'express';
|
||||
import { User } from '../controller/user-Controller.ts';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post("/signup", User.signup);
|
||||
router.post("/login", User.login);
|
||||
router.post('/signup',User.signup)
|
||||
router.post('/login',User.login)
|
||||
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import express from "express";
|
||||
import { WallItems } from "../controller/assets/wallitem-Services.ts";
|
||||
import express from 'express';
|
||||
import { WallItems } from '../controller/assets/wallitem-Services.ts';
|
||||
|
||||
|
||||
const router = express.Router();
|
||||
router.post("/setWallItems", WallItems.setWallItems);
|
||||
router.get("/findWallItems/:organization", WallItems.getWallItems);
|
||||
router.delete("/deleteWallItem", WallItems.deleteWallItems);
|
||||
router.post('/setWallItems',WallItems.setWallItems)
|
||||
router.get('/findWallItems/:organization',WallItems.getWallItems)
|
||||
router.delete('/deleteWallItem',WallItems.deleteWallItems)
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import * as express from "express";
|
||||
import { ZoneService } from "../controller/lines/zoneService.ts";
|
||||
import { zone } from "../controller/lines/zone-Services.ts";
|
||||
|
||||
const router = express.Router();
|
||||
/**
|
||||
* @swagger
|
||||
@@ -247,7 +245,7 @@ const router = express.Router();
|
||||
* type: string
|
||||
* example: "Internal server error"
|
||||
*/
|
||||
router.post("/zone/save", ZoneService.addandUpdateZone); //Zone create and update for the points
|
||||
router.post("/zone/save", ZoneService.addandUpdateZone);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -538,8 +536,7 @@ router.get("/A_zone/:zoneId/:organization", ZoneService.ZoneData);
|
||||
* type: string
|
||||
* example: "Internal Server Error"
|
||||
*/
|
||||
router.patch("/zone/:zoneId", ZoneService.deleteAZone); //delete Zone
|
||||
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||
router.patch("/zone/:zoneId", ZoneService.deleteAZone);
|
||||
|
||||
router.get("/findZones/:organization", zone.getZones);
|
||||
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||
export default router;
|
||||
|
||||
@@ -67,7 +67,6 @@ export const GetProjects = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { userId, organization, role } = req.user || {};
|
||||
// const { userId, organization } = req.params;
|
||||
if (!userId || !organization || !role) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
@@ -106,7 +105,6 @@ export const RemoveProject = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
// const { organization, userId } = req.body;
|
||||
const { organization, userId } = req.user || {};
|
||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||
res.status(401).json({ message: "Unauthorized" });
|
||||
|
||||
@@ -8,12 +8,7 @@ export const versioncontroller = async (
|
||||
try {
|
||||
console.log("req.body: ", req.body);
|
||||
const { projectId, userId, description, db } = req.body;
|
||||
// if (!userName || !Email || !description) {
|
||||
// res.status(400).json({
|
||||
// message: "All fields are required",
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
|
||||
const result = await versionService.saveCurrentStateAsVersion(
|
||||
db,
|
||||
projectId,
|
||||
|
||||
@@ -11,46 +11,36 @@ import {
|
||||
|
||||
const v1Zone = express.Router();
|
||||
|
||||
//Zone-Page
|
||||
v1Zone.post(
|
||||
"/zones",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
CreateZoneController
|
||||
);
|
||||
v1Zone.patch(
|
||||
"/zones/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DeleteZoneController
|
||||
);
|
||||
|
||||
//viz
|
||||
v1Zone.get(
|
||||
"/zones/visualization/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
VizZoneController
|
||||
);
|
||||
|
||||
//getzones
|
||||
v1Zone.get(
|
||||
"/zones/:projectId/:zoneId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
ZoneDataController
|
||||
);
|
||||
// viz
|
||||
v1Zone.get(
|
||||
"/zones/panel/:projectId/:zoneId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
SingleZonePanelController
|
||||
);
|
||||
v1Zone.get(
|
||||
"/zones/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetZoneController
|
||||
);
|
||||
export default v1Zone;
|
||||
|
||||
@@ -9,29 +9,24 @@ import {
|
||||
|
||||
const v1Asset = express.Router();
|
||||
|
||||
//Asset-Page
|
||||
v1Asset.post(
|
||||
"/setAsset",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
CreateAssetController
|
||||
);
|
||||
v1Asset.patch(
|
||||
"/updateFloorAssetPositions",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
AssetUpdatePosRotController
|
||||
);
|
||||
v1Asset.get(
|
||||
"/floorAssets/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetAssetController
|
||||
);
|
||||
v1Asset.patch(
|
||||
"/updateEventData",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
ReplaceEventDataController
|
||||
);
|
||||
export default v1Asset;
|
||||
|
||||
@@ -8,23 +8,19 @@ import {
|
||||
|
||||
const v1Camera = express.Router();
|
||||
|
||||
//Camera-Page
|
||||
v1Camera.post(
|
||||
"/setCamera",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
SetNewCamera
|
||||
);
|
||||
v1Camera.get(
|
||||
"/activeCameras",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
ActiveOnlineController
|
||||
);
|
||||
v1Camera.get(
|
||||
"/cameras/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
CameraList
|
||||
);
|
||||
|
||||
|
||||
@@ -11,41 +11,34 @@ import {
|
||||
|
||||
const v1Line = express.Router();
|
||||
|
||||
//Line-Page
|
||||
v1Line.post(
|
||||
"/lines",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
NewLineController
|
||||
);
|
||||
v1Line.post(
|
||||
"/points",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
UpdateLineController
|
||||
);
|
||||
v1Line.patch(
|
||||
"/layers/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DeleteLayerController
|
||||
);
|
||||
v1Line.patch(
|
||||
"/lines/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DeleteLineController
|
||||
);
|
||||
v1Line.patch(
|
||||
"/points/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DeleteLinePointsController
|
||||
);
|
||||
v1Line.get(
|
||||
"/lines/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetLinesController
|
||||
);
|
||||
export default v1Line;
|
||||
|
||||
@@ -8,23 +8,19 @@ import {
|
||||
|
||||
const v1Wall = express.Router();
|
||||
|
||||
//Wall-Page
|
||||
v1Wall.post(
|
||||
"/walls",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
WallSetup
|
||||
);
|
||||
v1Wall.patch(
|
||||
"/walls/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
WallDelete
|
||||
);
|
||||
v1Wall.get(
|
||||
"/walls/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
WallGet
|
||||
);
|
||||
export default v1Wall;
|
||||
|
||||
@@ -9,23 +9,19 @@ import {
|
||||
|
||||
const v1homeRoutes = express.Router();
|
||||
|
||||
//home-Page
|
||||
v1homeRoutes.get(
|
||||
"/RecentlyViewed",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
recentDataController
|
||||
);
|
||||
v1homeRoutes.get(
|
||||
"/searchProjects",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
searchProjectController
|
||||
);
|
||||
v1homeRoutes.get(
|
||||
"/searchTrashProjects",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
searchTrashProjectController
|
||||
);
|
||||
|
||||
|
||||
@@ -8,11 +8,9 @@ import {
|
||||
ViewData,
|
||||
} from "../../V1/v1Controllers/projectController/v1projectController.ts";
|
||||
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||
|
||||
const v1projectRouter = express.Router();
|
||||
|
||||
// project
|
||||
v1projectRouter.post("/NewProject", tokenValidator, createProjectController);
|
||||
v1projectRouter.post(
|
||||
"/project/Duplicate",
|
||||
@@ -22,26 +20,22 @@ v1projectRouter.post(
|
||||
v1projectRouter.get(
|
||||
"/Projects",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetProjects
|
||||
);
|
||||
v1projectRouter.patch(
|
||||
"/Projects/Archive/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
RemoveProject
|
||||
);
|
||||
|
||||
v1projectRouter.patch(
|
||||
"/Projects/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
updateProjectController
|
||||
);
|
||||
v1projectRouter.get(
|
||||
"/Project/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
ViewData
|
||||
);
|
||||
|
||||
|
||||
@@ -8,24 +8,20 @@ import {
|
||||
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
|
||||
|
||||
const v1TrashRoutes = express.Router();
|
||||
//trash
|
||||
v1TrashRoutes.get(
|
||||
"/TrashItems",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetTrashList
|
||||
);
|
||||
|
||||
v1TrashRoutes.patch(
|
||||
"/Trash/restore",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
RestoreTrash
|
||||
);
|
||||
v1TrashRoutes.patch(
|
||||
"/Trash/Delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DeleteTrashData
|
||||
);
|
||||
export default v1TrashRoutes;
|
||||
|
||||
@@ -10,35 +10,29 @@ import {
|
||||
|
||||
const v1FloatWidget = express.Router();
|
||||
|
||||
//floatWidget-Page
|
||||
v1FloatWidget.post(
|
||||
"/floatWidget/save",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
FloatAddController
|
||||
);
|
||||
v1FloatWidget.patch(
|
||||
"/floatWidget/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DeleteFloatController
|
||||
);
|
||||
v1FloatWidget.get(
|
||||
"/floatWidgets/:zoneId/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetFloatController
|
||||
);
|
||||
v1FloatWidget.get(
|
||||
"/floatWidget/:floatWidgetId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
SingleFloatController
|
||||
);
|
||||
v1FloatWidget.post(
|
||||
"/floatWidget/duplicate",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DuplicateFloatController
|
||||
);
|
||||
export default v1FloatWidget;
|
||||
|
||||
@@ -9,29 +9,24 @@ import {
|
||||
|
||||
const v1Template = express.Router();
|
||||
|
||||
//template-Page
|
||||
v1Template.post(
|
||||
"/template/save",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
AddTemplateController
|
||||
);
|
||||
v1Template.post(
|
||||
"/template/toZone",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
AddTemToZoneController
|
||||
);
|
||||
v1Template.get(
|
||||
"/template/data/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetTemplateController
|
||||
);
|
||||
v1Template.patch(
|
||||
"/template/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
TemplateDeleteController
|
||||
);
|
||||
export default v1Template;
|
||||
|
||||
@@ -8,23 +8,19 @@ import {
|
||||
|
||||
const v1PanelRoutes = express.Router();
|
||||
|
||||
//panel-Page
|
||||
v1PanelRoutes.post(
|
||||
"/panel/save",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
AddPanelController
|
||||
);
|
||||
v1PanelRoutes.patch(
|
||||
"/panel/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
DeletePanelController
|
||||
);
|
||||
v1PanelRoutes.patch(
|
||||
"/panel/clear",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
ClearPanelController
|
||||
);
|
||||
|
||||
|
||||
@@ -10,29 +10,26 @@ import {
|
||||
|
||||
const v1Widget3d = express.Router();
|
||||
|
||||
//widget3d-Page
|
||||
|
||||
v1Widget3d.post(
|
||||
"/widget3d/save",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
|
||||
Add3dWidgetController
|
||||
);
|
||||
v1Widget3d.patch(
|
||||
"/widget3d/update",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
Update3DwidgetController
|
||||
);
|
||||
v1Widget3d.get(
|
||||
"/widget3d/data/:zoneId/:projectId",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
Get3DWidgetController
|
||||
);
|
||||
v1Widget3d.patch(
|
||||
"/widget3d/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
Delete3DwidgetController
|
||||
);
|
||||
export default v1Widget3d;
|
||||
|
||||
@@ -9,29 +9,24 @@ import {
|
||||
|
||||
const v1Widget = express.Router();
|
||||
|
||||
//widget-Page
|
||||
v1Widget.post(
|
||||
"/widget/save",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
AddWidgetController
|
||||
);
|
||||
v1Widget.patch(
|
||||
"/widget/:widgetID",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
WidgetUpdateController
|
||||
);
|
||||
v1Widget.get(
|
||||
"/widget/data",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetWidgetController
|
||||
);
|
||||
v1Widget.patch(
|
||||
"/widget/delete",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
WidgetDeleteController
|
||||
);
|
||||
export default v1Widget;
|
||||
|
||||
@@ -8,7 +8,8 @@ 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/zoneRoutes.ts"; //update
|
||||
import zoneRoutes from "./Routes/zone-Routes.ts";
|
||||
import zoneRoutes2 from "./Routes/zoneRoutes.ts";
|
||||
import panelRouter from "./Routes/panelRoutes.ts";
|
||||
import widgetRouter from "./Routes/widgetRoute.ts";
|
||||
import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
||||
@@ -35,51 +36,20 @@ import v1PanelRoutes from "./V1/v1Routes/vizRoutes.ts/v1-panelRoutes.ts";
|
||||
import v1Template from "./V1/v1Routes/vizRoutes.ts/v1-TemplateRoutes.ts";
|
||||
import v1Widget from "./V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts";
|
||||
import v1Widget3d from "./V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts";
|
||||
// import productFlowRoutes from "./Routes/productFlowRouts.ts";
|
||||
redis;
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
// const allowedOriginsDev = [
|
||||
// "http://localhost:3000",
|
||||
// "http://192.168.0.183:8200",
|
||||
// "http://192.168.0.101:8200",
|
||||
// "http://192.168.0.105:8200",
|
||||
// "http://192.168.0.134:8200"
|
||||
// ];
|
||||
// const allowedOrigin =
|
||||
// process.env.NODE_ENV === "production"
|
||||
// ? process.env.FRONTEND_ORIGIN_PROD
|
||||
// : allowedOriginsDev;
|
||||
// app.use(cors({
|
||||
// origin: (origin, callback) => {
|
||||
// if (!origin) return callback(null, true);
|
||||
// if (
|
||||
// Array.isArray(allowedOrigin) &&
|
||||
// allowedOrigin.includes(origin)
|
||||
// ) {
|
||||
// return callback(null, true);
|
||||
// }
|
||||
|
||||
// if (typeof allowedOrigin === "string" && origin === allowedOrigin) {
|
||||
// return callback(null, true);
|
||||
// }
|
||||
|
||||
// return callback(new Error("Not allowed by CORS"));
|
||||
// },
|
||||
// credentials: true
|
||||
// }));
|
||||
|
||||
app.use(express.json({ limit: "50mb" }));
|
||||
app.use(
|
||||
express.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 })
|
||||
);
|
||||
dotenv.config();
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
app.get("/", (req, res) => {
|
||||
res.send("Hello, I am Major-Dwinzo API!");
|
||||
});
|
||||
app.get("/health", (req, res) => {
|
||||
res.status(200).json({ message: "Server is running" });
|
||||
});
|
||||
|
||||
app.use("/api/v1", cameraRoutes);
|
||||
app.use("/api/v1", environmentsRoutes);
|
||||
@@ -88,8 +58,9 @@ app.use("/api/v1", flooritemRoutes);
|
||||
app.use("/api/v1", WallitemRoutes);
|
||||
app.use("/api/v1", userRoutes);
|
||||
app.use("/api/v1", shareRoutes);
|
||||
//update
|
||||
app.use("/api/v2", zoneRoutes); //updates
|
||||
app.use("/api/v2", zoneRoutes);
|
||||
|
||||
app.use("/api/v2", zoneRoutes2);
|
||||
app.use("/api/v2", panelRouter);
|
||||
app.use("/api/v2", widgetRouter);
|
||||
app.use("/api/v2", assetpointRouter);
|
||||
@@ -98,12 +69,10 @@ app.use("/api/v2", floadWidgetRoutes);
|
||||
app.use("/api/v2", templateRoutes);
|
||||
app.use("/api/v2", widget3dRoutes);
|
||||
app.use("/api/v2", productRouter);
|
||||
// app.use("/api/v2", productFlowRoutes);
|
||||
app.use("/api/v1", projectRouter);
|
||||
app.use("/api/v1", trashRouter);
|
||||
app.use("/api/v1", homePageRouter);
|
||||
|
||||
//New versions--based on the token and role based
|
||||
app.use("/api/V1", Authrouter);
|
||||
app.use("/api/V1", v1projectRouter);
|
||||
app.use("/api/V1", v1TrashRoutes);
|
||||
|
||||
@@ -48,9 +48,7 @@ export class FloorItems {
|
||||
res.status(201).json(newValue);
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating flooritems:", error);
|
||||
res.status(500).json({ message: "Failed to create flooritems" });
|
||||
}
|
||||
}
|
||||
@@ -65,7 +63,6 @@ export class FloorItems {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
@@ -83,7 +80,6 @@ export class FloorItems {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,6 @@ interface IPointStaticMachine extends IPointBase {
|
||||
export class PointService {
|
||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||
const { type, modelfileID, organization } = req.body;
|
||||
|
||||
// Validate type
|
||||
if (!["Conveyor", "Vehicle", "ArmBot", "StaticMachine"].includes(type)) {
|
||||
return res.status(400).json({ message: "Invalid type requested" });
|
||||
}
|
||||
@@ -92,7 +90,6 @@ export class PointService {
|
||||
|
||||
if (type === "Conveyor") {
|
||||
const baseData = {
|
||||
// modelfileID: "672a090f80d91ac979f4d0bd",
|
||||
modelfileID: "7dc04e36882e4debbc1a8e3d",
|
||||
type: "Conveyor",
|
||||
};
|
||||
@@ -118,8 +115,6 @@ export class PointService {
|
||||
name: "trigger 1",
|
||||
type: "triggerType",
|
||||
bufferTime: 0,
|
||||
// delay: "Inherit",
|
||||
// spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
@@ -195,7 +190,6 @@ export class PointService {
|
||||
} else if (type === "Vehicle") {
|
||||
console.log("vehcile data");
|
||||
const baseData = {
|
||||
// modelfileID: "67e3da19c2e8f37134526e6a",
|
||||
modelfileID: "a1ee92554935007b10b3eb05",
|
||||
type: "Vehicle",
|
||||
};
|
||||
@@ -231,7 +225,6 @@ export class PointService {
|
||||
} else if (type === "ArmBot") {
|
||||
console.log("ArmBot data");
|
||||
const baseData = {
|
||||
// modelfileID: "67eb7904c2e8f37134527eae",
|
||||
modelfileID: "52e6681fbb743a890d96c914",
|
||||
type: "ArmBot",
|
||||
};
|
||||
@@ -269,7 +262,6 @@ export class PointService {
|
||||
} else if (type === "StaticMachine") {
|
||||
console.log("StaticMachine data");
|
||||
const baseData = {
|
||||
// modelfileID: "67e3db5ac2e8f37134526f40",
|
||||
modelfileID: "ca164ffdfa74f6622536bb0f",
|
||||
type: "StaticMachine",
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ export class WallItems {
|
||||
quaternion,
|
||||
scale,
|
||||
},
|
||||
{ new: true } // Return the updated document
|
||||
{ new: true }
|
||||
);
|
||||
res.status(201).json(updatevalue);
|
||||
} else {
|
||||
@@ -49,8 +49,6 @@ export class WallItems {
|
||||
|
||||
res.status(201).json(newValue);
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating wallitems:", error);
|
||||
res.status(500).json({ message: "Failed to create wallitems" });
|
||||
|
||||
@@ -28,8 +28,6 @@ export class Camera {
|
||||
|
||||
res.status(201).json(newCamera);
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating camera:", error);
|
||||
res.status(500).json({ message: "Failed to create camera" });
|
||||
@@ -38,7 +36,6 @@ export class Camera {
|
||||
static async getCamera(req: Request, res: Response) {
|
||||
try {
|
||||
const { userId, organization } = req.params;
|
||||
|
||||
const findCamera = await cameraModel(organization).findOne({
|
||||
userId: userId,
|
||||
});
|
||||
@@ -79,8 +76,6 @@ export class Camera {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Return null if no camera data is found for the user
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -46,7 +46,6 @@ export class Environment {
|
||||
res.status(201).json(newValue);
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating environments:", error);
|
||||
res.status(500).json({ message: "Failed to create environments" });
|
||||
|
||||
@@ -12,8 +12,6 @@ export class Lines {
|
||||
});
|
||||
|
||||
res.status(201).json(newLine);
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating Lines:", error);
|
||||
res.status(500).json({ message: "Failed to create Lines" });
|
||||
@@ -22,16 +20,12 @@ export class Lines {
|
||||
static async updateLines(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, uuid, position } = req.body;
|
||||
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
||||
// Update the position of the line matching the uuid
|
||||
const updateResult = await lineModel(organization).updateMany(
|
||||
{ "line.uuid": uuid }, // Filter: Find the line with the given uuid
|
||||
{ $set: { "line.$.position": position } } // Update the position and type
|
||||
{ "line.uuid": uuid },
|
||||
{ $set: { "line.$.position": position } }
|
||||
);
|
||||
|
||||
res.status(201).json(updateResult);
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating Lines:", error);
|
||||
res.status(500).json({ message: "Failed to create Lines" });
|
||||
@@ -54,11 +48,12 @@ export class Lines {
|
||||
}
|
||||
static async deleteLineItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, layer, line, type } = req.body;
|
||||
const { organization, line } = req.body;
|
||||
|
||||
const inputUuids = line.map((item: any) => item.uuid);
|
||||
|
||||
const findValue = await lineModel(organization).findOneAndDelete({
|
||||
"line.uuid": { $all: inputUuids },
|
||||
"line.uuid": { $all: inputUuids },
|
||||
});
|
||||
|
||||
if (!findValue) {
|
||||
@@ -73,7 +68,7 @@ export class Lines {
|
||||
}
|
||||
static async deleteLinPoiteItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, layer, uuid, type } = req.body;
|
||||
const { organization, uuid } = req.body;
|
||||
|
||||
const findValue = await lineModel(organization).deleteMany({
|
||||
"line.uuid": uuid,
|
||||
@@ -103,7 +98,7 @@ export class Lines {
|
||||
|
||||
const updateResult = await lineModel(organization).updateMany(
|
||||
{ layer: { $gt: layer } },
|
||||
{ $inc: { layer: -1 } }
|
||||
{ $inc: { layer: -1 } }
|
||||
);
|
||||
|
||||
res.status(201).json(updateResult);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Request, Response } from "express";
|
||||
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
||||
export class zone {
|
||||
export class Zone {
|
||||
static async setZone(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, userId, zoneData } = req.body;
|
||||
// console.log('req.body: ', req.body);
|
||||
const zoneId = zoneData.zoneId;
|
||||
const points = zoneData.points;
|
||||
const zoneName = zoneData.zoneName;
|
||||
@@ -26,11 +25,13 @@ export class zone {
|
||||
{ new: true }
|
||||
)
|
||||
.select("-_id -__v");
|
||||
res.status(201).json({
|
||||
message: "zone updated",
|
||||
data: updateZone,
|
||||
organization: organization,
|
||||
});
|
||||
res
|
||||
.status(201)
|
||||
.json({
|
||||
message: "zone updated",
|
||||
data: updateZone,
|
||||
organization: organization,
|
||||
});
|
||||
} else {
|
||||
const zoneCreate = await zoneModel(organization).create({
|
||||
zoneId,
|
||||
@@ -45,11 +46,13 @@ export class zone {
|
||||
.findById(zoneCreate._id)
|
||||
.select("-_id -__v")
|
||||
.lean();
|
||||
res.status(201).json({
|
||||
message: "zone created",
|
||||
data: createdZone,
|
||||
organization: organization,
|
||||
});
|
||||
res
|
||||
.status(201)
|
||||
.json({
|
||||
message: "zone created",
|
||||
data: createdZone,
|
||||
organization: organization,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
@@ -67,11 +70,13 @@ export class zone {
|
||||
const deleteZone = await zoneModel(organization)
|
||||
.findOneAndDelete({ zoneId: zoneId, createBy: userId })
|
||||
.select("-_id -__v");
|
||||
res.status(201).json({
|
||||
message: "zone deleted",
|
||||
data: deleteZone,
|
||||
organization: organization,
|
||||
});
|
||||
res
|
||||
.status(201)
|
||||
.json({
|
||||
message: "zone deleted",
|
||||
data: deleteZone,
|
||||
organization: organization,
|
||||
});
|
||||
} else {
|
||||
res.status(500).json({ message: "Invalid zone ID" });
|
||||
}
|
||||
@@ -82,7 +87,7 @@ export class zone {
|
||||
}
|
||||
static async getZones(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, userId } = req.params;
|
||||
const { organization } = req.params;
|
||||
|
||||
const findZoneId = await zoneModel(organization)
|
||||
.find()
|
||||
@@ -93,7 +98,7 @@ export class zone {
|
||||
if (!findZoneId) {
|
||||
res.status(500).json({ message: "Invalid zone" });
|
||||
}
|
||||
res.status(200).json({ data: findZoneId, organization: organization });
|
||||
res.status(201).json({ data: findZoneId, organization: organization });
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({ message: "Zone not found", error });
|
||||
@@ -107,7 +112,6 @@ export class zone {
|
||||
const findZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
});
|
||||
// .select("zoneName");
|
||||
console.log("findZone: ", findZone);
|
||||
if (findZone) return res.status(200).json(findZone);
|
||||
} catch (error: any) {
|
||||
|
||||
@@ -33,13 +33,6 @@ export class ZoneService {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// const existingZoneName = await zoneSchema(organization).find({
|
||||
// zoneName: zoneDatas.zoneName,
|
||||
// isArchive: false,
|
||||
// });
|
||||
// if (existingZoneName.length > 0) {
|
||||
// return res.json({ message: "Zone name already exists" });
|
||||
// }
|
||||
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
|
||||
{ zoneId: zoneDatas.zoneId, isArchive: false },
|
||||
{
|
||||
@@ -96,7 +89,6 @@ export class ZoneService {
|
||||
}
|
||||
}
|
||||
|
||||
//single zode panel and widget data
|
||||
static async singleZonePanelDatas(req: Request, res: Response): Promise<any> {
|
||||
const organization = req.query.organization;
|
||||
const zoneId = req.params.zoneId;
|
||||
@@ -157,7 +149,6 @@ export class ZoneService {
|
||||
}
|
||||
}
|
||||
|
||||
//page full zone Datas with panel and widget
|
||||
static async vizAllDatas(req: Request, res: Response): Promise<any> {
|
||||
const organization = req.query.organization;
|
||||
try {
|
||||
@@ -173,13 +164,11 @@ export class ZoneService {
|
||||
} else {
|
||||
const response = await Promise.all(
|
||||
existingZones.map(async (zone) => {
|
||||
// Fetch all panels associated with the current zone
|
||||
const panelData = await panelSchema(organization).find({
|
||||
zoneId: zone._id,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
// Fetch widgets for each panel
|
||||
const widgets = await Promise.all(
|
||||
panelData.map(async (panel) => {
|
||||
const widgetDataArray = await widgetSchema(organization).find({
|
||||
@@ -218,7 +207,6 @@ export class ZoneService {
|
||||
}
|
||||
}
|
||||
|
||||
//only for the name and zoneID
|
||||
static async allZones(req: Request, res: Response): Promise<any> {
|
||||
const organization = req.query.organization;
|
||||
const sceneID = req.params.sceneID || "scene123";
|
||||
@@ -244,7 +232,7 @@ export class ZoneService {
|
||||
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);
|
||||
@@ -284,21 +272,4 @@ export class ZoneService {
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ export class Share {
|
||||
if (!findValue) {
|
||||
res.status(404).json({ message: "Not found" });
|
||||
}
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating Share:", error);
|
||||
res.status(500).json({ message: "Failed to create Share" });
|
||||
@@ -37,7 +36,6 @@ export class Share {
|
||||
if (!findValue) {
|
||||
res.status(404).json({ message: "Not found" });
|
||||
}
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error Share:", error);
|
||||
res.status(500).json({ message: "Failed to Share datas " });
|
||||
|
||||
@@ -17,8 +17,6 @@ export class AssetsFloorService {
|
||||
isLocked,
|
||||
isVisible,
|
||||
organization,
|
||||
// modelfileID, //optional
|
||||
// eventData, // Optional
|
||||
} = req.body;
|
||||
|
||||
const existingAsset = await assetModel(organization).findOne({
|
||||
@@ -84,11 +82,9 @@ export class AssetsFloorService {
|
||||
organization,
|
||||
eventData,
|
||||
} = req.body;
|
||||
console.log("req.body: ", req.body);
|
||||
|
||||
const findvalue = await assetModel(organization).findOne({
|
||||
modelUuid,
|
||||
// modelName,
|
||||
isArchive: false,
|
||||
});
|
||||
await pointModel(organization).findOne({
|
||||
@@ -207,14 +203,11 @@ export class AssetsFloorService {
|
||||
return res.status(500).json({ message: "Failed to archive asset" });
|
||||
}
|
||||
|
||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
||||
await EventsDataModel(organization).updateMany(
|
||||
{ modelUuid },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
console.log("Archived asset:", archivedAsset);
|
||||
console.log("Updated events:", updatedEvents.modifiedCount);
|
||||
|
||||
return res.status(200).json({ message: "delete Asset successfully" });
|
||||
} catch (error) {
|
||||
console.error("Error deleting floor items:", error);
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from "express";
|
||||
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||
|
||||
export class ProductFlowservice {
|
||||
export class ProductFlowService {
|
||||
static async productAdd(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { productName, productId,eventDatas, organization } = req.body;
|
||||
const { productName, productId, eventDatas, organization } = req.body;
|
||||
if (!organization) {
|
||||
return res.json({ message: "organization not found" });
|
||||
}
|
||||
@@ -136,12 +136,10 @@ export class ProductFlowservice {
|
||||
productId: productId,
|
||||
});
|
||||
if (existingEventDatas) {
|
||||
// for (const event of existingEventDatas) {
|
||||
await EventsDataModel(organization).updateMany(
|
||||
{ productId },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
// }
|
||||
await EventsDataModel(organization).updateMany(
|
||||
{ productId },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
}
|
||||
return res.status(201).json({ message: "product deleted successfully" });
|
||||
} catch (error) {
|
||||
@@ -197,11 +195,9 @@ export class ProductFlowservice {
|
||||
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
||||
|
||||
result.push({
|
||||
// product: {
|
||||
productName: product.productName,
|
||||
productId: product.productId,
|
||||
eventDatas,
|
||||
// },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ export const GetTrashList = async (
|
||||
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
// message: "Project created Successfully",
|
||||
TrashDatas: result.ListDatas,
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -1,76 +1,72 @@
|
||||
import { Request, Response } from "express";
|
||||
import userModel from "../../shared/model/user-Model.ts";
|
||||
import {hashGenerate,hashValidator} from "../../shared/utils/Hasing.ts"
|
||||
import { hashGenerate, hashValidator } from "../../shared/security/Hasing.ts";
|
||||
|
||||
let serverAlive = true;
|
||||
export class User {
|
||||
static async signup(req: Request, res: Response) {
|
||||
try {
|
||||
let role;
|
||||
const { userName, email, password,organization,profilePicture } = req.body;
|
||||
const caseChange = email.toLowerCase();
|
||||
const emailcheck = await userModel(organization).findOne({ email: caseChange });
|
||||
if (emailcheck!==null) {
|
||||
res.json({
|
||||
message:"User already exists"
|
||||
});
|
||||
} else {
|
||||
const hashpassword=await hashGenerate(password)
|
||||
const userCount = await userModel(organization).countDocuments({});
|
||||
role = userCount === 0 ? "Admin" : "User";
|
||||
const isShare = "true";
|
||||
const newuser = await userModel(organization).create({
|
||||
userName: userName,
|
||||
email: caseChange,
|
||||
isShare:isShare,
|
||||
password: hashpassword,
|
||||
role:role,
|
||||
profilePicture:profilePicture
|
||||
});
|
||||
newuser.save();
|
||||
res.status(200).json({
|
||||
message:"New User created"
|
||||
});
|
||||
}
|
||||
} catch (error:any) {
|
||||
res.status(500).send(error);
|
||||
}
|
||||
static async signup(req: Request, res: Response) {
|
||||
try {
|
||||
let role;
|
||||
const { userName, email, password, organization, profilePicture } =
|
||||
req.body;
|
||||
const caseChange = email.toLowerCase();
|
||||
const emailcheck = await userModel(organization).findOne({
|
||||
email: caseChange,
|
||||
});
|
||||
if (emailcheck !== null) {
|
||||
res.json({
|
||||
message: "User already exists",
|
||||
});
|
||||
} else {
|
||||
const hashpassword = await hashGenerate(password);
|
||||
const userCount = await userModel(organization).countDocuments({});
|
||||
role = userCount === 0 ? "Admin" : "User";
|
||||
const isShare = "true";
|
||||
const newuser = await userModel(organization).create({
|
||||
userName: userName,
|
||||
email: caseChange,
|
||||
isShare: isShare,
|
||||
password: hashpassword,
|
||||
role: role,
|
||||
profilePicture: profilePicture,
|
||||
});
|
||||
newuser.save();
|
||||
res.status(200).json({
|
||||
message: "New User created",
|
||||
});
|
||||
}
|
||||
} catch (error: any) {
|
||||
res.status(500).send(error);
|
||||
}
|
||||
static async login(req: Request, res: Response) {
|
||||
try {
|
||||
let role;
|
||||
const { email, password,organization } = req.body;
|
||||
|
||||
const existingMail = await userModel(organization).findOne({
|
||||
email:email
|
||||
});
|
||||
|
||||
if (existingMail === null || !existingMail) {
|
||||
res.status(401).json({ message: "User Not Found!!! Kindly signup..." });
|
||||
} else {
|
||||
const hashedpassword= existingMail.password
|
||||
const checkpassword = await hashValidator(
|
||||
password,
|
||||
hashedpassword
|
||||
)
|
||||
if (checkpassword) {
|
||||
// const tokenValidation=await tokenGenerator(existingMail.email)
|
||||
res.status(200).send({
|
||||
message: "login successfull",
|
||||
email: existingMail.email,
|
||||
name: existingMail.userName,
|
||||
userId: existingMail._id,
|
||||
isShare:existingMail.isShare,
|
||||
// token:tokenValidation
|
||||
|
||||
});
|
||||
} else {
|
||||
res.status(404).json({message:"email & password is invalid...Check the credentials"})
|
||||
}
|
||||
}
|
||||
} catch (error:any) {
|
||||
res.status(500).send(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static async login(req: Request, res: Response) {
|
||||
try {
|
||||
let role;
|
||||
const { email, password, organization } = req.body;
|
||||
const existingMail = await userModel(organization).findOne({
|
||||
email: email,
|
||||
});
|
||||
|
||||
if (existingMail === null || !existingMail) {
|
||||
res.status(401).json({ message: "User Not Found!!! Kindly signup..." });
|
||||
} else {
|
||||
const hashedpassword = existingMail.password;
|
||||
const checkpassword = await hashValidator(password, hashedpassword);
|
||||
if (checkpassword) {
|
||||
res.status(200).send({
|
||||
message: "login successfull",
|
||||
email: existingMail.email,
|
||||
name: existingMail.userName,
|
||||
userId: existingMail._id,
|
||||
isShare: existingMail.isShare,
|
||||
});
|
||||
} else {
|
||||
res.status(404).json({
|
||||
message: "email & password is invalid...Check the credentials",
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
res.status(500).send(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ export class PanelService {
|
||||
try {
|
||||
const organization = req.body.organization;
|
||||
const zoneId = req.body.zoneId;
|
||||
// const panelName = req.body.panelName;
|
||||
const panelOrder = req.body.panelOrder;
|
||||
const findZone = await zoneSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
|
||||
@@ -8,16 +8,7 @@ import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts
|
||||
export class TemplateService {
|
||||
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const {
|
||||
organization,
|
||||
template,
|
||||
// id,
|
||||
// name,
|
||||
// panelOrder,
|
||||
// widgets,
|
||||
// snapshot,
|
||||
// floatWidgets,
|
||||
} = req.body;
|
||||
const { organization, template } = req.body;
|
||||
const existingTemplate = await templateModel(organization).findOne({
|
||||
templateID: template.id,
|
||||
isArchive: false,
|
||||
@@ -83,7 +74,6 @@ export class TemplateService {
|
||||
if (existingZone.panelOrder.length > 0) {
|
||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||
await existingZone.save();
|
||||
// Clear existing data before adding new data
|
||||
const archivePanelDatas = await panelSchema(organization).find({
|
||||
zoneId,
|
||||
isArchive: false,
|
||||
|
||||
@@ -5,12 +5,7 @@ import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||
export class WidgetService {
|
||||
static async addWidget(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const {
|
||||
organization,
|
||||
// panel,
|
||||
zoneId,
|
||||
widget,
|
||||
} = req.body;
|
||||
const { organization, zoneId, widget } = req.body;
|
||||
const existingZone = await zoneSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -30,7 +25,6 @@ export class WidgetService {
|
||||
panelID: existingPanel._id,
|
||||
widgetID: widget.id,
|
||||
isArchive: false,
|
||||
// widgetOrder: widget.widgetOrder,
|
||||
});
|
||||
if (existingWidget) {
|
||||
const updateWidget = await widgetSchema(
|
||||
@@ -43,8 +37,6 @@ export class WidgetService {
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
// panelID: existingPanel._id,
|
||||
// widgetID: widget.id,
|
||||
widgetName: widget?.widgetName,
|
||||
Data: {
|
||||
measurements: widget?.Data?.measurements || {},
|
||||
@@ -53,7 +45,7 @@ export class WidgetService {
|
||||
isArchive: false,
|
||||
},
|
||||
},
|
||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
||||
{ upsert: true, new: true }
|
||||
);
|
||||
if (!updateWidget) {
|
||||
return res.json({ message: "Widget update unsuccessful" });
|
||||
@@ -65,7 +57,6 @@ export class WidgetService {
|
||||
const newWidget = await widgetSchema(organization).create({
|
||||
widgetID: widget.id,
|
||||
elementType: widget.type,
|
||||
// widgetOrder: widgetOrder,
|
||||
zoneId,
|
||||
widgetName: widget.title,
|
||||
panelID: existingPanel._id,
|
||||
@@ -80,7 +71,6 @@ export class WidgetService {
|
||||
await existingPanel.save();
|
||||
return res.status(201).json({
|
||||
message: "Widget created successfully",
|
||||
// widgetID: newWidget._id,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -106,19 +96,11 @@ export class WidgetService {
|
||||
);
|
||||
|
||||
if (widgetData) {
|
||||
// Find all widgets in the same panel and sort them by widgetOrder
|
||||
await widgetSchema(organization).find({
|
||||
panelID: findWidget.panelID,
|
||||
zoneId: zoneId,
|
||||
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,
|
||||
zoneId: zoneId,
|
||||
@@ -147,7 +129,7 @@ export class WidgetService {
|
||||
return res.status(404).send({ message: "Data not found" });
|
||||
const updateData = {
|
||||
widgetName: values.widgetName,
|
||||
widgetSide: values.widgetSide, // Fixed typo from widgetside to widgetSide
|
||||
widgetSide: values.widgetSide,
|
||||
elementType: values.type,
|
||||
Data: {
|
||||
measurement: values.Data.measurement,
|
||||
|
||||
@@ -1,36 +1,25 @@
|
||||
import app from './app.ts';
|
||||
import http from 'http';
|
||||
|
||||
// import { startHealthCheck } from './controller/user-Controller';
|
||||
import swaggerUi from 'swagger-ui-express';
|
||||
import fs from 'fs';
|
||||
import app from "./app.ts";
|
||||
import http from "http";
|
||||
import swaggerUi from "swagger-ui-express";
|
||||
import fs from "fs";
|
||||
const server = http.createServer(app);
|
||||
|
||||
|
||||
let swaggerDocument = {};
|
||||
// try {
|
||||
// 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'));
|
||||
swaggerDocument = JSON.parse(fs.readFileSync("swagger-output.json", "utf-8"));
|
||||
} catch (error) {
|
||||
console.error('Error loading Swagger JSON:', error);
|
||||
console.error("Error loading Swagger JSON:", error);
|
||||
}
|
||||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||
const organization = process.env.ORGANIZATION_NAME || 'defaultOrganization'; // Replace with your logic
|
||||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||
const organization = process.env.ORGANIZATION_NAME || "defaultOrganization";
|
||||
|
||||
// mongoAdminCreation()
|
||||
if (!organization) {
|
||||
throw new Error('ORGANIZATION_NAME is not defined in the environment');
|
||||
throw new Error("ORGANIZATION_NAME is not defined in the environment");
|
||||
}
|
||||
|
||||
const PORT = process.env.API_PORT
|
||||
const PORT = process.env.API_PORT;
|
||||
server.listen(PORT, () => {
|
||||
console.log(`API-Server running on http://localhost:${PORT}`);
|
||||
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
|
||||
|
||||
console.log(`API-Server running on http://localhost:${PORT}`);
|
||||
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user