IsArchive updated and AssetPosition API updated
This commit is contained in:
@@ -3,5 +3,9 @@ import { assetsFloorservice } from "../controller/simulation/assetsFloorservice.
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/setasset", assetsFloorservice.setFloorassets);
|
router.post("/setasset", assetsFloorservice.setFloorassets);
|
||||||
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
||||||
|
router.patch(
|
||||||
|
"/updateFloorAssets",
|
||||||
|
assetsFloorservice.updateAssetPositionRotation
|
||||||
|
);
|
||||||
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ export class assetsFloorservice {
|
|||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modeluuid,
|
modeluuid,
|
||||||
modelname,
|
modelname,
|
||||||
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (findvalue) {
|
if (findvalue) {
|
||||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modeluuid, modelname },
|
{ modeluuid, modelname,isArchive:false },
|
||||||
{
|
{
|
||||||
position,
|
position,
|
||||||
rotation,
|
rotation,
|
||||||
@@ -125,7 +126,7 @@ export class assetsFloorservice {
|
|||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
const findValues = await assetModel(organization)
|
const findValues = await assetModel(organization)
|
||||||
.find()
|
.find({ isArchive: false })
|
||||||
.select("-_id")
|
.select("-_id")
|
||||||
.populate({
|
.populate({
|
||||||
path: "points",
|
path: "points",
|
||||||
@@ -173,13 +174,14 @@ export class assetsFloorservice {
|
|||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async deleteFloorItems(req: Request, res: Response) {
|
static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { modeluuid, modelname, organization } = req.body;
|
const { modeluuid, modelname, organization } = req.body;
|
||||||
|
|
||||||
const findValue = await assetModel(organization).findOneAndDelete({
|
const findValue = await assetModel(organization).findOneAndDelete({
|
||||||
modeluuid: modeluuid,
|
modeluuid: modeluuid,
|
||||||
modelname: modelname,
|
modelname: modelname,
|
||||||
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("user not found");
|
res.status(200).json("user not found");
|
||||||
@@ -191,6 +193,42 @@ export class assetsFloorservice {
|
|||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static async updateAssetPositionRotation(
|
||||||
|
req: Request,
|
||||||
|
res: Response
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
modeluuid,
|
||||||
|
modelname,
|
||||||
|
position,
|
||||||
|
modelfileID,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
organization,
|
||||||
|
// eventData, // Optional
|
||||||
|
} = req.body;
|
||||||
|
|
||||||
|
const existingAsset = await assetModel(organization).findOne({
|
||||||
|
modeluuid: modeluuid,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingAsset) return res.send("Asset not found");
|
||||||
|
const updateAsset = await assetModel(organization).updateMany(
|
||||||
|
{ modeluuid: modeluuid, modelname: modelname, isArchive: false },
|
||||||
|
{
|
||||||
|
position: position,
|
||||||
|
rotation: rotation,
|
||||||
|
isVisible: isVisible,
|
||||||
|
isLocked: isLocked,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (updateAsset)
|
||||||
|
return res.status(200).json({ message: "Asset updated successfully" });
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
static async updateActionsDatas(req: Request, res: Response) {}
|
static async updateActionsDatas(req: Request, res: Response) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ export class widgetService {
|
|||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
elementType: widget.type,
|
elementType: widget.type,
|
||||||
// widgetOrder: widgetOrder,
|
// widgetOrder: widgetOrder,
|
||||||
|
zoneId,
|
||||||
widgetName: widget.title,
|
widgetName: widget.title,
|
||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
widgetside: widget.panel,
|
widgetside: widget.panel,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export interface assetData extends Document {
|
|||||||
isLocked: boolean;
|
isLocked: boolean;
|
||||||
type: string;
|
type: string;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
|
isArchive:false
|
||||||
// position: [];
|
// position: [];
|
||||||
// rotation: {
|
// rotation: {
|
||||||
// x: number;
|
// x: number;
|
||||||
@@ -45,6 +46,7 @@ export interface assetData extends Document {
|
|||||||
|
|
||||||
// Define the Mongoose Schema
|
// Define the Mongoose Schema
|
||||||
const assetDataSchema: Schema = new Schema({
|
const assetDataSchema: Schema = new Schema({
|
||||||
|
isArchive:{type:Boolean,default:false},
|
||||||
modeluuid: { type: String },
|
modeluuid: { type: String },
|
||||||
modelfileID: { type: String },
|
modelfileID: { type: String },
|
||||||
modelname: { type: String },
|
modelname: { type: String },
|
||||||
|
|||||||
@@ -21,12 +21,13 @@ export const setAssetModel = async (data: any) => {
|
|||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modeluuid: modeluuid,
|
modeluuid: modeluuid,
|
||||||
modelname: modelname,
|
modelname: modelname,
|
||||||
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (findvalue) {
|
if (findvalue) {
|
||||||
console.log("findvalue: ", findvalue);
|
console.log("findvalue: ", findvalue);
|
||||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modeluuid: modeluuid, modelname: modelname },
|
{ modeluuid: modeluuid, modelname: modelname, isArchive: false },
|
||||||
{
|
{
|
||||||
position: position,
|
position: position,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
@@ -149,6 +150,7 @@ export const deleteAssetModel = async (data: any) => {
|
|||||||
const findValue = await assetModel(organization).findOneAndDelete({
|
const findValue = await assetModel(organization).findOneAndDelete({
|
||||||
modeluuid: modeluuid,
|
modeluuid: modeluuid,
|
||||||
modelname: modelname,
|
modelname: modelname,
|
||||||
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user