tango-app-api-store-zone 3.0.12-dev → 3.0.13-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.12-dev",
3
+ "version": "3.0.13-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.104",
25
- "tango-app-api-middleware": "^1.0.73-test",
24
+ "tango-api-schema": "^2.0.110",
25
+ "tango-app-api-middleware": "^3.1.12",
26
26
  "winston": "^3.13.0",
27
27
  "winston-daily-rotate-file": "^5.0.0"
28
28
  },
@@ -1,6 +1,7 @@
1
1
  import { logger } from 'tango-app-api-middleware';
2
2
  import * as cameraService from '../services/camera.service.js';
3
3
  import * as taggingService from '../services/tagging.service.js';
4
+ import * as storeService from '../services/store.service.js';
4
5
  import { appConfig, signedUrl, listFileByPath, fileUpload, insertOpenSearchData } from 'tango-app-api-middleware';
5
6
  import axios from 'axios';
6
7
  export const addCustomTag = async ( req, res ) => {
@@ -40,7 +41,13 @@ export const addCustomTag = async ( req, res ) => {
40
41
  export const customTagList = async ( req, res ) => {
41
42
  try {
42
43
  let customTagList = [];
43
- let defaultZone = [ 'Entry', 'Exit', 'Billing', 'Excluded Area' ];
44
+ let storeDetails = await storeService.findOne( { storeId: req.query.storeId }, { product: 1 } );
45
+ let defaultZone;
46
+ if ( storeDetails && storeDetails?.product.includes( 'tangoZone' ) ) {
47
+ defaultZone = [ 'Excluded Area', 'Passer By', 'Entry/Exit', 'Billing' ];
48
+ } else {
49
+ defaultZone = [ 'Excluded Area', 'Passer By' ];
50
+ }
44
51
  customTagList.push( ...defaultZone );
45
52
  let tagInfo = await taggingService.find( { clientId: req.query.clientId }, { tagName: 1 } );
46
53
  let deletedTag = await taggingService.find( { clientId: req.query.clientId, isDeleted: true }, { storeId: 1, tagName: 1 } );
@@ -94,6 +101,7 @@ export const customTagList = async ( req, res ) => {
94
101
  }
95
102
  return { tagName: item, count: count };
96
103
  } );
104
+ customTagList.sort( ( a, b ) => a.count > b.count ? -1 : 1 );
97
105
  return res.sendSuccess( customTagList );
98
106
  } catch ( e ) {
99
107
  logger.error( { error: e, function: 'customTagList' } );
@@ -143,6 +151,9 @@ export const tagging = async ( req, res ) => {
143
151
  if ( req.body?.redoPoint ) {
144
152
  taggingDetails.coordinates = InputData.coordinates[0];
145
153
  taggingDetails.save();
154
+ } else if ( req.body?.redraw ) {
155
+ taggingDetails.coordinates = InputData.coordinates;
156
+ taggingDetails.save();
146
157
  } else {
147
158
  if ( InputData.coordinates[0].coor.length ) {
148
159
  taggingDetails.coordinates.push( InputData.coordinates[0] );
@@ -183,7 +194,7 @@ export const tagging = async ( req, res ) => {
183
194
 
184
195
  export const getCameraList = async ( req, res ) => {
185
196
  try {
186
- let cameraDetails = await cameraService.find( { clientId: req.query.clientId, storeId: req.query.storeId, isActivated: true, isUp: true }, { cameraNumber: 1, streamName: 1 } );
197
+ let cameraDetails = await cameraService.find( { clientId: req.query.clientId, storeId: req.query.storeId }, { cameraNumber: 1, streamName: 1, isActivated: 1, isUp: 1 } );
187
198
  if ( !cameraDetails.length ) {
188
199
  return res.sendError( 'no data found', 204 );
189
200
  }
@@ -532,4 +543,4 @@ export const updateOldData = async ( req, res ) => {
532
543
  logger.error( { error: e, function: 'updateOldData' } );
533
544
  return res.sendError( e, 500 );
534
545
  }
535
- };
546
+ };
@@ -49,6 +49,7 @@ export const validateTaggingSchema = joi.object( {
49
49
  coordinates: joi.array().required(),
50
50
  streamName: joi.string().required(),
51
51
  redoPoint: joi.boolean().optional(),
52
+ redraw: joi.boolean().optional(),
52
53
  } );
53
54
 
54
55
  export const validateTaggingParams = {
@@ -0,0 +1,5 @@
1
+ import model from 'tango-api-schema';
2
+
3
+ export const findOne = async ( query = {}, record = {} ) => {
4
+ return await model.storeModel.findOne( query, record );
5
+ };