widget 2d, floating Data model added
This commit is contained in:
@@ -129,10 +129,10 @@ export class widget3dService {
|
||||
widgetID: id,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!widgetData) return res.send("WidgetID not found");
|
||||
if (!widgetData) return res.status(204).json({ message: "Widget not found" });
|
||||
const structureData = {
|
||||
measurements: widgetData?.Data.measurements,
|
||||
duration: widgetData?.Data.duration,
|
||||
measurements: widgetData?.Data?.measurements,
|
||||
duration: widgetData?.Data?.duration,
|
||||
};
|
||||
const widgetName = widgetData.widgetName;
|
||||
return res.status(200).json({ Data: structureData, widgetName });
|
||||
|
||||
@@ -127,11 +127,11 @@ export class floatWidgetService {
|
||||
})
|
||||
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
||||
if (!widgetData || widgetData.length === 0) {
|
||||
return res.send([]);
|
||||
return res.status(204).json({ message: "Widget not found" });
|
||||
}
|
||||
const Datastructure = {
|
||||
measurements: widgetData?.Data.measurements || {},
|
||||
duration: widgetData?.Data.duration || "1h",
|
||||
measurements: widgetData?.Data?.measurements || {},
|
||||
duration: widgetData?.Data?.duration || "1h",
|
||||
};
|
||||
const header = widgetData?.header;
|
||||
return res.status(200).json({ Data: Datastructure, header });
|
||||
|
||||
@@ -50,14 +50,18 @@ export class widgetService {
|
||||
// widgetID: widget.id,
|
||||
widgetName: widget?.widgetName,
|
||||
Data: {
|
||||
measurements: widget.Data?.measurements || {},
|
||||
duration: widget.Data?.duration || "1h",
|
||||
measurements: widget?.Data?.measurements || {},
|
||||
duration: widget?.Data?.duration || "1h",
|
||||
},
|
||||
// isArchive: false,
|
||||
isArchive: false,
|
||||
},
|
||||
},
|
||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
||||
);
|
||||
console.log("updateWidget: ", updateWidget);
|
||||
if (!updateWidget) {
|
||||
return res.json({ message: "Widget update unsuccessful" });
|
||||
}
|
||||
return res
|
||||
.status(200)
|
||||
.json({ message: "Widget updated successfully" });
|
||||
@@ -73,10 +77,10 @@ export class widgetService {
|
||||
widgetName: widget.title,
|
||||
panelID: existingPanel._id,
|
||||
widgetside: widget.panel,
|
||||
// Data: {
|
||||
// measurements: widget.Data.measurements || {},
|
||||
// duration: widget.Data.duration || "1h",
|
||||
// },
|
||||
Data: {
|
||||
measurements: widget?.Data?.measurements || {},
|
||||
duration: widget?.Data?.duration || "1h",
|
||||
},
|
||||
});
|
||||
if (newWidget) {
|
||||
existingPanel.widgets.push(newWidget._id);
|
||||
|
||||
Reference in New Issue
Block a user