Controller and routing for the Vizualtion and builder
This commit is contained in:
@@ -69,11 +69,6 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
|
||||
if (createdPanels.length === 0) {
|
||||
return { status: "No new panels were created. All panels already exist" };
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "No new panels were created. All panels already exist",
|
||||
// organization: organization,
|
||||
// };
|
||||
}
|
||||
|
||||
const zoneAndPanelData = await getZoneAndPanelData(
|
||||
@@ -85,12 +80,6 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
return zoneAndPanelData;
|
||||
}
|
||||
return { status: "Success", data: zoneAndPanelData };
|
||||
// return {
|
||||
// success: true,
|
||||
// message: "Panels created successfully",
|
||||
// data: zoneAndPanelData,
|
||||
// organization: organization,
|
||||
// };
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
@@ -120,11 +109,7 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingPanel) return { status: "Panel Already Deleted" };
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Panel Already Deleted",
|
||||
// organization: organization,
|
||||
// };
|
||||
|
||||
await panelModel(organization).updateOne(
|
||||
{ _id: existingPanel._id, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
@@ -154,12 +139,6 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||
return zoneAndPanelData;
|
||||
}
|
||||
return { status: "Success", data: zoneAndPanelData };
|
||||
// return {
|
||||
// success: true,
|
||||
// message: "Panel deleted successfully",
|
||||
// data: zoneAndPanelData,
|
||||
// organization: organization,
|
||||
// };
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
@@ -189,22 +168,13 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingPanel) return { status: "Requested Panel not found" };
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Requested Panel not found",
|
||||
// organization: organization,
|
||||
// };
|
||||
|
||||
const existingWidgets = await widgetModel(organization).find({
|
||||
panelID: existingPanel._id,
|
||||
isArchive: false,
|
||||
});
|
||||
if (existingWidgets.length === 0) return { status: "No widgets to clear" };
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "No widgets to clear",
|
||||
// organization: organization,
|
||||
// };
|
||||
|
||||
const clearWidgetsofPanel = await widgetModel(organization).updateMany(
|
||||
{ panelID: existingPanel._id, isArchive: false },
|
||||
{ isArchive: true }
|
||||
@@ -218,11 +188,6 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
);
|
||||
if (!clearWidgetsofPanel && !removeWidgetsInPanel)
|
||||
return { status: "Failed to clear widgets in panel" };
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Failed to clear widgets in panel",
|
||||
// organization: organization,
|
||||
// };
|
||||
|
||||
const zoneAndPanelData = await getZoneAndPanelData(
|
||||
organization,
|
||||
@@ -232,12 +197,7 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
if (!zoneAndPanelData) {
|
||||
return zoneAndPanelData;
|
||||
}
|
||||
// return {
|
||||
// success: true,
|
||||
// data: zoneAndPanelData,
|
||||
// message: "PanelWidgets cleared successfully",
|
||||
// organization: organization,
|
||||
// };
|
||||
|
||||
return {
|
||||
status: "Success",
|
||||
data: zoneAndPanelData,
|
||||
@@ -286,12 +246,6 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
||||
status: "Success",
|
||||
data: zoneAndPanelData,
|
||||
};
|
||||
// return {
|
||||
// success: true,
|
||||
// message: "locked panel updated successfully",
|
||||
// data: zoneAndPanelData,
|
||||
// organization: organization,
|
||||
// };
|
||||
}
|
||||
return { status: "locked panel not updated" };
|
||||
}
|
||||
@@ -324,11 +278,6 @@ const getZoneAndPanelData = async (
|
||||
);
|
||||
if (!existingZone) {
|
||||
return { status: "Zone not found" };
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Zone not found",
|
||||
// organization: organization,
|
||||
// };
|
||||
} else {
|
||||
const panelData = await panelModel(organization).find({
|
||||
zoneId: zoneId,
|
||||
@@ -371,11 +320,5 @@ const getZoneAndPanelData = async (
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
return { status: "Panel not found" };
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Panel not found",
|
||||
// error,
|
||||
// organization: organization,
|
||||
// };
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user