tango-app-api-trax 3.7.74 → 3.7.76
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.76",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"nodemon": "^3.1.4",
|
|
30
30
|
"path": "^0.12.7",
|
|
31
31
|
"puppeteer": "^24.39.1",
|
|
32
|
-
"tango-api-schema": "^2.5.
|
|
32
|
+
"tango-api-schema": "^2.5.67",
|
|
33
33
|
"tango-app-api-middleware": "^3.5.2",
|
|
34
34
|
"url": "^0.11.4",
|
|
35
35
|
"winston": "^3.13.1",
|
|
@@ -3367,3 +3367,56 @@ export async function getStoreTaskDetails( req, res ) {
|
|
|
3367
3367
|
return res.sendError( err, 500 );
|
|
3368
3368
|
}
|
|
3369
3369
|
}
|
|
3370
|
+
|
|
3371
|
+
export async function runAIFlag( req, res ) {
|
|
3372
|
+
try {
|
|
3373
|
+
let checklistDetails = await CLconfig.find( { publish: true, $expr: { $ne: [ { $size: '$notifyFlags.notifyType' }, 0 ] }, runAIQuestionCount: { $ne: 0 } }, { _id: 1 } );
|
|
3374
|
+
if ( checklistDetails.length ) {
|
|
3375
|
+
await Promise.all( checklistDetails.map( async ( ele ) => {
|
|
3376
|
+
let submitDetails = await processedchecklist.find( { sourceCheckList_id: ele._id, checklistStatus: 'submit' }, { storeName: 1, checkListName: 1, questionAnswers: 1 } );
|
|
3377
|
+
await Promise.all( submitDetails.map( ( store ) => {
|
|
3378
|
+
if ( questionAnswers.length ) {
|
|
3379
|
+
let runAIFlag = 0;
|
|
3380
|
+
questionAnswers.forEach( ( section ) => {
|
|
3381
|
+
section.questions.forEach( ( question ) => {
|
|
3382
|
+
if ( question.answerType == 'image' && ( question?.userAnswer?.[0]?.runAIDate.value == 'false' || !question?.userAnswer?.[0]?.runAIDate.value ) ) {
|
|
3383
|
+
runAIFlag++;
|
|
3384
|
+
}
|
|
3385
|
+
} );
|
|
3386
|
+
} );
|
|
3387
|
+
|
|
3388
|
+
if ( runAIFlag ) {
|
|
3389
|
+
let emailList = checklistDetails?.notifyFlags?.notifyType.includes( 'approver' ) ? checklistDetails.approver.map( ( ele ) => ele?.value ): [];
|
|
3390
|
+
emailList = [ ...emailList, ...checklistDetails?.notifyFlags?.users?.map( ( ele ) => ele?.value ) ];
|
|
3391
|
+
let data = {
|
|
3392
|
+
storeName: store.storeName,
|
|
3393
|
+
flagCount: 1,
|
|
3394
|
+
checklistName: store.checkListName?.trim(),
|
|
3395
|
+
submittedBy: '--',
|
|
3396
|
+
time: '--',
|
|
3397
|
+
domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
|
|
3398
|
+
type: 'delay',
|
|
3399
|
+
};
|
|
3400
|
+
const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
|
|
3401
|
+
const htmlContent = handlebars.compile( fileContent );
|
|
3402
|
+
const html = htmlContent( { data: data } );
|
|
3403
|
+
emailList.forEach( ( email ) => {
|
|
3404
|
+
let params = {
|
|
3405
|
+
toEmail: email,
|
|
3406
|
+
mailSubject: 'TangoEye | Checklist Flag',
|
|
3407
|
+
htmlBody: html,
|
|
3408
|
+
attachment: '',
|
|
3409
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
3410
|
+
};
|
|
3411
|
+
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
3412
|
+
} );
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
} ) );
|
|
3416
|
+
} ) );
|
|
3417
|
+
}
|
|
3418
|
+
} catch ( e ) {
|
|
3419
|
+
logger.error( { functionName: 'runAIFlag', error: e } );
|
|
3420
|
+
return res.sendError( e, 500 );
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
@@ -650,7 +650,7 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
650
650
|
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
-
if ( requestData
|
|
653
|
+
if ( !requestData?.editSubmit || requestData?.editSubmit == 'false' ) {
|
|
654
654
|
let reqAnswers = requestData.questionAnswers;
|
|
655
655
|
logger.error( { functionName: 'payload', message: reqAnswers } );
|
|
656
656
|
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
@@ -664,7 +664,7 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
664
664
|
section.questions.forEach( ( question ) => {
|
|
665
665
|
// question.answers.forEach( ( answer ) => {
|
|
666
666
|
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
667
|
-
if ( sectionQuestion.length ) {
|
|
667
|
+
if ( sectionQuestion.length && requestData.submittype == 'submit' ) {
|
|
668
668
|
if ( ( question.answerType == 'multiplechoicemultiple' || ( question.answerType =='dropdown' && question.allowMultiple ) ) && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
|
|
669
669
|
validationCount++;
|
|
670
670
|
} else {
|
|
@@ -1555,7 +1555,7 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1555
1555
|
|
|
1556
1556
|
if ( requestData.submittype == 'submit' ) {
|
|
1557
1557
|
reqAnswers.forEach( ( reqA ) => {
|
|
1558
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) &&
|
|
1558
|
+
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && ( reqA?.answerType == 'dropdown' && !reqA?.Multianswer?.length ) ) {
|
|
1559
1559
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
1560
1560
|
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1561
1561
|
}
|
|
@@ -2183,7 +2183,7 @@ export async function submitChecklist( req, res ) {
|
|
|
2183
2183
|
checklistName: getchecklist[0].checkListName,
|
|
2184
2184
|
submittedBy: getchecklist[0].userName,
|
|
2185
2185
|
time: updateData.submitTime_string,
|
|
2186
|
-
domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
|
|
2186
|
+
domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags?date=${dayjs().format( 'YYYY-MM-DD' )}`,
|
|
2187
2187
|
};
|
|
2188
2188
|
const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
|
|
2189
2189
|
const htmlContent = handlebars.compile( fileContent );
|
|
@@ -2451,9 +2451,9 @@ export async function submiteyeTestTask( req, res ) {
|
|
|
2451
2451
|
if ( findQrExists ) {
|
|
2452
2452
|
return res.sendError( 'Qr code already Exists', 400 );
|
|
2453
2453
|
}
|
|
2454
|
-
|
|
2455
|
-
await
|
|
2456
|
-
await
|
|
2454
|
+
await cameraService.updateOne( { streamName: streamId }, { qrCode: qrCode, isEyeTestStream: true } );
|
|
2455
|
+
let findCamera = await cameraService.findOne( { streamName: streamId } );
|
|
2456
|
+
await storeService.updateOne( { storeId: findCamera.storeId }, { 'edge.isSocketEnable': true } );
|
|
2457
2457
|
return res.sendSuccess( 'Qr code added successfully' );
|
|
2458
2458
|
|
|
2459
2459
|
const findQuery = [
|
|
@@ -3886,18 +3886,25 @@ export async function taskQuestionList( req, res ) {
|
|
|
3886
3886
|
|
|
3887
3887
|
if ( question?.userAnswer ) {
|
|
3888
3888
|
for ( let [ userAnsIndex, userAns ] of question.userAnswer.entries() ) {
|
|
3889
|
+
const rawAnswer = userAns.answer;
|
|
3890
|
+
if ( question.answerType == 'linearscale' && question.answers?.[0]?.linearType ) {
|
|
3891
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].linearType = question.answers[0].linearType;
|
|
3892
|
+
}
|
|
3889
3893
|
if ( ( userAns.validationType == 'Capture Image' || userAns.validationType == 'Capture Video' ) && userAns.validationAnswer && userAns.validationAnswer != '' ) {
|
|
3890
3894
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer = await signedUrl( {
|
|
3891
3895
|
file_path: decodeURIComponent( userAns.validationAnswer ),
|
|
3892
3896
|
Bucket: bucket.sop,
|
|
3893
3897
|
} );
|
|
3894
3898
|
}
|
|
3895
|
-
if ( [ 'image', 'descriptiveImage', 'video'
|
|
3899
|
+
if ( [ 'image', 'descriptiveImage', 'video' ].includes( question.answerType ) && rawAnswer != '' ) {
|
|
3896
3900
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = await signedUrl( {
|
|
3897
|
-
file_path: decodeURIComponent(
|
|
3901
|
+
file_path: decodeURIComponent( rawAnswer ),
|
|
3898
3902
|
Bucket: bucket.sop,
|
|
3899
3903
|
} );
|
|
3900
3904
|
}
|
|
3905
|
+
if ( question.answerType == 'image/video' && rawAnswer != '' ) {
|
|
3906
|
+
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = `${cdnurl.TraxAnswerCDN}${rawAnswer}`;
|
|
3907
|
+
}
|
|
3901
3908
|
if ( userAns.referenceImage != '' ) {
|
|
3902
3909
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].referenceImage = await signedUrl( {
|
|
3903
3910
|
file_path: decodeURIComponent( userAns.referenceImage ),
|
|
@@ -3905,14 +3912,14 @@ export async function taskQuestionList( req, res ) {
|
|
|
3905
3912
|
} );
|
|
3906
3913
|
}
|
|
3907
3914
|
if ( question.answerType == 'multiplechoicemultiple' || ( question.answerType == 'dropdown' && question.allowMultiple ) ) {
|
|
3908
|
-
let ansIndex = Multianswer.findIndex( ( item ) => item.answer ==
|
|
3915
|
+
let ansIndex = Multianswer.findIndex( ( item ) => item.answer == rawAnswer );
|
|
3909
3916
|
if ( ansIndex >= 0 ) {
|
|
3910
3917
|
Multianswer[ansIndex].validationAnswer = userAns.validationAnswer;
|
|
3911
3918
|
}
|
|
3912
3919
|
}
|
|
3913
3920
|
if ( question.answerType == 'multipleImage' || question.answerType == 'image/video' ) {
|
|
3914
|
-
if ( userAns &&
|
|
3915
|
-
let manswer = `${cdnurl.TraxAnswerCDN}${
|
|
3921
|
+
if ( userAns && rawAnswer && rawAnswer != '' ) {
|
|
3922
|
+
let manswer = `${cdnurl.TraxAnswerCDN}${rawAnswer}`;
|
|
3916
3923
|
Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '', ...( question.answerType == 'image/video' && { answerType: userAns?.answerType } ) } );
|
|
3917
3924
|
} else {
|
|
3918
3925
|
|
package/src/hbs/flag.hbs
CHANGED
|
@@ -165,26 +165,26 @@
|
|
|
165
165
|
<td></td>
|
|
166
166
|
<td class="flagText">{{data.storeName}}</td>
|
|
167
167
|
</tr>
|
|
168
|
-
<tr bgcolor="#ffffff" style="border:none;margin-top:
|
|
168
|
+
<tr bgcolor="#ffffff" style="border:none;margin-top:3px;">
|
|
169
169
|
<td class="flagText" style="padding-left:30px; line-height: 24px;">Checklist Name :</td>
|
|
170
170
|
<td></td>
|
|
171
171
|
<td></td>
|
|
172
|
-
<td class="flagText">{{data.checklistName}}
|
|
172
|
+
<td class="flagText">{{data.checklistName}}</td>
|
|
173
173
|
</tr>
|
|
174
174
|
|
|
175
|
-
<tr bgcolor="#ffffff" style="border:none;margin-top:
|
|
175
|
+
<tr bgcolor="#ffffff" style="border:none;margin-top:3px;">
|
|
176
176
|
<td class="flagText" style="padding-left:30px; line-height: 24px;">No of Flags :</td>
|
|
177
177
|
<td></td>
|
|
178
178
|
<td></td>
|
|
179
179
|
<td class="flagText">{{data.flagCount}}</td>
|
|
180
180
|
</tr>
|
|
181
|
-
<tr bgcolor="#ffffff" style="border:none;margin-top:
|
|
181
|
+
<tr bgcolor="#ffffff" style="border:none;margin-top:3px;">
|
|
182
182
|
<td class="flagText" style="padding-left:30px; line-height: 24px;">Submitted By :</td>
|
|
183
183
|
<td></td>
|
|
184
184
|
<td></td>
|
|
185
185
|
<td class="flagText">{{data.submittedBy}}</td>
|
|
186
186
|
</tr>
|
|
187
|
-
<tr bgcolor="#ffffff" style="border:none;margin-top:
|
|
187
|
+
<tr bgcolor="#ffffff" style="border:none;margin-top:3px;">
|
|
188
188
|
<td class="flagText" style="padding-left:30px; line-height: 24px;">Date & Time :</td>
|
|
189
189
|
<td></td>
|
|
190
190
|
<td></td>
|