tango-app-api-trax 3.7.57 → 3.7.59
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
|
@@ -3241,3 +3241,88 @@ export async function checklistTaskSubmissionDetails( req, res ) {
|
|
|
3241
3241
|
return res.sendError( e, 500 );
|
|
3242
3242
|
}
|
|
3243
3243
|
}
|
|
3244
|
+
|
|
3245
|
+
export async function getStoreTaskDetails( req, res ) {
|
|
3246
|
+
try {
|
|
3247
|
+
const checklistQuery = [
|
|
3248
|
+
{
|
|
3249
|
+
$match: {
|
|
3250
|
+
storeName: req.body.storeName,
|
|
3251
|
+
checkListName: { $regex: 'Store Tour', $options: 'i' },
|
|
3252
|
+
},
|
|
3253
|
+
},
|
|
3254
|
+
{
|
|
3255
|
+
$group: {
|
|
3256
|
+
_id: '$storeName',
|
|
3257
|
+
checklistStatus: { $last: '$checklistStatus' },
|
|
3258
|
+
checkListName: { $last: '$checkListName' },
|
|
3259
|
+
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3260
|
+
},
|
|
3261
|
+
},
|
|
3262
|
+
];
|
|
3263
|
+
const checkListDetails = await processedchecklist.aggregate( checklistQuery );
|
|
3264
|
+
const taskQuery = [
|
|
3265
|
+
{
|
|
3266
|
+
$match: {
|
|
3267
|
+
storeName: req.body.storeName,
|
|
3268
|
+
isPlano: true,
|
|
3269
|
+
planoType: { $in: [ 'fixture', 'merchRollout', 'vmRollout' ] },
|
|
3270
|
+
scheduleEndTime_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
3271
|
+
},
|
|
3272
|
+
},
|
|
3273
|
+
{
|
|
3274
|
+
$group: {
|
|
3275
|
+
_id: { store: '$storeName', type: '$planoType' },
|
|
3276
|
+
checklistStatus: { $last: '$checklistStatus' },
|
|
3277
|
+
checkListName: { $last: '$checkListName' },
|
|
3278
|
+
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3279
|
+
},
|
|
3280
|
+
},
|
|
3281
|
+
{
|
|
3282
|
+
$project: {
|
|
3283
|
+
store: '$_id.store',
|
|
3284
|
+
type: '$_id.type',
|
|
3285
|
+
checklistStatus: 1,
|
|
3286
|
+
checkListName: 1,
|
|
3287
|
+
scheduleEndTime_iso: 1,
|
|
3288
|
+
},
|
|
3289
|
+
},
|
|
3290
|
+
];
|
|
3291
|
+
|
|
3292
|
+
|
|
3293
|
+
const taskDetails = await processedTaskService.aggregate( taskQuery );
|
|
3294
|
+
console.log( taskDetails );
|
|
3295
|
+
let info = [ ...checkListDetails, ...taskDetails ];
|
|
3296
|
+
// const details = {
|
|
3297
|
+
// storeTourVideoChecklist: ( !checkListDetails.length || checkListDetails?.[0]?.checklistStatus == 'submit' ) ? true : false,
|
|
3298
|
+
// FixtureVerification: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'fixture' ) || taskDetails?.some( ( ele ) => ele?.type == 'fixture' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3299
|
+
// MerchRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3300
|
+
// VmRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3301
|
+
// };
|
|
3302
|
+
|
|
3303
|
+
let result = {
|
|
3304
|
+
storeId: req.body.storeName,
|
|
3305
|
+
tangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus == 'submit' ).map( ( ele ) => {
|
|
3306
|
+
return {
|
|
3307
|
+
blockName: ele?.checkListName,
|
|
3308
|
+
blockEnabled: true,
|
|
3309
|
+
blockReason: `${ele?.checkListName} is completed`,
|
|
3310
|
+
};
|
|
3311
|
+
} ),
|
|
3312
|
+
upcomingTangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus !== 'submit' ).map( ( ele ) => {
|
|
3313
|
+
return {
|
|
3314
|
+
blockName: ele?.checkListName,
|
|
3315
|
+
blockReason: `Compelete ${ele?.checkListName} before ${dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' )} to avoid ABC block`,
|
|
3316
|
+
dueDate: dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ),
|
|
3317
|
+
};
|
|
3318
|
+
} ),
|
|
3319
|
+
};
|
|
3320
|
+
|
|
3321
|
+
|
|
3322
|
+
return res.sendSuccess( result );
|
|
3323
|
+
} catch ( error ) {
|
|
3324
|
+
const err = error.message || 'Internal Server Error';
|
|
3325
|
+
logger.error( { error: error, message: req.body, function: 'getStoretaskDetails' } );
|
|
3326
|
+
return res.sendError( err, 500 );
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
@@ -667,10 +667,10 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
667
667
|
// question.answers.forEach( ( answer ) => {
|
|
668
668
|
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
669
669
|
if ( sectionQuestion.length ) {
|
|
670
|
-
if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
|
|
670
|
+
if ( question.answerType == 'multiplechoicemultiple' || ( question.answerType =='dropdown' && question.allowMultiple ) && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
|
|
671
671
|
validationCount++;
|
|
672
672
|
} else {
|
|
673
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
|
|
673
|
+
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( question.answerType =='dropdown' && !question.allowMultiple ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
|
|
674
674
|
validationCount++;
|
|
675
675
|
}
|
|
676
676
|
}
|
|
@@ -1268,6 +1268,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1268
1268
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1269
1269
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1270
1270
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1271
|
+
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1271
1272
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1272
1273
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1273
1274
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1328,6 +1329,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1328
1329
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1329
1330
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1330
1331
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1332
|
+
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1331
1333
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1332
1334
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1333
1335
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -4577,53 +4579,44 @@ export async function downloadChecklist( req, res ) {
|
|
|
4577
4579
|
Bucket: JSON.parse( process.env.BUCKET )?.assets,
|
|
4578
4580
|
file_path: `${bucketpath}/${clientDetails?.profileDetails?.logo}`,
|
|
4579
4581
|
};
|
|
4580
|
-
let
|
|
4581
|
-
let brandImage = await convertUrltoBase64( url );
|
|
4582
|
+
let brandImage = await signedUrl( params );
|
|
4583
|
+
// let brandImage = await convertUrltoBase64( url );
|
|
4582
4584
|
if ( brandImage ) {
|
|
4583
4585
|
checklistDetails['brandLogo'] = brandImage;
|
|
4584
4586
|
}
|
|
4585
4587
|
}
|
|
4586
4588
|
checklistDetails['brandName'] = clientDetails?.clientName;
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
+
checklistDetails.questionAnswers.forEach( ( section ) => {
|
|
4590
|
+
section.questions.forEach( ( question ) => {
|
|
4589
4591
|
question.remarks = question.remarks == null || question.remarks == 'null' ? '' : question.remarks;
|
|
4590
|
-
|
|
4592
|
+
question.userAnswer.forEach( ( answer ) => {
|
|
4591
4593
|
if ( answer?.referenceImage?.trim() ) {
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
const base64Image = await convertUrltoBase64( url );
|
|
4598
|
-
if ( base64Image ) {
|
|
4599
|
-
answer.referenceImage = base64Image;
|
|
4600
|
-
}
|
|
4594
|
+
answer.referenceImage = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.referenceImage;
|
|
4595
|
+
// const base64Image = await convertUrltoBase64( url );
|
|
4596
|
+
// if ( base64Image ) {
|
|
4597
|
+
// answer.referenceImage = base64Image;
|
|
4598
|
+
// }
|
|
4601
4599
|
}
|
|
4602
4600
|
if ( answer.validationType == 'Capture Image' && answer?.validationAnswer?.trim() ) {
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
const base64Image = await convertUrltoBase64( url );
|
|
4609
|
-
if ( base64Image ) {
|
|
4610
|
-
answer.validationAnswer = base64Image;
|
|
4611
|
-
}
|
|
4601
|
+
answer.validationAnswer = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.validationAnswer;
|
|
4602
|
+
// const base64Image = await convertUrltoBase64( url );
|
|
4603
|
+
// if ( base64Image ) {
|
|
4604
|
+
// answer.validationAnswer = base64Image;
|
|
4605
|
+
// }
|
|
4612
4606
|
}
|
|
4613
4607
|
if ( answer?.answer?.trim() && [ 'image', 'descriptiveImage', 'multipleImage', 'image/video' ].includes( question.answerType ) ) {
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
};
|
|
4618
|
-
let url = await signedUrl( inputData );
|
|
4619
|
-
const base64Image = await convertUrltoBase64( url );
|
|
4620
|
-
if ( base64Image ) {
|
|
4621
|
-
answer.answer = base64Image;
|
|
4608
|
+
answer.answer = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.answer;
|
|
4609
|
+
if ( question.answerType == 'multipleImage' ) {
|
|
4610
|
+
console.log( answer.answer );
|
|
4622
4611
|
}
|
|
4612
|
+
// const base64Image = await convertUrltoBase64( url );
|
|
4613
|
+
// if ( base64Image ) {
|
|
4614
|
+
// answer.answer = base64Image;
|
|
4615
|
+
// }
|
|
4623
4616
|
}
|
|
4624
|
-
}
|
|
4625
|
-
}
|
|
4626
|
-
}
|
|
4617
|
+
} );
|
|
4618
|
+
} );
|
|
4619
|
+
} );
|
|
4627
4620
|
const targetFolder = path.join( __dirname, '..', '/hbs/template.hbs' );
|
|
4628
4621
|
const templateHtml = fs.readFileSync( targetFolder, 'utf8' );
|
|
4629
4622
|
const template = handlebars.compile( templateHtml );
|
|
@@ -26,6 +26,7 @@ import * as teamsServices from '../services/teams.service.js';
|
|
|
26
26
|
import * as runAIFeatureServices from '../services/runAIFeatures.services.js';
|
|
27
27
|
import * as runAIRequestServices from '../services/runAIRequest.services.js';
|
|
28
28
|
import * as processedTaskService from '../services/processedTaskList.service.js';
|
|
29
|
+
import ExcelJS from 'exceljs';
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
export const checklist = async ( req, res ) => {
|
|
@@ -5075,3 +5076,71 @@ export async function updateOSProcessedData( req, res ) {
|
|
|
5075
5076
|
return res.sendError( error, 500 );
|
|
5076
5077
|
}
|
|
5077
5078
|
}
|
|
5079
|
+
|
|
5080
|
+
export async function downloadQuestionTemplate( req, res ) {
|
|
5081
|
+
try {
|
|
5082
|
+
let questionDetails = await questionService.find( { checkListId: req.body.checklistId } );
|
|
5083
|
+
let answerType = {
|
|
5084
|
+
'descriptive': 'Descriptive Answer',
|
|
5085
|
+
'yes/no': 'A/B Question',
|
|
5086
|
+
'multiplechoicesingle': 'Multiple Choice Single',
|
|
5087
|
+
'multiplechoicemultiple': 'Multiple Choice Multiple',
|
|
5088
|
+
'descriptiveImage': 'Capture Image with Description',
|
|
5089
|
+
'image': 'Capture Image as answer',
|
|
5090
|
+
'video': 'Capture video as answer',
|
|
5091
|
+
'multipleImage': 'Capture Multiple Image',
|
|
5092
|
+
'date': 'Date',
|
|
5093
|
+
'linearscale': 'Linear Scale',
|
|
5094
|
+
'image/video': 'Capture Image/Video as Answer',
|
|
5095
|
+
'time': 'Time',
|
|
5096
|
+
'dropdown': 'Dropdown',
|
|
5097
|
+
};
|
|
5098
|
+
const workbook = new ExcelJS.Workbook();
|
|
5099
|
+
const sheet = workbook.addWorksheet( 'Fixture Library' );
|
|
5100
|
+
|
|
5101
|
+
sheet.getRow( 1 ).values = [ 'Section Name', 'Question', 'Answer Type', 'Answer Options' ];
|
|
5102
|
+
|
|
5103
|
+
let rowStart = 2;
|
|
5104
|
+
|
|
5105
|
+
questionDetails.forEach( ( section ) => {
|
|
5106
|
+
section.question.forEach( ( qn ) => {
|
|
5107
|
+
sheet.getRow( rowStart ).values = [ section.section, qn.qname, answerType[`${qn.answerType}`], [ 'multiplechoicesingle', 'multiplechoicemultiple', 'dropdown' ].includes( qn.answerType ) ? qn.answers.map( ( ans ) => ans.answer )?.toString() : '' ];
|
|
5108
|
+
rowStart += 1;
|
|
5109
|
+
} );
|
|
5110
|
+
} );
|
|
5111
|
+
|
|
5112
|
+
|
|
5113
|
+
const maxRows = 500000;
|
|
5114
|
+
|
|
5115
|
+
let dropDownRange = [ { key: `C2:C${maxRows}`, optionList: [ '"Descriptive Answer,A/B Question,Multiple Choice Single,Multiple Choice Multiple,Capture Image with Description,Capture Image as answer,Capture video as answer,Capture Multiple Image,Date,Linear Scale,Capture Image/Video as Answer,Time,Dropdown,"' ] } ];
|
|
5116
|
+
|
|
5117
|
+
dropDownRange.forEach( ( ele ) => {
|
|
5118
|
+
sheet.dataValidations.add( ele.key, {
|
|
5119
|
+
type: 'list',
|
|
5120
|
+
allowBlank: true,
|
|
5121
|
+
formulae: ele.optionList,
|
|
5122
|
+
showErrorMessage: true,
|
|
5123
|
+
errorTitle: 'Invalid Choice',
|
|
5124
|
+
error: 'Please select from the dropdown list.',
|
|
5125
|
+
} );
|
|
5126
|
+
} );
|
|
5127
|
+
|
|
5128
|
+
sheet.columns.forEach( ( column ) => {
|
|
5129
|
+
let maxLength = 10;
|
|
5130
|
+
column.eachCell( { includeEmpty: true }, ( cell ) => {
|
|
5131
|
+
const cellValue = cell.value ? cell.value.toString() : '';
|
|
5132
|
+
if ( cellValue.length > maxLength ) {
|
|
5133
|
+
maxLength = cellValue.length;
|
|
5134
|
+
}
|
|
5135
|
+
} );
|
|
5136
|
+
column.width = maxLength + 2;
|
|
5137
|
+
} );
|
|
5138
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
|
5139
|
+
res.setHeader( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
|
|
5140
|
+
res.setHeader( 'Content-Disposition', 'attachment; filename="Checklist Question.xlsx"' );
|
|
5141
|
+
return res.send( buffer );
|
|
5142
|
+
} catch ( e ) {
|
|
5143
|
+
logger.error( { functionName: 'downloadQuestionTemplate', error: e } );
|
|
5144
|
+
return res.sendError( e, 500 );
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
@@ -35,6 +35,7 @@ internalTraxRouter
|
|
|
35
35
|
.get( '/getSubmittedDetails', isAllowedInternalAPIHandler, internalController.submittedInfo )
|
|
36
36
|
.post( '/checklistCreation', isAllowedInternalAPIHandler, internalController.checklistCreation )
|
|
37
37
|
.post( '/getSubmissionDetails', isAllowedInternalAPIHandler, internalController.checklistTaskSubmissionDetails )
|
|
38
|
+
.post( '/posblock', isAllowedInternalAPIHandler, internalController.getStoreTaskDetails )
|
|
38
39
|
;
|
|
39
40
|
|
|
40
41
|
|
|
@@ -35,6 +35,7 @@ traxRouter
|
|
|
35
35
|
.post( '/updateRunAIFeatures', isAllowedSessionHandler, traxController.updateRunAIFeatures )
|
|
36
36
|
.post( '/updateRunAIRequest', isAllowedSessionHandler, validate( runAIRequestValidation ), traxController.updateRunAIRequest )
|
|
37
37
|
.post( '/createChecklistName', isAllowedSessionHandler, validate( createChecklistNameValidation ), traxController.createChecklistName )
|
|
38
|
-
.post( '/updateOSProcessedData', isAllowedInternalAPIHandler, validate( updateOSDataValidation ), traxController.updateOSProcessedData )
|
|
38
|
+
.post( '/updateOSProcessedData', isAllowedInternalAPIHandler, validate( updateOSDataValidation ), traxController.updateOSProcessedData )
|
|
39
|
+
.post( '/exportQuestions', isAllowedSessionHandler, traxController.downloadQuestionTemplate );
|
|
39
40
|
|
|
40
41
|
// isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ),
|