tango-app-api-trax 3.4.1-activitylog-8 → 3.4.1-activitylog-10
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 +1 -1
- package/src/controllers/mobileTrax.controller.js +13 -12
- package/src/controllers/trax.controller.js +31 -21
- package/src/hbs/login-otp.hbs +943 -943
package/package.json
CHANGED
|
@@ -264,7 +264,7 @@ export async function startChecklist( req, res ) {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
267
|
-
console.log( 'openSearch', openSearch );
|
|
267
|
+
// console.log( 'openSearch', openSearch );
|
|
268
268
|
let inserttraxlogs = {
|
|
269
269
|
client_id: req.user.clientId,
|
|
270
270
|
createAt: new Date(),
|
|
@@ -288,7 +288,7 @@ export async function startChecklist( req, res ) {
|
|
|
288
288
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
289
289
|
}
|
|
290
290
|
} catch ( e ) {
|
|
291
|
-
console.log( 'e =>', e );
|
|
291
|
+
// console.log( 'e =>', e );
|
|
292
292
|
logger.error( { function: 'startChecklist', error: e, body: req.body } );
|
|
293
293
|
return res.sendError( e, 500 );
|
|
294
294
|
}
|
|
@@ -455,7 +455,7 @@ export async function startTask( req, res ) {
|
|
|
455
455
|
await checklistLogs.create( logData );
|
|
456
456
|
|
|
457
457
|
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
458
|
-
console.log( 'openSearch', openSearch );
|
|
458
|
+
// console.log( 'openSearch', openSearch );
|
|
459
459
|
let inserttraxlogs = {
|
|
460
460
|
client_id: req.user.clientId,
|
|
461
461
|
createAt: new Date(),
|
|
@@ -470,9 +470,10 @@ export async function startTask( req, res ) {
|
|
|
470
470
|
createdBy: task.userName || '',
|
|
471
471
|
coverage: task.coverage || '',
|
|
472
472
|
logDetails: {},
|
|
473
|
+
userType: req.user.userType,
|
|
473
474
|
};
|
|
474
475
|
// let insertOS = await insertOpenSearchData( 'test-traxlogs', inserttraxlogs );
|
|
475
|
-
console.log( 'inserttraxlogs', inserttraxlogs );
|
|
476
|
+
// console.log( 'inserttraxlogs', inserttraxlogs );
|
|
476
477
|
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
477
478
|
return res.sendSuccess( getUpdatedTask );
|
|
478
479
|
} catch ( error ) {
|
|
@@ -1847,7 +1848,7 @@ export async function submitChecklist( req, res ) {
|
|
|
1847
1848
|
userName: getchecklist[0].userName || '',
|
|
1848
1849
|
coverage: getchecklist[0].coverage || '',
|
|
1849
1850
|
};
|
|
1850
|
-
console.log( 'logInsertData=>', logInsertData );
|
|
1851
|
+
// console.log( 'logInsertData=>', logInsertData );
|
|
1851
1852
|
await checklistLogs.create( logInsertData );
|
|
1852
1853
|
// let time = dayjs().format( 'HH:mm:ss' );
|
|
1853
1854
|
// let [ hours, minutes ] = time.split( ':' ).map( Number );
|
|
@@ -1883,7 +1884,7 @@ export async function submitChecklist( req, res ) {
|
|
|
1883
1884
|
if ( requestData.submittype == 'submit' ) {
|
|
1884
1885
|
updateOpenSearch( req.user, requestData );
|
|
1885
1886
|
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1886
|
-
console.log( 'openSearch', openSearch );
|
|
1887
|
+
// console.log( 'openSearch', openSearch );
|
|
1887
1888
|
let inserttraxlogs = {
|
|
1888
1889
|
client_id: req.user.clientId,
|
|
1889
1890
|
createAt: new Date(),
|
|
@@ -1902,7 +1903,7 @@ export async function submitChecklist( req, res ) {
|
|
|
1902
1903
|
logDetails: {},
|
|
1903
1904
|
userType: req.user.userType,
|
|
1904
1905
|
};
|
|
1905
|
-
console.log( 'inserttraxlogs', inserttraxlogs );
|
|
1906
|
+
// console.log( 'inserttraxlogs', inserttraxlogs );
|
|
1906
1907
|
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
1907
1908
|
}
|
|
1908
1909
|
|
|
@@ -2071,7 +2072,7 @@ export async function submitTask( req, res ) {
|
|
|
2071
2072
|
if ( submittype == 'submit' ) {
|
|
2072
2073
|
updateOpenSearchTask( user, requestData );
|
|
2073
2074
|
let openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
2074
|
-
console.log( 'openSearch', openSearch );
|
|
2075
|
+
// console.log( 'openSearch', openSearch );
|
|
2075
2076
|
let inserttraxlogs = {
|
|
2076
2077
|
client_id: req.user.clientId,
|
|
2077
2078
|
createAt: new Date(),
|
|
@@ -2090,7 +2091,7 @@ export async function submitTask( req, res ) {
|
|
|
2090
2091
|
logDetails: {},
|
|
2091
2092
|
userType: req.user.userType,
|
|
2092
2093
|
};
|
|
2093
|
-
console.log( 'inserttraxlogs', inserttraxlogs );
|
|
2094
|
+
// console.log( 'inserttraxlogs', inserttraxlogs );
|
|
2094
2095
|
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
2095
2096
|
}
|
|
2096
2097
|
|
|
@@ -2107,7 +2108,7 @@ export async function submiteyeTestTask( req, res ) {
|
|
|
2107
2108
|
try {
|
|
2108
2109
|
const { body: requestData, user } = req;
|
|
2109
2110
|
const { processedcheckListId, date, submittype, currentTime, questionAnswers, streamId, qrCode } = requestData;
|
|
2110
|
-
console.log( requestData );
|
|
2111
|
+
// console.log( requestData );
|
|
2111
2112
|
if ( !streamId ) {
|
|
2112
2113
|
return res.sendError( 'streamId is required', 400 );
|
|
2113
2114
|
}
|
|
@@ -2119,7 +2120,7 @@ export async function submiteyeTestTask( req, res ) {
|
|
|
2119
2120
|
return res.sendError( 'Qr code already Exists', 400 );
|
|
2120
2121
|
}
|
|
2121
2122
|
let findQrExists = await cameraService.findOne( { streamName: streamId, qrCode: qrCode } );
|
|
2122
|
-
console.log( findQrExists );
|
|
2123
|
+
// console.log( findQrExists );
|
|
2123
2124
|
if ( findQrExists ) {
|
|
2124
2125
|
return res.sendError( 'Qr code already Exists', 400 );
|
|
2125
2126
|
}
|
|
@@ -2557,7 +2558,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2557
2558
|
|
|
2558
2559
|
return res.sendSuccess( totalResult );
|
|
2559
2560
|
} catch ( e ) {
|
|
2560
|
-
console.log( 'v1 =>', e );
|
|
2561
|
+
// console.log( 'v1 =>', e );
|
|
2561
2562
|
logger.error( { function: 'dashboardv1', error: e, body: req.body } );
|
|
2562
2563
|
return res.sendError( e, 500 );
|
|
2563
2564
|
}
|
|
@@ -344,7 +344,7 @@ export const create = async ( req, res ) => {
|
|
|
344
344
|
return res.sendError( e, 500 );
|
|
345
345
|
} );
|
|
346
346
|
} catch ( e ) {
|
|
347
|
-
console.log( 'e', e );
|
|
347
|
+
// console.log( 'e', e );
|
|
348
348
|
logger.error( 'create =>', e );
|
|
349
349
|
return res.sendError( e, 500 );
|
|
350
350
|
}
|
|
@@ -2387,7 +2387,7 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2387
2387
|
}, {} );
|
|
2388
2388
|
|
|
2389
2389
|
const duplicateUsers = Object.keys( duplicateUser ).filter( ( storeName ) => duplicateUser[storeName].count > 1 );
|
|
2390
|
-
console.log( duplicateUsers, 'user' );
|
|
2390
|
+
// console.log( duplicateUsers, 'user' );
|
|
2391
2391
|
if ( duplicateUsers.length ) {
|
|
2392
2392
|
return res.sendError( { validate: false, duplicates: duplicateUsers, message: 'Email is Duplicated' }, 400 );
|
|
2393
2393
|
}
|
|
@@ -3352,7 +3352,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3352
3352
|
if ( getCLconfig.coverage == 'store' ) {
|
|
3353
3353
|
let clusterList = allQuestion.filter( ( ele ) => ele?.clusterName ).map( ( item ) => item.assignId );
|
|
3354
3354
|
if ( clusterList.length ) {
|
|
3355
|
-
let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList } } );
|
|
3355
|
+
let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList }, clientId: getCLconfig.client_id } );
|
|
3356
3356
|
if ( clusterDetails.length ) {
|
|
3357
3357
|
let idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
|
|
3358
3358
|
let getStoreDetails = await storeService.find( { _id: { $in: idList }, status: 'active' } );
|
|
@@ -3419,7 +3419,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3419
3419
|
if ( getCLconfig.coverage == 'user' ) {
|
|
3420
3420
|
let teamsList = allQuestion.filter( ( ele ) => ele?.teamName ).map( ( item ) => item.assignId );
|
|
3421
3421
|
if ( teamsList.length ) {
|
|
3422
|
-
let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList } } );
|
|
3422
|
+
let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList }, clientId: getCLconfig.client_id } );
|
|
3423
3423
|
if ( teamDetails.length ) {
|
|
3424
3424
|
let idList = [ ...teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) ), ...teamDetails.flatMap( ( item ) => item.Teamlead.map( ( ele ) => ele.userId ) ) ];
|
|
3425
3425
|
let userIdList = allQuestion.filter( ( qn ) => !qn?.teamName ).map( ( qn ) => qn.assignId.toString() );
|
|
@@ -3536,7 +3536,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3536
3536
|
}
|
|
3537
3537
|
if ( getsubmitDetails ) {
|
|
3538
3538
|
getsubmitDetails = [ getsubmitDetails ];
|
|
3539
|
-
console.log( submittedDetails, getsubmitDetails );
|
|
3539
|
+
// console.log( submittedDetails, getsubmitDetails );
|
|
3540
3540
|
}
|
|
3541
3541
|
function findDifferences( obj1, obj2 ) {
|
|
3542
3542
|
return Object.keys( obj1 ).reduce( ( diff, key ) => {
|
|
@@ -4071,7 +4071,7 @@ export const selectAssign = async ( req, res ) => {
|
|
|
4071
4071
|
}
|
|
4072
4072
|
return res.sendSuccess( { 'totalCount': resuldData.length, 'data': resuldData } );
|
|
4073
4073
|
} catch ( e ) {
|
|
4074
|
-
console.log( 'e =>', e );
|
|
4074
|
+
// console.log( 'e =>', e );
|
|
4075
4075
|
logger.error( 'selectAssign =>', e );
|
|
4076
4076
|
return res.sendError( e, 500 );
|
|
4077
4077
|
}
|
|
@@ -4083,7 +4083,9 @@ async function assignUsers( data ) {
|
|
|
4083
4083
|
let clusterDetails = await clusterServices.findcluster( { clientId: data.clientId, _id: new mongoose.Types.ObjectId( data.id ) } );
|
|
4084
4084
|
if ( clusterDetails.length ) {
|
|
4085
4085
|
let clusterList = clusterDetails[0].stores.map( ( ele ) => ele.store );
|
|
4086
|
+
// console.log( clusterList );
|
|
4086
4087
|
let storeDetails = await storeService.find( { _id: { $in: clusterList }, status: 'active' } );
|
|
4088
|
+
// console.log( storeDetails.length );
|
|
4087
4089
|
assignedData = await Promise.all( storeDetails.map( async ( store ) => {
|
|
4088
4090
|
let userData = {
|
|
4089
4091
|
storeId: store.storeId,
|
|
@@ -4091,7 +4093,7 @@ async function assignUsers( data ) {
|
|
|
4091
4093
|
userName: store.spocDetails?.[0]?.name,
|
|
4092
4094
|
userEmail: store.spocDetails?.[0]?.email,
|
|
4093
4095
|
clusterName: clusterDetails?.[0]?.clusterName,
|
|
4094
|
-
id: clusterDetails?.[0]?._id,
|
|
4096
|
+
id: [ clusterDetails?.[0]?._id ],
|
|
4095
4097
|
};
|
|
4096
4098
|
return userData;
|
|
4097
4099
|
} ) );
|
|
@@ -4106,7 +4108,7 @@ async function assignUsers( data ) {
|
|
|
4106
4108
|
userName: user.userName,
|
|
4107
4109
|
userEmail: user.email,
|
|
4108
4110
|
teamName: teamDetails?.[0]?.teamName,
|
|
4109
|
-
id: teamDetails?.[0]?._id,
|
|
4111
|
+
id: [ teamDetails?.[0]?._id ],
|
|
4110
4112
|
};
|
|
4111
4113
|
return userData;
|
|
4112
4114
|
} );
|
|
@@ -4144,12 +4146,12 @@ export async function checklistAssign( req, res ) {
|
|
|
4144
4146
|
uniqueArr.push( ...uploadData );
|
|
4145
4147
|
}
|
|
4146
4148
|
} ) );
|
|
4147
|
-
|
|
4148
4149
|
if ( uniqueArr.length ) {
|
|
4149
4150
|
if ( req.body.coverage == 'store' ) {
|
|
4150
4151
|
uniqueArr = uniqueArr.reduce( ( acc, obj ) => {
|
|
4151
4152
|
if ( acc[obj.storeName] ) {
|
|
4152
4153
|
acc[obj.storeName].clusterName += ',' + obj.clusterName;
|
|
4154
|
+
acc[obj.storeName].id.push( ...obj.id );
|
|
4153
4155
|
} else {
|
|
4154
4156
|
acc[obj.storeName] = { ...obj };
|
|
4155
4157
|
}
|
|
@@ -4161,6 +4163,7 @@ export async function checklistAssign( req, res ) {
|
|
|
4161
4163
|
uniqueArr = uniqueArr.reduce( ( acc, obj ) => {
|
|
4162
4164
|
if ( acc[obj.userEmail] ) {
|
|
4163
4165
|
acc[obj.userEmail].teamName += ','+ obj.teamName;
|
|
4166
|
+
acc[obj.userEmail].id.push( ...obj.id );
|
|
4164
4167
|
} else {
|
|
4165
4168
|
acc[obj.userEmail] = { ...obj };
|
|
4166
4169
|
}
|
|
@@ -4186,18 +4189,25 @@ export async function updateAssign( req, res ) {
|
|
|
4186
4189
|
if ( !checklistDetails ) {
|
|
4187
4190
|
return res.sendError( 'No data found', 204 );
|
|
4188
4191
|
}
|
|
4189
|
-
let groupList =
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4192
|
+
let groupList = [];
|
|
4193
|
+
let groupAssignList = req.body.assignedGroup;
|
|
4194
|
+
req.body.assignedGroup = [ ...new Set( req.body.assignedGroup.flatMap( ( item ) => item.id ) ) ];
|
|
4195
|
+
|
|
4196
|
+
groupAssignList.forEach( ( ele ) => {
|
|
4197
|
+
let gName;
|
|
4198
|
+
if ( ele?.clusterName ) {
|
|
4199
|
+
gName = ele.clusterName.split( ',' );
|
|
4200
|
+
}
|
|
4201
|
+
if ( ele?.teamName ) {
|
|
4202
|
+
gName = ele.teamName.split( ',' );
|
|
4203
|
+
}
|
|
4204
|
+
gName.forEach( ( name ) => {
|
|
4205
|
+
if ( !groupList.includes( name ) ) {
|
|
4206
|
+
groupList.push( name );
|
|
4207
|
+
}
|
|
4208
|
+
} );
|
|
4209
|
+
} );
|
|
4210
|
+
|
|
4201
4211
|
let getAssignedDetails = await assignedService.find( { checkListId: req.body.checkListId } );
|
|
4202
4212
|
let oldCoverage;
|
|
4203
4213
|
if ( getAssignedDetails.length ) {
|