tango-app-api-trax 3.6.2-bulktask-4 → 3.6.2-bulktask-6
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.6.2-bulktask-
|
|
3
|
+
"version": "3.6.2-bulktask-6",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"body-parser": "^1.20.3",
|
|
18
18
|
"dayjs": "^1.11.13",
|
|
19
19
|
"dotenv": "^16.4.5",
|
|
20
|
+
"exceljs": "^4.4.0",
|
|
20
21
|
"express": "^4.21.1",
|
|
21
22
|
"express-fileupload": "^1.5.1",
|
|
22
23
|
"firebase-admin": "^13.0.0",
|
|
@@ -8,7 +8,7 @@ import * as processedchecklistconfigService from '../services/processedchecklist
|
|
|
8
8
|
import * as processedChecklist from '../services/processedchecklist.services.js';
|
|
9
9
|
import * as checklistLogs from '../services/checklistlog.service.js';
|
|
10
10
|
import * as ApproverModel from '../services/approver.service.js';
|
|
11
|
-
|
|
11
|
+
import ExcelJS from 'exceljs';
|
|
12
12
|
import mongoose from 'mongoose';
|
|
13
13
|
import dayjs from 'dayjs';
|
|
14
14
|
import { aggregateTeams, findteams } from '../services/teams.service.js';
|
|
@@ -289,7 +289,7 @@ export async function approveChecklist( req, res ) {
|
|
|
289
289
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
290
290
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
291
291
|
let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, $or: [ { checklistStatus: 'submit' }, { redoStatus: true } ], approvalEnable: true };
|
|
292
|
-
if ( !( req.body.assignedStores && req.body.assignedStores.length >0 ) ) {
|
|
292
|
+
if ( !( req.body.assignedStores && req.body.assignedStores.length > 0 ) ) {
|
|
293
293
|
req.body.assignedStores = req.body.storeId;
|
|
294
294
|
}
|
|
295
295
|
if ( req.body?.storeId?.length ) {
|
|
@@ -318,13 +318,13 @@ export async function approveChecklist( req, res ) {
|
|
|
318
318
|
|
|
319
319
|
let teamsMsg;
|
|
320
320
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
321
|
-
teamsMsg = 'ClientId: '+ checklistDetails[0].client_id + ', Type: Checklist, Process: started, Action: Approval, ChecklistId: '+ checklistDetails[0].sourceCheckList_id + ', Checklist Name: '+ checklistDetails[0].checkListName +', UpDatedBy: '+ req.user.email;
|
|
321
|
+
teamsMsg = 'ClientId: ' + checklistDetails[0].client_id + ', Type: Checklist, Process: started, Action: Approval, ChecklistId: ' + checklistDetails[0].sourceCheckList_id + ', Checklist Name: ' + checklistDetails[0].checkListName + ', UpDatedBy: ' + req.user.email;
|
|
322
322
|
if ( teamsAlertUrls && teamsAlertUrls.approvalAlert ) {
|
|
323
323
|
sendTeamsNotification( teamsAlertUrls.approvalAlert, teamsMsg );
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
|
|
327
|
-
teamsMsg = 'ClientId: '+ checklistDetails[0].client_id + ', Type: Checklist, Process: Completed, Updated Count: '+updateResponse.modifiedCount+' Action: Approval, ChecklistId: '+ checklistDetails[0].sourceCheckList_id + ', Checklist Name: '+ checklistDetails[0].checkListName +', UpDatedBy: '+ req.user.email;
|
|
327
|
+
teamsMsg = 'ClientId: ' + checklistDetails[0].client_id + ', Type: Checklist, Process: Completed, Updated Count: ' + updateResponse.modifiedCount + ' Action: Approval, ChecklistId: ' + checklistDetails[0].sourceCheckList_id + ', Checklist Name: ' + checklistDetails[0].checkListName + ', UpDatedBy: ' + req.user.email;
|
|
328
328
|
if ( teamsAlertUrls && teamsAlertUrls.approvalAlert ) {
|
|
329
329
|
sendTeamsNotification( teamsAlertUrls.approvalAlert, teamsMsg );
|
|
330
330
|
}
|
|
@@ -360,7 +360,7 @@ export async function approveChecklist( req, res ) {
|
|
|
360
360
|
let searchResponse = await fetch( url.approveChecklist, requestOptions );
|
|
361
361
|
// console.log( searchResponse );
|
|
362
362
|
const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
|
|
363
|
-
let logData= {
|
|
363
|
+
let logData = {
|
|
364
364
|
'client_id': checklistDetails[0].client_id,
|
|
365
365
|
'createAt': new Date(),
|
|
366
366
|
'sourceCheckList_id': req.body.sourceCheckList_id,
|
|
@@ -559,11 +559,11 @@ export async function redomultiChecklist( req, res ) {
|
|
|
559
559
|
return res.sendError( 'Question number is Required', 400 );
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
let findcomment= {};
|
|
562
|
+
let findcomment = {};
|
|
563
563
|
if ( !inputBody.payload.showcomment ) {
|
|
564
|
-
if ( inputBody.payload?.coverage ==='store' ) {
|
|
564
|
+
if ( inputBody.payload?.coverage === 'store' ) {
|
|
565
565
|
findcomment = inputBody.payload.excelData.find( ( ele ) => ele.storeName === originalData.storeName );
|
|
566
|
-
} else if ( inputBody.payload?.coverage==='users' ) {
|
|
566
|
+
} else if ( inputBody.payload?.coverage === 'users' ) {
|
|
567
567
|
findcomment = inputBody.payload.excelData.find( ( ele ) => ele.userEmail === originalData.userEmail );
|
|
568
568
|
}
|
|
569
569
|
}
|
|
@@ -583,7 +583,7 @@ export async function redomultiChecklist( req, res ) {
|
|
|
583
583
|
|
|
584
584
|
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
|
|
585
585
|
|
|
586
|
-
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.showcomment? req.body.payload?.checklistDescription:findcomment?.comments };
|
|
586
|
+
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.showcomment ? req.body.payload?.checklistDescription : findcomment?.comments };
|
|
587
587
|
// if ( checklistDetails.client_id == '458' ) {
|
|
588
588
|
data.answers.forEach( ( item ) => {
|
|
589
589
|
if ( item.showLinked ) {
|
|
@@ -630,7 +630,7 @@ export async function redomultiChecklist( req, res ) {
|
|
|
630
630
|
data = {
|
|
631
631
|
checklistId: checklistDetails.sourceCheckList_id,
|
|
632
632
|
checkListName: checklistDetails.checkListName,
|
|
633
|
-
checklistDescription: req.body.payload?.showcomment? req.body.payload?.checklistDescription:findcomment?.comments,
|
|
633
|
+
checklistDescription: req.body.payload?.showcomment ? req.body.payload?.checklistDescription : findcomment?.comments,
|
|
634
634
|
sectionId: originalData.section_id,
|
|
635
635
|
sectionName: question[sectionIndex].sectionName,
|
|
636
636
|
questionName: question[sectionIndex].questions[findQuestion].qname,
|
|
@@ -1160,7 +1160,7 @@ export async function checkNotificationCount( req, res ) {
|
|
|
1160
1160
|
export async function taskvalidateUserData( req, res ) {
|
|
1161
1161
|
try {
|
|
1162
1162
|
let error = [];
|
|
1163
|
-
if ( req.body.coverage==='store' ) {
|
|
1163
|
+
if ( req.body.coverage === 'store' ) {
|
|
1164
1164
|
for ( let [ index, store ] of req.body.assignedData.entries() ) {
|
|
1165
1165
|
let findstore = await storeService.findOne( { clientId: req.body.clientId, storeName: store.storeName } );
|
|
1166
1166
|
console.log( findstore );
|
|
@@ -1169,7 +1169,7 @@ export async function taskvalidateUserData( req, res ) {
|
|
|
1169
1169
|
}
|
|
1170
1170
|
}
|
|
1171
1171
|
}
|
|
1172
|
-
if ( req.body.coverage==='users' ) {
|
|
1172
|
+
if ( req.body.coverage === 'users' ) {
|
|
1173
1173
|
for ( let [ index, user ] of req.body.assignedData.entries() ) {
|
|
1174
1174
|
let finduser = await findOne( { clientId: req.body.clientId, email: user.userEmail } );
|
|
1175
1175
|
if ( !finduser ) {
|
|
@@ -1207,3 +1207,71 @@ export async function vehicleCheckInUpdate( req, res ) {
|
|
|
1207
1207
|
return res.sendError( { error: error }, 500 );
|
|
1208
1208
|
}
|
|
1209
1209
|
}
|
|
1210
|
+
export async function getallchecklist( req, res ) {
|
|
1211
|
+
try {
|
|
1212
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1213
|
+
console.log( url.getallchecklist );
|
|
1214
|
+
|
|
1215
|
+
let resultData = await LamdaServiceCall( url.getallchecklist, req.body );
|
|
1216
|
+
console.log( resultData );
|
|
1217
|
+
if ( resultData ) {
|
|
1218
|
+
if ( resultData.status_code == '200' ) {
|
|
1219
|
+
resultData.message = '';
|
|
1220
|
+
return res.sendSuccess( resultData );
|
|
1221
|
+
} else {
|
|
1222
|
+
return res.sendError( 'No Content', 204 );
|
|
1223
|
+
}
|
|
1224
|
+
} else {
|
|
1225
|
+
return res.sendError( 'No Content', 204 );
|
|
1226
|
+
}
|
|
1227
|
+
} catch ( error ) {
|
|
1228
|
+
logger.error( { error: error, function: 'getallchecklist' } );
|
|
1229
|
+
return res.sendError( { error: error }, 500 );
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
export async function exportTemplate( req, res ) {
|
|
1233
|
+
try {
|
|
1234
|
+
const workbook = new ExcelJS.Workbook();
|
|
1235
|
+
const worksheet = workbook.addWorksheet( 'Sheet1' );
|
|
1236
|
+
if ( req.body.coverage === 'store' ) {
|
|
1237
|
+
worksheet.addRow( [ 'Checklist Name', 'Question Name', 'Store Name', 'Comments' ] );
|
|
1238
|
+
} else {
|
|
1239
|
+
worksheet.addRow( [ 'Checklist Name', 'Question Name', 'User Email', 'Comments' ] );
|
|
1240
|
+
}
|
|
1241
|
+
for ( let data of req.body.excelData ) {
|
|
1242
|
+
worksheet.addRow( [ data.checklistName, data.questionName, req.body.coverage === 'store'?data.storeName:data.userEmail, '' ] );
|
|
1243
|
+
}
|
|
1244
|
+
worksheet.eachRow( ( row, rowNumber ) => {
|
|
1245
|
+
row.eachCell( { includeEmpty: true }, ( cell, colNumber ) => {
|
|
1246
|
+
if ( colNumber === 1 || colNumber === 2 || colNumber === 3 ) {
|
|
1247
|
+
cell.protection = { locked: true }; // Lock Name & Email
|
|
1248
|
+
} else {
|
|
1249
|
+
cell.protection = { locked: false }; // Unlock Phone
|
|
1250
|
+
}
|
|
1251
|
+
} );
|
|
1252
|
+
} );
|
|
1253
|
+
|
|
1254
|
+
// Protect the worksheet
|
|
1255
|
+
await worksheet.protect( 'yourPassword123', {
|
|
1256
|
+
selectLockedCells: true,
|
|
1257
|
+
selectUnlockedCells: true,
|
|
1258
|
+
formatCells: false,
|
|
1259
|
+
formatColumns: false,
|
|
1260
|
+
formatRows: false,
|
|
1261
|
+
insertColumns: false,
|
|
1262
|
+
insertRows: false,
|
|
1263
|
+
insertHyperlinks: false,
|
|
1264
|
+
deleteColumns: false,
|
|
1265
|
+
deleteRows: false,
|
|
1266
|
+
} );
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
|
1270
|
+
res.setHeader( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
|
|
1271
|
+
res.setHeader( 'Content-Disposition', 'attachment; filename="Fixture Library.xlsx"' );
|
|
1272
|
+
return res.send( buffer );
|
|
1273
|
+
} catch ( error ) {
|
|
1274
|
+
logger.error( { error: error, function: 'exportTemplate' } );
|
|
1275
|
+
return res.sendError( { error: error }, 500 );
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { getchecklist, viewchecklist, getMobileUseagelist, storeOpencloselist, getcustomerunattendedlist,
|
|
4
4
|
storesList, checklistDropdown, redoChecklist, redomultiChecklist, approveChecklist,
|
|
5
|
-
approvalstatus, getLogs, headerStoresV2, teamsList, userList, checkNotificationCount, vehicleCheckInUpdate, taskvalidateUserData } from '../controllers/gallery.controller.js';
|
|
5
|
+
approvalstatus, getLogs, headerStoresV2, teamsList, userList, checkNotificationCount, vehicleCheckInUpdate, taskvalidateUserData, getallchecklist, exportTemplate } from '../controllers/gallery.controller.js';
|
|
6
6
|
import express from 'express';
|
|
7
7
|
export const galleryRouter = express.Router();
|
|
8
8
|
import { validate, isAllowedSessionHandler, isAllowedClient, getAssinedStore } from 'tango-app-api-middleware';
|
|
@@ -34,4 +34,6 @@ galleryRouter
|
|
|
34
34
|
.post( '/userList', isAllowedSessionHandler, isAllowedClient, userList )
|
|
35
35
|
.post( '/taskvalidateUserData', isAllowedSessionHandler, isAllowedClient, taskvalidateUserData )
|
|
36
36
|
.post( '/checkNotificationCount', isAllowedSessionHandler, getAssinedStore, checkNotificationCount )
|
|
37
|
-
.post( '/vehicleCheckInUpdate', isAllowedSessionHandler, vehicleCheckInUpdate )
|
|
37
|
+
.post( '/vehicleCheckInUpdate', isAllowedSessionHandler, vehicleCheckInUpdate )
|
|
38
|
+
.post( '/exportTemplate', isAllowedSessionHandler, exportTemplate )
|
|
39
|
+
.post( '/getallchecklist', isAllowedSessionHandler, getallchecklist );
|