tango-app-api-store-zone 3.3.1-beta.0 → 3.3.1-beta.2
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.
|
|
3
|
+
"version": "3.3.1-beta.2",
|
|
4
4
|
"description": "zone",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
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.
|
|
24
|
+
"tango-api-schema": "^2.1.1",
|
|
25
25
|
"tango-app-api-middleware": "^3.1.19",
|
|
26
26
|
"winston": "^3.13.0",
|
|
27
27
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -15,6 +15,8 @@ export const addCustomTag = async ( req, res ) => {
|
|
|
15
15
|
clientId: inputData.clientId,
|
|
16
16
|
storeId: inputData.storeId,
|
|
17
17
|
tagName: inputData.tagName,
|
|
18
|
+
rgbColor: inputData.rgbColor,
|
|
19
|
+
rgbBorderColor: inputData.rgbBorderColor,
|
|
18
20
|
};
|
|
19
21
|
await taggingService.deleteMany( { clientId: inputData.clientId, storeId: inputData.storeId, tagName: inputData.tagName, isDeleted: true } );
|
|
20
22
|
await taggingService.create( data );
|
|
@@ -54,7 +56,10 @@ export const customTagList = async ( req, res ) => {
|
|
|
54
56
|
if ( storeDetails && storeDetails?.product.includes( 'tangoZone' ) ) {
|
|
55
57
|
customTagList = customTagList.concat( [ 'Entry/Exit', 'Billing' ] );
|
|
56
58
|
}
|
|
57
|
-
let tagInfo = await taggingService.find( { clientId: req.query.clientId }, { tagName: 1 } );
|
|
59
|
+
let tagInfo = await taggingService.find( { clientId: req.query.clientId }, { tagName: 1, rgbColor: 1, rgbBorderColor: 1 } );
|
|
60
|
+
|
|
61
|
+
const allTags = tagInfo;
|
|
62
|
+
|
|
58
63
|
let deletedTag = await taggingService.find( { clientId: req.query.clientId, isDeleted: true }, { storeId: 1, tagName: 1 } );
|
|
59
64
|
tagInfo = [ ...new Set( tagInfo.map( ( item ) => item.tagName ) ) ];
|
|
60
65
|
deletedTag.forEach( ( item ) => {
|
|
@@ -90,10 +95,13 @@ export const customTagList = async ( req, res ) => {
|
|
|
90
95
|
tagName: '$_id',
|
|
91
96
|
count: 1,
|
|
92
97
|
|
|
98
|
+
|
|
93
99
|
},
|
|
94
100
|
},
|
|
95
101
|
];
|
|
96
102
|
let taggingDetails = await taggingService.aggregate( query );
|
|
103
|
+
|
|
104
|
+
|
|
97
105
|
customTagList = customTagList.map( ( item ) => {
|
|
98
106
|
let count = '';
|
|
99
107
|
if ( taggingDetails.length ) {
|
|
@@ -107,6 +115,42 @@ export const customTagList = async ( req, res ) => {
|
|
|
107
115
|
return { tagName: item, count: count };
|
|
108
116
|
} );
|
|
109
117
|
customTagList.sort( ( a, b ) => a.count > b.count ? -1 : 1 );
|
|
118
|
+
|
|
119
|
+
const allTagsMap = new Map( allTags.map( ( tag ) => [ tag.tagName, tag ] ) );
|
|
120
|
+
|
|
121
|
+
customTagList.forEach( ( i ) => {
|
|
122
|
+
const matchingTag = allTagsMap.get( i.tagName );
|
|
123
|
+
if ( matchingTag ) {
|
|
124
|
+
i.rgbColor = matchingTag.rgbColor;
|
|
125
|
+
i.rgbBorderColor = matchingTag.rgbBorderColor;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if ( i.tagName === 'Front' ) {
|
|
129
|
+
i.rgbColor = 'rgba(89, 80, 5, 0.5)';
|
|
130
|
+
i.rgbBorderColor = 'rgb(99, 90, 15)';
|
|
131
|
+
}
|
|
132
|
+
if ( i.tagName === 'Back' ) {
|
|
133
|
+
i.rgbColor = 'rgba(94, 60, 107, 0.5)';
|
|
134
|
+
i.rgbBorderColor = 'rgb(104, 70, 117)';
|
|
135
|
+
}
|
|
136
|
+
if ( i.tagName === 'Excluded Area' ) {
|
|
137
|
+
i.rgbColor = 'rgba(186, 60, 214, 0.5)';
|
|
138
|
+
i.rgbBorderColor = 'rgb(196, 70, 224)';
|
|
139
|
+
}
|
|
140
|
+
if ( i.tagName === 'Passer By' ) {
|
|
141
|
+
i.rgbColor = 'rgba(81, 153, 247, 0.5)';
|
|
142
|
+
i.rgbBorderColor = 'rgb(91, 163, 257)';
|
|
143
|
+
}
|
|
144
|
+
if ( i.tagName === 'Entry/Exit' ) {
|
|
145
|
+
i.rgbColor = 'rgba(224, 43, 170, 0.5)';
|
|
146
|
+
i.rgbBorderColor = 'rgb(234, 53, 180)';
|
|
147
|
+
}
|
|
148
|
+
if ( i.tagName === 'Billing' ) {
|
|
149
|
+
i.rgbColor = 'rgba(193, 214, 114, 0.5)';
|
|
150
|
+
i.rgbBorderColor = 'rgb(203, 224, 124)';
|
|
151
|
+
}
|
|
152
|
+
} );
|
|
153
|
+
|
|
110
154
|
return res.sendSuccess( customTagList );
|
|
111
155
|
} catch ( e ) {
|
|
112
156
|
logger.error( { error: e, function: 'customTagList' } );
|
|
@@ -128,6 +172,7 @@ export const tagging = async ( req, res ) => {
|
|
|
128
172
|
}
|
|
129
173
|
} );
|
|
130
174
|
let taggingDetails = await taggingService.findOne( { clientId: InputData.clientId, storeId: InputData.storeId, cameraId: InputData.cameraId, tagName: InputData.tagName, isDeleted: false } );
|
|
175
|
+
|
|
131
176
|
if ( !taggingDetails ) {
|
|
132
177
|
const logObj = {
|
|
133
178
|
clientId: InputData.clientId,
|
|
@@ -142,6 +187,13 @@ export const tagging = async ( req, res ) => {
|
|
|
142
187
|
showTo: [ 'client', 'tango' ],
|
|
143
188
|
};
|
|
144
189
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
190
|
+
if ( InputData.coordinates[0].color ) {
|
|
191
|
+
InputData = { ...InputData, rgbColor: InputData.coordinates[0].color };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if ( InputData.coordinates[0].rgbBorderColor ) {
|
|
195
|
+
InputData = { ...InputData, rgbBorderColor: InputData.coordinates[0].rgbBorderColor };
|
|
196
|
+
}
|
|
145
197
|
let response = await taggingService.create( InputData );
|
|
146
198
|
await taggingService.deleteOne( { clientId: InputData.clientId, storeId: InputData.storeId, cameraId: { $exists: false }, tagName: InputData.tagName } );
|
|
147
199
|
axios.post( `${JSON.parse( process.env.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 } ) );
|
|
@@ -370,11 +422,14 @@ export const updateTag = async ( req, res ) => {
|
|
|
370
422
|
};
|
|
371
423
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
372
424
|
if ( tagUpdate.modifiedCount || tagUpdate.matchedCount ) {
|
|
425
|
+
await externalService.updateMany( { zoneName: req.body.existTag, clientId: req.body.clientId }, { zoneName: req.body.tagName } );
|
|
373
426
|
logger.info( 'Custom Tag Updated Successfully' );
|
|
374
|
-
|
|
427
|
+
updateJsonFile( req, res );
|
|
428
|
+
res.sendSuccess( 'Custom Tag Updated Successfully' );
|
|
429
|
+
} else {
|
|
430
|
+
logger.error( { error: 'something went wrong', function: 'updateTag' } );
|
|
431
|
+
return res.sendError( 'something went wrong', 500 );
|
|
375
432
|
}
|
|
376
|
-
logger.error( { error: 'something went wrong', function: 'updateTag' } );
|
|
377
|
-
return res.sendError( 'something went wrong', 500 );
|
|
378
433
|
} catch ( e ) {
|
|
379
434
|
logger.error( { error: e, function: 'updateTag' } );
|
|
380
435
|
return res.sendError( e, 500 );
|
|
@@ -634,3 +689,29 @@ export const deletezoneTagging = async ( req, res ) => {
|
|
|
634
689
|
await updatezoneTagging( req, res );
|
|
635
690
|
} );
|
|
636
691
|
};
|
|
692
|
+
|
|
693
|
+
async function updateJsonFile( req, res ) {
|
|
694
|
+
if ( req.body.clientId ) {
|
|
695
|
+
let tagDetails = await taggingService.find( { clientId: req.body.clientId, tagName: req.body.tagName }, { storeId: 1 } );
|
|
696
|
+
if ( tagDetails.length ) {
|
|
697
|
+
for ( let item of tagDetails ) {
|
|
698
|
+
req.body.storeId = item.storeId;
|
|
699
|
+
let camDetails = await getCamTaggingDetails( req, res );
|
|
700
|
+
if ( !camDetails ) {
|
|
701
|
+
logger.error( { message: 'no data', store: item.storeId } );
|
|
702
|
+
}
|
|
703
|
+
let fileData = {
|
|
704
|
+
Key: `${req.body.storeId}/zonetagging/`,
|
|
705
|
+
fileName: `${req.body.storeId}_zonetagging.json`,
|
|
706
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
707
|
+
body: JSON.stringify( camDetails ),
|
|
708
|
+
ContentType: 'application/json',
|
|
709
|
+
};
|
|
710
|
+
let upload = await fileUpload( fileData );
|
|
711
|
+
if ( !upload.Key ) {
|
|
712
|
+
logger.error( { message: `JSON Upload Error`, store: item.storeId } );
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
};
|
|
@@ -4,6 +4,8 @@ export const addTagSchema = joi.object( {
|
|
|
4
4
|
clientId: joi.string().required(),
|
|
5
5
|
tagName: joi.string().required(),
|
|
6
6
|
storeId: joi.string().required(),
|
|
7
|
+
rgbColor: joi.string().required(),
|
|
8
|
+
rgbBorderColor: joi.string().required(),
|
|
7
9
|
} );
|
|
8
10
|
|
|
9
11
|
export const validateAddTagParams = {
|
|
@@ -17,4 +17,8 @@ export const deleteMany = async ( query = {} ) => {
|
|
|
17
17
|
return await model.externalParameterModel.deleteMany( query );
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
export const updateMany = async ( query = {}, record={} ) => {
|
|
21
|
+
return await model.externalParameterModel.updateMany( query, { $set: record } );
|
|
22
|
+
};
|
|
23
|
+
|
|
20
24
|
|