tango-app-api-store-zone 3.0.10-dev → 3.0.12-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.10-dev",
3
+ "version": "3.0.12-dev",
4
4
  "description": "zone",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -21,8 +21,8 @@
21
21
  "mongodb": "^6.5.0",
22
22
  "nodemon": "^3.1.0",
23
23
  "swagger-ui-express": "^5.0.0",
24
- "tango-api-schema": "^2.0.102",
25
- "tango-app-api-middleware": "^1.0.71-test",
24
+ "tango-api-schema": "^2.0.104",
25
+ "tango-app-api-middleware": "^1.0.73-test",
26
26
  "winston": "^3.13.0",
27
27
  "winston-daily-rotate-file": "^5.0.0"
28
28
  },
@@ -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' );
@@ -23,12 +23,13 @@ export const addCustomTag = async ( req, res ) => {
23
23
  userName: req.user?.userName,
24
24
  email: req.user?.email,
25
25
  date: new Date(),
26
- logType: 'add Zone',
27
- logSubType: inputData.tagName,
28
- changes: [ ],
29
- eventType: 'add',
26
+ logType: 'zone',
27
+ logSubType: 'addCustomTag',
28
+ changes: [ `${inputData.tagName} customtag Created.` ],
29
+ eventType: '',
30
+ showTo: [ 'client', 'tango' ],
30
31
  };
31
- insertOpenSearchData( 'tango-retail-activity-logs', logObj );
32
+ insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
32
33
  return res.sendSuccess( 'Tag Created Successfully' );
33
34
  } catch ( e ) {
34
35
  logger.error( { error: 'e', function: 'addCustomTag' } );
@@ -43,16 +44,17 @@ export const customTagList = async ( req, res ) => {
43
44
  customTagList.push( ...defaultZone );
44
45
  let tagInfo = await taggingService.find( { clientId: req.query.clientId }, { tagName: 1 } );
45
46
  let deletedTag = await taggingService.find( { clientId: req.query.clientId, isDeleted: true }, { storeId: 1, tagName: 1 } );
47
+ tagInfo = [ ...new Set( tagInfo.map( ( item ) => item.tagName ) ) ];
46
48
  deletedTag.forEach( ( item ) => {
47
- let findTag = tagInfo.findIndex( ( tag ) => tag.tagName == item.tagName && item.storeId == req.query.storeId );
49
+ let findTag = tagInfo.findIndex( ( tag ) => tag == item.tagName && item.storeId == req.query.storeId );
48
50
  if ( findTag != -1 ) {
49
51
  tagInfo.splice( findTag, 1 );
50
52
  }
51
53
  } );
52
54
  if ( tagInfo.length ) {
53
55
  tagInfo.forEach( ( item ) => {
54
- if ( !customTagList.includes( item.tagName ) ) {
55
- customTagList.push( item.tagName );
56
+ if ( !customTagList.includes( item ) ) {
57
+ customTagList.push( item );
56
58
  }
57
59
  } );
58
60
  }
@@ -113,12 +115,13 @@ export const tagging = async ( req, res ) => {
113
115
  userName: req.user?.userName,
114
116
  email: req.user?.email,
115
117
  date: new Date(),
116
- logType: 'add Zone Tagging',
117
- logSubType: InputData.tagName,
118
- changes: [ 'coordinates' ],
119
- eventType: 'add Tagging',
118
+ logType: 'zone',
119
+ logSubType: 'addZoneTagging',
120
+ changes: [ `${InputData.tagName} zone added tagging` ],
121
+ eventType: '',
122
+ showTo: [ 'client', 'tango' ],
120
123
  };
121
- insertOpenSearchData( 'tango-retail-activity-logs', logObj );
124
+ insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
122
125
  let response = await taggingService.create( InputData );
123
126
  await taggingService.deleteOne( { clientId: InputData.clientId, storeId: InputData.storeId, cameraId: { $exists: false }, tagName: InputData.tagName } );
124
127
  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 } ) );
@@ -129,12 +132,12 @@ export const tagging = async ( req, res ) => {
129
132
  userName: req.user?.userName,
130
133
  email: req.user?.email,
131
134
  date: new Date(),
132
- logType: 'add Zone Tagging',
133
- logSubType: InputData.tagName,
134
- changes: [ 'coordinates' ],
135
- eventType: 'update Tagging',
135
+ logType: 'zone',
136
+ logSubType: 'updateZoneTagging',
137
+ changes: [ `${InputData.tagName} zone Updated tagging` ],
138
+ eventType: '',
136
139
  };
137
- insertOpenSearchData( 'tango-retail-activity-logs', logObj );
140
+ insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
138
141
  taggingDetails.cameraId = InputData.cameraId;
139
142
  taggingDetails.streamName = InputData.streamName;
140
143
  if ( req.body?.redoPoint ) {
@@ -201,7 +204,7 @@ export const getCameraList = async ( req, res ) => {
201
204
  baseImg: '',
202
205
  tagImg: '',
203
206
  };
204
- let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.query.clientId }, { tagName: 1, coordinates: 1 } );
207
+ let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.query.clientId, isDeleted: false }, { tagName: 1, coordinates: 1 } );
205
208
  if ( taggingDetails.length ) {
206
209
  tagList = taggingDetails.map( ( item ) => {
207
210
  if ( item.coordinates.length ) {
@@ -261,8 +264,8 @@ export const updateTag = async ( req, res ) => {
261
264
  if ( !taggingDetails ) {
262
265
  return res.sendError( 'no data found', 204 );
263
266
  }
264
- let tagUpdate = await taggingService.updateMany( { clientId: req.body.clientId, tagName: req.body.existTag, isDeleted: false }, { tagName: req.body.tagName } );
265
- await taggingService.deleteMany( { clientId: req.body.clientId, tagName: req.body.tagName, isDeleted: true } );
267
+ let tagUpdate = await taggingService.updateMany( { clientId: req.body.clientId, tagName: req.body.existTag }, { tagName: req.body.tagName } );
268
+ // await taggingService.deleteMany( { clientId: req.body.clientId, tagName: req.body.existTag, isDeleted: true } );
266
269
  if ( tagUpdate.modifiedCount ) {
267
270
  logger.info( 'Custom Tag Updated Successfully' );
268
271
  return res.sendSuccess( 'Custom Tag Updated Successfully' );
@@ -280,12 +283,13 @@ export const updateTag = async ( req, res ) => {
280
283
  userName: req.user?.userName,
281
284
  email: req.user?.email,
282
285
  date: new Date(),
283
- logType: 'add Zone Tagging',
284
- logSubType: req.body.existTag,
285
- changes: [ 'tagName' ],
286
- eventType: 'update Custom Tag Name',
286
+ logType: 'zone',
287
+ logSubType: 'updateCustomTag',
288
+ changes: [ `${req.body.tagName} tagName Updated` ],
289
+ eventType: '',
290
+ showTo: [ 'client', 'tango' ],
287
291
  };
288
- insertOpenSearchData( 'tango-retail-activity-logs', logObj );
292
+ insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
289
293
  logger.error( { error: 'something went wrong', function: 'updateTag' } );
290
294
  return res.sendError( 'something went wrong', 500 );
291
295
  } catch ( e ) {
@@ -296,7 +300,7 @@ export const updateTag = async ( req, res ) => {
296
300
 
297
301
  export const deleteTag = async ( req, res ) => {
298
302
  try {
299
- let taggingDetails = await taggingService.find( { clientId: req.body.clientId, tagName: req.body.tagName, isDeleted: false }, { storeId: 1 } );
303
+ let taggingDetails = await taggingService.find( { clientId: req.body.clientId, tagName: req.body.tagName }, { storeId: 1 } );
300
304
  if ( !taggingDetails.length ) {
301
305
  return res.sendError( 'no data found', 204 );
302
306
  }
@@ -339,12 +343,13 @@ export const deleteTag = async ( req, res ) => {
339
343
  userName: req.user?.userName,
340
344
  email: req.user?.email,
341
345
  date: new Date(),
342
- logType: 'add Zone Tagging',
343
- logSubType: req.body?.tagName,
344
- changes: [ 'tagName' ],
345
- eventType: 'Delete Tagging Name',
346
+ logType: 'zone',
347
+ logSubType: 'deleteTag',
348
+ changes: [ `${req.body.tagName} tag Deleted` ],
349
+ eventType: '',
350
+ showTo: [ 'client', 'tango' ],
346
351
  };
347
- insertOpenSearchData( 'tango-retail-activity-logs', logObj );
352
+ insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
348
353
  await updatezoneTagging( req, res );
349
354
  // return res.sendSuccess( 'Tag Deleted Successfully' );
350
355
  } catch ( e ) {
@@ -362,7 +367,7 @@ export const getCameraTagging = async ( req, res ) => {
362
367
  return res.sendError( 'no data found', 204 );
363
368
  }
364
369
  if ( camDetails ) {
365
- query = { clientId: req.query.clientId, cameraId: camDetails._id, streamName: camDetails.streamName, storeId: req.query.storeId };
370
+ query = { clientId: req.query.clientId, cameraId: camDetails._id, streamName: camDetails.streamName, storeId: req.query.storeId, isDeleted: false };
366
371
  if ( req.query?.tagName != 'undefined' && req.query?.tagName != '' ) {
367
372
  query.tagName = req.query.tagName;
368
373
  }
@@ -421,11 +426,11 @@ async function getCamTaggingDetails( req, res ) {
421
426
  try {
422
427
  let camDetails = await cameraService.find( { storeId: req.body.storeId, isActivated: true, isUp: true } );
423
428
  if ( !camDetails.length ) {
424
- return res.sendError( 'no data found', 204 );
429
+ return false;
425
430
  }
426
431
  let result = [];
427
432
  for ( let camera of camDetails ) {
428
- let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, storeId: req.body.storeId, clientId: camera.clientId } );
433
+ let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, storeId: req.body.storeId, clientId: camera.clientId, isDeleted: false } );
429
434
  let zoneList = [];
430
435
  if ( taggingDetails.length ) {
431
436
  taggingDetails.forEach( ( zone ) => {
@@ -514,8 +519,8 @@ export const updateOldData = async ( req, res ) => {
514
519
  if ( !upload.Key ) {
515
520
  logger.error( { message: `JSON Upload Error`, store: item.storeId } );
516
521
  }
517
- if ( index == tagDetails.length-1 ) {
518
- return res.sendSuccess( 'Zone Updated Successfully' );
522
+ if ( index == 0 ) {
523
+ res.sendSuccess( 'Zone Updated Successfully' );
519
524
  }
520
525
  } else {
521
526
  logger.error( { message: 'no data', store: item.storeId } );