tango-app-api-trax 3.6.0-inditech-1 → 3.6.0-sec-1
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/gallery.controller.js +24 -43
- package/src/controllers/internalTrax.controller.js +1 -118
- package/src/controllers/trax.controller.js +13 -0
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/gallery.routes.js +8 -8
- package/src/routes/internalTraxApi.router.js +1 -2
- package/src/services/notification.service.js +0 -31
package/package.json
CHANGED
|
@@ -16,7 +16,6 @@ import { aggregate } from '../services/user.service.js';
|
|
|
16
16
|
// import axios from 'axios';
|
|
17
17
|
import timeZone from 'dayjs/plugin/timezone.js';
|
|
18
18
|
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
19
|
-
import * as notificationModel from '../services/notification.service.js';
|
|
20
19
|
|
|
21
20
|
dayjs.extend( customParseFormat );
|
|
22
21
|
dayjs.extend( timeZone );
|
|
@@ -484,8 +483,8 @@ export async function redoChecklist( req, res ) {
|
|
|
484
483
|
sectionName: question[sectionIndex].sectionName,
|
|
485
484
|
questionName: question[sectionIndex].questions[findQuestion].qname,
|
|
486
485
|
action: 'redo',
|
|
487
|
-
store_id: checklistDetails?.store_id
|
|
488
|
-
storeName: checklistDetails?.storeName
|
|
486
|
+
store_id: checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
487
|
+
storeName: checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
489
488
|
client_id: checklistDetails.client_id,
|
|
490
489
|
processedChecklistId: checklistDetails._id,
|
|
491
490
|
type: checklistDetails.checkListType,
|
|
@@ -508,16 +507,16 @@ export async function redoChecklist( req, res ) {
|
|
|
508
507
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
509
508
|
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
510
509
|
// console.log( searchResponse.ok );
|
|
511
|
-
let logData
|
|
510
|
+
let logData= {
|
|
512
511
|
'client_id': checklistDetails.client_id,
|
|
513
512
|
'createAt': new Date(),
|
|
514
513
|
'sourceCheckList_id': checklistDetails.sourceCheckList_id,
|
|
515
514
|
'checkListName': checklistDetails.checkListName,
|
|
516
515
|
'fromCheckListName': checklistDetails.checkListName,
|
|
517
516
|
'type': 'checklist',
|
|
518
|
-
'action': checklistDetails.redoStatus
|
|
519
|
-
'storeName': checklistDetails?.storeName
|
|
520
|
-
'store_id': checklistDetails?.store_id
|
|
517
|
+
'action': checklistDetails.redoStatus?'multiredo': 'redo',
|
|
518
|
+
'storeName': checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
519
|
+
'store_id': checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
521
520
|
'userName': checklistDetails.userName,
|
|
522
521
|
'userEmail': checklistDetails.userEmail,
|
|
523
522
|
'createdByEmail': req.user.email,
|
|
@@ -545,7 +544,7 @@ export async function redoChecklist( req, res ) {
|
|
|
545
544
|
|
|
546
545
|
export async function redomultiChecklist( req, res ) {
|
|
547
546
|
try {
|
|
548
|
-
let inputData = req.body.payload.coverage
|
|
547
|
+
let inputData = req.body.payload.coverage==='user'?req.body.payload.userEmail:req.body.payload.storeName;
|
|
549
548
|
|
|
550
549
|
|
|
551
550
|
for ( let originalData of inputData ) {
|
|
@@ -626,8 +625,8 @@ export async function redomultiChecklist( req, res ) {
|
|
|
626
625
|
sectionName: question[sectionIndex].sectionName,
|
|
627
626
|
questionName: question[sectionIndex].questions[findQuestion].qname,
|
|
628
627
|
action: 'redo',
|
|
629
|
-
store_id: checklistDetails?.store_id
|
|
630
|
-
storeName: checklistDetails?.storeName
|
|
628
|
+
store_id: checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
629
|
+
storeName: checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
631
630
|
client_id: checklistDetails.client_id,
|
|
632
631
|
processedChecklistId: checklistDetails._id,
|
|
633
632
|
type: checklistDetails.checkListType,
|
|
@@ -641,9 +640,9 @@ export async function redomultiChecklist( req, res ) {
|
|
|
641
640
|
await checklistLogs.create( data );
|
|
642
641
|
|
|
643
642
|
|
|
644
|
-
req.body.payload._id
|
|
645
|
-
req.body.payload.section_id
|
|
646
|
-
req.body.payload.uniqueNo
|
|
643
|
+
req.body.payload._id=originalData.checklistId;
|
|
644
|
+
req.body.payload.section_id=originalData.section_id;
|
|
645
|
+
req.body.payload.uniqueNo=originalData.uniqueNo;
|
|
647
646
|
// console.log( req.body );
|
|
648
647
|
|
|
649
648
|
|
|
@@ -657,16 +656,16 @@ export async function redomultiChecklist( req, res ) {
|
|
|
657
656
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
658
657
|
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
659
658
|
console.log( searchResponse.ok );
|
|
660
|
-
let logData
|
|
659
|
+
let logData= {
|
|
661
660
|
'client_id': checklistDetails.client_id,
|
|
662
661
|
'createAt': new Date(),
|
|
663
662
|
'sourceCheckList_id': checklistDetails.sourceCheckList_id,
|
|
664
663
|
'checkListName': checklistDetails.checkListName,
|
|
665
664
|
'fromCheckListName': checklistDetails.checkListName,
|
|
666
665
|
'type': 'checklist',
|
|
667
|
-
'action': checklistDetails.redoStatus
|
|
668
|
-
'storeName': checklistDetails?.storeName
|
|
669
|
-
'store_id': checklistDetails?.store_id
|
|
666
|
+
'action': checklistDetails.redoStatus?'multiredo': 'redo',
|
|
667
|
+
'storeName': checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
668
|
+
'store_id': checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
670
669
|
'userName': checklistDetails.userName,
|
|
671
670
|
'userEmail': checklistDetails.userEmail,
|
|
672
671
|
'createdByEmail': req.user.email,
|
|
@@ -770,7 +769,6 @@ export async function approvalstatus( req, res ) {
|
|
|
770
769
|
export const headerStoresV2 = async ( req, res ) => {
|
|
771
770
|
try {
|
|
772
771
|
let reqestData = req.body;
|
|
773
|
-
|
|
774
772
|
let getUserEmail = req.user.email;
|
|
775
773
|
let getUserType = req.user.userType;
|
|
776
774
|
let getRole = req.user.role;
|
|
@@ -1050,7 +1048,7 @@ export async function teamsList( req, res ) {
|
|
|
1050
1048
|
];
|
|
1051
1049
|
|
|
1052
1050
|
|
|
1053
|
-
if ( req.user
|
|
1051
|
+
if ( req.user&&req.user.userType==='client'&&req.user.role!='superadmin' ) {
|
|
1054
1052
|
query.push( {
|
|
1055
1053
|
$match: {
|
|
1056
1054
|
Teamlead: {
|
|
@@ -1090,16 +1088,14 @@ export async function userList( req, res ) {
|
|
|
1090
1088
|
},
|
|
1091
1089
|
},
|
|
1092
1090
|
];
|
|
1093
|
-
if ( req.user
|
|
1094
|
-
let findTeams = await findteams( {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}, clientId: req.body.clientId,
|
|
1100
|
-
} );
|
|
1091
|
+
if ( req.user&&req.user.userType==='client'&&req.user.role!='superadmin' ) {
|
|
1092
|
+
let findTeams = await findteams( { Teamlead: {
|
|
1093
|
+
$elemMatch: {
|
|
1094
|
+
email: req.user.email,
|
|
1095
|
+
},
|
|
1096
|
+
}, clientId: req.body.clientId } );
|
|
1101
1097
|
req.body.teams = findTeams.map( ( data ) => data.teamName );
|
|
1102
|
-
if ( req.body.teams.length
|
|
1098
|
+
if ( req.body.teams.length===0 ) {
|
|
1103
1099
|
query.push( {
|
|
1104
1100
|
$match: {
|
|
1105
1101
|
userEmail: { $in: [ req.user.email ] },
|
|
@@ -1133,18 +1129,3 @@ export async function userList( req, res ) {
|
|
|
1133
1129
|
return res.sendError( { error: error }, 500 );
|
|
1134
1130
|
}
|
|
1135
1131
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
export async function checkNotificationCount( req, res ) {
|
|
1139
|
-
try {
|
|
1140
|
-
console.log( req.user._id );
|
|
1141
|
-
let notifyRecord = await notificationModel.findnotification( { 'userId': new mongoose.Types.ObjectId( req.user._id ), 'status': 'unsend' } );
|
|
1142
|
-
let findRecord = notifyRecord.map( ( data ) => data._id );
|
|
1143
|
-
console.log( findRecord );
|
|
1144
|
-
await notificationModel.updateManynotification( { _id: { $in: findRecord } }, { $set: { 'status': 'send' } } );
|
|
1145
|
-
return res.sendSuccess( notifyRecord );
|
|
1146
|
-
} catch ( error ) {
|
|
1147
|
-
logger.error( { error: error, function: 'checkNotificationCount' } );
|
|
1148
|
-
return res.sendError( { error: error }, 500 );
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
@@ -22,7 +22,7 @@ import { sendPushNotification, sendAiPushNotification } from 'tango-app-api-midd
|
|
|
22
22
|
// import * as planoService from '../services/planogram.service.js';
|
|
23
23
|
import * as clusterServices from '../services/cluster.service.js';
|
|
24
24
|
import * as teamsServices from '../services/teams.service.js';
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
|
|
27
27
|
const ObjectId = mongoose.Types.ObjectId;
|
|
28
28
|
dayjs.extend( customParseFormat );
|
|
@@ -2345,120 +2345,3 @@ export async function getLiveChecklistClients( req, res ) {
|
|
|
2345
2345
|
else res.sendError( error, 500 );
|
|
2346
2346
|
}
|
|
2347
2347
|
}
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
export async function notificationCreate( req, res ) {
|
|
2351
|
-
try {
|
|
2352
|
-
let insertData= [];
|
|
2353
|
-
let findAllUser = await userService.find( { clientId: '464', isActive: true } );
|
|
2354
|
-
for ( let user of findAllUser ) {
|
|
2355
|
-
for ( let store of req.body ) {
|
|
2356
|
-
let data= {};
|
|
2357
|
-
data.userId = user._id;
|
|
2358
|
-
data.storeId = store.storeId;
|
|
2359
|
-
data.storeName = store.storeName;
|
|
2360
|
-
data.captureTime = store.captureTime;
|
|
2361
|
-
data.slotNo = store.slotNo;
|
|
2362
|
-
let payload = {
|
|
2363
|
-
userType: user.userType,
|
|
2364
|
-
role: user.role,
|
|
2365
|
-
assignedStores: user.assignedStores,
|
|
2366
|
-
clientId: user.clientId,
|
|
2367
|
-
email: user.email,
|
|
2368
|
-
};
|
|
2369
|
-
let result = await storecheckExists( payload );
|
|
2370
|
-
if ( result ) {
|
|
2371
|
-
insertData.push( data );
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
}
|
|
2375
|
-
let create = await notificationModel.insertManynotificationModel( insertData );
|
|
2376
|
-
// console.log( create );
|
|
2377
|
-
if ( create ) {
|
|
2378
|
-
return res.sendSuccess( 'updated successfully' );
|
|
2379
|
-
}
|
|
2380
|
-
} catch ( e ) {
|
|
2381
|
-
logger.error( { error: e, function: 'notificationCreate' } );
|
|
2382
|
-
if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
|
|
2383
|
-
else res.sendError( e, 500 );
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
export async function storecheckExists( data ) {
|
|
2389
|
-
try {
|
|
2390
|
-
if ( data && data.userType === 'client' && data.role !== 'superadmin' ) {
|
|
2391
|
-
let storeIds = new Set( data.assignedStores.map( ( store ) => store.storeId ) );
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
// Fetch clusters and teams in parallel
|
|
2395
|
-
const [ clustersList, teamsList ] = await Promise.all( [
|
|
2396
|
-
clusterServices.findcluster( { clientId: data.clientId, Teamlead: { $elemMatch: { email: data.email } } } ),
|
|
2397
|
-
teamsServices.findteams( { clientId: data.clientId, Teamlead: { $elemMatch: { email: data.email } } } ),
|
|
2398
|
-
] );
|
|
2399
|
-
|
|
2400
|
-
// Process clusters
|
|
2401
|
-
if ( clustersList.length > 0 ) {
|
|
2402
|
-
for ( let cluster of clustersList ) {
|
|
2403
|
-
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
// Process teams
|
|
2408
|
-
if ( teamsList.length > 0 ) {
|
|
2409
|
-
for ( let team of teamsList ) {
|
|
2410
|
-
for ( let user of team.users ) {
|
|
2411
|
-
let findUser = await userService.findOne( { _id: user.userId } );
|
|
2412
|
-
if ( findUser && findUser.assignedStores?.length > 0 ) {
|
|
2413
|
-
findUser.assignedStores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2414
|
-
}
|
|
2415
|
-
|
|
2416
|
-
// Fetch clusters for the user
|
|
2417
|
-
let userClustersList = await clusterServices.findcluster( { clientId: data.clientId, Teamlead: { $elemMatch: { email: findUser.email } } } );
|
|
2418
|
-
if ( userClustersList.length > 0 ) {
|
|
2419
|
-
for ( let cluster of userClustersList ) {
|
|
2420
|
-
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
let TeamMember = await teamsServices.findteams( { clientId: data.clientId, users: { $elemMatch: { email: data.email } } } );
|
|
2427
|
-
if ( TeamMember&&TeamMember.length>0 ) {
|
|
2428
|
-
for ( let team of TeamMember ) {
|
|
2429
|
-
let clusterList = await clusterServices.findcluster( { clientId: data.clientId, teams: { $elemMatch: { name: team.teamName } } } );
|
|
2430
|
-
if ( clusterList.length > 0 ) {
|
|
2431
|
-
for ( let cluster of clusterList ) {
|
|
2432
|
-
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
let TeamLeader = await teamsServices.findteams( { clientId: data.clientId, Teamlead: { $elemMatch: { email: data.email } } } );
|
|
2438
|
-
if ( TeamLeader&&TeamLeader.length>0 ) {
|
|
2439
|
-
for ( let team of TeamLeader ) {
|
|
2440
|
-
let clusterList = await clusterServices.findcluster( { clientId: data.clientId, teams: { $elemMatch: { name: team.teamName } } } );
|
|
2441
|
-
if ( clusterList.length > 0 ) {
|
|
2442
|
-
for ( let cluster of clusterList ) {
|
|
2443
|
-
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
// Convert Set back to Array if needed
|
|
2449
|
-
|
|
2450
|
-
let resultStores = Array.from( storeIds );
|
|
2451
|
-
resultStores.filter( ( ele ) => ele.storeId===data.storeId );
|
|
2452
|
-
|
|
2453
|
-
if ( resultStores.length>0 ) {
|
|
2454
|
-
return true;
|
|
2455
|
-
} else {
|
|
2456
|
-
return false;
|
|
2457
|
-
}
|
|
2458
|
-
} else {
|
|
2459
|
-
return true;
|
|
2460
|
-
}
|
|
2461
|
-
} catch ( error ) {
|
|
2462
|
-
logger.error( { error: error, function: 'internalAISendPushNotification' } );
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
@@ -280,6 +280,7 @@ export const create = async ( req, res ) => {
|
|
|
280
280
|
checkListId: checkListId,
|
|
281
281
|
question: section.questions,
|
|
282
282
|
checkList: inputBody.checklistName,
|
|
283
|
+
sectionNumber: section.sectionNumber,
|
|
283
284
|
};
|
|
284
285
|
await questionService.create( sectionList ).then( async ( data ) => {
|
|
285
286
|
if ( i == inputBody.sections.length - 1 ) {
|
|
@@ -429,6 +430,7 @@ export const getConfigDetails = async ( req, res ) => {
|
|
|
429
430
|
name: item.section,
|
|
430
431
|
oldName: item?.sectionOldName,
|
|
431
432
|
questions: item.question,
|
|
433
|
+
sectionNumber: item.sectionNumber,
|
|
432
434
|
} );
|
|
433
435
|
} );
|
|
434
436
|
sectionList = sections;
|
|
@@ -906,11 +908,13 @@ export const update = async ( req, res ) => {
|
|
|
906
908
|
checkListId: checkListId,
|
|
907
909
|
question: section.questions,
|
|
908
910
|
checkList: inputBody.checklistName,
|
|
911
|
+
sectionNumber: section.sectionNumber,
|
|
909
912
|
} );
|
|
910
913
|
}
|
|
911
914
|
}
|
|
912
915
|
await questionService.deleteMany( { checkListId: checkListId, client_id: req.body.clientId } );
|
|
913
916
|
if ( sectionList.length ) {
|
|
917
|
+
sectionList.sort( ( a, b ) => a.sectionNumber - b.sectionNumber );
|
|
914
918
|
await questionService.insertMany( sectionList );
|
|
915
919
|
}
|
|
916
920
|
|
|
@@ -1022,6 +1026,14 @@ export const update = async ( req, res ) => {
|
|
|
1022
1026
|
userType: req.user.userType,
|
|
1023
1027
|
};
|
|
1024
1028
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, insertLogData );
|
|
1029
|
+
|
|
1030
|
+
// / Teams Alert
|
|
1031
|
+
let teamsMsg;
|
|
1032
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
1033
|
+
teamsMsg = 'ClientId: '+ insertLogData.client_id + ', Type: Checklist, Action: Checklist Question Edited, ChecklistId: '+ insertLogData.sourceCheckList_id + ', Checklist Name: '+ insertLogData.checkListName +', UpDatedBy: '+ req.user.email;
|
|
1034
|
+
if ( teamsAlertUrls && teamsAlertUrls.questionEditAlert ) {
|
|
1035
|
+
sendTeamsNotification( teamsAlertUrls.questionEditAlert, teamsMsg );
|
|
1036
|
+
}
|
|
1025
1037
|
}
|
|
1026
1038
|
|
|
1027
1039
|
if ( inputBody.submitType == 'save' ) {
|
|
@@ -1670,6 +1682,7 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1670
1682
|
client_id: req.body.clientId,
|
|
1671
1683
|
createdByEmail: req.user.email,
|
|
1672
1684
|
approver: inputBody?.checkListDetails?.approver || [],
|
|
1685
|
+
sections: inputBody?.checkListDetails?.sections || [],
|
|
1673
1686
|
};
|
|
1674
1687
|
await checklistLogs.create( logInsertData );
|
|
1675
1688
|
|