clear the testing commits
This commit is contained in:
@@ -3,7 +3,7 @@ import MainModel from "../../connect/mongoose.ts";
|
||||
import { User } from "./userAuthModel.ts";
|
||||
export interface UserData extends Document {
|
||||
userId: User["_id"];
|
||||
isShare: Boolean;
|
||||
isShare: boolean;
|
||||
activeStatus: string;
|
||||
notificationEnable: boolean;
|
||||
About: string;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Project } from "../Project/project-model.ts";
|
||||
import { Version } from "../Version/versionModel.ts";
|
||||
export interface Zone extends Document {
|
||||
zoneName: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
points: [];
|
||||
viewPortCenter: [];
|
||||
viewPortposition: [];
|
||||
@@ -20,7 +20,7 @@ export interface Zone extends Document {
|
||||
const zoneSchema: Schema = new Schema(
|
||||
{
|
||||
zoneName: { type: String },
|
||||
zoneId: { type: String },
|
||||
zoneUuid: { type: String },
|
||||
createdBy: { type: Schema.Types.ObjectId, ref: "User" },
|
||||
projectId: { type: Schema.Types.ObjectId, ref: "Project" },
|
||||
versionId: { type: Schema.Types.ObjectId, ref: "Version" },
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface Widget3d extends Document {
|
||||
type: string;
|
||||
widgetID: string;
|
||||
@@ -8,7 +7,7 @@ export interface Widget3d extends Document {
|
||||
position: [];
|
||||
rotation: [];
|
||||
isArchive: boolean;
|
||||
zoneId: Zone["_id"];
|
||||
zoneUuid:string
|
||||
Data: {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
@@ -21,7 +20,7 @@ const Widget3dSchema: Schema = new Schema(
|
||||
widgetName: { type: String, default: "Widget3D" },
|
||||
position: { type: Array },
|
||||
rotation: { type: Array },
|
||||
zoneId:{ type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
zoneUuid:{ type: String },
|
||||
Data: {
|
||||
measurements: { type: Object, default: {} },
|
||||
duration: { type: String, default: "1h" },
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface FloatingWidget extends Document {
|
||||
className: string;
|
||||
iconName: string;
|
||||
@@ -10,7 +9,7 @@ export interface FloatingWidget extends Document {
|
||||
per: string;
|
||||
value: string;
|
||||
isArchive: boolean;
|
||||
zoneId: Zone["_id"];
|
||||
zoneUuid: string
|
||||
Data: {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
@@ -25,7 +24,7 @@ const floatingWidgetSchema: Schema = new Schema(
|
||||
position: { type: Object },
|
||||
per: { type: String },
|
||||
value: { type: String },
|
||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
zoneUuid: { type: String },
|
||||
Data: {
|
||||
measurements: { type: Object, default: {} },
|
||||
duration: { type: String, default: "1h" },
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import mongoose, { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface Panel extends Document {
|
||||
zoneId: Zone["_id"];
|
||||
zoneUuid: string
|
||||
panelName: string;
|
||||
widgets: [mongoose.Types.ObjectId];
|
||||
isArchive: boolean;
|
||||
}
|
||||
const panelSchema: Schema = new Schema(
|
||||
{
|
||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
zoneUuid: { type: String },
|
||||
panelName: { type: String },
|
||||
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||
isArchive: { type: Boolean, default: false },
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import mongoose, { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface Widget extends Document {
|
||||
widgetName: string;
|
||||
widgetside: string;
|
||||
@@ -17,7 +16,7 @@ export interface Widget extends Document {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
};
|
||||
zoneId: Zone["_id"];
|
||||
zoneUuid: string
|
||||
}
|
||||
const widgetSchema: Schema = new Schema(
|
||||
{
|
||||
@@ -36,7 +35,7 @@ const widgetSchema: Schema = new Schema(
|
||||
fontWeight: { type: String },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
zoneUuid: { type: String }
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ interface ISetZone {
|
||||
organization: string;
|
||||
projectId: string;
|
||||
zoneData: {
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
points: [];
|
||||
zoneName: string;
|
||||
layer: number;
|
||||
@@ -21,7 +21,7 @@ interface ISetZone {
|
||||
interface IZone {
|
||||
organization: string;
|
||||
projectId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
userId: string;
|
||||
}
|
||||
interface IVizZone {
|
||||
@@ -42,7 +42,7 @@ interface IGetZones {
|
||||
export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, projectId, zoneData, userId } = data;
|
||||
const zoneId = zoneData.zoneId;
|
||||
const zoneUuid = zoneData.zoneUuid;
|
||||
const points = zoneData.points;
|
||||
const zoneName = zoneData.zoneName;
|
||||
const layer = zoneData.layer;
|
||||
@@ -58,12 +58,12 @@ export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findZoneId = await zoneModel(organization).findOne({
|
||||
projectId: projectId,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
});
|
||||
if (findZoneId) {
|
||||
const updateZone = await zoneModel(organization)
|
||||
.findOneAndUpdate(
|
||||
{ zoneId: zoneId, projectId: projectId, isArchive: false },
|
||||
{ zoneUuid: zoneUuid, projectId: projectId, isArchive: false },
|
||||
{
|
||||
points: points,
|
||||
viewPortposition: viewPortposition,
|
||||
@@ -75,7 +75,7 @@ export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
||||
return { status: "zone updated", data: updateZone };
|
||||
} else {
|
||||
const zoneCreate = await zoneModel(organization).create({
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
createdBy: userId,
|
||||
projectId,
|
||||
zoneName: zoneName,
|
||||
@@ -103,9 +103,9 @@ export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
||||
};
|
||||
export const DelZone = async (data: IZone): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, userId, zoneId, projectId } = data;
|
||||
const { organization, userId, zoneUuid, projectId } = data;
|
||||
const findZoneId = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
projectId: projectId,
|
||||
isArchive: false,
|
||||
});
|
||||
@@ -120,7 +120,7 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
|
||||
if (findZoneId) {
|
||||
const deleteZone = await zoneModel(organization)
|
||||
.findOneAndUpdate({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
createdBy: userId,
|
||||
projectId: projectId,
|
||||
isArchive: false,
|
||||
@@ -128,7 +128,7 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
|
||||
.select("-_id -__v");
|
||||
if (deleteZone) {
|
||||
const panels = await panelModel(organization).find({
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
@@ -142,21 +142,21 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
|
||||
);
|
||||
|
||||
await panelModel(organization).updateMany(
|
||||
{ zoneId, isArchive: false },
|
||||
{ zoneUuid, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
await Promise.all([
|
||||
widget3dModel(organization).updateMany(
|
||||
{ zoneId, isArchive: false },
|
||||
{ zoneUuid, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
),
|
||||
templateModel(organization).updateMany(
|
||||
{ zoneId, isArchive: false },
|
||||
{ zoneUuid, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
),
|
||||
floatWidgetModel(organization).updateMany(
|
||||
{ zoneId, isArchive: false },
|
||||
{ zoneUuid, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
),
|
||||
]);
|
||||
@@ -191,7 +191,7 @@ export const GetZones = async (data: IGetZones): Promise<IResult> => {
|
||||
const findZoneId = await zoneModel(organization)
|
||||
.find({ projectId: projectId, isArchive: false })
|
||||
.select(
|
||||
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
||||
"zoneUuid zoneName layer points viewPortCenter viewPortposition -_id"
|
||||
);
|
||||
|
||||
if (!findZoneId) {
|
||||
@@ -212,7 +212,7 @@ export const GetZones = async (data: IGetZones): Promise<IResult> => {
|
||||
};
|
||||
export const ZoneData = async (data: IZone): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, userId, projectId, zoneId } = data;
|
||||
const { organization, userId, projectId, zoneUuid } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -222,7 +222,7 @@ export const ZoneData = async (data: IZone): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
projectId: projectId,
|
||||
isArchive: false,
|
||||
});
|
||||
@@ -248,7 +248,7 @@ export const ZoneData = async (data: IZone): Promise<IResult> => {
|
||||
};
|
||||
export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, userId, projectId, zoneId } = data;
|
||||
const { organization, userId, projectId, zoneUuid } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -260,17 +260,17 @@ export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
||||
const existingZone = await zoneModel(organization)
|
||||
.findOne({
|
||||
projectId: projectId,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
})
|
||||
.select(
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition points"
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneUuid viewPortCenter viewPortposition points"
|
||||
);
|
||||
if (!existingZone) {
|
||||
return { status: "Zone not found for the UUID" };
|
||||
} else {
|
||||
const panelData = await panelModel(organization).find({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
const zoneName = existingZone.zoneName as string;
|
||||
@@ -297,7 +297,7 @@ export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
||||
const objectData = {
|
||||
zoneName,
|
||||
viewPortposition: existingZone.viewPortposition,
|
||||
zoneId: existingZone.zoneId,
|
||||
zoneUuid: existingZone.zoneUuid,
|
||||
viewPortCenter: existingZone.viewPortCenter,
|
||||
activeSides: existingZone.panelOrder || [],
|
||||
panelOrder: existingZone.panelOrder || [],
|
||||
@@ -337,7 +337,7 @@ export const VizZoneDatas = async (data: IVizZone): Promise<IResult> => {
|
||||
isArchive: false,
|
||||
})
|
||||
.select(
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition points"
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneUuid viewPortCenter viewPortposition points"
|
||||
);
|
||||
if (!existingZones) {
|
||||
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(
|
||||
existingZones.map(async (zone) => {
|
||||
const panelData = await panelModel(organization).find({
|
||||
zoneId: zone._id,
|
||||
zoneUuid: zone._id,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
@@ -368,7 +368,7 @@ export const VizZoneDatas = async (data: IVizZone): Promise<IResult> => {
|
||||
|
||||
return {
|
||||
zoneName: zone.zoneName,
|
||||
zoneId: zone.zoneId,
|
||||
zoneUuid: zone.zoneUuid,
|
||||
viewPortposition: zone.viewPortposition,
|
||||
viewPortCenter: zone.viewPortCenter,
|
||||
activeSides: zone.panelOrder || [],
|
||||
|
||||
@@ -22,20 +22,20 @@ interface IAddFloatData {
|
||||
per: string;
|
||||
value: string;
|
||||
isArchive: boolean;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
Data: {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
};
|
||||
};
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
index: number;
|
||||
projectId: string;
|
||||
}
|
||||
interface IDelFloat {
|
||||
userId: string;
|
||||
organization: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
floatWidgetID: string;
|
||||
projectId: string;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ interface ISingleFloat {
|
||||
interface IGetZoneFloat {
|
||||
userId: string;
|
||||
organization: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
projectId: string;
|
||||
}
|
||||
interface IDuplicateFloatData {
|
||||
@@ -63,19 +63,19 @@ interface IDuplicateFloatData {
|
||||
per: string;
|
||||
value: string;
|
||||
isArchive: boolean;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
Data: {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
};
|
||||
};
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
index: number;
|
||||
projectId: string;
|
||||
}
|
||||
export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, widget, zoneId, index, projectId, userId } = data;
|
||||
const { organization, widget, zoneUuid, index, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -85,16 +85,16 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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({
|
||||
floatWidgetID: widget.id,
|
||||
isArchive: false,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
});
|
||||
if (existingFloatWidget) {
|
||||
const updateFloatWidget = await floatWidgetModel(
|
||||
@@ -122,7 +122,7 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
||||
const floatUpdateDatas = {
|
||||
position: updateFloatWidget.position,
|
||||
index: index,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
return { status: "Widget updated successfully", data: floatUpdateDatas };
|
||||
@@ -135,7 +135,7 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
||||
position: widget.position,
|
||||
per: widget.per,
|
||||
value: widget.value,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
});
|
||||
if (newFloadWidget) {
|
||||
const floatDatas = {
|
||||
@@ -147,7 +147,7 @@ export const AddFloat = async (data: IAddFloatData): Promise<IResult> => {
|
||||
className: newFloadWidget.className,
|
||||
id: newFloadWidget.floatWidgetID,
|
||||
},
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
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> => {
|
||||
try {
|
||||
const { organization, floatWidgetID, zoneId, projectId, userId } = data;
|
||||
const { organization, floatWidgetID, zoneUuid, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) { return { status: "User not found" } }
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -179,11 +179,11 @@ export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) { return { status: "Project not found" } }
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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({
|
||||
floatWidgetID: floatWidgetID,
|
||||
@@ -199,7 +199,7 @@ export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
|
||||
if (widgetData) {
|
||||
const floatDeleteData = {
|
||||
floatWidgetID: findfloatWidget.floatWidgetID,
|
||||
zoneId: findfloatWidget.zoneId,
|
||||
zoneUuid: findfloatWidget.zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
return { status: "Success", data: floatDeleteData };
|
||||
@@ -222,7 +222,7 @@ export const DuplicateFloat = async (
|
||||
data: IDuplicateFloatData
|
||||
): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, widget, zoneId, index, projectId, userId } = data;
|
||||
const { organization, widget, zoneUuid, index, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) {return { status: "User not found" }};
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -232,16 +232,16 @@ export const DuplicateFloat = async (
|
||||
);
|
||||
if (!LivingProject) {return { status: "Project not found" }};
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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({
|
||||
floatWidgetID: widget.id,
|
||||
isArchive: false,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
});
|
||||
if (existingFloatWidget) {
|
||||
const updateFloatWidget = await floatWidgetModel(
|
||||
@@ -272,7 +272,7 @@ export const DuplicateFloat = async (
|
||||
const floatUpdateDatas = {
|
||||
position: updateFloatWidget.position,
|
||||
index: index,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
return {
|
||||
@@ -287,7 +287,7 @@ export const DuplicateFloat = async (
|
||||
position: widget.position,
|
||||
per: widget.per,
|
||||
value: widget.value,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
Data: {
|
||||
measurements: widget?.Data?.measurements,
|
||||
duration: widget?.Data?.duration,
|
||||
@@ -303,7 +303,7 @@ export const DuplicateFloat = async (
|
||||
className: newFloadWidget.className,
|
||||
id: newFloadWidget.floatWidgetID,
|
||||
},
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
index: index,
|
||||
};
|
||||
@@ -330,7 +330,7 @@ export const DuplicateFloat = async (
|
||||
|
||||
export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, zoneId, projectId, userId } = data;
|
||||
const { organization, zoneUuid, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) {return { status: "User not found" }}
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -340,17 +340,17 @@ export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) {return { status: "Project not found" }};
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!existingZone) return { status: "Zone not found" };
|
||||
const widgetData = await floatWidgetModel(organization)
|
||||
.find({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
})
|
||||
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
||||
.select("-_id -zoneUuid -createdAt -updatedAt -__v");
|
||||
if (!widgetData || widgetData.length === 0) {
|
||||
return { status: "All Datas" };
|
||||
}
|
||||
@@ -394,7 +394,7 @@ export const SingleFloatWidget = async (
|
||||
floatWidgetID: floatWidgetID,
|
||||
isArchive: false,
|
||||
})
|
||||
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
||||
.select("-_id -zoneUuid -createdAt -updatedAt -__v");
|
||||
if (!widgetData || widgetData.length === 0) {
|
||||
return { status: "Widget not found" };
|
||||
}
|
||||
|
||||
@@ -11,28 +11,28 @@ interface IResult {
|
||||
}
|
||||
interface IAddPanel {
|
||||
organization: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
panelOrder: string[];
|
||||
userId: string;
|
||||
projectId: string;
|
||||
}
|
||||
interface IPanel {
|
||||
organization: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
panelName: string;
|
||||
userId: string;
|
||||
projectId: string;
|
||||
}
|
||||
interface ILockedPanel {
|
||||
organization: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
lockedPanel: string[];
|
||||
userId: string;
|
||||
projectId: string;
|
||||
}
|
||||
export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, zoneId, panelOrder, userId, projectId } = data;
|
||||
const { organization, zoneUuid, panelOrder, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -42,18 +42,18 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!existingZone) return { status: "Zone not found" };
|
||||
await zoneModel(organization).findOneAndUpdate(
|
||||
{ zoneId: zoneId, isArchive: false },
|
||||
{ zoneUuid: zoneUuid, isArchive: false },
|
||||
{ panelOrder: panelOrder },
|
||||
{ new: true }
|
||||
);
|
||||
const existingPanels = await panelModel(organization).find({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
const createdPanels = [];
|
||||
for (const panelName of missingPanels) {
|
||||
const newPanel = await panelModel(organization).create({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
panelName: panelName,
|
||||
widgets: [],
|
||||
isArchive: false,
|
||||
@@ -82,7 +82,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
|
||||
const zoneAndPanelData = await getZoneAndPanelData(
|
||||
organization,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
projectId
|
||||
);
|
||||
if (!zoneAndPanelData) {
|
||||
@@ -103,7 +103,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
};
|
||||
export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, zoneId, panelName, userId, projectId } = data;
|
||||
const { organization, zoneUuid, panelName, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -113,13 +113,13 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!existingZone) return { status: "Zone not found" };
|
||||
const existingPanel = await panelModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
panelName: panelName,
|
||||
isArchive: false,
|
||||
});
|
||||
@@ -147,7 +147,7 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||
}
|
||||
const zoneAndPanelData = await getZoneAndPanelData(
|
||||
organization,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
projectId
|
||||
);
|
||||
if (!zoneAndPanelData) {
|
||||
@@ -168,7 +168,7 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||
};
|
||||
export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, zoneId, panelName, userId, projectId } = data;
|
||||
const { organization, zoneUuid, panelName, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -178,13 +178,13 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!existingZone) return { status: "Zone not found" };
|
||||
const existingPanel = await panelModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
panelName: panelName,
|
||||
isArchive: false,
|
||||
});
|
||||
@@ -212,7 +212,7 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
|
||||
const zoneAndPanelData = await getZoneAndPanelData(
|
||||
organization,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
projectId
|
||||
);
|
||||
if (!zoneAndPanelData) {
|
||||
@@ -237,7 +237,7 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
};
|
||||
export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, zoneId, lockedPanel, userId, projectId } = data;
|
||||
const { organization, zoneUuid, lockedPanel, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -247,14 +247,14 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!existingZone) return { status: "Zone not found" };
|
||||
else {
|
||||
const updateLockedPanel = await zoneModel(organization).findOneAndUpdate(
|
||||
{ zoneId: zoneId, isArchive: false },
|
||||
{ zoneUuid: zoneUuid, isArchive: false },
|
||||
{
|
||||
lockedPanel: lockedPanel,
|
||||
},
|
||||
@@ -262,7 +262,7 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
||||
);
|
||||
const zoneAndPanelData = await getZoneAndPanelData(
|
||||
organization,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
projectId
|
||||
);
|
||||
if (!zoneAndPanelData) {
|
||||
@@ -290,7 +290,7 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
||||
};
|
||||
const getZoneAndPanelData = async (
|
||||
organization: string,
|
||||
zoneId: string,
|
||||
zoneUuid: string,
|
||||
projectId: string
|
||||
) => {
|
||||
try {
|
||||
@@ -298,18 +298,18 @@ const getZoneAndPanelData = async (
|
||||
|
||||
const existingZone = await zoneModel(organization)
|
||||
.findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
})
|
||||
.select(
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition"
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneUuid viewPortCenter viewPortposition"
|
||||
);
|
||||
if (!existingZone) {
|
||||
return { status: "Zone not found" };
|
||||
} else {
|
||||
const panelData = await panelModel(organization).find({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
const zoneName = existingZone.zoneName as string;
|
||||
@@ -336,7 +336,7 @@ const getZoneAndPanelData = async (
|
||||
const objectData = {
|
||||
zoneName,
|
||||
viewPortposition: existingZone.viewPortposition,
|
||||
zoneId: existingZone.zoneId,
|
||||
zoneUuid: existingZone.zoneUuid,
|
||||
viewPortCenter: existingZone.viewPortCenter,
|
||||
activeSides: existingZone.panelOrder || [],
|
||||
panelOrder: existingZone.panelOrder || [],
|
||||
|
||||
@@ -29,7 +29,7 @@ interface ITemplateToZone {
|
||||
organization: string;
|
||||
templateID: string;
|
||||
projectId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
userId: string;
|
||||
}
|
||||
interface ITemplate {
|
||||
@@ -102,7 +102,7 @@ export const AddTemplateToZone = async (
|
||||
data: ITemplateToZone
|
||||
): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, templateID, projectId, zoneId, userId } = data;
|
||||
const { organization, templateID, projectId, zoneUuid, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -112,7 +112,7 @@ export const AddTemplateToZone = async (
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
@@ -135,7 +135,7 @@ export const AddTemplateToZone = async (
|
||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||
await existingZone.save();
|
||||
const archivePanelDatas = await panelModel(organization).find({
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
for (const panelData of archivePanelDatas) {
|
||||
@@ -145,18 +145,18 @@ export const AddTemplateToZone = async (
|
||||
});
|
||||
}
|
||||
await panelModel(organization).deleteMany({
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
await floatWidgetModel(organization).deleteMany({
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
}
|
||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||
await existingZone.save();
|
||||
const existingPanels = await panelModel(organization).find({
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
const existingPanelNames = existingPanels.map(
|
||||
@@ -169,7 +169,7 @@ export const AddTemplateToZone = async (
|
||||
await Promise.all(
|
||||
missingPanels.map((panelName: any) =>
|
||||
panelModel(organization).create({
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
panelName,
|
||||
widgets: [],
|
||||
isArchive: false,
|
||||
@@ -180,7 +180,7 @@ export const AddTemplateToZone = async (
|
||||
for (const widgetData of existingTemplate.widgets) {
|
||||
const addedExistingPanel = await panelModel(organization).findOne({
|
||||
panelName: widgetData.panel,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!addedExistingPanel) continue;
|
||||
@@ -195,7 +195,7 @@ export const AddTemplateToZone = async (
|
||||
const newWidget = await widgetModel(organization).create({
|
||||
widgetID: widgetData.id,
|
||||
elementType: widgetData.type,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
widgetName: widgetData.widgetName || "Widget",
|
||||
panelID: addedExistingPanel._id,
|
||||
widgetside: widgetData.panel,
|
||||
@@ -208,7 +208,7 @@ export const AddTemplateToZone = async (
|
||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||
floatWidgetID: floatData.id,
|
||||
isArchive: false,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
});
|
||||
if (existingFloatWidget) continue;
|
||||
|
||||
@@ -219,7 +219,7 @@ export const AddTemplateToZone = async (
|
||||
position: floatData.position,
|
||||
per: floatData.per,
|
||||
value: floatData.value,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
});
|
||||
}
|
||||
const templateZoneDatas = {
|
||||
@@ -231,7 +231,7 @@ export const AddTemplateToZone = async (
|
||||
snapshot: existingTemplate.snapshot,
|
||||
floatingWidget: existingTemplate.floatWidgets,
|
||||
},
|
||||
zoneId: existingZone.zoneId,
|
||||
zoneUuid: existingZone.zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ interface IWidget3DAdd {
|
||||
};
|
||||
};
|
||||
projectId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
userId: string;
|
||||
}
|
||||
interface IWidget3dUpdate {
|
||||
organization: string;
|
||||
id: string;
|
||||
projectId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
userId: string;
|
||||
}
|
||||
interface IWidgetUpdate {
|
||||
@@ -36,18 +36,18 @@ interface IWidgetUpdate {
|
||||
position: [];
|
||||
rotation: [];
|
||||
projectId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
userId: string;
|
||||
}
|
||||
interface I3dWidgetGet {
|
||||
organization: string;
|
||||
projectId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
userId: string;
|
||||
}
|
||||
export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, widget, userId, zoneId, projectId } = data;
|
||||
const { organization, widget, userId, zoneUuid, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -57,11 +57,11 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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({
|
||||
widgetID: widget.id,
|
||||
@@ -71,7 +71,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
||||
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
||||
{
|
||||
widgetID: widget.id,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
},
|
||||
{ position: widget.position },
|
||||
@@ -87,7 +87,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
||||
type: widget.type,
|
||||
widgetID: widget.id,
|
||||
position: widget.position,
|
||||
zoneId,
|
||||
zoneUuid,
|
||||
Data: {
|
||||
measurements: widget?.Data?.measurements || {},
|
||||
duration: widget?.Data?.duration || "1h",
|
||||
@@ -101,7 +101,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
||||
position: newWidget3d.position,
|
||||
},
|
||||
Data: newWidget3d.Data,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -125,7 +125,7 @@ export const Add3DWidget = async (data: IWidget3DAdd): Promise<IResult> => {
|
||||
};
|
||||
export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, id, position, rotation, userId, zoneId, projectId } =
|
||||
const { organization, id, position, rotation, userId, zoneUuid, projectId } =
|
||||
data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
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" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
@@ -148,14 +148,14 @@ export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
||||
|
||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||
widgetID: id,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (existing3Dwidget) {
|
||||
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
||||
{
|
||||
widgetID: id,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
},
|
||||
{ position: position, rotation: rotation },
|
||||
@@ -169,7 +169,7 @@ export const Update3Dwidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
||||
position: update3dwidget.position,
|
||||
rotation: update3dwidget.rotation,
|
||||
},
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
};
|
||||
return {
|
||||
status: "Success",
|
||||
@@ -196,7 +196,7 @@ export const Delete3Dwidget = async (
|
||||
data: IWidget3dUpdate
|
||||
): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, id, userId, zoneId, projectId } = data;
|
||||
const { organization, id, userId, zoneUuid, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -206,7 +206,7 @@ export const Delete3Dwidget = async (
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
@@ -218,7 +218,7 @@ export const Delete3Dwidget = async (
|
||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||
widgetID: id,
|
||||
isArchive: false,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
});
|
||||
if (!existing3Dwidget) {
|
||||
return { status: "3D widget not found for the ID" };
|
||||
@@ -226,7 +226,7 @@ export const Delete3Dwidget = async (
|
||||
const updateWidget = await widget3dModel(organization).findOneAndUpdate(
|
||||
{
|
||||
widgetID: id,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
},
|
||||
{ isArchive: true },
|
||||
@@ -234,7 +234,7 @@ export const Delete3Dwidget = async (
|
||||
);
|
||||
if (updateWidget) {
|
||||
const delete_Datas = {
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
id: existing3Dwidget.widgetID,
|
||||
};
|
||||
return {
|
||||
@@ -257,7 +257,7 @@ export const Delete3Dwidget = async (
|
||||
};
|
||||
export const Get3Dwidget = async (data: I3dWidgetGet): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, userId, zoneId, projectId } = data;
|
||||
const { organization, userId, zoneUuid, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -267,7 +267,7 @@ export const Get3Dwidget = async (data: I3dWidgetGet): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
projectId: projectId,
|
||||
});
|
||||
@@ -276,7 +276,7 @@ export const Get3Dwidget = async (data: I3dWidgetGet): Promise<IResult> => {
|
||||
status: "Zone not found",
|
||||
};
|
||||
const widgetData = await widget3dModel(organization).find({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!widgetData || widgetData.length === 0) {
|
||||
|
||||
@@ -12,7 +12,7 @@ interface IResult {
|
||||
interface IWidgetCreate {
|
||||
organization: string;
|
||||
userId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
projectId: string;
|
||||
widget: {
|
||||
type: string;
|
||||
@@ -28,14 +28,14 @@ interface IWidgetCreate {
|
||||
interface IWidgetDelete {
|
||||
organization: string;
|
||||
userId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
projectId: string;
|
||||
widgetID: string;
|
||||
}
|
||||
interface IWidgetUpdate {
|
||||
organization: string;
|
||||
userId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
projectId: string;
|
||||
widgetID: string;
|
||||
values: {
|
||||
@@ -55,13 +55,13 @@ interface IWidgetUpdate {
|
||||
interface IGetWidget {
|
||||
organization: string;
|
||||
userId: string;
|
||||
zoneId: string;
|
||||
zoneUuid: string;
|
||||
projectId: string;
|
||||
widgetID: string;
|
||||
}
|
||||
export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, widget, userId, zoneId, projectId } = data;
|
||||
const { organization, widget, userId, zoneUuid, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -71,15 +71,15 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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({
|
||||
panelName: widget.panel,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingPanel) return { status: "panelName not found" };
|
||||
@@ -121,7 +121,7 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
||||
widgetName: widget.title,
|
||||
panelID: existingPanel._id,
|
||||
widgetside: widget.panel,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
Data: {
|
||||
measurements: widget?.Data?.measurements || {},
|
||||
duration: widget?.Data?.duration || "1hr",
|
||||
@@ -138,7 +138,7 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
||||
};
|
||||
const finaldata = {
|
||||
widgetData: widgetData,
|
||||
zoneId: existingZone.zoneId,
|
||||
zoneUuid: existingZone.zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
return {
|
||||
@@ -164,7 +164,7 @@ export const AddWidget = async (data: IWidgetCreate): Promise<IResult> => {
|
||||
};
|
||||
export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, widgetID, userId, zoneId, projectId } = data;
|
||||
const { organization, widgetID, userId, zoneUuid, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -174,35 +174,35 @@ export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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({
|
||||
widgetID: widgetID,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!findWidget) return { status: "Widget not found" };
|
||||
|
||||
const widgetData = await widgetModel(organization).updateOne(
|
||||
{ _id: findWidget._id, isArchive: false, zoneId: zoneId },
|
||||
{ _id: findWidget._id, isArchive: false, zoneUuid: zoneUuid },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
if (widgetData) {
|
||||
await widgetModel(organization).find({
|
||||
panelID: findWidget.panelID,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
const panelData = await panelModel(organization).findOne({
|
||||
_id: findWidget.panelID,
|
||||
isArchive: false,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
});
|
||||
if (panelData.widgets.includes(findWidget._id)) {
|
||||
const index1 = panelData.widgets.indexOf(findWidget._id);
|
||||
@@ -211,7 +211,7 @@ export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
||||
await panelData.save();
|
||||
|
||||
const activeWidgets = await widgetModel(organization).find({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
@@ -227,7 +227,7 @@ export const WidgetDelete = async (data: IWidgetDelete): Promise<IResult> => {
|
||||
}));
|
||||
const widgetData1 = {
|
||||
widgetDeleteDatas: formattedWidgets,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
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> => {
|
||||
try {
|
||||
const { organization, widgetID, userId, projectId, zoneId, values } = data;
|
||||
const { organization, widgetID, userId, projectId, zoneUuid, values } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -257,15 +257,15 @@ export const UpdateWidget = async (data: IWidgetUpdate): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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({
|
||||
widgetID: widgetID,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
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> => {
|
||||
try {
|
||||
const { organization, widgetID, userId, projectId, zoneId } = data;
|
||||
const { organization, widgetID, userId, projectId, zoneUuid } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
@@ -321,16 +321,16 @@ export const GetWidget = async (data: IGetWidget): Promise<IResult> => {
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
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)
|
||||
.findOne({
|
||||
widgetID: widgetID,
|
||||
zoneId: zoneId,
|
||||
zoneUuid: zoneUuid,
|
||||
isArchive: false,
|
||||
})
|
||||
.select("Data widgetName -_id");
|
||||
|
||||
Reference in New Issue
Block a user