fetch req conflict resolved
This commit is contained in:
1
.env
1
.env
@@ -23,6 +23,5 @@ REFRESH_JWT_SECRET="RefreshDwinzoProject"
|
|||||||
|
|
||||||
|
|
||||||
REDIS_ENV= true
|
REDIS_ENV= true
|
||||||
|
|
||||||
REDIS_DOCKER =185.100.212.76
|
REDIS_DOCKER =185.100.212.76
|
||||||
REDIS_PORT=6666
|
REDIS_PORT=6666
|
||||||
@@ -11,16 +11,8 @@ import {
|
|||||||
|
|
||||||
const v1Zone = express.Router();
|
const v1Zone = express.Router();
|
||||||
|
|
||||||
v1Zone.post(
|
v1Zone.post("/zones", tokenValidator, CreateZoneController);
|
||||||
"/zones",
|
v1Zone.patch("/zones/delete", tokenValidator, DeleteZoneController);
|
||||||
tokenValidator,
|
|
||||||
CreateZoneController
|
|
||||||
);
|
|
||||||
v1Zone.patch(
|
|
||||||
"/zones/delete",
|
|
||||||
tokenValidator,
|
|
||||||
DeleteZoneController
|
|
||||||
);
|
|
||||||
|
|
||||||
v1Zone.get(
|
v1Zone.get(
|
||||||
"/zones/visualization/:projectId",
|
"/zones/visualization/:projectId",
|
||||||
@@ -38,9 +30,5 @@ v1Zone.get(
|
|||||||
tokenValidator,
|
tokenValidator,
|
||||||
SingleZonePanelController
|
SingleZonePanelController
|
||||||
);
|
);
|
||||||
v1Zone.get(
|
v1Zone.get("/zones/:projectId", tokenValidator, GetZoneController);
|
||||||
"/zones/:projectId",
|
|
||||||
tokenValidator,
|
|
||||||
GetZoneController
|
|
||||||
);
|
|
||||||
export default v1Zone;
|
export default v1Zone;
|
||||||
|
|||||||
@@ -238,25 +238,6 @@ export class ZoneService {
|
|||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getZones(req: Request, res: Response) {
|
|
||||||
try {
|
|
||||||
const { organization } = req.params;
|
|
||||||
|
|
||||||
const findZoneId = await zoneSchema(organization)
|
|
||||||
.find({isArchive:false})
|
|
||||||
.select(
|
|
||||||
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!findZoneId) {
|
|
||||||
res.status(500).json({ message: "Invalid zone" });
|
|
||||||
}
|
|
||||||
res.status(201).json({ data: findZoneId, organization: organization });
|
|
||||||
} catch (error) {
|
|
||||||
console.log("error: ", error);
|
|
||||||
res.status(500).json({ message: "Zone not found", error });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static async lockedPanel(req: Request, res: Response): Promise<any> {
|
static async lockedPanel(req: Request, res: Response): Promise<any> {
|
||||||
console.log(req.body);
|
console.log(req.body);
|
||||||
const organization = req.body.organization;
|
const organization = req.body.organization;
|
||||||
@@ -290,4 +271,24 @@ export class ZoneService {
|
|||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getZones(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization } = req.params;
|
||||||
|
|
||||||
|
const findZoneId = await zoneSchema(organization)
|
||||||
|
.find({ isArchive: false })
|
||||||
|
.select(
|
||||||
|
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!findZoneId) {
|
||||||
|
res.status(500).json({ message: "Invalid zone" });
|
||||||
|
}
|
||||||
|
res.status(200).json({ data: findZoneId, organization: organization });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import MainModel from "../../../connect/mongoose.ts";
|
|||||||
export interface Zone extends Document {
|
export interface Zone extends Document {
|
||||||
zoneName: string;
|
zoneName: string;
|
||||||
zoneId: string;
|
zoneId: string;
|
||||||
zonePoints: [];
|
points: [];
|
||||||
viewPortCenter: [];
|
viewPortCenter: [];
|
||||||
viewPortposition: [];
|
viewPortposition: [];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import templateModel from "../../../shared/model/vizualization/templatemodel.ts"
|
|||||||
import widgetModel from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetModel from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
export const setZone = async (data: any) => {
|
export const setZone = async (data: any) => {
|
||||||
const { organization, userId, zoneData } = data;
|
const { organization, userId, zoneData } = data;
|
||||||
console.log('data:zone ', data);
|
console.log("data service: ", data);
|
||||||
try {
|
try {
|
||||||
const zoneId = zoneData.zoneId;
|
const zoneId = zoneData.zoneId;
|
||||||
const points = zoneData.points;
|
const points = zoneData.points;
|
||||||
@@ -16,6 +16,7 @@ export const setZone = async (data: any) => {
|
|||||||
const viewPortposition = zoneData.viewPortposition;
|
const viewPortposition = zoneData.viewPortposition;
|
||||||
const findZoneId = await zoneModel(organization).findOne({
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (findZoneId) {
|
if (findZoneId) {
|
||||||
const updateZone = await zoneModel(organization)
|
const updateZone = await zoneModel(organization)
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ const lineHandleEvent = async (
|
|||||||
data: any,
|
data: any,
|
||||||
io: any
|
io: any
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization|| typeof data.organization !== 'string') {
|
if (!data?.organization || typeof data.organization !== "string") {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -420,6 +420,7 @@ const zoneHandleEvent = async (
|
|||||||
let result;
|
let result;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVENTS.setZone: {
|
case EVENTS.setZone: {
|
||||||
|
// console.log("create zonedata: ", data);
|
||||||
result = await setZone(data);
|
result = await setZone(data);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -956,8 +957,6 @@ interface UserSocketInfo {
|
|||||||
|
|
||||||
|
|
||||||
export const initSocketServer = (io: Server) => {
|
export const initSocketServer = (io: Server) => {
|
||||||
|
|
||||||
|
|
||||||
const namespaces = {
|
const namespaces = {
|
||||||
Builder: io.of("/Builder"),
|
Builder: io.of("/Builder"),
|
||||||
visualization: io.of("/Visualization"),
|
visualization: io.of("/Visualization"),
|
||||||
@@ -981,7 +980,7 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
namespace.on("connection", async (socket: Socket) => {
|
namespace.on("connection", async (socket: Socket) => {
|
||||||
|
|
||||||
@@ -1071,5 +1070,4 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return io;
|
return io;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user