tango-app-api-store-zone 3.3.1-beta.14 → 3.3.1-beta.16
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
|
@@ -418,12 +418,12 @@ export const tagging = async ( req, res ) => {
|
|
|
418
418
|
...taggingDetails.toObject(),
|
|
419
419
|
},
|
|
420
420
|
oldData: {
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
TagName: taggingDetails.tagName,
|
|
422
|
+
StreamName: taggingDetails.streamName,
|
|
423
423
|
},
|
|
424
424
|
newData: {
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
TagName: taggingDetails.tagName,
|
|
426
|
+
StreamName: taggingDetails.streamName,
|
|
427
427
|
},
|
|
428
428
|
showTo: [ 'tango', 'client' ],
|
|
429
429
|
};
|
|
@@ -639,7 +639,6 @@ export const getCameraListv2 = async ( req, res ) => {
|
|
|
639
639
|
}
|
|
640
640
|
} );
|
|
641
641
|
}
|
|
642
|
-
|
|
643
642
|
if ( tagFileList.data.length ) {
|
|
644
643
|
tagFileList.data.forEach( ( item ) => {
|
|
645
644
|
if ( item.Key.length > 1 ) {
|
|
@@ -734,10 +733,10 @@ export const updateTag = async ( req, res ) => {
|
|
|
734
733
|
tagName: req.body.tagName,
|
|
735
734
|
},
|
|
736
735
|
oldData: {
|
|
737
|
-
|
|
736
|
+
TagName: req.body.existTag,
|
|
738
737
|
},
|
|
739
738
|
newData: {
|
|
740
|
-
|
|
739
|
+
TagName: req.body.tagName,
|
|
741
740
|
},
|
|
742
741
|
showTo: [ 'tango', 'client' ],
|
|
743
742
|
};
|
|
@@ -764,18 +763,18 @@ export const deleteTag = async ( req, res ) => {
|
|
|
764
763
|
return res.sendError( 'no data found', 204 );
|
|
765
764
|
}
|
|
766
765
|
let enableDelete = false;
|
|
767
|
-
if ( req.user.permission ) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
}
|
|
778
|
-
if ( req.user?.role == 'superadmin' || ( req.user?.role == 'admin'
|
|
766
|
+
// if ( req.user.permission ) {
|
|
767
|
+
// let permissions = req.user.permission;
|
|
768
|
+
// permissions.forEach( ( permission ) => {
|
|
769
|
+
// if ( permission.featureName == 'analytics' ) {
|
|
770
|
+
// let product = permission.product.find( ( item ) => item.name == 'tangoZone' );
|
|
771
|
+
// if ( product ) {
|
|
772
|
+
// enableDelete = product.isDelete;
|
|
773
|
+
// }
|
|
774
|
+
// }
|
|
775
|
+
// } );
|
|
776
|
+
// }
|
|
777
|
+
if ( req.user?.role == 'superadmin' || ( req.user?.role == 'admin' ) ) {
|
|
779
778
|
await taggingService.deleteMany( { clientId: req.body.clientId, tagName: req.body.tagName } );
|
|
780
779
|
await externalService.deleteMany( { zoneName: req.body.tagName, clientId: req.body.clientId } );
|
|
781
780
|
} else {
|
|
@@ -1058,3 +1057,81 @@ async function updateJsonFile( req, res ) {
|
|
|
1058
1057
|
}
|
|
1059
1058
|
}
|
|
1060
1059
|
};
|
|
1060
|
+
|
|
1061
|
+
export const getCameraStreamList = async ( req, res ) => {
|
|
1062
|
+
try {
|
|
1063
|
+
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 } );
|
|
1064
|
+
if ( !cameraDetails.length ) {
|
|
1065
|
+
return res.sendError( 'no data found', 204 );
|
|
1066
|
+
}
|
|
1067
|
+
const folderPath = { file_path: `${req.body.storeId}/zone_base_images/`,
|
|
1068
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage, MaxKeys: 1000,
|
|
1069
|
+
};
|
|
1070
|
+
let fileList = await listFileByPath( folderPath );
|
|
1071
|
+
const TaggedfolderPath = { file_path: `${req.body.storeId}/zone_tagged_image/`,
|
|
1072
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage, MaxKeys: 1000,
|
|
1073
|
+
};
|
|
1074
|
+
let tagFileList = await listFileByPath( TaggedfolderPath );
|
|
1075
|
+
for ( let [ index, camera ] of cameraDetails.entries() ) {
|
|
1076
|
+
let tagList = [];
|
|
1077
|
+
let tagPath;
|
|
1078
|
+
let imgPath;
|
|
1079
|
+
camera = {
|
|
1080
|
+
...camera._doc,
|
|
1081
|
+
baseImg: '',
|
|
1082
|
+
tagImg: '',
|
|
1083
|
+
};
|
|
1084
|
+
let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.body.clientId, isDeleted: false }, { tagName: 1, coordinates: 1 } );
|
|
1085
|
+
if ( taggingDetails.length ) {
|
|
1086
|
+
tagList = taggingDetails.filter( ( item ) => item.coordinates.length ).map( ( item ) => {
|
|
1087
|
+
if ( item.coordinates.length ) {
|
|
1088
|
+
return { tagName: item.tagName, color: item.coordinates[0].color };
|
|
1089
|
+
}
|
|
1090
|
+
} );
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if ( tagFileList.data.length ) {
|
|
1094
|
+
tagFileList.data.forEach( ( item ) => {
|
|
1095
|
+
if ( item.Key.length > 1 ) {
|
|
1096
|
+
let splitStream = item.Key.split( '/' );
|
|
1097
|
+
let getStream = splitStream[splitStream.length -1].split( '.' );
|
|
1098
|
+
|
|
1099
|
+
if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
|
|
1100
|
+
tagPath = item.Key;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
} );
|
|
1104
|
+
}
|
|
1105
|
+
if ( fileList?.data.length ) {
|
|
1106
|
+
fileList.data.forEach( ( ele ) => {
|
|
1107
|
+
let splitStream = ele.Key.split( '/' );
|
|
1108
|
+
let getStream = splitStream[splitStream.length -1].split( '.' );
|
|
1109
|
+
if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
|
|
1110
|
+
imgPath = ele.Key;
|
|
1111
|
+
}
|
|
1112
|
+
} );
|
|
1113
|
+
}
|
|
1114
|
+
if ( tagPath ) {
|
|
1115
|
+
const params = { file_path: tagPath,
|
|
1116
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
1117
|
+
};
|
|
1118
|
+
const cameraTagImage = await signedUrl( params );
|
|
1119
|
+
camera.tagImg = cameraTagImage;
|
|
1120
|
+
}
|
|
1121
|
+
if ( imgPath ) {
|
|
1122
|
+
const baseParams = { file_path: imgPath,
|
|
1123
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage,
|
|
1124
|
+
};
|
|
1125
|
+
const cameraBaseImage = await signedUrl( baseParams );
|
|
1126
|
+
camera.baseImg = cameraBaseImage;
|
|
1127
|
+
}
|
|
1128
|
+
camera.tagging = tagList;
|
|
1129
|
+
cameraDetails[index] = camera;
|
|
1130
|
+
}
|
|
1131
|
+
cameraDetails.sort( ( a, b ) => a.tagging?.length > b.tagging?.length ? -1 : 1 );
|
|
1132
|
+
return res.sendSuccess( cameraDetails );
|
|
1133
|
+
} catch ( e ) {
|
|
1134
|
+
logger.error( { error: e, function: 'getCameraList' } );
|
|
1135
|
+
return res.sendError( e, 500 );
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
@@ -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 );
|