tango-app-api-store-zone 3.3.1-beta.12 → 3.3.1-beta.14

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.3.1-beta.12",
3
+ "version": "3.3.1-beta.14",
4
4
  "description": "zone",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -5,7 +5,7 @@ import * as storeService from '../services/store.service.js';
5
5
  import * as clientService from '../services/client.service.js';
6
6
  import * as externalService from '../services/external.service.js';
7
7
  import { signedUrl, listFileByPath, fileUpload, insertOpenSearchData } from 'tango-app-api-middleware';
8
- import * as processedchecklistconfigService from '../services/processedchecklistconfig.services.js';
8
+ import * as checklistconfigService from '../services/checklistconfig.services.js';
9
9
 
10
10
  import axios from 'axios';
11
11
  export const addCustomTag = async ( req, res ) => {
@@ -269,8 +269,8 @@ export const customTagListv2 = async ( req, res ) => {
269
269
  },
270
270
  }, {
271
271
  $group: {
272
- _id: '$sourceCheckList_id',
273
- sourceCheckList_id: { $last: '$sourceCheckList_id' },
272
+ _id: '$_id',
273
+ sourceCheckList_id: { $last: '$_id' },
274
274
  tagName: { $last: '$checkListName' },
275
275
  },
276
276
  },
@@ -300,11 +300,25 @@ export const customTagListv2 = async ( req, res ) => {
300
300
  ], as: 'cameraList',
301
301
  },
302
302
  },
303
-
304
303
  {
305
304
  $project: {
306
305
  tagName: 1,
307
306
  type: 'checklist',
307
+ cameraList: {
308
+ $filter: {
309
+ input: '$cameraList',
310
+ as: 'item',
311
+ cond: {
312
+ $eq: [ '$$item.storeId', req.query.storeId ],
313
+ },
314
+ },
315
+ },
316
+ },
317
+ },
318
+ {
319
+ $project: {
320
+ tagName: 1,
321
+ type: 1,
308
322
  count: { $size: '$cameraList' },
309
323
  },
310
324
  },
@@ -315,8 +329,9 @@ export const customTagListv2 = async ( req, res ) => {
315
329
  },
316
330
 
317
331
  ];
318
- let getChecklistData = await processedchecklistconfigService.aggregate( Query );
319
- if ( finalTags&&finalTags.length>0 ) {
332
+ let getChecklistData = await checklistconfigService.aggregate( Query );
333
+ console.log( getChecklistData, finalTags );
334
+ if ( finalTags && finalTags.length > 0 ) {
320
335
  let merged = getChecklistData.map( ( item ) => {
321
336
  let match = finalTags.find( ( a ) => a.tagName === item.tagName );
322
337
  if ( match ) {
@@ -324,7 +339,7 @@ export const customTagListv2 = async ( req, res ) => {
324
339
  }
325
340
  return item;
326
341
  } );
327
-
342
+ console.log( merged );
328
343
  // also include any arr1 items not in arr2
329
344
  finalTags.forEach( ( a ) => {
330
345
  if ( !merged.find( ( m ) => m.tagName === a.tagName ) ) {
@@ -593,17 +608,17 @@ export const getCameraList = async ( req, res ) => {
593
608
  };
594
609
  export const getCameraListv2 = async ( req, res ) => {
595
610
  try {
596
- let cameraDetails = await cameraService.find( { clientId: req.query.clientId, storeId: req.query.storeId, isActivated: true, isUp: true }, { cameraNumber: 1, streamName: 1, isActivated: 1, isUp: 1, cameraName: 1, taggedChecklist: 1 } );
611
+ let cameraDetails = await cameraService.find( { clientId: req.body.clientId, storeId: req.body.storeId, isActivated: true, isUp: true }, { cameraNumber: 1, streamName: 1, isActivated: 1, isUp: 1, cameraName: 1, taggedChecklist: 1 } );
597
612
  if ( !cameraDetails.length ) {
598
613
  return res.sendError( 'no data found', 204 );
599
614
  }
600
615
  const folderPath = {
601
- file_path: `${req.query.storeId}/zone_base_images/`,
616
+ file_path: `${req.body.storeId}/zone_base_images/`,
602
617
  Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage, MaxKeys: 1000,
603
618
  };
604
619
  let fileList = await listFileByPath( folderPath );
605
620
  const TaggedfolderPath = {
606
- file_path: `${req.query.storeId}/zone_tagged_image/`,
621
+ file_path: `${req.body.storeId}/zone_tagged_image/`,
607
622
  Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage, MaxKeys: 1000,
608
623
  };
609
624
  let tagFileList = await listFileByPath( TaggedfolderPath );
@@ -616,7 +631,7 @@ export const getCameraListv2 = async ( req, res ) => {
616
631
  baseImg: '',
617
632
  tagImg: '',
618
633
  };
619
- let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.query.clientId, isDeleted: false }, { tagName: 1, coordinates: 1 } );
634
+ let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.body.clientId, isDeleted: false }, { tagName: 1, coordinates: 1 } );
620
635
  if ( taggingDetails.length ) {
621
636
  tagList = taggingDetails.filter( ( item ) => item.coordinates.length ).map( ( item ) => {
622
637
  if ( item.coordinates.length ) {
@@ -631,7 +646,7 @@ export const getCameraListv2 = async ( req, res ) => {
631
646
  let splitStream = item.Key.split( '/' );
632
647
  let getStream = splitStream[splitStream.length - 1].split( '.' );
633
648
 
634
- if ( getStream && getStream[0] == `${req.query.storeId}_${camera.streamName}` ) {
649
+ if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
635
650
  tagPath = item.Key;
636
651
  }
637
652
  }
@@ -641,7 +656,7 @@ export const getCameraListv2 = async ( req, res ) => {
641
656
  fileList.data.forEach( ( ele ) => {
642
657
  let splitStream = ele.Key.split( '/' );
643
658
  let getStream = splitStream[splitStream.length - 1].split( '.' );
644
- if ( getStream && getStream[0] == `${req.query.storeId}_${camera.streamName}` ) {
659
+ if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
645
660
  imgPath = ele.Key;
646
661
  }
647
662
  } );
@@ -663,7 +678,7 @@ export const getCameraListv2 = async ( req, res ) => {
663
678
  camera.baseImg = cameraBaseImage;
664
679
  }
665
680
  camera.tagging = tagList;
666
- camera.taggedCount = tagList.filter( ( ele ) => ele.tagName===req.query.tagName );
681
+ camera.taggedCount = tagList.filter( ( ele ) => ele.tagName === req.body.tagName );
667
682
  cameraDetails[index] = camera;
668
683
  }
669
684
  cameraDetails.sort( ( a, b ) => a.tagging?.length > b.tagging?.length ? -1 : 1 );
@@ -985,7 +1000,7 @@ export const updateOldData = async ( req, res ) => {
985
1000
  };
986
1001
  export async function updateCamera( req, res ) {
987
1002
  try {
988
- let findoneCheckList = await processedchecklistconfigService.findOne( {
1003
+ let findoneCheckList = await checklistconfigService.findOne( {
989
1004
  client_id: req.body.clientId, checkListName: req.body.selectedZone,
990
1005
  } );
991
1006
 
@@ -20,7 +20,7 @@ export const tagSchema = joi.object( {
20
20
  } );
21
21
 
22
22
  export const validateTagParams = {
23
- query: tagSchema,
23
+ body: tagSchema,
24
24
  };
25
25
 
26
26
  export const validateUpdateTagSchema = joi.object( {
@@ -12,7 +12,7 @@ zoneTaggingRouter.get( '/customTagList', isAllowedSessionHandler, accessVerifica
12
12
  zoneTaggingRouter.get( '/customTagListv2', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ ] } ] } ), tagController.customTagListv2 );
13
13
  zoneTaggingRouter.post( '/tagging', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), validate( validation.validateTaggingParams ), tagController.tagging );
14
14
  zoneTaggingRouter.get( '/cameraList', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ ] } ] } ), validate( validation.validateTagParams ), tagController.getCameraList );
15
- zoneTaggingRouter.get( '/cameraListv2', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ ] } ] } ), validate( validation.validateTagParams ), tagController.getCameraListv2 );
15
+ zoneTaggingRouter.post( '/cameraListv2', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ ] } ] } ), validate( validation.validateTagParams ), tagController.getCameraListv2 );
16
16
  zoneTaggingRouter.post( '/updateCustomTag', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), validate( validation.validateUpdateTagParams ), tagController.updateTag );
17
17
  zoneTaggingRouter.post( '/deleteCustomTag', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), validate( validation.validateDeleteTagParams ), tagController.deleteTag );
18
18
  zoneTaggingRouter.get( '/getCameraTagging', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ ] } ] } ), validate( validation.validateCameraTagParams ), tagController.getCameraTagging );
@@ -0,0 +1,31 @@
1
+ import model from 'tango-api-schema';
2
+
3
+ export const findOne = async ( query={}, field={} ) => {
4
+ return model.checklistconfigModel.findOne( query, field );
5
+ };
6
+
7
+ export const find = async ( query={}, field={} ) => {
8
+ return model.checklistconfigModel.find( query, field );
9
+ };
10
+
11
+ export const create = async ( document = {} ) => {
12
+ return model.checklistconfigModel.create( document );
13
+ };
14
+
15
+ export const deleteOne = async ( query = {} ) => {
16
+ return model.checklistconfigModel.deleteOne( query );
17
+ };
18
+
19
+ export const updateOne = async ( query = {}, record={} ) => {
20
+ return model.checklistconfigModel.updateOne( query, { $set: record }, { upsert: true } );
21
+ };
22
+
23
+ export const updateMany = async ( query = {}, record={} ) => {
24
+ return model.checklistconfigModel.updateMany( query, { $set: record } );
25
+ };
26
+
27
+ export const aggregate = async ( query = {} ) => {
28
+ return model.checklistconfigModel.aggregate( query );
29
+ };
30
+
31
+
@@ -1,35 +0,0 @@
1
- import model from 'tango-api-schema';
2
-
3
- export const find = ( query = {}, record = {} ) => {
4
- return model.processedchecklistconfigModel.find( query, record );
5
- };
6
-
7
- export const findOne = ( query = {}, record = {} ) => {
8
- return model.processedchecklistconfigModel.findOne( query, record ).sort( { updatedAt: -1 } );
9
- };
10
-
11
- export const updateOne = ( query = {}, record = {} ) => {
12
- return model.processedchecklistconfigModel.updateOne( query, { $set: record }, { upsert: true } );
13
- };
14
-
15
- export const updateMany = ( query = {}, record = {} ) => {
16
- return model.processedchecklistconfigModel.updateMany( query, { $set: record } );
17
- };
18
-
19
- export const deleteMany = ( query = {} ) => {
20
- return model.processedchecklistconfigModel.deleteMany( query );
21
- };
22
-
23
- export const aggregate = ( query = [] ) => {
24
- return model.processedchecklistconfigModel.aggregate( query );
25
- };
26
-
27
- export const getClientCount = ( query = {} ) => {
28
- return model.processedchecklistconfigModel.count( query );
29
- };
30
-
31
- export const insert = ( document={} ) => {
32
- return model.processedchecklistconfigModel.create( document );
33
- };
34
-
35
-