tango-app-api-store-zone 3.3.1-beta.6 → 3.3.1-beta.7
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
|
@@ -754,3 +754,81 @@ async function updateJsonFile( req, res ) {
|
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
756
|
};
|
|
757
|
+
|
|
758
|
+
export const getCameraStreamList = async ( req, res ) => {
|
|
759
|
+
try {
|
|
760
|
+
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 } );
|
|
761
|
+
if ( !cameraDetails.length ) {
|
|
762
|
+
return res.sendError( 'no data found', 204 );
|
|
763
|
+
}
|
|
764
|
+
const folderPath = { file_path: `${req.body.storeId}/zone_base_images/`,
|
|
765
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage, MaxKeys: 1000,
|
|
766
|
+
};
|
|
767
|
+
let fileList = await listFileByPath( folderPath );
|
|
768
|
+
const TaggedfolderPath = { file_path: `${req.body.storeId}/zone_tagged_image/`,
|
|
769
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage, MaxKeys: 1000,
|
|
770
|
+
};
|
|
771
|
+
let tagFileList = await listFileByPath( TaggedfolderPath );
|
|
772
|
+
for ( let [ index, camera ] of cameraDetails.entries() ) {
|
|
773
|
+
let tagList = [];
|
|
774
|
+
let tagPath;
|
|
775
|
+
let imgPath;
|
|
776
|
+
camera = {
|
|
777
|
+
...camera._doc,
|
|
778
|
+
baseImg: '',
|
|
779
|
+
tagImg: '',
|
|
780
|
+
};
|
|
781
|
+
let taggingDetails = await taggingService.find( { cameraId: camera._id, streamName: camera.streamName, clientId: req.body.clientId, isDeleted: false }, { tagName: 1, coordinates: 1 } );
|
|
782
|
+
if ( taggingDetails.length ) {
|
|
783
|
+
tagList = taggingDetails.filter( ( item ) => item.coordinates.length ).map( ( item ) => {
|
|
784
|
+
if ( item.coordinates.length ) {
|
|
785
|
+
return { tagName: item.tagName, color: item.coordinates[0].color };
|
|
786
|
+
}
|
|
787
|
+
} );
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
if ( tagFileList.data.length ) {
|
|
791
|
+
tagFileList.data.forEach( ( item ) => {
|
|
792
|
+
if ( item.Key.length > 1 ) {
|
|
793
|
+
let splitStream = item.Key.split( '/' );
|
|
794
|
+
let getStream = splitStream[splitStream.length -1].split( '.' );
|
|
795
|
+
|
|
796
|
+
if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
|
|
797
|
+
tagPath = item.Key;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
} );
|
|
801
|
+
}
|
|
802
|
+
if ( fileList?.data.length ) {
|
|
803
|
+
fileList.data.forEach( ( ele ) => {
|
|
804
|
+
let splitStream = ele.Key.split( '/' );
|
|
805
|
+
let getStream = splitStream[splitStream.length -1].split( '.' );
|
|
806
|
+
if ( getStream && getStream[0] == `${req.body.storeId}_${camera.streamName}` ) {
|
|
807
|
+
imgPath = ele.Key;
|
|
808
|
+
}
|
|
809
|
+
} );
|
|
810
|
+
}
|
|
811
|
+
if ( tagPath ) {
|
|
812
|
+
const params = { file_path: tagPath,
|
|
813
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
814
|
+
};
|
|
815
|
+
const cameraTagImage = await signedUrl( params );
|
|
816
|
+
camera.tagImg = cameraTagImage;
|
|
817
|
+
}
|
|
818
|
+
if ( imgPath ) {
|
|
819
|
+
const baseParams = { file_path: imgPath,
|
|
820
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage,
|
|
821
|
+
};
|
|
822
|
+
const cameraBaseImage = await signedUrl( baseParams );
|
|
823
|
+
camera.baseImg = cameraBaseImage;
|
|
824
|
+
}
|
|
825
|
+
camera.tagging = tagList;
|
|
826
|
+
cameraDetails[index] = camera;
|
|
827
|
+
}
|
|
828
|
+
cameraDetails.sort( ( a, b ) => a.tagging?.length > b.tagging?.length ? -1 : 1 );
|
|
829
|
+
return res.sendSuccess( cameraDetails );
|
|
830
|
+
} catch ( e ) {
|
|
831
|
+
logger.error( { error: e, function: 'getCameraList' } );
|
|
832
|
+
return res.sendError( e, 500 );
|
|
833
|
+
}
|
|
834
|
+
};
|
|
@@ -97,3 +97,13 @@ export const updateCoordinatesSchema= joi.object( {
|
|
|
97
97
|
export const updateCoordinatesParams = {
|
|
98
98
|
body: updateCoordinatesSchema,
|
|
99
99
|
};
|
|
100
|
+
|
|
101
|
+
export const getStreamSchema= joi.object( {
|
|
102
|
+
storeId: joi.string().required(),
|
|
103
|
+
clientId: joi.string().required(),
|
|
104
|
+
streamName: joi.string().required(),
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
export const getStreamParams = {
|
|
108
|
+
body: getStreamSchema,
|
|
109
|
+
};
|
|
@@ -17,6 +17,7 @@ zoneTaggingRouter.get( '/getCameraTagging', isAllowedSessionHandler, accessVerif
|
|
|
17
17
|
zoneTaggingRouter.get( '/getZoneTagging', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ ] } ] } ), validate( validation.validateZonetagParams ), tagController.getZoneList );
|
|
18
18
|
zoneTaggingRouter.post( '/updatezoneTagging', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), validate( validation.validateCamZonetagParams ), tagController.updatezoneTagging );
|
|
19
19
|
zoneTaggingRouter.post( '/deleteZoneTag', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoEye', name: 'ZoneTag', permissions: [ 'isEdit' ] } ] } ), validate( validation.updateCoordinatesParams ), tagController.deletezoneTagging );
|
|
20
|
+
zoneTaggingRouter.post( '/getStreamDetails', isAllowedSessionHandler, validate( validation.getStreamParams ), tagController.getCameraStreamList );
|
|
20
21
|
|
|
21
22
|
zoneTaggingRouter.get( '/updateOldZone', tagController.updateOldData );
|
|
22
23
|
|