tango-app-api-store-zone 3.3.1-beta.13 → 3.3.1-beta.15
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
|
@@ -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
|
|
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: '$
|
|
273
|
-
sourceCheckList_id: { $last: '$
|
|
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
|
|
319
|
-
|
|
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 ) ) {
|
|
@@ -403,12 +418,12 @@ export const tagging = async ( req, res ) => {
|
|
|
403
418
|
...taggingDetails.toObject(),
|
|
404
419
|
},
|
|
405
420
|
oldData: {
|
|
406
|
-
|
|
407
|
-
|
|
421
|
+
TagName: taggingDetails.tagName,
|
|
422
|
+
StreamName: taggingDetails.streamName,
|
|
408
423
|
},
|
|
409
424
|
newData: {
|
|
410
|
-
|
|
411
|
-
|
|
425
|
+
TagName: taggingDetails.tagName,
|
|
426
|
+
StreamName: taggingDetails.streamName,
|
|
412
427
|
},
|
|
413
428
|
showTo: [ 'tango', 'client' ],
|
|
414
429
|
};
|
|
@@ -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.body.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 );
|
|
@@ -719,10 +734,10 @@ export const updateTag = async ( req, res ) => {
|
|
|
719
734
|
tagName: req.body.tagName,
|
|
720
735
|
},
|
|
721
736
|
oldData: {
|
|
722
|
-
|
|
737
|
+
TagName: req.body.existTag,
|
|
723
738
|
},
|
|
724
739
|
newData: {
|
|
725
|
-
|
|
740
|
+
TagName: req.body.tagName,
|
|
726
741
|
},
|
|
727
742
|
showTo: [ 'tango', 'client' ],
|
|
728
743
|
};
|
|
@@ -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
|
|
1003
|
+
let findoneCheckList = await checklistconfigService.findOne( {
|
|
989
1004
|
client_id: req.body.clientId, checkListName: req.body.selectedZone,
|
|
990
1005
|
} );
|
|
991
1006
|
|
|
@@ -1043,3 +1058,81 @@ async function updateJsonFile( req, res ) {
|
|
|
1043
1058
|
}
|
|
1044
1059
|
}
|
|
1045
1060
|
};
|
|
1061
|
+
|
|
1062
|
+
export const getCameraStreamList = async ( req, res ) => {
|
|
1063
|
+
try {
|
|
1064
|
+
let cameraDetails = await cameraService.find( { clientId: req.body.clientId, storeId: req.body.storeId, streamName: req.body.streamName }, { cameraNumber: 1, streamName: 1, isActivated: 1, isUp: 1, cameraName: 1 } );
|
|
1065
|
+
if ( !cameraDetails.length ) {
|
|
1066
|
+
return res.sendError( 'no data found', 204 );
|
|
1067
|
+
}
|
|
1068
|
+
const folderPath = { file_path: `${req.body.storeId}/zone_base_images/`,
|
|
1069
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage, MaxKeys: 1000,
|
|
1070
|
+
};
|
|
1071
|
+
let fileList = await listFileByPath( folderPath );
|
|
1072
|
+
const TaggedfolderPath = { file_path: `${req.body.storeId}/zone_tagged_image/`,
|
|
1073
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage, MaxKeys: 1000,
|
|
1074
|
+
};
|
|
1075
|
+
let tagFileList = await listFileByPath( TaggedfolderPath );
|
|
1076
|
+
for ( let [ index, camera ] of cameraDetails.entries() ) {
|
|
1077
|
+
let tagList = [];
|
|
1078
|
+
let tagPath;
|
|
1079
|
+
let imgPath;
|
|
1080
|
+
camera = {
|
|
1081
|
+
...camera._doc,
|
|
1082
|
+
baseImg: '',
|
|
1083
|
+
tagImg: '',
|
|
1084
|
+
};
|
|
1085
|
+
let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.body.clientId, isDeleted: false }, { tagName: 1, coordinates: 1 } );
|
|
1086
|
+
if ( taggingDetails.length ) {
|
|
1087
|
+
tagList = taggingDetails.filter( ( item ) => item.coordinates.length ).map( ( item ) => {
|
|
1088
|
+
if ( item.coordinates.length ) {
|
|
1089
|
+
return { tagName: item.tagName, color: item.coordinates[0].color };
|
|
1090
|
+
}
|
|
1091
|
+
} );
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
if ( tagFileList.data.length ) {
|
|
1095
|
+
tagFileList.data.forEach( ( item ) => {
|
|
1096
|
+
if ( item.Key.length > 1 ) {
|
|
1097
|
+
let splitStream = item.Key.split( '/' );
|
|
1098
|
+
let getStream = splitStream[splitStream.length -1].split( '.' );
|
|
1099
|
+
|
|
1100
|
+
if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
|
|
1101
|
+
tagPath = item.Key;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
} );
|
|
1105
|
+
}
|
|
1106
|
+
if ( fileList?.data.length ) {
|
|
1107
|
+
fileList.data.forEach( ( ele ) => {
|
|
1108
|
+
let splitStream = ele.Key.split( '/' );
|
|
1109
|
+
let getStream = splitStream[splitStream.length -1].split( '.' );
|
|
1110
|
+
if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
|
|
1111
|
+
imgPath = ele.Key;
|
|
1112
|
+
}
|
|
1113
|
+
} );
|
|
1114
|
+
}
|
|
1115
|
+
if ( tagPath ) {
|
|
1116
|
+
const params = { file_path: tagPath,
|
|
1117
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
1118
|
+
};
|
|
1119
|
+
const cameraTagImage = await signedUrl( params );
|
|
1120
|
+
camera.tagImg = cameraTagImage;
|
|
1121
|
+
}
|
|
1122
|
+
if ( imgPath ) {
|
|
1123
|
+
const baseParams = { file_path: imgPath,
|
|
1124
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage,
|
|
1125
|
+
};
|
|
1126
|
+
const cameraBaseImage = await signedUrl( baseParams );
|
|
1127
|
+
camera.baseImg = cameraBaseImage;
|
|
1128
|
+
}
|
|
1129
|
+
camera.tagging = tagList;
|
|
1130
|
+
cameraDetails[index] = camera;
|
|
1131
|
+
}
|
|
1132
|
+
cameraDetails.sort( ( a, b ) => a.tagging?.length > b.tagging?.length ? -1 : 1 );
|
|
1133
|
+
return res.sendSuccess( cameraDetails );
|
|
1134
|
+
} catch ( e ) {
|
|
1135
|
+
logger.error( { error: e, function: 'getCameraList' } );
|
|
1136
|
+
return res.sendError( e, 500 );
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
@@ -101,3 +101,13 @@ export const updateCoordinatesSchema= joi.object( {
|
|
|
101
101
|
export const updateCoordinatesParams = {
|
|
102
102
|
body: updateCoordinatesSchema,
|
|
103
103
|
};
|
|
104
|
+
|
|
105
|
+
export const getStreamSchema= joi.object( {
|
|
106
|
+
storeId: joi.string().required(),
|
|
107
|
+
clientId: joi.string().required(),
|
|
108
|
+
streamName: joi.string().required(),
|
|
109
|
+
} );
|
|
110
|
+
|
|
111
|
+
export const getStreamParams = {
|
|
112
|
+
body: getStreamSchema,
|
|
113
|
+
};
|
|
@@ -19,6 +19,7 @@ zoneTaggingRouter.get( '/getCameraTagging', isAllowedSessionHandler, accessVerif
|
|
|
19
19
|
zoneTaggingRouter.get( '/getZoneTagging', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ ] } ] } ), validate( validation.validateZonetagParams ), tagController.getZoneList );
|
|
20
20
|
zoneTaggingRouter.post( '/updatezoneTagging', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), validate( validation.validateCamZonetagParams ), tagController.updatezoneTagging );
|
|
21
21
|
zoneTaggingRouter.post( '/deleteZoneTag', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), validate( validation.updateCoordinatesParams ), tagController.deletezoneTagging );
|
|
22
|
+
zoneTaggingRouter.post( '/getStreamDetails', isAllowedSessionHandler, validate( validation.getStreamParams ), tagController.getCameraStreamList );
|
|
22
23
|
zoneTaggingRouter.post( '/updateCamera', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), tagController.updateCamera );
|
|
23
24
|
|
|
24
25
|
zoneTaggingRouter.get( '/updateOldZone', tagController.updateOldData );
|
|
@@ -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
|
-
|