tango-app-api-store-zone 3.0.9-dev → 3.0.11-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-store-zone",
3
- "version": "3.0.9-dev",
3
+ "version": "3.0.11-dev",
4
4
  "description": "zone",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -13,7 +13,7 @@ export const addCustomTag = async ( req, res ) => {
13
13
  storeId: inputData.storeId,
14
14
  tagName: inputData.tagName,
15
15
  };
16
- await taggingService.deleteMany( { clientId: inputData.clientId, tagName: inputData.tagName, isDeleted: true } );
16
+ await taggingService.deleteMany( { clientId: inputData.clientId, storeId: inputData.storeId, tagName: inputData.tagName, isDeleted: true } );
17
17
  await taggingService.create( data );
18
18
  }
19
19
  logger.info( 'Tag Created Successfully' );
@@ -43,16 +43,17 @@ export const customTagList = async ( req, res ) => {
43
43
  customTagList.push( ...defaultZone );
44
44
  let tagInfo = await taggingService.find( { clientId: req.query.clientId }, { tagName: 1 } );
45
45
  let deletedTag = await taggingService.find( { clientId: req.query.clientId, isDeleted: true }, { storeId: 1, tagName: 1 } );
46
+ tagInfo = [ ...new Set( tagInfo.map( ( item ) => item.tagName ) ) ];
46
47
  deletedTag.forEach( ( item ) => {
47
- let findTag = tagInfo.findIndex( ( tag ) => tag.tagName == item.tagName && item.storeId == req.query.storeId );
48
+ let findTag = tagInfo.findIndex( ( tag ) => tag == item.tagName && item.storeId == req.query.storeId );
48
49
  if ( findTag != -1 ) {
49
50
  tagInfo.splice( findTag, 1 );
50
51
  }
51
52
  } );
52
53
  if ( tagInfo.length ) {
53
54
  tagInfo.forEach( ( item ) => {
54
- if ( !customTagList.includes( item.tagName ) ) {
55
- customTagList.push( item.tagName );
55
+ if ( !customTagList.includes( item ) ) {
56
+ customTagList.push( item );
56
57
  }
57
58
  } );
58
59
  }
@@ -119,8 +120,9 @@ export const tagging = async ( req, res ) => {
119
120
  eventType: 'add Tagging',
120
121
  };
121
122
  insertOpenSearchData( 'tango-retail-activity-logs', logObj );
122
- await taggingService.create( InputData );
123
+ let response = await taggingService.create( InputData );
123
124
  await taggingService.deleteOne( { clientId: InputData.clientId, storeId: InputData.storeId, cameraId: { $exists: false }, tagName: InputData.tagName } );
125
+ await axios.post( `${appConfig.url.oldapidomain}/tagging/oldTaggingAdd`, [ response ], { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => logger.info( res?.data ) ).catch( ( error ) => logger.error( { error: error } ) );
124
126
  } else {
125
127
  const logObj = {
126
128
  clientId: InputData.clientId,
@@ -143,6 +145,11 @@ export const tagging = async ( req, res ) => {
143
145
  if ( InputData.coordinates[0].coor.length ) {
144
146
  taggingDetails.coordinates.push( InputData.coordinates[0] );
145
147
  taggingDetails.save();
148
+ await axios.post( `${appConfig.url.oldapidomain}/tagging/oldTaggingUpdate/${taggingDetails._id}`, taggingDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => {
149
+ logger.info( res?.data );
150
+ } ).catch( ( error ) => {
151
+ logger.error( { error: error } );
152
+ } );
146
153
  } else {
147
154
  return res.sendError( 'coordinate is required', 500 );
148
155
  }
@@ -195,7 +202,7 @@ export const getCameraList = async ( req, res ) => {
195
202
  baseImg: '',
196
203
  tagImg: '',
197
204
  };
198
- let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.query.clientId }, { tagName: 1, coordinates: 1 } );
205
+ let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.query.clientId, isDeleted: false }, { tagName: 1, coordinates: 1 } );
199
206
  if ( taggingDetails.length ) {
200
207
  tagList = taggingDetails.map( ( item ) => {
201
208
  if ( item.coordinates.length ) {
@@ -255,12 +262,19 @@ export const updateTag = async ( req, res ) => {
255
262
  if ( !taggingDetails ) {
256
263
  return res.sendError( 'no data found', 204 );
257
264
  }
258
- let tagUpdate = await taggingService.updateMany( { clientId: req.body.clientId, tagName: req.body.existTag, isDeleted: false }, { tagName: req.body.tagName } );
259
- await taggingService.deleteMany( { clientId: req.body.clientId, tagName: req.body.tagName, isDeleted: true } );
265
+ let tagUpdate = await taggingService.updateMany( { clientId: req.body.clientId, tagName: req.body.existTag }, { tagName: req.body.tagName } );
266
+ // await taggingService.deleteMany( { clientId: req.body.clientId, tagName: req.body.existTag, isDeleted: true } );
260
267
  if ( tagUpdate.modifiedCount ) {
261
268
  logger.info( 'Custom Tag Updated Successfully' );
262
269
  return res.sendSuccess( 'Custom Tag Updated Successfully' );
263
270
  }
271
+ taggingDetails.forEach( async ( item ) => {
272
+ await axios.post( `${appConfig.url.oldapidomain}/tagging/oldTaggingUpdate/${item._id}`, item, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => {
273
+ logger.info( res?.data );
274
+ } ).catch( ( error ) => {
275
+ logger.error( { error: error } );
276
+ } );
277
+ } );
264
278
  const logObj = {
265
279
  clientId: req.body.clientId,
266
280
  storeId: taggingDetails?.storeId,
@@ -283,7 +297,7 @@ export const updateTag = async ( req, res ) => {
283
297
 
284
298
  export const deleteTag = async ( req, res ) => {
285
299
  try {
286
- let taggingDetails = await taggingService.find( { clientId: req.body.clientId, tagName: req.body.tagName, isDeleted: false }, { storeId: 1 } );
300
+ let taggingDetails = await taggingService.find( { clientId: req.body.clientId, tagName: req.body.tagName }, { storeId: 1 } );
287
301
  if ( !taggingDetails.length ) {
288
302
  return res.sendError( 'no data found', 204 );
289
303
  }
@@ -302,8 +316,24 @@ export const deleteTag = async ( req, res ) => {
302
316
  if ( req.user?.role == 'superadmin' || ( req.user?.role == 'admin' && enableDelete ) ) {
303
317
  await taggingService.deleteMany( { clientId: req.body.clientId, tagName: req.body.tagName } );
304
318
  } else {
305
- await taggingService.updateOne( { clientId: req.body.clientId, storeId: req.body.storeId, tagName: req.body.tagName }, { isDeleted: true } );
319
+ let deleteTag = await taggingService.updateOne( { clientId: req.body.clientId, storeId: req.body.storeId, tagName: req.body.tagName }, { isDeleted: true } );
320
+ if ( !deleteTag.modifiedCount ) {
321
+ let data = {
322
+ clientId: req.body.clientId,
323
+ storeId: req.body.storeId,
324
+ tagName: req.body.tagName,
325
+ isDeleted: true,
326
+ };
327
+ taggingService.create( data );
328
+ }
306
329
  }
330
+ taggingDetails.forEach( async ( item ) => {
331
+ await axios.post( `${appConfig.url.oldapidomain}/tagging/oldTaggingDelete/${item._id}`, '', { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => {
332
+ logger.info( res?.data );
333
+ } ).catch( ( error ) => {
334
+ logger.error( { error: error } );
335
+ } );
336
+ } );
307
337
  const logObj = {
308
338
  clientId: req.body?.clientId,
309
339
  storeId: taggingDetails ? taggingDetails.map( ( item ) => item?.storeId ) : '',
@@ -333,7 +363,7 @@ export const getCameraTagging = async ( req, res ) => {
333
363
  return res.sendError( 'no data found', 204 );
334
364
  }
335
365
  if ( camDetails ) {
336
- query = { clientId: req.query.clientId, cameraId: camDetails._id, streamName: camDetails.streamName, storeId: req.query.storeId };
366
+ query = { clientId: req.query.clientId, cameraId: camDetails._id, streamName: camDetails.streamName, storeId: req.query.storeId, isDeleted: false };
337
367
  if ( req.query?.tagName != 'undefined' && req.query?.tagName != '' ) {
338
368
  query.tagName = req.query.tagName;
339
369
  }
@@ -396,7 +426,7 @@ async function getCamTaggingDetails( req, res ) {
396
426
  }
397
427
  let result = [];
398
428
  for ( let camera of camDetails ) {
399
- let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, storeId: req.body.storeId, clientId: camera.clientId } );
429
+ let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, storeId: req.body.storeId, clientId: camera.clientId, isDeleted: false } );
400
430
  let zoneList = [];
401
431
  if ( taggingDetails.length ) {
402
432
  taggingDetails.forEach( ( zone ) => {