clear the testing commits
This commit is contained in:
@@ -11,10 +11,8 @@ RUN npm install -g tsx --ignore-scripts
|
|||||||
|
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
COPY package-lock.json ./
|
COPY package-lock.json ./
|
||||||
RUN npm install --ignore-scripts
|
RUN npm install --ignore-scripts && \
|
||||||
|
addgroup -S appgroup && \
|
||||||
|
|
||||||
RUN addgroup -S appgroup && \
|
|
||||||
adduser -S appuser -G appgroup && \
|
adduser -S appuser -G appgroup && \
|
||||||
chown -R appuser:appgroup /usr/src/app
|
chown -R appuser:appgroup /usr/src/app
|
||||||
|
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ router.get("/A_zone/:zoneId/:organization", ZoneService.ZoneData);
|
|||||||
* example: "Internal Server Error"
|
* example: "Internal Server Error"
|
||||||
*/
|
*/
|
||||||
router.patch("/zone/:zoneId", ZoneService.deleteAZone);
|
router.patch("/zone/:zoneId", ZoneService.deleteAZone);
|
||||||
|
router.get("/findZones/:organization", ZoneService.getZones);
|
||||||
|
|
||||||
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export const SignupController = async (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await AuthSignup(req.body);
|
const result = await AuthSignup(req.body);
|
||||||
|
console.log('result: ', result);
|
||||||
|
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
case "User already exists":
|
case "User already exists":
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ export const DeleteZoneController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, userId } = req.user || {};
|
const { organization, userId } = req.user || {};
|
||||||
const { zoneId, projectId } = req.body;
|
const { zoneUuid, projectId } = req.body;
|
||||||
if (!organization || !userId || !zoneId || !projectId) {
|
if (!organization || !userId || !zoneUuid || !projectId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -81,7 +81,7 @@ export const DeleteZoneController = async (
|
|||||||
}
|
}
|
||||||
const result = await DelZone({
|
const result = await DelZone({
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
@@ -226,8 +226,8 @@ export const ZoneDataController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, userId } = req.user || {};
|
const { organization, userId } = req.user || {};
|
||||||
const { projectId, zoneId } = req.params;
|
const { projectId, zoneUuid } = req.params;
|
||||||
if (!organization || !userId || !projectId || !zoneId) {
|
if (!organization || !userId || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -237,7 +237,7 @@ export const ZoneDataController = async (
|
|||||||
organization,
|
organization,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
@@ -277,8 +277,8 @@ export const SingleZonePanelController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, userId } = req.user || {};
|
const { organization, userId } = req.user || {};
|
||||||
const { projectId, zoneId } = req.params;
|
const { projectId, zoneUuid } = req.params;
|
||||||
if (!organization || !userId || !projectId || !zoneId) {
|
if (!organization || !userId || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -288,7 +288,7 @@ export const SingleZonePanelController = async (
|
|||||||
organization,
|
organization,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ export const FloatAddController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { widget, zoneId, index, projectId } = req.body;
|
const { widget, zoneUuid, index, projectId } = req.body;
|
||||||
if (
|
if (
|
||||||
!userId ||
|
!userId ||
|
||||||
!organization ||
|
!organization ||
|
||||||
!widget ||
|
!widget ||
|
||||||
!zoneId ||
|
!zoneUuid ||
|
||||||
!index ||
|
!index ||
|
||||||
!projectId
|
!projectId
|
||||||
) {
|
) {
|
||||||
@@ -31,7 +31,7 @@ export const FloatAddController = async (
|
|||||||
const result = await AddFloat({
|
const result = await AddFloat({
|
||||||
organization,
|
organization,
|
||||||
widget,
|
widget,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
index,
|
index,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
@@ -48,9 +48,9 @@ export const FloatAddController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneUuid",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Widget updated successfully":
|
case "Widget updated successfully":
|
||||||
@@ -87,8 +87,8 @@ export const DeleteFloatController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { floatWidgetID, projectId, zoneId } = req.body;
|
const { floatWidgetID, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !floatWidgetID || !projectId || !zoneId) {
|
if (!userId || !organization || !floatWidgetID || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -97,7 +97,7 @@ export const DeleteFloatController = async (
|
|||||||
const result = await DelFloat({
|
const result = await DelFloat({
|
||||||
organization,
|
organization,
|
||||||
floatWidgetID,
|
floatWidgetID,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
@@ -112,9 +112,9 @@ export const DeleteFloatController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneUuid",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "FloatWidget not found for the Id":
|
case "FloatWidget not found for the Id":
|
||||||
@@ -151,13 +151,13 @@ export const DuplicateFloatController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { widget, projectId, zoneId, index } = req.body;
|
const { widget, projectId, zoneUuid, index } = req.body;
|
||||||
if (
|
if (
|
||||||
!userId ||
|
!userId ||
|
||||||
!organization ||
|
!organization ||
|
||||||
!widget ||
|
!widget ||
|
||||||
!projectId ||
|
!projectId ||
|
||||||
!zoneId ||
|
!zoneUuid ||
|
||||||
!index
|
!index
|
||||||
) {
|
) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
@@ -168,7 +168,7 @@ export const DuplicateFloatController = async (
|
|||||||
const result = await DuplicateFloat({
|
const result = await DuplicateFloat({
|
||||||
organization,
|
organization,
|
||||||
widget,
|
widget,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
index,
|
index,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
@@ -184,9 +184,9 @@ export const DuplicateFloatController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneUuid",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "FloatWidget update unsuccessfull":
|
case "FloatWidget update unsuccessfull":
|
||||||
@@ -228,8 +228,8 @@ export const GetFloatController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { projectId, zoneId } = req.params;
|
const { projectId, zoneUuid } = req.params;
|
||||||
if (!userId || !organization || !projectId || !zoneId) {
|
if (!userId || !organization || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -237,7 +237,7 @@ export const GetFloatController = async (
|
|||||||
}
|
}
|
||||||
const result = await GetFloatWidget({
|
const result = await GetFloatWidget({
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ export const AddPanelController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { panelOrder, zoneId, projectId } = req.body;
|
const { panelOrder, zoneUuid, projectId } = req.body;
|
||||||
if (!userId || !organization || !panelOrder || !zoneId || !projectId) {
|
if (!userId || !organization || !panelOrder || !zoneUuid || !projectId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -23,7 +23,7 @@ export const AddPanelController = async (
|
|||||||
const result = await AddPanel({
|
const result = await AddPanel({
|
||||||
organization,
|
organization,
|
||||||
panelOrder,
|
panelOrder,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
@@ -74,8 +74,8 @@ export const DeletePanelController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { panelName, projectId, zoneId } = req.body;
|
const { panelName, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !panelName || !projectId || !zoneId) {
|
if (!userId || !organization || !panelName || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -84,7 +84,7 @@ export const DeletePanelController = async (
|
|||||||
const result = await DelPanel({
|
const result = await DelPanel({
|
||||||
organization,
|
organization,
|
||||||
panelName,
|
panelName,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
@@ -133,8 +133,8 @@ export const ClearPanelController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { panelName, projectId, zoneId } = req.body;
|
const { panelName, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !panelName || !projectId || !zoneId) {
|
if (!userId || !organization || !panelName || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -143,7 +143,7 @@ export const ClearPanelController = async (
|
|||||||
const result = await ClearPanel({
|
const result = await ClearPanel({
|
||||||
organization,
|
organization,
|
||||||
panelName,
|
panelName,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
@@ -197,8 +197,8 @@ export const LockedPanelController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { projectId, zoneId, lockedPanel } = req.body;
|
const { projectId, zoneUuid, lockedPanel } = req.body;
|
||||||
if (!userId || !organization || !projectId || !zoneId || !lockedPanel) {
|
if (!userId || !organization || !projectId || !zoneUuid || !lockedPanel) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -206,7 +206,7 @@ export const LockedPanelController = async (
|
|||||||
}
|
}
|
||||||
const result = await LockedPanel({
|
const result = await LockedPanel({
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
lockedPanel,
|
lockedPanel,
|
||||||
userId,
|
userId,
|
||||||
projectId,
|
projectId,
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ export const AddTemToZoneController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { templateID, projectId, zoneId } = req.body;
|
const { templateID, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !templateID || !projectId || !zoneId) {
|
if (!userId || !organization || !templateID || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -82,7 +82,7 @@ export const AddTemToZoneController = async (
|
|||||||
const result = await AddTemplateToZone({
|
const result = await AddTemplateToZone({
|
||||||
organization,
|
organization,
|
||||||
templateID,
|
templateID,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ export const AddWidgetController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { widget, projectId, zoneId } = req.body;
|
const { widget, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !widget || !projectId || !zoneId) {
|
if (!userId || !organization || !widget || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -25,7 +25,7 @@ export const AddWidgetController = async (
|
|||||||
widget,
|
widget,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
@@ -39,7 +39,7 @@ export const AddWidgetController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Zone not found",
|
message: "Zone not found",
|
||||||
});
|
});
|
||||||
@@ -88,8 +88,8 @@ export const WidgetDeleteController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { widgetID, projectId, zoneId } = req.body;
|
const { widgetID, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !widgetID || !projectId || !zoneId) {
|
if (!userId || !organization || !widgetID || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -98,7 +98,7 @@ export const WidgetDeleteController = async (
|
|||||||
const result = await WidgetDelete({
|
const result = await WidgetDelete({
|
||||||
organization,
|
organization,
|
||||||
widgetID,
|
widgetID,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
@@ -113,9 +113,9 @@ export const WidgetDeleteController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneUuid",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Widget not found":
|
case "Widget not found":
|
||||||
@@ -147,14 +147,14 @@ export const WidgetUpdateController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { values, projectId, zoneId, widgetID } = req.body;
|
const { values, projectId, zoneUuid, widgetID } = req.body;
|
||||||
if (
|
if (
|
||||||
!userId ||
|
!userId ||
|
||||||
!organization ||
|
!organization ||
|
||||||
!widgetID ||
|
!widgetID ||
|
||||||
!values ||
|
!values ||
|
||||||
!projectId ||
|
!projectId ||
|
||||||
!zoneId
|
!zoneUuid
|
||||||
) {
|
) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
@@ -164,7 +164,7 @@ export const WidgetUpdateController = async (
|
|||||||
const result = await UpdateWidget({
|
const result = await UpdateWidget({
|
||||||
organization,
|
organization,
|
||||||
values,
|
values,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
widgetID,
|
widgetID,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
@@ -180,9 +180,9 @@ export const WidgetUpdateController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneUuid",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Data not found":
|
case "Data not found":
|
||||||
@@ -214,12 +214,12 @@ export const GetWidgetController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { projectId, zoneId, widgetID } = req.query as {
|
const { projectId, zoneUuid, widgetID } = req.query as {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
widgetID: string;
|
widgetID: string;
|
||||||
};
|
};
|
||||||
if (!userId || !organization || !widgetID || !projectId || !zoneId) {
|
if (!userId || !organization || !widgetID || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -227,7 +227,7 @@ export const GetWidgetController = async (
|
|||||||
}
|
}
|
||||||
const result = await GetWidget({
|
const result = await GetWidget({
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
widgetID,
|
widgetID,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
@@ -243,9 +243,9 @@ export const GetWidgetController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneUuid",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Widget not found for the widgetID":
|
case "Widget not found for the widgetID":
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ export const Add3dWidgetController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { widget, projectId, zoneId } = req.body;
|
const { widget, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !widget || !projectId || !zoneId) {
|
if (!userId || !organization || !widget || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -24,7 +24,7 @@ export const Add3dWidgetController = async (
|
|||||||
organization,
|
organization,
|
||||||
widget,
|
widget,
|
||||||
userId,
|
userId,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ export const Add3dWidgetController = async (
|
|||||||
message: "Project not found",
|
message: "Project not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "Zone not found for the zoneId":
|
case "Zone not found for the zoneUuid":
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
message: "Zone not found",
|
message: "Zone not found",
|
||||||
});
|
});
|
||||||
@@ -83,7 +83,7 @@ export const Update3DwidgetController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { id, position, rotation, projectId, zoneId } = req.body;
|
const { id, position, rotation, projectId, zoneUuid } = req.body;
|
||||||
if (
|
if (
|
||||||
!userId ||
|
!userId ||
|
||||||
!organization ||
|
!organization ||
|
||||||
@@ -91,7 +91,7 @@ export const Update3DwidgetController = async (
|
|||||||
!position ||
|
!position ||
|
||||||
!rotation ||
|
!rotation ||
|
||||||
!projectId ||
|
!projectId ||
|
||||||
!zoneId
|
!zoneUuid
|
||||||
) {
|
) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
@@ -104,7 +104,7 @@ export const Update3DwidgetController = async (
|
|||||||
position,
|
position,
|
||||||
rotation,
|
rotation,
|
||||||
userId,
|
userId,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
});
|
});
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
@@ -157,8 +157,8 @@ export const Delete3DwidgetController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { id, projectId, zoneId } = req.body;
|
const { id, projectId, zoneUuid } = req.body;
|
||||||
if (!userId || !organization || !id || !projectId || !zoneId) {
|
if (!userId || !organization || !id || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -168,7 +168,7 @@ export const Delete3DwidgetController = async (
|
|||||||
organization,
|
organization,
|
||||||
id,
|
id,
|
||||||
userId,
|
userId,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
});
|
});
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
@@ -221,7 +221,7 @@ export const Get3DWidgetController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { projectId, zoneId } = req.params;
|
const { projectId, zoneUuid } = req.params;
|
||||||
if (!userId || !organization || !projectId) {
|
if (!userId || !organization || !projectId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
@@ -231,7 +231,7 @@ export const Get3DWidgetController = async (
|
|||||||
const result = await Get3Dwidget({
|
const result = await Get3Dwidget({
|
||||||
organization,
|
organization,
|
||||||
userId,
|
userId,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
});
|
});
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ v1Zone.get(
|
|||||||
);
|
);
|
||||||
|
|
||||||
v1Zone.get(
|
v1Zone.get(
|
||||||
"/zones/:projectId/:zoneId",
|
"/zones/:projectId/:zoneUuid",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
ZoneDataController
|
ZoneDataController
|
||||||
);
|
);
|
||||||
v1Zone.get(
|
v1Zone.get(
|
||||||
"/zones/panel/:projectId/:zoneId",
|
"/zones/panel/:projectId/:zoneUuid",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
SingleZonePanelController
|
SingleZonePanelController
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ v1FloatWidget.patch(
|
|||||||
DeleteFloatController
|
DeleteFloatController
|
||||||
);
|
);
|
||||||
v1FloatWidget.get(
|
v1FloatWidget.get(
|
||||||
"/floatWidgets/:zoneId/:projectId",
|
"/floatWidgets/:zoneUuid/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
GetFloatController
|
GetFloatController
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ v1Widget3d.patch(
|
|||||||
Update3DwidgetController
|
Update3DwidgetController
|
||||||
);
|
);
|
||||||
v1Widget3d.get(
|
v1Widget3d.get(
|
||||||
"/widget3d/data/:zoneId/:projectId",
|
"/widget3d/data/:zoneUuid/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
Get3DWidgetController
|
Get3DWidgetController
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -238,7 +238,25 @@ 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;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import MainModel from "../../connect/mongoose.ts";
|
|||||||
import { User } from "./userAuthModel.ts";
|
import { User } from "./userAuthModel.ts";
|
||||||
export interface UserData extends Document {
|
export interface UserData extends Document {
|
||||||
userId: User["_id"];
|
userId: User["_id"];
|
||||||
isShare: Boolean;
|
isShare: boolean;
|
||||||
activeStatus: string;
|
activeStatus: string;
|
||||||
notificationEnable: boolean;
|
notificationEnable: boolean;
|
||||||
About: string;
|
About: string;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Project } from "../Project/project-model.ts";
|
|||||||
import { Version } from "../Version/versionModel.ts";
|
import { Version } from "../Version/versionModel.ts";
|
||||||
export interface Zone extends Document {
|
export interface Zone extends Document {
|
||||||
zoneName: string;
|
zoneName: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
points: [];
|
points: [];
|
||||||
viewPortCenter: [];
|
viewPortCenter: [];
|
||||||
viewPortposition: [];
|
viewPortposition: [];
|
||||||
@@ -20,7 +20,7 @@ export interface Zone extends Document {
|
|||||||
const zoneSchema: Schema = new Schema(
|
const zoneSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
zoneName: { type: String },
|
zoneName: { type: String },
|
||||||
zoneId: { type: String },
|
zoneUuid: { type: String },
|
||||||
createdBy: { type: Schema.Types.ObjectId, ref: "User" },
|
createdBy: { type: Schema.Types.ObjectId, ref: "User" },
|
||||||
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||||
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
import { Zone } from "../Builder/zoneModel.ts";
|
|
||||||
export interface Widget3d extends Document {
|
export interface Widget3d extends Document {
|
||||||
type: string;
|
type: string;
|
||||||
widgetID: string;
|
widgetID: string;
|
||||||
@@ -8,7 +7,7 @@ export interface Widget3d extends Document {
|
|||||||
position: [];
|
position: [];
|
||||||
rotation: [];
|
rotation: [];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
zoneId: Zone["_id"];
|
zoneUuid:string
|
||||||
Data: {
|
Data: {
|
||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
@@ -21,7 +20,7 @@ const Widget3dSchema: Schema = new Schema(
|
|||||||
widgetName: { type: String, default: "Widget3D" },
|
widgetName: { type: String, default: "Widget3D" },
|
||||||
position: { type: Array },
|
position: { type: Array },
|
||||||
rotation: { type: Array },
|
rotation: { type: Array },
|
||||||
zoneId:{ type: Schema.Types.ObjectId, ref: "Zone" },
|
zoneUuid:{ type: String },
|
||||||
Data: {
|
Data: {
|
||||||
measurements: { type: Object, default: {} },
|
measurements: { type: Object, default: {} },
|
||||||
duration: { type: String, default: "1h" },
|
duration: { type: String, default: "1h" },
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
import { Zone } from "../Builder/zoneModel.ts";
|
|
||||||
export interface FloatingWidget extends Document {
|
export interface FloatingWidget extends Document {
|
||||||
className: string;
|
className: string;
|
||||||
iconName: string;
|
iconName: string;
|
||||||
@@ -10,7 +9,7 @@ export interface FloatingWidget extends Document {
|
|||||||
per: string;
|
per: string;
|
||||||
value: string;
|
value: string;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
zoneId: Zone["_id"];
|
zoneUuid: string
|
||||||
Data: {
|
Data: {
|
||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
@@ -25,7 +24,7 @@ const floatingWidgetSchema: Schema = new Schema(
|
|||||||
position: { type: Object },
|
position: { type: Object },
|
||||||
per: { type: String },
|
per: { type: String },
|
||||||
value: { type: String },
|
value: { type: String },
|
||||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
zoneUuid: { type: String },
|
||||||
Data: {
|
Data: {
|
||||||
measurements: { type: Object, default: {} },
|
measurements: { type: Object, default: {} },
|
||||||
duration: { type: String, default: "1h" },
|
duration: { type: String, default: "1h" },
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import mongoose, { Schema, Document } from "mongoose";
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
import { Zone } from "../Builder/zoneModel.ts";
|
|
||||||
export interface Panel extends Document {
|
export interface Panel extends Document {
|
||||||
zoneId: Zone["_id"];
|
zoneUuid: string
|
||||||
panelName: string;
|
panelName: string;
|
||||||
widgets: [mongoose.Types.ObjectId];
|
widgets: [mongoose.Types.ObjectId];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
}
|
}
|
||||||
const panelSchema: Schema = new Schema(
|
const panelSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
zoneUuid: { type: String },
|
||||||
panelName: { type: String },
|
panelName: { type: String },
|
||||||
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import mongoose, { Schema, Document } from "mongoose";
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
import { Zone } from "../Builder/zoneModel.ts";
|
|
||||||
export interface Widget extends Document {
|
export interface Widget extends Document {
|
||||||
widgetName: string;
|
widgetName: string;
|
||||||
widgetside: string;
|
widgetside: string;
|
||||||
@@ -17,7 +16,7 @@ export interface Widget extends Document {
|
|||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
zoneId: Zone["_id"];
|
zoneUuid: string
|
||||||
}
|
}
|
||||||
const widgetSchema: Schema = new Schema(
|
const widgetSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
@@ -36,7 +35,7 @@ const widgetSchema: Schema = new Schema(
|
|||||||
fontWeight: { type: String },
|
fontWeight: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
zoneUuid: { type: String }
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ interface ISetZone {
|
|||||||
organization: string;
|
organization: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneData: {
|
zoneData: {
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
points: [];
|
points: [];
|
||||||
zoneName: string;
|
zoneName: string;
|
||||||
layer: number;
|
layer: number;
|
||||||
@@ -21,7 +21,7 @@ interface ISetZone {
|
|||||||
interface IZone {
|
interface IZone {
|
||||||
organization: string;
|
organization: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
interface IVizZone {
|
interface IVizZone {
|
||||||
@@ -42,7 +42,7 @@ interface IGetZones {
|
|||||||
export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, projectId, zoneData, userId } = data;
|
const { organization, projectId, zoneData, userId } = data;
|
||||||
const zoneId = zoneData.zoneId;
|
const zoneUuid = zoneData.zoneUuid;
|
||||||
const points = zoneData.points;
|
const points = zoneData.points;
|
||||||
const zoneName = zoneData.zoneName;
|
const zoneName = zoneData.zoneName;
|
||||||
const layer = zoneData.layer;
|
const layer = zoneData.layer;
|
||||||
@@ -58,12 +58,12 @@ export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
|||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const findZoneId = await zoneModel(organization).findOne({
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
});
|
});
|
||||||
if (findZoneId) {
|
if (findZoneId) {
|
||||||
const updateZone = await zoneModel(organization)
|
const updateZone = await zoneModel(organization)
|
||||||
.findOneAndUpdate(
|
.findOneAndUpdate(
|
||||||
{ zoneId: zoneId, projectId: projectId, isArchive: false },
|
{ zoneUuid: zoneUuid, projectId: projectId, isArchive: false },
|
||||||
{
|
{
|
||||||
points: points,
|
points: points,
|
||||||
viewPortposition: viewPortposition,
|
viewPortposition: viewPortposition,
|
||||||
@@ -75,7 +75,7 @@ export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
|||||||
return { status: "zone updated", data: updateZone };
|
return { status: "zone updated", data: updateZone };
|
||||||
} else {
|
} else {
|
||||||
const zoneCreate = await zoneModel(organization).create({
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
zoneId,
|
zoneUuid,
|
||||||
createdBy: userId,
|
createdBy: userId,
|
||||||
projectId,
|
projectId,
|
||||||
zoneName: zoneName,
|
zoneName: zoneName,
|
||||||
@@ -103,9 +103,9 @@ export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const DelZone = async (data: IZone): Promise<IResult> => {
|
export const DelZone = async (data: IZone): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, zoneId, projectId } = data;
|
const { organization, userId, zoneUuid, projectId } = data;
|
||||||
const findZoneId = await zoneModel(organization).findOne({
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
@@ -120,7 +120,7 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
|
|||||||
if (findZoneId) {
|
if (findZoneId) {
|
||||||
const deleteZone = await zoneModel(organization)
|
const deleteZone = await zoneModel(organization)
|
||||||
.findOneAndUpdate({
|
.findOneAndUpdate({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
createdBy: userId,
|
createdBy: userId,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -128,7 +128,7 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
|
|||||||
.select("-_id -__v");
|
.select("-_id -__v");
|
||||||
if (deleteZone) {
|
if (deleteZone) {
|
||||||
const panels = await panelModel(organization).find({
|
const panels = await panelModel(organization).find({
|
||||||
zoneId,
|
zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,21 +142,21 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await panelModel(organization).updateMany(
|
await panelModel(organization).updateMany(
|
||||||
{ zoneId, isArchive: false },
|
{ zoneUuid, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
widget3dModel(organization).updateMany(
|
widget3dModel(organization).updateMany(
|
||||||
{ zoneId, isArchive: false },
|
{ zoneUuid, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
),
|
),
|
||||||
templateModel(organization).updateMany(
|
templateModel(organization).updateMany(
|
||||||
{ zoneId, isArchive: false },
|
{ zoneUuid, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
),
|
),
|
||||||
floatWidgetModel(organization).updateMany(
|
floatWidgetModel(organization).updateMany(
|
||||||
{ zoneId, isArchive: false },
|
{ zoneUuid, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@@ -191,7 +191,7 @@ export const GetZones = async (data: IGetZones): Promise<IResult> => {
|
|||||||
const findZoneId = await zoneModel(organization)
|
const findZoneId = await zoneModel(organization)
|
||||||
.find({ projectId: projectId, isArchive: false })
|
.find({ projectId: projectId, isArchive: false })
|
||||||
.select(
|
.select(
|
||||||
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
"zoneUuid zoneName layer points viewPortCenter viewPortposition -_id"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!findZoneId) {
|
if (!findZoneId) {
|
||||||
@@ -212,7 +212,7 @@ export const GetZones = async (data: IGetZones): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const ZoneData = async (data: IZone): Promise<IResult> => {
|
export const ZoneData = async (data: IZone): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, projectId, zoneId } = data;
|
const { organization, userId, projectId, zoneUuid } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -222,7 +222,7 @@ export const ZoneData = async (data: IZone): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const findZone = await zoneModel(organization).findOne({
|
const findZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
@@ -248,7 +248,7 @@ export const ZoneData = async (data: IZone): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, projectId, zoneId } = data;
|
const { organization, userId, projectId, zoneUuid } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -260,17 +260,17 @@ export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
|||||||
const existingZone = await zoneModel(organization)
|
const existingZone = await zoneModel(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select(
|
.select(
|
||||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition points"
|
"panelOrder zoneName zonePoints lockedPanel zoneUuid viewPortCenter viewPortposition points"
|
||||||
);
|
);
|
||||||
if (!existingZone) {
|
if (!existingZone) {
|
||||||
return { status: "Zone not found for the UUID" };
|
return { status: "Zone not found for the UUID" };
|
||||||
} else {
|
} else {
|
||||||
const panelData = await panelModel(organization).find({
|
const panelData = await panelModel(organization).find({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
const zoneName = existingZone.zoneName as string;
|
const zoneName = existingZone.zoneName as string;
|
||||||
@@ -297,7 +297,7 @@ export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
|||||||
const objectData = {
|
const objectData = {
|
||||||
zoneName,
|
zoneName,
|
||||||
viewPortposition: existingZone.viewPortposition,
|
viewPortposition: existingZone.viewPortposition,
|
||||||
zoneId: existingZone.zoneId,
|
zoneUuid: existingZone.zoneUuid,
|
||||||
viewPortCenter: existingZone.viewPortCenter,
|
viewPortCenter: existingZone.viewPortCenter,
|
||||||
activeSides: existingZone.panelOrder || [],
|
activeSides: existingZone.panelOrder || [],
|
||||||
panelOrder: existingZone.panelOrder || [],
|
panelOrder: existingZone.panelOrder || [],
|
||||||
@@ -337,7 +337,7 @@ export const VizZoneDatas = async (data: IVizZone): Promise<IResult> => {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select(
|
.select(
|
||||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition points"
|
"panelOrder zoneName zonePoints lockedPanel zoneUuid viewPortCenter viewPortposition points"
|
||||||
);
|
);
|
||||||
if (!existingZones) {
|
if (!existingZones) {
|
||||||
return { status: "Zone not found for the UUID" };
|
return { status: "Zone not found for the UUID" };
|
||||||
@@ -345,7 +345,7 @@ export const VizZoneDatas = async (data: IVizZone): Promise<IResult> => {
|
|||||||
const response = await Promise.all(
|
const response = await Promise.all(
|
||||||
existingZones.map(async (zone) => {
|
existingZones.map(async (zone) => {
|
||||||
const panelData = await panelModel(organization).find({
|
const panelData = await panelModel(organization).find({
|
||||||
zoneId: zone._id,
|
zoneUuid: zone._id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ export const VizZoneDatas = async (data: IVizZone): Promise<IResult> => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
zoneName: zone.zoneName,
|
zoneName: zone.zoneName,
|
||||||
zoneId: zone.zoneId,
|
zoneUuid: zone.zoneUuid,
|
||||||
viewPortposition: zone.viewPortposition,
|
viewPortposition: zone.viewPortposition,
|
||||||
viewPortCenter: zone.viewPortCenter,
|
viewPortCenter: zone.viewPortCenter,
|
||||||
activeSides: zone.panelOrder || [],
|
activeSides: zone.panelOrder || [],
|
||||||
|
|||||||
@@ -22,20 +22,20 @@ interface IAddFloatData {
|
|||||||
per: string;
|
per: string;
|
||||||
value: string;
|
value: string;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
Data: {
|
Data: {
|
||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
index: number;
|
index: number;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
interface IDelFloat {
|
interface IDelFloat {
|
||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
floatWidgetID: string;
|
floatWidgetID: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ interface ISingleFloat {
|
|||||||
interface IGetZoneFloat {
|
interface IGetZoneFloat {
|
||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
interface IDuplicateFloatData {
|
interface IDuplicateFloatData {
|
||||||
@@ -63,19 +63,19 @@ interface IDuplicateFloatData {
|
|||||||
per: string;
|
per: string;
|
||||||
value: string;
|
value: string;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
Data: {
|
Data: {
|
||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
index: number;
|
index: number;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, widget, zoneId, index, projectId, userId } = data;
|
const { organization, widget, zoneUuid, index, projectId, userId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -85,16 +85,16 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
const updateFloatWidget = await floatWidgetModel(
|
||||||
@@ -122,7 +122,7 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
|||||||
const floatUpdateDatas = {
|
const floatUpdateDatas = {
|
||||||
position: updateFloatWidget.position,
|
position: updateFloatWidget.position,
|
||||||
index: index,
|
index: index,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return { status: "Widget updated successfully", data: floatUpdateDatas };
|
return { status: "Widget updated successfully", data: floatUpdateDatas };
|
||||||
@@ -135,7 +135,7 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
|||||||
position: widget.position,
|
position: widget.position,
|
||||||
per: widget.per,
|
per: widget.per,
|
||||||
value: widget.value,
|
value: widget.value,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
});
|
});
|
||||||
if (newFloadWidget) {
|
if (newFloadWidget) {
|
||||||
const floatDatas = {
|
const floatDatas = {
|
||||||
@@ -147,7 +147,7 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
|||||||
className: newFloadWidget.className,
|
className: newFloadWidget.className,
|
||||||
id: newFloadWidget.floatWidgetID,
|
id: newFloadWidget.floatWidgetID,
|
||||||
},
|
},
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return { status: "Success", data: floatDatas };
|
return { status: "Success", data: floatDatas };
|
||||||
@@ -169,7 +169,7 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
|||||||
|
|
||||||
export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
|
export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, floatWidgetID, zoneId, projectId, userId } = data;
|
const { organization, floatWidgetID, zoneUuid, projectId, userId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) { return { status: "User not found" } }
|
if (!UserExists) { return { status: "User not found" } }
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -179,11 +179,11 @@ export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) { return { status: "Project not found" } }
|
if (!LivingProject) { return { status: "Project not found" } }
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const findfloatWidget = await floatWidgetModel(organization).findOne({
|
const findfloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: floatWidgetID,
|
floatWidgetID: floatWidgetID,
|
||||||
@@ -199,7 +199,7 @@ export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
|
|||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
const floatDeleteData = {
|
const floatDeleteData = {
|
||||||
floatWidgetID: findfloatWidget.floatWidgetID,
|
floatWidgetID: findfloatWidget.floatWidgetID,
|
||||||
zoneId: findfloatWidget.zoneId,
|
zoneUuid: findfloatWidget.zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return { status: "Success", data: floatDeleteData };
|
return { status: "Success", data: floatDeleteData };
|
||||||
@@ -222,7 +222,7 @@ export const DuplicateFloat = async (
|
|||||||
data: IDuplicateFloatData
|
data: IDuplicateFloatData
|
||||||
): Promise<IResult> => {
|
): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, widget, zoneId, index, projectId, userId } = data;
|
const { organization, widget, zoneUuid, index, projectId, userId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) {return { status: "User not found" }};
|
if (!UserExists) {return { status: "User not found" }};
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -232,16 +232,16 @@ export const DuplicateFloat = async (
|
|||||||
);
|
);
|
||||||
if (!LivingProject) {return { status: "Project not found" }};
|
if (!LivingProject) {return { status: "Project not found" }};
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
const updateFloatWidget = await floatWidgetModel(
|
||||||
@@ -272,7 +272,7 @@ export const DuplicateFloat = async (
|
|||||||
const floatUpdateDatas = {
|
const floatUpdateDatas = {
|
||||||
position: updateFloatWidget.position,
|
position: updateFloatWidget.position,
|
||||||
index: index,
|
index: index,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -287,7 +287,7 @@ export const DuplicateFloat = async (
|
|||||||
position: widget.position,
|
position: widget.position,
|
||||||
per: widget.per,
|
per: widget.per,
|
||||||
value: widget.value,
|
value: widget.value,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements,
|
measurements: widget?.Data?.measurements,
|
||||||
duration: widget?.Data?.duration,
|
duration: widget?.Data?.duration,
|
||||||
@@ -303,7 +303,7 @@ export const DuplicateFloat = async (
|
|||||||
className: newFloadWidget.className,
|
className: newFloadWidget.className,
|
||||||
id: newFloadWidget.floatWidgetID,
|
id: newFloadWidget.floatWidgetID,
|
||||||
},
|
},
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
index: index,
|
index: index,
|
||||||
};
|
};
|
||||||
@@ -330,7 +330,7 @@ export const DuplicateFloat = async (
|
|||||||
|
|
||||||
export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, zoneId, projectId, userId } = data;
|
const { organization, zoneUuid, projectId, userId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) {return { status: "User not found" }}
|
if (!UserExists) {return { status: "User not found" }}
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -340,17 +340,17 @@ export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) {return { status: "Project not found" }};
|
if (!LivingProject) {return { status: "Project not found" }};
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found" };
|
if (!existingZone) return { status: "Zone not found" };
|
||||||
const widgetData = await floatWidgetModel(organization)
|
const widgetData = await floatWidgetModel(organization)
|
||||||
.find({
|
.find({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
.select("-_id -zoneUuid -createdAt -updatedAt -__v");
|
||||||
if (!widgetData || widgetData.length === 0) {
|
if (!widgetData || widgetData.length === 0) {
|
||||||
return { status: "All Datas" };
|
return { status: "All Datas" };
|
||||||
}
|
}
|
||||||
@@ -394,7 +394,7 @@ export const SingleFloatWidget = async (
|
|||||||
floatWidgetID: floatWidgetID,
|
floatWidgetID: floatWidgetID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
.select("-_id -zoneUuid -createdAt -updatedAt -__v");
|
||||||
if (!widgetData || widgetData.length === 0) {
|
if (!widgetData || widgetData.length === 0) {
|
||||||
return { status: "Widget not found" };
|
return { status: "Widget not found" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,28 +11,28 @@ interface IResult {
|
|||||||
}
|
}
|
||||||
interface IAddPanel {
|
interface IAddPanel {
|
||||||
organization: string;
|
organization: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
panelOrder: string[];
|
panelOrder: string[];
|
||||||
userId: string;
|
userId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
interface IPanel {
|
interface IPanel {
|
||||||
organization: string;
|
organization: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
panelName: string;
|
panelName: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
interface ILockedPanel {
|
interface ILockedPanel {
|
||||||
organization: string;
|
organization: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
lockedPanel: string[];
|
lockedPanel: string[];
|
||||||
userId: string;
|
userId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, zoneId, panelOrder, userId, projectId } = data;
|
const { organization, zoneUuid, panelOrder, userId, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -42,18 +42,18 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found" };
|
if (!existingZone) return { status: "Zone not found" };
|
||||||
await zoneModel(organization).findOneAndUpdate(
|
await zoneModel(organization).findOneAndUpdate(
|
||||||
{ zoneId: zoneId, isArchive: false },
|
{ zoneUuid: zoneUuid, isArchive: false },
|
||||||
{ panelOrder: panelOrder },
|
{ panelOrder: panelOrder },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
const existingPanels = await panelModel(organization).find({
|
const existingPanels = await panelModel(organization).find({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
|||||||
const createdPanels = [];
|
const createdPanels = [];
|
||||||
for (const panelName of missingPanels) {
|
for (const panelName of missingPanels) {
|
||||||
const newPanel = await panelModel(organization).create({
|
const newPanel = await panelModel(organization).create({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
panelName: panelName,
|
panelName: panelName,
|
||||||
widgets: [],
|
widgets: [],
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -82,7 +82,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
|||||||
|
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(
|
const zoneAndPanelData = await getZoneAndPanelData(
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId
|
projectId
|
||||||
);
|
);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
@@ -103,7 +103,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, zoneId, panelName, userId, projectId } = data;
|
const { organization, zoneUuid, panelName, userId, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -113,13 +113,13 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found" };
|
if (!existingZone) return { status: "Zone not found" };
|
||||||
const existingPanel = await panelModel(organization).findOne({
|
const existingPanel = await panelModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
panelName: panelName,
|
panelName: panelName,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
@@ -147,7 +147,7 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
|||||||
}
|
}
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(
|
const zoneAndPanelData = await getZoneAndPanelData(
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId
|
projectId
|
||||||
);
|
);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
@@ -168,7 +168,7 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, zoneId, panelName, userId, projectId } = data;
|
const { organization, zoneUuid, panelName, userId, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -178,13 +178,13 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found" };
|
if (!existingZone) return { status: "Zone not found" };
|
||||||
const existingPanel = await panelModel(organization).findOne({
|
const existingPanel = await panelModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
panelName: panelName,
|
panelName: panelName,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
@@ -212,7 +212,7 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
|||||||
|
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(
|
const zoneAndPanelData = await getZoneAndPanelData(
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId
|
projectId
|
||||||
);
|
);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
@@ -237,7 +237,7 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, zoneId, lockedPanel, userId, projectId } = data;
|
const { organization, zoneUuid, lockedPanel, userId, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -247,14 +247,14 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found" };
|
if (!existingZone) return { status: "Zone not found" };
|
||||||
else {
|
else {
|
||||||
const updateLockedPanel = await zoneModel(organization).findOneAndUpdate(
|
const updateLockedPanel = await zoneModel(organization).findOneAndUpdate(
|
||||||
{ zoneId: zoneId, isArchive: false },
|
{ zoneUuid: zoneUuid, isArchive: false },
|
||||||
{
|
{
|
||||||
lockedPanel: lockedPanel,
|
lockedPanel: lockedPanel,
|
||||||
},
|
},
|
||||||
@@ -262,7 +262,7 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
const zoneAndPanelData = await getZoneAndPanelData(
|
const zoneAndPanelData = await getZoneAndPanelData(
|
||||||
organization,
|
organization,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
projectId
|
projectId
|
||||||
);
|
);
|
||||||
if (!zoneAndPanelData) {
|
if (!zoneAndPanelData) {
|
||||||
@@ -290,7 +290,7 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
const getZoneAndPanelData = async (
|
const getZoneAndPanelData = async (
|
||||||
organization: string,
|
organization: string,
|
||||||
zoneId: string,
|
zoneUuid: string,
|
||||||
projectId: string
|
projectId: string
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
@@ -298,18 +298,18 @@ const getZoneAndPanelData = async (
|
|||||||
|
|
||||||
const existingZone = await zoneModel(organization)
|
const existingZone = await zoneModel(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
})
|
})
|
||||||
.select(
|
.select(
|
||||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition"
|
"panelOrder zoneName zonePoints lockedPanel zoneUuid viewPortCenter viewPortposition"
|
||||||
);
|
);
|
||||||
if (!existingZone) {
|
if (!existingZone) {
|
||||||
return { status: "Zone not found" };
|
return { status: "Zone not found" };
|
||||||
} else {
|
} else {
|
||||||
const panelData = await panelModel(organization).find({
|
const panelData = await panelModel(organization).find({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
const zoneName = existingZone.zoneName as string;
|
const zoneName = existingZone.zoneName as string;
|
||||||
@@ -336,7 +336,7 @@ const getZoneAndPanelData = async (
|
|||||||
const objectData = {
|
const objectData = {
|
||||||
zoneName,
|
zoneName,
|
||||||
viewPortposition: existingZone.viewPortposition,
|
viewPortposition: existingZone.viewPortposition,
|
||||||
zoneId: existingZone.zoneId,
|
zoneUuid: existingZone.zoneUuid,
|
||||||
viewPortCenter: existingZone.viewPortCenter,
|
viewPortCenter: existingZone.viewPortCenter,
|
||||||
activeSides: existingZone.panelOrder || [],
|
activeSides: existingZone.panelOrder || [],
|
||||||
panelOrder: existingZone.panelOrder || [],
|
panelOrder: existingZone.panelOrder || [],
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ interface ITemplateToZone {
|
|||||||
organization: string;
|
organization: string;
|
||||||
templateID: string;
|
templateID: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
interface ITemplate {
|
interface ITemplate {
|
||||||
@@ -102,7 +102,7 @@ export const AddTemplateToZone = async (
|
|||||||
data: ITemplateToZone
|
data: ITemplateToZone
|
||||||
): Promise<IResult> => {
|
): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, templateID, projectId, zoneId, userId } = data;
|
const { organization, templateID, projectId, zoneUuid, userId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -112,7 +112,7 @@ export const AddTemplateToZone = async (
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
@@ -135,7 +135,7 @@ export const AddTemplateToZone = async (
|
|||||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||||
await existingZone.save();
|
await existingZone.save();
|
||||||
const archivePanelDatas = await panelModel(organization).find({
|
const archivePanelDatas = await panelModel(organization).find({
|
||||||
zoneId,
|
zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
for (const panelData of archivePanelDatas) {
|
for (const panelData of archivePanelDatas) {
|
||||||
@@ -145,18 +145,18 @@ export const AddTemplateToZone = async (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
await panelModel(organization).deleteMany({
|
await panelModel(organization).deleteMany({
|
||||||
zoneId,
|
zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
await floatWidgetModel(organization).deleteMany({
|
await floatWidgetModel(organization).deleteMany({
|
||||||
zoneId,
|
zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||||
await existingZone.save();
|
await existingZone.save();
|
||||||
const existingPanels = await panelModel(organization).find({
|
const existingPanels = await panelModel(organization).find({
|
||||||
zoneId,
|
zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
const existingPanelNames = existingPanels.map(
|
const existingPanelNames = existingPanels.map(
|
||||||
@@ -169,7 +169,7 @@ export const AddTemplateToZone = async (
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
missingPanels.map((panelName: any) =>
|
missingPanels.map((panelName: any) =>
|
||||||
panelModel(organization).create({
|
panelModel(organization).create({
|
||||||
zoneId,
|
zoneUuid,
|
||||||
panelName,
|
panelName,
|
||||||
widgets: [],
|
widgets: [],
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -180,7 +180,7 @@ export const AddTemplateToZone = async (
|
|||||||
for (const widgetData of existingTemplate.widgets) {
|
for (const widgetData of existingTemplate.widgets) {
|
||||||
const addedExistingPanel = await panelModel(organization).findOne({
|
const addedExistingPanel = await panelModel(organization).findOne({
|
||||||
panelName: widgetData.panel,
|
panelName: widgetData.panel,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!addedExistingPanel) continue;
|
if (!addedExistingPanel) continue;
|
||||||
@@ -195,7 +195,7 @@ export const AddTemplateToZone = async (
|
|||||||
const newWidget = await widgetModel(organization).create({
|
const newWidget = await widgetModel(organization).create({
|
||||||
widgetID: widgetData.id,
|
widgetID: widgetData.id,
|
||||||
elementType: widgetData.type,
|
elementType: widgetData.type,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
widgetName: widgetData.widgetName || "Widget",
|
widgetName: widgetData.widgetName || "Widget",
|
||||||
panelID: addedExistingPanel._id,
|
panelID: addedExistingPanel._id,
|
||||||
widgetside: widgetData.panel,
|
widgetside: widgetData.panel,
|
||||||
@@ -208,7 +208,7 @@ export const AddTemplateToZone = async (
|
|||||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: floatData.id,
|
floatWidgetID: floatData.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) continue;
|
if (existingFloatWidget) continue;
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ export const AddTemplateToZone = async (
|
|||||||
position: floatData.position,
|
position: floatData.position,
|
||||||
per: floatData.per,
|
per: floatData.per,
|
||||||
value: floatData.value,
|
value: floatData.value,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const templateZoneDatas = {
|
const templateZoneDatas = {
|
||||||
@@ -231,7 +231,7 @@ export const AddTemplateToZone = async (
|
|||||||
snapshot: existingTemplate.snapshot,
|
snapshot: existingTemplate.snapshot,
|
||||||
floatingWidget: existingTemplate.floatWidgets,
|
floatingWidget: existingTemplate.floatWidgets,
|
||||||
},
|
},
|
||||||
zoneId: existingZone.zoneId,
|
zoneUuid: existingZone.zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ interface IWidget3DAdd {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
interface IWidget3dUpdate {
|
interface IWidget3dUpdate {
|
||||||
organization: string;
|
organization: string;
|
||||||
id: string;
|
id: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
interface IWidgetUpdate {
|
interface IWidgetUpdate {
|
||||||
@@ -36,18 +36,18 @@ interface IWidgetUpdate {
|
|||||||
position: [];
|
position: [];
|
||||||
rotation: [];
|
rotation: [];
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
interface I3dWidgetGet {
|
interface I3dWidgetGet {
|
||||||
organization: string;
|
organization: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, widget, userId, zoneId, projectId } = data;
|
const { organization, widget, userId, zoneUuid, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -57,11 +57,11 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
@@ -71,7 +71,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
|||||||
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{ position: widget.position },
|
{ position: widget.position },
|
||||||
@@ -87,7 +87,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
|||||||
type: widget.type,
|
type: widget.type,
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
zoneId,
|
zoneUuid,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements || {},
|
measurements: widget?.Data?.measurements || {},
|
||||||
duration: widget?.Data?.duration || "1h",
|
duration: widget?.Data?.duration || "1h",
|
||||||
@@ -101,7 +101,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
|||||||
position: newWidget3d.position,
|
position: newWidget3d.position,
|
||||||
},
|
},
|
||||||
Data: newWidget3d.Data,
|
Data: newWidget3d.Data,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -125,7 +125,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, id, position, rotation, userId, zoneId, projectId } =
|
const { organization, id, position, rotation, userId, zoneUuid, projectId } =
|
||||||
data;
|
data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
@@ -137,7 +137,7 @@ export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
@@ -148,14 +148,14 @@ export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
|||||||
|
|
||||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existing3Dwidget) {
|
if (existing3Dwidget) {
|
||||||
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{ position: position, rotation: rotation },
|
{ position: position, rotation: rotation },
|
||||||
@@ -169,7 +169,7 @@ export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
|||||||
position: update3dwidget.position,
|
position: update3dwidget.position,
|
||||||
rotation: update3dwidget.rotation,
|
rotation: update3dwidget.rotation,
|
||||||
},
|
},
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
@@ -196,7 +196,7 @@ export const Delete3Dwidget = async (
|
|||||||
data: IWidget3dUpdate
|
data: IWidget3dUpdate
|
||||||
): Promise<IResult> => {
|
): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, id, userId, zoneId, projectId } = data;
|
const { organization, id, userId, zoneUuid, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -206,7 +206,7 @@ export const Delete3Dwidget = async (
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
@@ -218,7 +218,7 @@ export const Delete3Dwidget = async (
|
|||||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
});
|
});
|
||||||
if (!existing3Dwidget) {
|
if (!existing3Dwidget) {
|
||||||
return { status: "3D widget not found for the ID" };
|
return { status: "3D widget not found for the ID" };
|
||||||
@@ -226,7 +226,7 @@ export const Delete3Dwidget = async (
|
|||||||
const updateWidget = await widget3dModel(organization).findOneAndUpdate(
|
const updateWidget = await widget3dModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{ isArchive: true },
|
{ isArchive: true },
|
||||||
@@ -234,7 +234,7 @@ export const Delete3Dwidget = async (
|
|||||||
);
|
);
|
||||||
if (updateWidget) {
|
if (updateWidget) {
|
||||||
const delete_Datas = {
|
const delete_Datas = {
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
id: existing3Dwidget.widgetID,
|
id: existing3Dwidget.widgetID,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -257,7 +257,7 @@ export const Delete3Dwidget = async (
|
|||||||
};
|
};
|
||||||
export const Get3Dwidget = async (data: I3dWidgetGet): Promise<IResult> => {
|
export const Get3Dwidget = async (data: I3dWidgetGet): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, zoneId, projectId } = data;
|
const { organization, userId, zoneUuid, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -267,7 +267,7 @@ export const Get3Dwidget = async (data: I3dWidgetGet): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
@@ -276,7 +276,7 @@ export const Get3Dwidget = async (data: I3dWidgetGet): Promise<IResult> => {
|
|||||||
status: "Zone not found",
|
status: "Zone not found",
|
||||||
};
|
};
|
||||||
const widgetData = await widget3dModel(organization).find({
|
const widgetData = await widget3dModel(organization).find({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!widgetData || widgetData.length === 0) {
|
if (!widgetData || widgetData.length === 0) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ interface IResult {
|
|||||||
interface IWidgetCreate {
|
interface IWidgetCreate {
|
||||||
organization: string;
|
organization: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
widget: {
|
widget: {
|
||||||
type: string;
|
type: string;
|
||||||
@@ -28,14 +28,14 @@ interface IWidgetCreate {
|
|||||||
interface IWidgetDelete {
|
interface IWidgetDelete {
|
||||||
organization: string;
|
organization: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
widgetID: string;
|
widgetID: string;
|
||||||
}
|
}
|
||||||
interface IWidgetUpdate {
|
interface IWidgetUpdate {
|
||||||
organization: string;
|
organization: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
widgetID: string;
|
widgetID: string;
|
||||||
values: {
|
values: {
|
||||||
@@ -55,13 +55,13 @@ interface IWidgetUpdate {
|
|||||||
interface IGetWidget {
|
interface IGetWidget {
|
||||||
organization: string;
|
organization: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
widgetID: string;
|
widgetID: string;
|
||||||
}
|
}
|
||||||
export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, widget, userId, zoneId, projectId } = data;
|
const { organization, widget, userId, zoneUuid, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -71,15 +71,15 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const existingPanel = await panelModel(organization).findOne({
|
const existingPanel = await panelModel(organization).findOne({
|
||||||
panelName: widget.panel,
|
panelName: widget.panel,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingPanel) return { status: "panelName not found" };
|
if (!existingPanel) return { status: "panelName not found" };
|
||||||
@@ -121,7 +121,7 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
|||||||
widgetName: widget.title,
|
widgetName: widget.title,
|
||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
widgetside: widget.panel,
|
widgetside: widget.panel,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements || {},
|
measurements: widget?.Data?.measurements || {},
|
||||||
duration: widget?.Data?.duration || "1hr",
|
duration: widget?.Data?.duration || "1hr",
|
||||||
@@ -138,7 +138,7 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
const finaldata = {
|
const finaldata = {
|
||||||
widgetData: widgetData,
|
widgetData: widgetData,
|
||||||
zoneId: existingZone.zoneId,
|
zoneUuid: existingZone.zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -164,7 +164,7 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, widgetID, userId, zoneId, projectId } = data;
|
const { organization, widgetID, userId, zoneUuid, projectId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -174,35 +174,35 @@ export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const findWidget = await widgetModel(organization).findOne({
|
const findWidget = await widgetModel(organization).findOne({
|
||||||
widgetID: widgetID,
|
widgetID: widgetID,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findWidget) return { status: "Widget not found" };
|
if (!findWidget) return { status: "Widget not found" };
|
||||||
|
|
||||||
const widgetData = await widgetModel(organization).updateOne(
|
const widgetData = await widgetModel(organization).updateOne(
|
||||||
{ _id: findWidget._id, isArchive: false, zoneId: zoneId },
|
{ _id: findWidget._id, isArchive: false, zoneUuid: zoneUuid },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
await widgetModel(organization).find({
|
await widgetModel(organization).find({
|
||||||
panelID: findWidget.panelID,
|
panelID: findWidget.panelID,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const panelData = await panelModel(organization).findOne({
|
const panelData = await panelModel(organization).findOne({
|
||||||
_id: findWidget.panelID,
|
_id: findWidget.panelID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
});
|
});
|
||||||
if (panelData.widgets.includes(findWidget._id)) {
|
if (panelData.widgets.includes(findWidget._id)) {
|
||||||
const index1 = panelData.widgets.indexOf(findWidget._id);
|
const index1 = panelData.widgets.indexOf(findWidget._id);
|
||||||
@@ -211,7 +211,7 @@ export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
|||||||
await panelData.save();
|
await panelData.save();
|
||||||
|
|
||||||
const activeWidgets = await widgetModel(organization).find({
|
const activeWidgets = await widgetModel(organization).find({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
|||||||
}));
|
}));
|
||||||
const widgetData1 = {
|
const widgetData1 = {
|
||||||
widgetDeleteDatas: formattedWidgets,
|
widgetDeleteDatas: formattedWidgets,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return { status: "Success", data: widgetData1 };
|
return { status: "Success", data: widgetData1 };
|
||||||
@@ -247,7 +247,7 @@ export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const UpdateWidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
export const UpdateWidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, widgetID, userId, projectId, zoneId, values } = data;
|
const { organization, widgetID, userId, projectId, zoneUuid, values } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -257,15 +257,15 @@ export const UpdateWidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const findWidget = await widgetModel(organization).findOne({
|
const findWidget = await widgetModel(organization).findOne({
|
||||||
widgetID: widgetID,
|
widgetID: widgetID,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findWidget) return { status: "Data not found" };
|
if (!findWidget) return { status: "Data not found" };
|
||||||
@@ -311,7 +311,7 @@ export const UpdateWidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
|||||||
};
|
};
|
||||||
export const GetWidget = async (data: IGetWidget): Promise<IResult> => {
|
export const GetWidget = async (data: IGetWidget): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, widgetID, userId, projectId, zoneId } = data;
|
const { organization, widgetID, userId, projectId, zoneUuid } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) return { status: "User not found" };
|
||||||
const LivingProject = await existingProjectById(
|
const LivingProject = await existingProjectById(
|
||||||
@@ -321,16 +321,16 @@ export const GetWidget = async (data: IGetWidget): Promise<IResult> => {
|
|||||||
);
|
);
|
||||||
if (!LivingProject) return { status: "Project not found" };
|
if (!LivingProject) return { status: "Project not found" };
|
||||||
const existingZone = await zoneModel(organization).findOne({
|
const existingZone = await zoneModel(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
});
|
});
|
||||||
if (!existingZone) return { status: "Zone not found for the zoneId" };
|
if (!existingZone) return { status: "Zone not found for the zoneUuid" };
|
||||||
|
|
||||||
const existingWidget = await widgetModel(organization)
|
const existingWidget = await widgetModel(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
widgetID: widgetID,
|
widgetID: widgetID,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("Data widgetName -_id");
|
.select("Data widgetName -_id");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Socket, Server } from "socket.io";
|
|||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
||||||
import { deleteAssetModel, replaceEventDatas, setAssetModel } from "../../../shared/services/builder/assetService.ts";
|
import { deleteAssetModel, replaceEventDatas, setAssetModel } from "../../../shared/services/builder/assetService.ts";
|
||||||
|
import { ErrorResponse, FinalResponse, validateFields } from "../../utils/socketfunctionHelpers.ts";
|
||||||
export const setAssetHandleEvent = async (
|
export const setAssetHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
@@ -23,18 +24,11 @@ export const setAssetHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1UpdateResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1UpdateResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await setAssetModel(data);
|
const result = await setAssetModel(data);
|
||||||
@@ -54,24 +48,12 @@ export const setAssetHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
|
||||||
success: status === "Success",
|
const response = FinalResponse(status, socket, data.organization, messages, Asset_Datas);
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Asset_Datas ? { data: Asset_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1UpdateResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1UpdateResponse, response, connectedUsersByOrg)
|
||||||
@@ -91,18 +73,11 @@ export const deleteAssetHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1DeleteResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1DeleteResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await deleteAssetModel(data);
|
const result = await deleteAssetModel(data);
|
||||||
@@ -123,24 +98,10 @@ export const deleteAssetHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const response = FinalResponse(status, socket, data.organization, messages, Asset_Datas);
|
||||||
const response = {
|
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Asset_Datas ? { data: Asset_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1DeleteResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1DeleteResponse, response, connectedUsersByOrg)
|
||||||
@@ -160,18 +121,10 @@ export const replaceEventDatasHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1EventDataResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1EventDataResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await replaceEventDatas(data);
|
const result = await replaceEventDatas(data);
|
||||||
@@ -192,25 +145,11 @@ export const replaceEventDatasHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, Asset_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Asset_Datas ? { data: Asset_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1EventDataResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.asset_v1EventDataResponse, response, connectedUsersByOrg)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ import { Socket, Server } from "socket.io";
|
|||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
||||||
import { SetCamera } from "../../../shared/services/builder/cameraService.ts";
|
import { SetCamera } from "../../../shared/services/builder/cameraService.ts";
|
||||||
|
import { ErrorResponse, FinalResponse, validateFields } from "../../utils/socketfunctionHelpers.ts";
|
||||||
export const SetCameraHandleEvent = async (
|
export const SetCameraHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
@@ -18,20 +19,13 @@ export const SetCameraHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.camera_v1CreateResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.camera_v1CreateResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await SetCamera(data);
|
const result = await SetCamera(data);
|
||||||
const status = typeof result?.status === "string" ? result.status : "unknown";
|
const status = typeof result?.status === "string" ? result.status : "unknown";
|
||||||
|
|
||||||
@@ -49,24 +43,11 @@ export const SetCameraHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, Camera_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Camera_Datas ? { data: Camera_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.camera_v1CreateResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.camera_v1CreateResponse, response, connectedUsersByOrg)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Socket, Server } from "socket.io";
|
|||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
||||||
import { setEnvironment } from "../../../shared/services/builder/EnvironmentService.ts";
|
import { setEnvironment } from "../../../shared/services/builder/EnvironmentService.ts";
|
||||||
|
import { ErrorResponse, FinalResponse, validateFields } from "../../utils/socketfunctionHelpers.ts";
|
||||||
|
|
||||||
export const setEnvironmentHandleEvent = async (
|
export const setEnvironmentHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
@@ -16,20 +18,13 @@ export const setEnvironmentHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Environment_v1UpdateResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Environment_v1UpdateResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await setEnvironment(data);
|
const result = await setEnvironment(data);
|
||||||
const status = typeof result?.status === "string" ? result.status : "unknown";
|
const status = typeof result?.status === "string" ? result.status : "unknown";
|
||||||
|
|
||||||
@@ -43,28 +38,14 @@ export const setEnvironmentHandleEvent = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const msg = messages[status] || { message: "Internal server error" };
|
const msg = messages[status] || { message: "Internal server error" };
|
||||||
const Camera_Datas =
|
const environment_Datas =
|
||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const response = FinalResponse(status, socket, data.organization, messages, environment_Datas);
|
||||||
const response = {
|
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Camera_Datas ? { data: Camera_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Environment_v1UpdateResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Environment_v1UpdateResponse, response, connectedUsersByOrg)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Socket, Server } from "socket.io";
|
|||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
||||||
import { CreateLineItems, DeleteLayer, DeleteLineItems, DeleteLinePoints, UpdateLineItems } from "../../../shared/services/builder/lineService.ts";
|
import { CreateLineItems, DeleteLayer, DeleteLineItems, DeleteLinePoints, UpdateLineItems } from "../../../shared/services/builder/lineService.ts";
|
||||||
|
import { ErrorResponse, FinalResponse, validateFields } from "../../utils/socketfunctionHelpers.ts";
|
||||||
export const CreateLineHandleEvent = async (
|
export const CreateLineHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
@@ -18,18 +19,10 @@ export const CreateLineHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.createLine_v1Response,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.createLine_v1Response, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await CreateLineItems(data);
|
const result = await CreateLineItems(data);
|
||||||
@@ -49,24 +42,11 @@ export const CreateLineHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, Line_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Line_Datas ? { data: Line_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.createLine_v1Response, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.createLine_v1Response, response, connectedUsersByOrg)
|
||||||
@@ -86,18 +66,11 @@ export const UpdateLineHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.updateLine_v1Response,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.updateLine_v1Response, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await UpdateLineItems(data);
|
const result = await UpdateLineItems(data);
|
||||||
@@ -116,24 +89,12 @@ export const UpdateLineHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, Line_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Line_Datas ? { data: Line_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.updateLine_v1Response, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.updateLine_v1Response, response, connectedUsersByOrg)
|
||||||
@@ -152,18 +113,12 @@ export const DeleteLineHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
|
||||||
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLine_v1Response,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLine_v1Response, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await DeleteLineItems(data);
|
const result = await DeleteLineItems(data);
|
||||||
@@ -183,25 +138,11 @@ export const DeleteLineHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, Line_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Line_Datas ? { data: Line_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLine_v1Response, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLine_v1Response, response, connectedUsersByOrg)
|
||||||
}
|
}
|
||||||
@@ -219,18 +160,11 @@ export const DeleteLayerHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLineLayer_v1Response,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLineLayer_v1Response, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await DeleteLayer(data);
|
const result = await DeleteLayer(data);
|
||||||
@@ -250,25 +184,11 @@ export const DeleteLayerHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, Line_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Line_Datas ? { data: Line_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLineLayer_v1Response, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteLineLayer_v1Response, response, connectedUsersByOrg)
|
||||||
}
|
}
|
||||||
@@ -286,18 +206,12 @@ export const DeleteLinePointsHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
|
||||||
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deletePoint_v1Response,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deletePoint_v1Response, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await DeleteLinePoints(data);
|
const result = await DeleteLinePoints(data);
|
||||||
@@ -317,25 +231,11 @@ export const DeleteLinePointsHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, Line_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Line_Datas ? { data: Line_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deletePoint_v1Response, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deletePoint_v1Response, response, connectedUsersByOrg)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ import { Socket, Server } from "socket.io";
|
|||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
||||||
import { deleteWallItems, setWallItems } from "../../../shared/services/builder/wallService.ts";
|
import { deleteWallItems, setWallItems } from "../../../shared/services/builder/wallService.ts";
|
||||||
|
import { ErrorResponse, FinalResponse, validateFields } from "../../utils/socketfunctionHelpers.ts";
|
||||||
|
|
||||||
export const setWallItemsHandleEvent = async (
|
export const setWallItemsHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
@@ -24,18 +25,12 @@ export const setWallItemsHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
|
||||||
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1UpdateResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1UpdateResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await setWallItems(data);
|
const result = await setWallItems(data);
|
||||||
@@ -51,29 +46,15 @@ export const setWallItemsHandleEvent = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const msg = messages[status] || { message: "Internal server error" };
|
const msg = messages[status] || { message: "Internal server error" };
|
||||||
const Camera_Datas =
|
const wall_Datas =
|
||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, wall_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Camera_Datas ? { data: Camera_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1UpdateResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1UpdateResponse, response, connectedUsersByOrg)
|
||||||
}
|
}
|
||||||
@@ -92,23 +73,16 @@ export const deleteWallItemsHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
|
||||||
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1DeleteResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1DeleteResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await deleteWallItems(data);
|
const result = await deleteWallItems(data);
|
||||||
const status = typeof result?.status === "string" ? result.status : "unknown";
|
const status = typeof result?.status === "string" ? result.status : "unknown";
|
||||||
|
|
||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
Success: { message: "wall Item deleted successfully" },
|
Success: { message: "wall Item deleted successfully" },
|
||||||
"User not found": { message: "User not found" },
|
"User not found": { message: "User not found" },
|
||||||
@@ -119,7 +93,7 @@ export const deleteWallItemsHandleEvent = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const msg = messages[status] || { message: "Internal server error" };
|
const msg = messages[status] || { message: "Internal server error" };
|
||||||
const Camera_Datas =
|
const wall_Datas =
|
||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
@@ -132,15 +106,8 @@ export const deleteWallItemsHandleEvent = async (
|
|||||||
// zoneId: result.data.zoneId,
|
// zoneId: result.data.zoneId,
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const response = FinalResponse(status, socket, data.organization, messages, wall_Datas);
|
||||||
|
|
||||||
const response = {
|
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Camera_Datas ? { data: Camera_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1DeleteResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.wallItems_v1DeleteResponse, response, connectedUsersByOrg)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Socket, Server } from "socket.io";
|
|||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
||||||
import { DelZone, SetZone } from "../../../shared/services/builder/zoneService.ts";
|
import { DelZone, SetZone } from "../../../shared/services/builder/zoneService.ts";
|
||||||
|
import { ErrorResponse, FinalResponse, validateFields } from "../../utils/socketfunctionHelpers.ts";
|
||||||
|
|
||||||
|
|
||||||
export const SetZoneHandleEvent = async (
|
export const SetZoneHandleEvent = async (
|
||||||
@@ -18,18 +19,11 @@ export const SetZoneHandleEvent = async (
|
|||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.zone_v1UpdateResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.zone_v1UpdateResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await SetZone(data);
|
const result = await SetZone(data);
|
||||||
@@ -45,28 +39,15 @@ export const SetZoneHandleEvent = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const msg = messages[status] || { message: "Internal server error" };
|
const msg = messages[status] || { message: "Internal server error" };
|
||||||
const Camera_Datas =
|
const zone_Datas =
|
||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, zone_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Camera_Datas ? { data: Camera_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.zone_v1UpdateResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.zone_v1UpdateResponse, response, connectedUsersByOrg)
|
||||||
@@ -80,23 +61,17 @@ export const DeleteZoneHandleEvent = async (
|
|||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.deleteZone_v1 || !data?.organization) return;
|
if (event !== EVENTS.deleteZone_v1 || !data?.organization) return;
|
||||||
const requiredFields = [
|
const requiredFields = [
|
||||||
"zoneId",
|
"zoneUuid",
|
||||||
"projectId",
|
"projectId",
|
||||||
"userId",
|
"userId",
|
||||||
"organization",
|
"organization",
|
||||||
];
|
];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
|
||||||
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Zone_v1DeleteResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Zone_v1DeleteResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await DelZone(data);
|
const result = await DelZone(data);
|
||||||
@@ -111,29 +86,15 @@ export const DeleteZoneHandleEvent = async (
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const msg = messages[status] || { message: "Internal server error" };
|
const zone_Datas =
|
||||||
const Camera_Datas =
|
|
||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, zone_Datas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(Camera_Datas ? { data: Camera_Datas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Zone_v1DeleteResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.Zone_v1DeleteResponse, response, connectedUsersByOrg)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { Socket, Server } from "socket.io";
|
import { Socket, Server } from "socket.io";
|
||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitEventResponse, emitToSenderAndAdmins, } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins, } from "../../utils/emitEventResponse.ts";
|
||||||
import { createProject, DeleteProject, DuplicateProject, updateProject } from "../../../shared/services/v1Project/v1projectservice.ts";
|
import { createProject, DeleteProject, DuplicateProject, updateProject } from "../../../shared/services/v1Project/v1projectservice.ts";
|
||||||
|
import { ErrorResponse, FinalResponse, validateFields } from "../../utils/socketfunctionHelpers.ts";
|
||||||
|
|
||||||
export const projectHandleEvent = async (
|
export const projectHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
@@ -13,18 +14,11 @@ export const projectHandleEvent = async (
|
|||||||
console.log('event: ', event);
|
console.log('event: ', event);
|
||||||
if (event !== EVENTS.addProject || !data?.organization) return;
|
if (event !== EVENTS.addProject || !data?.organization) return;
|
||||||
const requiredFields = ["projectUuid", "userId", "thumbnail", "organization"];
|
const requiredFields = ["projectUuid", "userId", "thumbnail", "organization"];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('data:controller ', data);
|
console.log('data:controller ', data);
|
||||||
@@ -36,29 +30,18 @@ export const projectHandleEvent = async (
|
|||||||
"user_not_found": { message: "User not found" },
|
"user_not_found": { message: "User not found" },
|
||||||
"project_exists": { message: "Project already exists" },
|
"project_exists": { message: "Project already exists" },
|
||||||
};
|
};
|
||||||
|
let responseData = undefined;
|
||||||
const msg = messages[status] || { message: "Internal server error", };
|
|
||||||
|
|
||||||
let projectDatas = undefined;
|
|
||||||
if (status === "Success" && result?.project) {
|
if (status === "Success" && result?.project) {
|
||||||
projectDatas = {
|
responseData = {
|
||||||
projectUuid: result.project.projectUuid,
|
projectUuid: result.project.projectUuid,
|
||||||
projectName: result.project.projectName,
|
projectName: result.project.projectName,
|
||||||
thumbnail: result.project.thumbnail,
|
thumbnail: result.project.thumbnail,
|
||||||
createdBy: result.project.createdBy,
|
createdBy: result.project.createdBy,
|
||||||
|
projectId: result.project._id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, responseData);
|
||||||
success: status === "Success",
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectResponse, response, connectedUsersByOrg);
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(status === "Success" ? { data: projectDatas, projectId: result.project._id } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectResponse, response, connectedUsersByOrg)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
export const projectDeleteHandleEvent = async (
|
export const projectDeleteHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
@@ -71,18 +54,11 @@ export const projectDeleteHandleEvent = async (
|
|||||||
|
|
||||||
if (event !== EVENTS.deleteProject || !data?.organization) return;
|
if (event !== EVENTS.deleteProject || !data?.organization) return;
|
||||||
const requiredFields = ["projectId", "userId", "organization"];
|
const requiredFields = ["projectId", "userId", "organization"];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteProjectResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteProjectResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await DeleteProject(data);
|
const result = await DeleteProject(data);
|
||||||
@@ -105,17 +81,8 @@ export const projectDeleteHandleEvent = async (
|
|||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, projectDeleteDatas);
|
||||||
success: status === "Success",
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectResponse, response, connectedUsersByOrg);
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(projectDeleteDatas ? { data: projectDeleteDatas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.deleteProjectResponse, response, connectedUsersByOrg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const projecUpdateHandleEvent = async (
|
export const projecUpdateHandleEvent = async (
|
||||||
@@ -128,18 +95,11 @@ export const projecUpdateHandleEvent = async (
|
|||||||
console.log('event: ', event);
|
console.log('event: ', event);
|
||||||
if (event !== EVENTS.ProjectUpdate || !data?.organization) return;
|
if (event !== EVENTS.ProjectUpdate || !data?.organization) return;
|
||||||
const requiredFields = ["projectId", "userId", "organization"];
|
const requiredFields = ["projectId", "userId", "organization"];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectUpdateResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectUpdateResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await updateProject(data);
|
const result = await updateProject(data);
|
||||||
@@ -163,16 +123,7 @@ export const projecUpdateHandleEvent = async (
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, projectDeleteDatas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(projectDeleteDatas ? { data: projectDeleteDatas } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectUpdateResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.projectUpdateResponse, response, connectedUsersByOrg)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -185,19 +136,12 @@ export const DuplicateProjectHandleEvent = async (
|
|||||||
) => {
|
) => {
|
||||||
console.log('event: ', event);
|
console.log('event: ', event);
|
||||||
if (event !== EVENTS.DuplicateProject || !data?.organization) return;
|
if (event !== EVENTS.DuplicateProject || !data?.organization) return;
|
||||||
const requiredFields = ["projectUuid", "projectName","userId", "thumbnail", "organization"];
|
const requiredFields = ["projectUuid", "projectName", "userId", "thumbnail", "organization"];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = validateFields(data, requiredFields);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const response = {
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.DuplicateprojectResponse,
|
||||||
success: false,
|
ErrorResponse(missingFields, socket, data.organization), connectedUsersByOrg);
|
||||||
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
|
||||||
status: "MissingFields",
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data?.organization ?? "unknown",
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.DuplicateprojectResponse, response, connectedUsersByOrg)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('data:controller ', data);
|
console.log('data:controller ', data);
|
||||||
@@ -221,14 +165,8 @@ export const DuplicateProjectHandleEvent = async (
|
|||||||
createdBy: result.project.createdBy,
|
createdBy: result.project.createdBy,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const response = {
|
const response = FinalResponse(status, socket, data.organization, messages, projectDatas);
|
||||||
success: status === "Success",
|
|
||||||
message: msg.message,
|
|
||||||
status,
|
|
||||||
socketId: socket.id,
|
|
||||||
organization: data.organization,
|
|
||||||
...(status === "Success" ? { data: projectDatas, projectId: result.project._id } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.DuplicateprojectResponse, response, connectedUsersByOrg)
|
emitToSenderAndAdmins(io, socket, data.organization, EVENTS.DuplicateprojectResponse, response, connectedUsersByOrg)
|
||||||
|
|
||||||
|
|||||||
@@ -48,13 +48,7 @@ export const productAddHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Socket, Server } from "socket.io";
|
import { Socket, Server } from "socket.io";
|
||||||
import { EVENTS } from "../../socket/events.ts";
|
import { EVENTS } from "../../socket/events.ts";
|
||||||
import { emitEventResponse, emitToSenderAndAdmins, } from "../../utils/emitEventResponse.ts";
|
import { emitToSenderAndAdmins, } from "../../utils/emitEventResponse.ts";
|
||||||
import {
|
import {
|
||||||
TrashDelete,
|
TrashDelete,
|
||||||
} from "../../../shared/services/v1trash/v1trashservice.ts";
|
} from "../../../shared/services/v1trash/v1trashservice.ts";
|
||||||
@@ -43,13 +43,7 @@ export const TrashDeleteHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
const response = {
|
const response = {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const add3DwidgetHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.addWidget3D || !data?.organization) return;
|
if (event !== EVENTS.addWidget3D || !data?.organization) return;
|
||||||
const requiredFields = ["projectId", "userId", "organization", "zoneId", "widget"];
|
const requiredFields = ["projectId", "userId", "organization", "zoneUuid", "widget"];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -31,7 +31,7 @@ export const add3DwidgetHandleEvent = async (
|
|||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
Success: { message: "Widget created successfully" },
|
Success: { message: "Widget created successfully" },
|
||||||
"User not found": { message: "User not found" },
|
"User not found": { message: "User not found" },
|
||||||
"Zone not found for the zoneId": { message: "Zone not found for the zoneId" },
|
"Zone not found for the zoneUuid": { message: "Zone not found for the zoneUuid" },
|
||||||
"3dwidget update successfully": { message: "widget update successfully" },
|
"3dwidget update successfully": { message: "widget update successfully" },
|
||||||
"3dWidget not updated": { message: "3dWidget not updated" },
|
"3dWidget not updated": { message: "3dWidget not updated" },
|
||||||
"Widget 3d not created": { message: "Widget 3d not created" },
|
"Widget 3d not created": { message: "Widget 3d not created" },
|
||||||
@@ -42,13 +42,6 @@ export const add3DwidgetHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@@ -72,7 +65,7 @@ export const update3DHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.updateWidget3DPosition || !data?.organization) return;
|
if (event !== EVENTS.updateWidget3DPosition || !data?.organization) return;
|
||||||
const requiredFields = ["projectId", "id", "position", "rotation", "userId", "organization", "zoneId", "widget"];
|
const requiredFields = ["projectId", "id", "position", "rotation", "userId", "organization", "zoneUuid", "widget"];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -127,7 +120,7 @@ export const Delete3DwidgetHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.deleteWidget3D || !data?.organization) return;
|
if (event !== EVENTS.deleteWidget3D || !data?.organization) return;
|
||||||
const requiredFields = ["projectId", "id", "userId", "organization", "zoneId",];
|
const requiredFields = ["projectId", "id", "userId", "organization", "zoneUuid",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const AddFloatHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.addFloat_v1 || !data?.organization) return;
|
if (event !== EVENTS.addFloat_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "index", "widget", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "index", "widget", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -31,7 +31,7 @@ export const AddFloatHandleEvent = async (
|
|||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
Success: { message: "FloatWidget created successfully" },
|
Success: { message: "FloatWidget created successfully" },
|
||||||
"User not found": { message: "User not found" },
|
"User not found": { message: "User not found" },
|
||||||
"Zone not found for the zoneId": { message: "Zone not found for the zoneId" },
|
"Zone not found for the zoneUuid": { message: "Zone not found for the zoneUuid" },
|
||||||
"Widget updated successfully": { message: "Widget updated successfully" },
|
"Widget updated successfully": { message: "Widget updated successfully" },
|
||||||
"Failed to create FloatWidget": { message: "Failed to create FloatWidget" },
|
"Failed to create FloatWidget": { message: "Failed to create FloatWidget" },
|
||||||
};
|
};
|
||||||
@@ -41,13 +41,7 @@ export const AddFloatHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@@ -71,7 +65,7 @@ export const DeleteFloatHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.deleteFloat_v1 || !data?.organization) return;
|
if (event !== EVENTS.deleteFloat_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "floatWidgetID", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "floatWidgetID", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -92,7 +86,7 @@ export const DeleteFloatHandleEvent = async (
|
|||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
Success: { message: "FloatingWidget deleted successfully" },
|
Success: { message: "FloatingWidget deleted successfully" },
|
||||||
"User not found": { message: "User not found" },
|
"User not found": { message: "User not found" },
|
||||||
"Zone not found for the zoneId": { message: "Zone not found for the zoneId" },
|
"Zone not found for the zoneUuid": { message: "Zone not found for the zoneUuid" },
|
||||||
"FloatWidget not found for the Id": { message: "FloatWidget not found for the Id" },
|
"FloatWidget not found for the Id": { message: "FloatWidget not found for the Id" },
|
||||||
"FloatWidget not deleted": { message: "FloatWidget not deleted" },
|
"FloatWidget not deleted": { message: "FloatWidget not deleted" },
|
||||||
};
|
};
|
||||||
@@ -102,13 +96,7 @@ export const DeleteFloatHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@@ -132,7 +120,7 @@ export const DuplicateFloatHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.duplicatefloat_v1 || !data?.organization) return;
|
if (event !== EVENTS.duplicatefloat_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "index", "widget", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "index", "widget", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -153,7 +141,7 @@ export const DuplicateFloatHandleEvent = async (
|
|||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
Success: { message: "duplicate FloatWidget created successfully" },
|
Success: { message: "duplicate FloatWidget created successfully" },
|
||||||
"User not found": { message: "User not found" },
|
"User not found": { message: "User not found" },
|
||||||
"Zone not found for the zoneId": { message: "Zone not found for the zoneId" },
|
"Zone not found for the zoneUuid": { message: "Zone not found for the zoneUuid" },
|
||||||
"FloatWidget update unsuccessfull": { message: "FloatWidget update unsuccessfull" },
|
"FloatWidget update unsuccessfull": { message: "FloatWidget update unsuccessfull" },
|
||||||
"FloatWidget not deleted": { message: "FloatWidget not deleted" },
|
"FloatWidget not deleted": { message: "FloatWidget not deleted" },
|
||||||
};
|
};
|
||||||
@@ -163,13 +151,7 @@ export const DuplicateFloatHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const AddPanelHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.addPanel_v1 || !data?.organization) return;
|
if (event !== EVENTS.addPanel_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "panelOrder", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "panelOrder", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -40,13 +40,7 @@ export const AddPanelHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@@ -70,7 +64,7 @@ export const DeletePanelHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.deletePanel_v1 || !data?.organization) return;
|
if (event !== EVENTS.deletePanel_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "panelName", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "panelName", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -100,13 +94,7 @@ export const DeletePanelHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@@ -130,7 +118,7 @@ export const ClearPanelHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.clearPanel_v1 || !data?.organization) return;
|
if (event !== EVENTS.clearPanel_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "panelName", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "panelName", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -162,14 +150,7 @@ export const ClearPanelHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
}
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const response = {
|
const response = {
|
||||||
@@ -192,7 +173,7 @@ export const LockedPanelHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.lockedPanel_v1 || !data?.organization) return;
|
if (event !== EVENTS.lockedPanel_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "lockedPanel", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "lockedPanel", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -223,13 +204,7 @@ export const LockedPanelHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,7 @@ export const AddTemplateHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@@ -109,7 +103,7 @@ export const addTemplateZoneHandleEvent = async (
|
|||||||
// snapshot: existingTemplate.snapshot,
|
// snapshot: existingTemplate.snapshot,
|
||||||
// floatingWidget: existingTemplate.floatWidgets,
|
// floatingWidget: existingTemplate.floatWidgets,
|
||||||
// },
|
// },
|
||||||
// zoneId: existingZone.zoneId,
|
// zoneUuid: existingZone.zoneUuid,
|
||||||
// zoneName: existingZone.zoneName,
|
// zoneName: existingZone.zoneName,
|
||||||
// };
|
// };
|
||||||
}
|
}
|
||||||
@@ -171,7 +165,7 @@ export const TemplateDeleteHandleEvent = async (
|
|||||||
// position: result.data.position,
|
// position: result.data.position,
|
||||||
// },
|
// },
|
||||||
// Data: result.data.Data,
|
// Data: result.data.Data,
|
||||||
// zoneId: result.data.zoneId,
|
// zoneUuid: result.data.zoneUuid,
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const AddWidgetHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.addWidget_v1 || !data?.organization) return;
|
if (event !== EVENTS.addWidget_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "widget", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "widget", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -31,7 +31,7 @@ export const AddWidgetHandleEvent = async (
|
|||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
Success: { message: "Widget created successfully" },
|
Success: { message: "Widget created successfully" },
|
||||||
"User not found": { message: "User not found" },
|
"User not found": { message: "User not found" },
|
||||||
"Zone not found for the zoneId": { message: "Zone not found for the zoneId" },
|
"Zone not found for the zoneUuid": { message: "Zone not found for the zoneUuid" },
|
||||||
"panelName not found": { message: "panelName not found" },
|
"panelName not found": { message: "panelName not found" },
|
||||||
"Widget update unsuccessfull": { message: "Widget update unsuccessfull" },
|
"Widget update unsuccessfull": { message: "Widget update unsuccessfull" },
|
||||||
"Type mismatch": { message: "Type mismatch" },
|
"Type mismatch": { message: "Type mismatch" },
|
||||||
@@ -43,13 +43,7 @@ export const AddWidgetHandleEvent = async (
|
|||||||
status === "Success" && result?.data
|
status === "Success" && result?.data
|
||||||
|
|
||||||
? {
|
? {
|
||||||
// widget: {
|
|
||||||
// id: result.data.widgetID,
|
|
||||||
// type: result.data.projectName,
|
|
||||||
// position: result.data.position,
|
|
||||||
// },
|
|
||||||
// Data: result.data.Data,
|
|
||||||
// zoneId: result.data.zoneId,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@@ -73,7 +67,7 @@ export const WidgetDeleteHandleEvent = async (
|
|||||||
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
connectedUsersByOrg: { [org: string]: { socketId: string; userId: string; role: string }[] },
|
||||||
) => {
|
) => {
|
||||||
if (event !== EVENTS.deleteWidget_v1 || !data?.organization) return;
|
if (event !== EVENTS.deleteWidget_v1 || !data?.organization) return;
|
||||||
const requiredFields = ["zoneId", "widgetID", "projectId", "userId", "organization",];
|
const requiredFields = ["zoneUuid", "widgetID", "projectId", "userId", "organization",];
|
||||||
const missingFields = requiredFields.filter(field => !data?.[field]);
|
const missingFields = requiredFields.filter(field => !data?.[field]);
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
@@ -94,7 +88,7 @@ export const WidgetDeleteHandleEvent = async (
|
|||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
Success: { message: "Widget deleted successfully" },
|
Success: { message: "Widget deleted successfully" },
|
||||||
"User not found": { message: "User not found" },
|
"User not found": { message: "User not found" },
|
||||||
"Zone not found for the zoneId": { message: "Zone not found for the zoneId" },
|
"Zone not found for the zoneUuid": { message: "Zone not found for the zoneUuid" },
|
||||||
"Widget not found": { message: "Widget not found" },
|
"Widget not found": { message: "Widget not found" },
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -110,7 +104,7 @@ export const WidgetDeleteHandleEvent = async (
|
|||||||
// position: result.data.position,
|
// position: result.data.position,
|
||||||
// },
|
// },
|
||||||
// Data: result.data.Data,
|
// Data: result.data.Data,
|
||||||
// zoneId: result.data.zoneId,
|
// zoneUuid: result.data.zoneUuid,
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -18,25 +18,25 @@ import { AddPanelHandleEvent, ClearPanelHandleEvent, DeletePanelHandleEvent, Loc
|
|||||||
import { AddTemplateHandleEvent, addTemplateZoneHandleEvent, TemplateDeleteHandleEvent } from '../controllers/vizualizationController/template-Controller.ts';
|
import { AddTemplateHandleEvent, addTemplateZoneHandleEvent, TemplateDeleteHandleEvent } from '../controllers/vizualizationController/template-Controller.ts';
|
||||||
import { AddWidgetHandleEvent, WidgetDeleteHandleEvent } from '../controllers/vizualizationController/widget-Controller.ts';
|
import { AddWidgetHandleEvent, WidgetDeleteHandleEvent } from '../controllers/vizualizationController/widget-Controller.ts';
|
||||||
import { getUserRole } from '../utils/getUsers.ts';
|
import { getUserRole } from '../utils/getUsers.ts';
|
||||||
import { initSocketServer } from "../socket/socketManager.ts";
|
|
||||||
|
|
||||||
interface UserSocketInfo {
|
interface UserSocketInfo {
|
||||||
socketId: string;
|
socketId: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
role: string;
|
role: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const connectedUsersByOrg: { [organization: string]: UserSocketInfo[] } = {};
|
const connectedUsersByOrg: { [organization: string]: UserSocketInfo[] } = {};
|
||||||
export const SocketServer = (io: Server) => {
|
export const SocketServer = (io: Server) => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const namespaces = {
|
const namespaces = {
|
||||||
dashboard: io.of('/dashboard'),
|
dashboard: io.of('/dashboard'),
|
||||||
project: io.of('/project'),
|
project: io.of('/project'),
|
||||||
thread: io.of('/thread'),
|
thread: io.of('/thread'),
|
||||||
Builder: io.of("/Builder_v1"),
|
Builder_v1: io.of("/Builder_v1"),
|
||||||
visualization: io.of("/Visualization_v1"),
|
visualization_v1: io.of("/Visualization_v1"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -73,12 +73,12 @@ export const SocketServer = (io: Server) => {
|
|||||||
return next(new Error("Authentication error: User not found"));
|
return next(new Error("Authentication error: User not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
(socket as any).user = {
|
(socket as any).user = {
|
||||||
|
|
||||||
organization: decoded.organization,
|
organization: decoded.organization,
|
||||||
Email: decoded.Email,
|
Email: decoded.Email,
|
||||||
userId: decoded.userId,
|
userId: decoded.userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -88,10 +88,9 @@ export const SocketServer = (io: Server) => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
namespace.on("connection",async (socket: Socket) => {
|
namespace.on("connection", async (socket: Socket) => {
|
||||||
const user = (socket as any).user;
|
const user = (socket as any).user;
|
||||||
const organization = user.organization;
|
const organization = user.organization;
|
||||||
const Email = user.Email;
|
|
||||||
const userId = user.userId;
|
const userId = user.userId;
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ export const SocketServer = (io: Server) => {
|
|||||||
if (organization) {
|
if (organization) {
|
||||||
socket.join(organization);
|
socket.join(organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
const role = await getUserRole(userId, organization);
|
const role = await getUserRole(userId, organization);
|
||||||
if (role === "Admin") {
|
if (role === "Admin") {
|
||||||
socket.join(`${organization}_admins`);
|
socket.join(`${organization}_admins`);
|
||||||
@@ -120,10 +119,9 @@ export const SocketServer = (io: Server) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
socket.onAny((event: string, data: any, callback: any) => {
|
socket.onAny((event: string, data: any, callback: any) => {
|
||||||
console.log('data: dahbord', data);
|
|
||||||
eventHandlers.forEach(handler =>
|
eventHandlers.forEach(handler =>
|
||||||
handler(event, socket, io, data, connectedUsersByOrg, callback)
|
handler(event, socket, io, data, connectedUsersByOrg, callback)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
@@ -144,14 +142,23 @@ export const SocketServer = (io: Server) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
handleNamespace(namespaces.dashboard);
|
handleNamespace(namespaces.dashboard);
|
||||||
handleNamespace(namespaces.thread,createThreadHandleEvent,deleteThreadHandleEvent,addCommentHandleEvent,deleteCommentHandleEvent)
|
handleNamespace(namespaces.thread,
|
||||||
|
createThreadHandleEvent,
|
||||||
|
deleteThreadHandleEvent,
|
||||||
|
addCommentHandleEvent,
|
||||||
|
deleteCommentHandleEvent)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
handleNamespace(namespaces.project, projectHandleEvent, projectDeleteHandleEvent, projecUpdateHandleEvent,DuplicateProjectHandleEvent,TrashDeleteHandleEvent )
|
handleNamespace(namespaces.project,
|
||||||
handleNamespace(namespaces.Builder,
|
projectHandleEvent,
|
||||||
|
projectDeleteHandleEvent,
|
||||||
|
projecUpdateHandleEvent,
|
||||||
|
DuplicateProjectHandleEvent,
|
||||||
|
TrashDeleteHandleEvent)
|
||||||
|
handleNamespace(namespaces.Builder_v1,
|
||||||
setAssetHandleEvent,
|
setAssetHandleEvent,
|
||||||
deleteAssetHandleEvent,
|
deleteAssetHandleEvent,
|
||||||
replaceEventDatasHandleEvent,
|
replaceEventDatasHandleEvent,
|
||||||
@@ -167,7 +174,7 @@ handleNamespace(namespaces.thread,createThreadHandleEvent,deleteThreadHandleEven
|
|||||||
SetZoneHandleEvent,
|
SetZoneHandleEvent,
|
||||||
DeleteZoneHandleEvent
|
DeleteZoneHandleEvent
|
||||||
)
|
)
|
||||||
handleNamespace(namespaces.visualization,
|
handleNamespace(namespaces.visualization_v1,
|
||||||
add3DwidgetHandleEvent,
|
add3DwidgetHandleEvent,
|
||||||
update3DHandleEvent,
|
update3DHandleEvent,
|
||||||
Delete3DwidgetHandleEvent,
|
Delete3DwidgetHandleEvent,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Request, Response } from "express";
|
|
||||||
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
|
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
|
||||||
|
|
||||||
export const setWallItems = async (data: any) => {
|
export const setWallItems = async (data: any) => {
|
||||||
|
|||||||
@@ -108,8 +108,7 @@ export const EVENTS = {
|
|||||||
addWidget3D: "v1:viz-3D-widget:add",
|
addWidget3D: "v1:viz-3D-widget:add",
|
||||||
addWidget3DResponse: "v1:viz-widget3D:response:add",
|
addWidget3DResponse: "v1:viz-widget3D:response:add",
|
||||||
updateWidget3DPosition: "v1:viz-3D-widget:modifyPositionRotation",
|
updateWidget3DPosition: "v1:viz-3D-widget:modifyPositionRotation",
|
||||||
updateWidget3DPositionResponse:
|
updateWidget3DPositionResponse:"v1:viz-widget3D:response:modifyPositionRotation",
|
||||||
"v1:viz-widget3D:response:modifyPositionRotation",
|
|
||||||
deleteWidget3D: "v1:viz-3D-widget:delete",
|
deleteWidget3D: "v1:viz-3D-widget:delete",
|
||||||
deletewidget3DResponse: "v1:viz-widget3D:response:delete",
|
deletewidget3DResponse: "v1:viz-widget3D:response:delete",
|
||||||
|
|
||||||
@@ -142,7 +141,7 @@ export const EVENTS = {
|
|||||||
widget_v1DeleteResponse: "v1:viz-widget:response:delete",
|
widget_v1DeleteResponse: "v1:viz-widget:response:delete",
|
||||||
|
|
||||||
setAssetModel_v1: "v1:model-asset:add",
|
setAssetModel_v1: "v1:model-asset:add",
|
||||||
asset_v1UpdateResponse: "v1:model-asset:response:updates",
|
asset_v1UpdateResponse: "v1:model-asset:response:add",
|
||||||
delete_v1AssetModel: "v1:model-asset:delete",
|
delete_v1AssetModel: "v1:model-asset:delete",
|
||||||
asset_v1DeleteResponse: "v1:model-asset:response:delete",
|
asset_v1DeleteResponse: "v1:model-asset:response:delete",
|
||||||
asset_v1EventData: "v1:model-asset:updateEventData",
|
asset_v1EventData: "v1:model-asset:updateEventData",
|
||||||
@@ -163,12 +162,12 @@ export const EVENTS = {
|
|||||||
deleteLineLayer_v1Response: "v1:Line:response:delete:layer",
|
deleteLineLayer_v1Response: "v1:Line:response:delete:layer",
|
||||||
|
|
||||||
setenvironment_v1: "v1:Environment:set",
|
setenvironment_v1: "v1:Environment:set",
|
||||||
Environment_v1UpdateResponse: "v1:EnvironmentUpdateResponse",
|
Environment_v1UpdateResponse: "v1:Environment:Response:set",
|
||||||
|
|
||||||
setWallItems_v1: "v1:wallItems:set",
|
setWallItems_v1: "v1:wallItems:set",
|
||||||
wallItems_v1UpdateResponse: "v1:wallItemsUpdateResponse",
|
wallItems_v1UpdateResponse: "v1:wallItems:Response:Update",
|
||||||
deleteWallItems_v1: "v1:wallItems:delete",
|
deleteWallItems_v1: "v1:wallItems:delete",
|
||||||
wallItems_v1DeleteResponse: "v1:wallItemsDeleteResponse",
|
wallItems_v1DeleteResponse: "v1:wallItem:Response:Delete",
|
||||||
|
|
||||||
setZone_v1: "v1:zone:set",
|
setZone_v1: "v1:zone:set",
|
||||||
zone_v1UpdateResponse: "v1:zone:response:updates",
|
zone_v1UpdateResponse: "v1:zone:response:updates",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
deleteLinPoiteItems,
|
deleteLinPoiteItems,
|
||||||
updateLineItems,
|
updateLineItems,
|
||||||
createLineItems,
|
createLineItems,
|
||||||
deleteLayer,
|
|
||||||
} from "../services/lines/line-Controller.ts";
|
} from "../services/lines/line-Controller.ts";
|
||||||
import {
|
import {
|
||||||
activeUserOffline,
|
activeUserOffline,
|
||||||
@@ -57,14 +57,11 @@ import {
|
|||||||
projectHandleEvent,
|
projectHandleEvent,
|
||||||
projecUpdateHandleEvent,
|
projecUpdateHandleEvent,
|
||||||
} from "../controllers/projectController/projectController.ts";
|
} from "../controllers/projectController/projectController.ts";
|
||||||
import { getUserRole } from "../utils/getUsers.ts";
|
|
||||||
|
|
||||||
const cameraHandleEvent = async (
|
const cameraHandleEvent = async (
|
||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
namespace: any,
|
|
||||||
notifySender: boolean = false
|
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
@@ -100,7 +97,7 @@ const EnvironmentHandleEvent = async (
|
|||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
io: any
|
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
@@ -469,8 +466,6 @@ const panelHandleEvent = async (
|
|||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
namespace: any,
|
|
||||||
notifySender: boolean = false
|
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
@@ -565,8 +560,6 @@ const widgetHandleEvent = async (
|
|||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
namespace: any,
|
|
||||||
notifySender: boolean = false,
|
|
||||||
callback: any
|
callback: any
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
@@ -627,8 +620,6 @@ const floatHandleEvent = async (
|
|||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
namespace: any,
|
|
||||||
notifySender: boolean = false,
|
|
||||||
callback: any
|
callback: any
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
@@ -707,8 +698,6 @@ const templateHandleEvent = async (
|
|||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
namespace: any,
|
|
||||||
notifySender: boolean = false
|
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
@@ -787,8 +776,6 @@ const Widget3DHandleEvent = async (
|
|||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
namespace: any,
|
|
||||||
notifySender: boolean = false,
|
|
||||||
callback: any
|
callback: any
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
@@ -870,8 +857,6 @@ const modelAssetHandleEvent = async (
|
|||||||
event: string,
|
event: string,
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
data: any,
|
data: any,
|
||||||
namespace: any,
|
|
||||||
notifySender: boolean = false
|
|
||||||
) => {
|
) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
@@ -969,7 +954,6 @@ interface UserSocketInfo {
|
|||||||
role: string;
|
role: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const connectedUsersByOrg: { [organization: string]: UserSocketInfo[] } = {};
|
|
||||||
|
|
||||||
export const initSocketServer = (io: Server) => {
|
export const initSocketServer = (io: Server) => {
|
||||||
|
|
||||||
@@ -987,6 +971,8 @@ export const initSocketServer = (io: Server) => {
|
|||||||
namespace: any,
|
namespace: any,
|
||||||
...eventHandlers: Function[]
|
...eventHandlers: Function[]
|
||||||
) => {
|
) => {
|
||||||
|
if (namespace._handlersRegistered) return;
|
||||||
|
namespace._handlersRegistered = true;
|
||||||
namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
||||||
const token = socket.handshake.auth.token;
|
const token = socket.handshake.auth.token;
|
||||||
|
|
||||||
@@ -998,11 +984,12 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
namespace.on("connection", async (socket: Socket) => {
|
namespace.on("connection", async (socket: Socket) => {
|
||||||
|
|
||||||
const { organization, email, userId } = socket.handshake.auth;
|
const { organization, email,} = socket.handshake.auth;
|
||||||
|
|
||||||
if (organization) {
|
if (organization) {
|
||||||
socket.join(organization);
|
socket.join(organization);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (organization && email) {
|
if (organization && email) {
|
||||||
if (!onlineUsers[organization]) {
|
if (!onlineUsers[organization]) {
|
||||||
@@ -1014,7 +1001,6 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
|||||||
userStatus(EVENTS.connection, socket, socket.handshake.auth, socket);
|
userStatus(EVENTS.connection, socket, socket.handshake.auth, socket);
|
||||||
|
|
||||||
socket.onAny((event: string, data: any, callback: any) => {
|
socket.onAny((event: string, data: any, callback: any) => {
|
||||||
console.log('data: socketmanager', data);
|
|
||||||
eventHandlers.forEach((handler) =>
|
eventHandlers.forEach((handler) =>
|
||||||
handler(event, socket, data, namespace, io, callback)
|
handler(event, socket, data, namespace, io, callback)
|
||||||
);
|
);
|
||||||
@@ -1025,9 +1011,6 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
|||||||
if (onlineUsers[organization]?.size === 0)
|
if (onlineUsers[organization]?.size === 0)
|
||||||
delete onlineUsers[organization];
|
delete onlineUsers[organization];
|
||||||
userStatus(EVENTS.disconnect, socket, socket.handshake.auth, socket);
|
userStatus(EVENTS.disconnect, socket, socket.handshake.auth, socket);
|
||||||
// connectedUsersByOrg[organization] = connectedUsersByOrg[
|
|
||||||
// organization
|
|
||||||
// ].filter((u) => u.socketId !== socket.id);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("reconnect", (attempt: number) => {
|
socket.on("reconnect", (attempt: number) => {
|
||||||
|
|||||||
32
src/socket-server/utils/socketfunctionHelpers.ts
Normal file
32
src/socket-server/utils/socketfunctionHelpers.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { Socket, Server } from "socket.io";
|
||||||
|
|
||||||
|
export const validateFields = (data: any, requiredFields: string[]): string[] => {
|
||||||
|
return requiredFields.filter(field => !data?.[field]);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const ErrorResponse = (missingFields: string[], socket: Socket, organization: string) => ({
|
||||||
|
success: false,
|
||||||
|
message: `Missing required field(s): ${missingFields.join(", ")}`,
|
||||||
|
status: "MissingFields",
|
||||||
|
socketId: socket.id,
|
||||||
|
organization: organization ?? "unknown",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const FinalResponse = (
|
||||||
|
status: string,
|
||||||
|
socket: Socket,
|
||||||
|
organization: string,
|
||||||
|
messages: Record<string, { message: string }>,
|
||||||
|
data?: any
|
||||||
|
) => {
|
||||||
|
const msg = messages[status] || { message: "Internal server error" };
|
||||||
|
return {
|
||||||
|
success: status === "Success",
|
||||||
|
message: msg.message,
|
||||||
|
status,
|
||||||
|
socketId: socket.id,
|
||||||
|
organization,
|
||||||
|
...(status === "Success" && data ? { data } : {}),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user