tango-app-api-trax 1.0.0-task.129 → 1.1.0
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/fir-51e77-firebase-adminsdk-x3sdp-fd902b74ae.json +2 -3
- package/package.json +2 -2
- package/src/controllers/download.controller.js +71 -24
- package/src/controllers/gallery.controller.js +347 -36
- package/src/controllers/internalTrax.controller.js +427 -19
- package/src/controllers/mobileTrax.controller.js +635 -203
- package/src/controllers/teaxFlag.controller.js +24 -3
- package/src/controllers/trax.controller.js +53 -10
- package/src/controllers/traxDashboard.controllers.js +273 -162
- package/src/dtos/downloadValidation.dtos.js +3 -0
- package/src/dtos/validation.dtos.js +9 -0
- package/src/routes/download.router.js +3 -1
- package/src/routes/gallery.routes.js +5 -3
- package/src/routes/internalTraxApi.router.js +6 -1
- package/src/routes/mobileTrax.routes.js +3 -1
- package/src/routes/traxDashboard.routes.js +3 -1
- package/src/services/app.service.js +4 -0
- package/src/services/cluster.service.js +28 -0
- package/src/services/otp.service.js +3 -0
- package/src/services/processedchecklist.services.js +8 -0
- package/src/services/taskConfig.service.js +32 -0
- package/src/services/user.service.js +2 -2
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
1
|
{
|
|
3
2
|
"type": "service_account",
|
|
4
3
|
"project_id": "tango-trax",
|
|
5
|
-
"private_key_id": "
|
|
6
|
-
"private_key": "-----BEGIN PRIVATE KEY-----\
|
|
4
|
+
"private_key_id": "25f62c55f9ad649f333b54f62ab8b1aa97b7038e",
|
|
5
|
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDEZRGyxM+TUN+j\nqv6rSGWUqN9sEn9BxhdmCKZ8vsp73QIp71plFQSzWCL8pH5cfiwIu2zJlE1suApj\nGxJ+3/4X8CxWZ374HZBTSGVhsXcchYEGIwKWY6D3kfma8zRoPft3RULbus9fW0l/\nADcOMkLlN6OsawfvJXGPkMyM4e67ZOAkjlLWDGWYRnakbJZPqFN0U7aqGaXxgGoR\n1oN9qgnqQUqLl/085it5rqJ08hTXIsTViDrbD9gsShesC4L95C9jE1fnrJseghLM\n91qlJcspWGU6MgI1H44SYT0SttFaYZ2hJXmISMH9CnI9sdFmQBs8oBZXPHL3oXhM\nsrnMy169AgMBAAECggEABdpRj3S5jz/uVkPoNdsLue/ZbrCowwv1UmNeG3gac9wH\ng+U/709pIIjMdsqBKzOluiHkcVJz3JJUhD/ANUXqyN8DDJUmLcdAb+xHpy8WfWQG\nJGnChTsABvi+SfhG/sygE/MdYGEowRmo7vm8P6D5qOKXrwb73sw3Hj/tX00euU4Q\nKek3W9Sd5j3MDvSoCM7tlqmOuyQjD1z4taUmeQ8I4KOOWmpamS4wg90iW13FxgSK\n/vNpqb/xWqlxoFfpwgZaT8xM6TKBURyDeDi0Fu+WAP6gIDM8lHoW1tPtSJifE5bU\ngMmAhR+DlWZM6wuDJvdJRomHl7huT36rYp1IFa/nkQKBgQDswbL21UbkdV2YsSRn\nwmDjgO/VAGv27OhTtHJpSSOQ9O1Fk94BLG9RPqx6CXm+86Kmxctrl3EIsEbfPcBK\nOHF0yknhwhTfDZuEtLdsqvK06bLaBYdq0E0RghUiqi9jtQvaQJeu3e0735gfHsrp\nhE21rctn85uo31WCVrjW5WegUQKBgQDUW4sYZ+46RrjPhVNj2W1w0A6qAaWeN/BC\nJn0y2kS0AbDSRzqfLrGivwDGRwlAzVyo76ARRZKVxqR4XlzygGELV0obGtKj1a1R\nwjLCbmsFIf7xXl2+rWeQh9oNsOfa2OR1cuG/ne8IS2dLayGOyZBoku45SOWLhwDA\nINwCCcmIrQKBgQC9fHmjnCbVCioS3xPoB2ZMLxHEREYkpo97DtzS7zqL9btBCIuS\nHOIrACJCufq6nXv8Rin8voQ1FABlA6M2w93qP0zKZu8VZmql141GZ7tAmBoQ7IPp\nNTW5YYdQ6yxqfKgz0aaUygHo/ZdesOJt6vnXAnXdiNd4XOavHoFpXMmHQQKBgB42\nV/fE8ZPA9BIyOcb+7B8curldOp7j/n6q0y0k+JlTlECWebSkBAnPeuC6wopBrWkr\njm5mo5BDjqrBYh/uO+BNLvHkQwukHuB+7JHU+8zjJU5ZyqSSLyXU7iT8gkAUk4xS\nJ+QHKDbZ43xLZZ7W9oCqRtJHmMDdGDI9eo+frNiRAoGBANN7ZkuPdUAqBbMmj5I7\n+C9k5Jg5OFsw9CYzi5LBETKcy1YiUw4PX5xSWV0hlhjrSbCuvpbX1fVwcz4UNYaK\nNdgt2GJOQZ6vtnaInhx737D31l5ZXpb+9IH7O5iZ711PXV3Ic4zQSPbDkC8V5z+k\nafICa9PE9II8SypV9b5kVbpl\n-----END PRIVATE KEY-----\n",
|
|
7
6
|
"client_email": "firebase-adminsdk-k7lom@tango-trax.iam.gserviceaccount.com",
|
|
8
7
|
"client_id": "112026772051782321525",
|
|
9
8
|
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.8.0",
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
|
-
"tango-api-schema": "^2.
|
|
29
|
+
"tango-api-schema": "^2.2.9",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.43-alpha.10",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -2,7 +2,10 @@ import { logger, signedUrl, sendMessageToQueue } from 'tango-app-api-middleware'
|
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import * as downloadService from '../services/download.services.js';
|
|
4
4
|
import * as processedchecklistService from '../services/processedchecklist.services.js';
|
|
5
|
+
import * as processedTaskService from '../services/processedTaskList.service.js';
|
|
6
|
+
import * as taskConfigService from '../services/taskConfig.service.js';
|
|
5
7
|
import * as checklistService from '../services/checklist.service.js';
|
|
8
|
+
// import * as processedTaskconfigService from '../services/processedTaskConfig.service.js';
|
|
6
9
|
import * as clientService from '../services/clients.services.js';
|
|
7
10
|
import * as storeService from '../services/store.service.js';
|
|
8
11
|
|
|
@@ -40,23 +43,29 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id !='' ) {
|
|
46
|
+
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id != '' ) {
|
|
44
47
|
let getChecklistQuery = [];
|
|
45
|
-
getChecklistQuery.push( { $project: { sourceCheckList_id: 1, date_iso: 1, store_id: 1, checklistStatus: 1 } } );
|
|
48
|
+
getChecklistQuery.push( { $project: { sourceCheckList_id: 1, date_iso: 1, store_id: 1, checklistStatus: 1, redoStatus: 1 } } );
|
|
46
49
|
getChecklistQuery.push( {
|
|
47
50
|
$match: {
|
|
48
51
|
$and: [
|
|
49
52
|
{ sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
|
|
50
53
|
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
51
54
|
{ store_id: { $in: requestData.storeIds } },
|
|
55
|
+
],
|
|
56
|
+
$or: [
|
|
52
57
|
{ checklistStatus: 'submit' },
|
|
58
|
+
{ redoStatus: true },
|
|
53
59
|
],
|
|
54
60
|
},
|
|
55
61
|
} );
|
|
56
62
|
getChecklistQuery.push( { $count: 'totalCount' } );
|
|
57
|
-
let getChecklistCount = await processedchecklistService.aggregate( getChecklistQuery );
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
let getChecklistCount = await processedchecklistService.aggregate( getChecklistQuery );
|
|
65
|
+
if ( requestData.insertType === 'task' ) {
|
|
66
|
+
getChecklistCount = await processedTaskService.aggregate( getChecklistQuery );
|
|
67
|
+
}
|
|
68
|
+
if ( getChecklistCount && getChecklistCount[0]?.totalCount && getChecklistCount[0].totalCount > 0 ) {
|
|
60
69
|
// console.log( 'if' );
|
|
61
70
|
// console.log( 'getChecklistCountgetChecklistCount[0].totalCount =>', getChecklistCount[0]?.totalCount );
|
|
62
71
|
} else {
|
|
@@ -65,7 +74,7 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
if ( requestData.fileType == 'pdf' ) {
|
|
68
|
-
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id !='' ) {
|
|
77
|
+
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id != '' ) {
|
|
69
78
|
fileType = 'pdfzip';
|
|
70
79
|
}
|
|
71
80
|
if ( requestData?.checklistId && requestData?.checklistId.length > 1 ) {
|
|
@@ -76,7 +85,7 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
76
85
|
if ( requestData.checklistName != '' ) {
|
|
77
86
|
name = requestData.checklistName + '_' + dayjs( requestData.fromDate ).format( 'DD/MM/YYYY' );
|
|
78
87
|
if ( requestData?.toDate ) {
|
|
79
|
-
name = name + '-'+ dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
88
|
+
name = name + '-' + dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
80
89
|
}
|
|
81
90
|
let regexName = new RegExp( `^${name.split( '(' )[0]} \\(.*\\)$`, 'i' );
|
|
82
91
|
let type = requestData.fileType || 'pdfzip';
|
|
@@ -88,7 +97,7 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
88
97
|
name = requestData?.checklistName;
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
name = name+'-'+requestData.fileType;
|
|
100
|
+
name = name + '-' + requestData.fileType;
|
|
92
101
|
let insertData = {
|
|
93
102
|
'date_string': requestData.fromDate || '',
|
|
94
103
|
'sourceCheckList_id': requestData?.sourceCheckList_id || '',
|
|
@@ -110,6 +119,9 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
110
119
|
'downloadInsertFrom': requestData.downloadInsertFrom || '',
|
|
111
120
|
'answerType': requestData.answerType || '',
|
|
112
121
|
'searchValue': requestData.searchValue || '',
|
|
122
|
+
'insertType': requestData.insertType || '',
|
|
123
|
+
'viewRedo': requestData.viewRedo || false,
|
|
124
|
+
|
|
113
125
|
};
|
|
114
126
|
let resultData = await downloadService.insert( insertData );
|
|
115
127
|
if ( resultData ) {
|
|
@@ -151,10 +163,10 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
151
163
|
{ date_iso: { $lte: todate } },
|
|
152
164
|
{ checklistStatus: 'submit' },
|
|
153
165
|
);
|
|
154
|
-
if ( requestData.storeIds && requestData.storeIds.length >0 ) {
|
|
166
|
+
if ( requestData.storeIds && requestData.storeIds.length > 0 ) {
|
|
155
167
|
findAndQuery.push( { store_id: { $in: requestData.storeIds } } );
|
|
156
168
|
}
|
|
157
|
-
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id !='' ) {
|
|
169
|
+
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id != '' ) {
|
|
158
170
|
findAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) } );
|
|
159
171
|
}
|
|
160
172
|
if ( requestData.checklistId && requestData.checklistId.length > 0 ) {
|
|
@@ -175,11 +187,11 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
175
187
|
},
|
|
176
188
|
} );
|
|
177
189
|
let checklistDetails = await processedchecklistService.aggregate( findQuery );
|
|
178
|
-
if ( checklistDetails && checklistDetails.length >0 ) {
|
|
190
|
+
if ( checklistDetails && checklistDetails.length > 0 ) {
|
|
179
191
|
let name;
|
|
180
192
|
let fileType = requestData?.fileType || 'pdfzip';
|
|
181
193
|
if ( requestData.fileType == 'pdf' ) {
|
|
182
|
-
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id !='' ) {
|
|
194
|
+
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id != '' ) {
|
|
183
195
|
fileType = 'pdfzip';
|
|
184
196
|
}
|
|
185
197
|
if ( requestData?.checklistId && requestData?.checklistId.length > 1 ) {
|
|
@@ -191,7 +203,7 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
191
203
|
if ( requestData.checklistName != '' ) {
|
|
192
204
|
name = requestData.checklistName + '_' + dayjs( requestData.fromDate ).format( 'DD/MM/YYYY' );
|
|
193
205
|
if ( requestData?.toDate ) {
|
|
194
|
-
name = name + '-'+ dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
206
|
+
name = name + '-' + dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
195
207
|
}
|
|
196
208
|
let regexName = new RegExp( `^${name.split( '(' )[0]} \\(.*\\)$`, 'i' );
|
|
197
209
|
let type = requestData.fileType || 'pdfzip';
|
|
@@ -203,7 +215,7 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
203
215
|
name = requestData?.checklistName;
|
|
204
216
|
}
|
|
205
217
|
|
|
206
|
-
name = name+'-'+requestData.fileType;
|
|
218
|
+
name = name + '-' + requestData.fileType;
|
|
207
219
|
let insertData = {
|
|
208
220
|
'date_string': requestData.fromDate || '',
|
|
209
221
|
'sourceCheckList_id': requestData?.sourceCheckList_id || '',
|
|
@@ -270,6 +282,7 @@ export const downloadList = async ( req, res ) => {
|
|
|
270
282
|
findAndQuery.push(
|
|
271
283
|
{ client_id: requestData.clientId },
|
|
272
284
|
{ createdBy: new mongoose.Types.ObjectId( requestData.createdBy ) },
|
|
285
|
+
{ status: { $ne: 'canceled' } },
|
|
273
286
|
);
|
|
274
287
|
|
|
275
288
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -296,7 +309,7 @@ export const downloadList = async ( req, res ) => {
|
|
|
296
309
|
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
297
310
|
}
|
|
298
311
|
|
|
299
|
-
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
312
|
+
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy != '' ) {
|
|
300
313
|
findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
|
|
301
314
|
} else {
|
|
302
315
|
findQuery.push( { $sort: { ['_id']: -1 } } );
|
|
@@ -307,8 +320,8 @@ export const downloadList = async ( req, res ) => {
|
|
|
307
320
|
findQuery.push( { $skip: skip }, { $limit: limit } );
|
|
308
321
|
let getDownlaodData = await downloadService.aggregate( findQuery );
|
|
309
322
|
let bucket = JSON.parse( process.env.BUCKET );
|
|
310
|
-
for ( let i=0; i<getDownlaodData.length; i++ ) {
|
|
311
|
-
if ( getDownlaodData[i].url && getDownlaodData[i].url !='' ) {
|
|
323
|
+
for ( let i = 0; i < getDownlaodData.length; i++ ) {
|
|
324
|
+
if ( getDownlaodData[i].url && getDownlaodData[i].url != '' ) {
|
|
312
325
|
let inputData1 = {
|
|
313
326
|
Bucket: bucket.sop,
|
|
314
327
|
file_path: getDownlaodData[i].url,
|
|
@@ -345,10 +358,10 @@ export const downloadUpdate = async ( req, res ) => {
|
|
|
345
358
|
if ( resultData ) {
|
|
346
359
|
return res.sendSuccess( 'download updated successfully' );
|
|
347
360
|
} else {
|
|
348
|
-
return res.
|
|
361
|
+
return res.sendError( { error: 'something went wrong, please try again' }, 500 );
|
|
349
362
|
}
|
|
350
363
|
} else {
|
|
351
|
-
return res.
|
|
364
|
+
return res.sendError( { error: 'Invalid Zip Id' }, 400 );
|
|
352
365
|
}
|
|
353
366
|
} catch ( error ) {
|
|
354
367
|
console.log( 'error =>', error );
|
|
@@ -367,12 +380,11 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
367
380
|
brandLogo: '',
|
|
368
381
|
checkListDescription: '',
|
|
369
382
|
};
|
|
370
|
-
|
|
371
383
|
if ( getzipdata ) {
|
|
372
384
|
let getClientData = await clientService.findOne( { clientId: getzipdata.client_id } );
|
|
373
385
|
if ( getClientData ) {
|
|
374
386
|
brandInfo.clientName = getClientData.clientName;
|
|
375
|
-
brandInfo.brandLogo = getzipdata.client_id+'/logo/'+getClientData.profileDetails.logo;
|
|
387
|
+
brandInfo.brandLogo = getzipdata.client_id + '/logo/' + getClientData.profileDetails.logo;
|
|
376
388
|
}
|
|
377
389
|
|
|
378
390
|
// if ( getzipdata.fileType == 'zipfiles' ) {
|
|
@@ -387,7 +399,12 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
387
399
|
|
|
388
400
|
if ( getzipdata.sourceCheckList_id && getzipdata.sourceCheckList_id != '' ) {
|
|
389
401
|
let getChecklistDescription = await checklistService.findOne( { _id: getzipdata.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
390
|
-
|
|
402
|
+
if ( getzipdata.insertType == 'task' ) {
|
|
403
|
+
let getChecklistDescription = await taskConfigService.findOne( { _id: getzipdata.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
404
|
+
brandInfo.checkListDescription = getChecklistDescription.checkListDescription || '';
|
|
405
|
+
} else {
|
|
406
|
+
brandInfo.checkListDescription = getChecklistDescription.checkListDescription || '';
|
|
407
|
+
}
|
|
391
408
|
|
|
392
409
|
resultData.brandInfo = brandInfo;
|
|
393
410
|
if ( getzipdata.sourceCheckList_id && getzipdata.sourceCheckList_id != '' ) {
|
|
@@ -404,13 +421,23 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
404
421
|
resultData.viewFlag = getzipdata.viewFlag;
|
|
405
422
|
resultData.previewType = getzipdata.previewType || '';
|
|
406
423
|
resultData.answerType = getzipdata.answerType || '';
|
|
424
|
+
resultData.insertType = getzipdata.insertType;
|
|
425
|
+
resultData.status = getzipdata.status;
|
|
426
|
+
|
|
407
427
|
return res.sendSuccess( resultData );
|
|
408
428
|
} else {
|
|
409
429
|
let getchecklistsQuery = {};
|
|
410
430
|
getchecklistsQuery._id = new mongoose.Types.ObjectId( getzipdata.checklistIdList[0] );
|
|
411
431
|
let getchecklistsData = await processedchecklistService.findOne( getchecklistsQuery, { _id: 1, sourceCheckList_id: 1 } );
|
|
432
|
+
if ( getzipdata.insertType == 'task' ) {
|
|
433
|
+
getchecklistsData = await processedTaskService.findOne( getchecklistsQuery, { _id: 1, sourceCheckList_id: 1 } );
|
|
434
|
+
}
|
|
435
|
+
|
|
412
436
|
if ( getchecklistsData ) {
|
|
413
437
|
let getChecklistDescription = await checklistService.findOne( { _id: getchecklistsData.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
438
|
+
if ( getzipdata.insertType == 'task' ) {
|
|
439
|
+
getChecklistDescription = await taskConfigService.findOne( { _id: getzipdata.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
440
|
+
}
|
|
414
441
|
brandInfo.checkListDescription = getChecklistDescription.checkListDescription || '';
|
|
415
442
|
}
|
|
416
443
|
|
|
@@ -418,6 +445,8 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
418
445
|
resultData.checklistIds = getzipdata.checklistIdList;
|
|
419
446
|
resultData.fileType = getzipdata.fileType;
|
|
420
447
|
resultData.questions = getzipdata.questions;
|
|
448
|
+
resultData.insertType = getzipdata.insertType;
|
|
449
|
+
resultData.status = getzipdata.status;
|
|
421
450
|
return res.sendSuccess( resultData );
|
|
422
451
|
}
|
|
423
452
|
} else {
|
|
@@ -459,12 +488,14 @@ export const getPDFCSVChecklistDetails = async ( req, res ) => {
|
|
|
459
488
|
];
|
|
460
489
|
|
|
461
490
|
let getchecklistsData = await processedchecklistService.aggregate( query );
|
|
462
|
-
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
if ( getchecklistsData && getchecklistsData.length > 0 ) {
|
|
463
494
|
let getbrand = await clientService.findOne( { clientId: getchecklistsData[0].client_id }, { clientName: 1 } );
|
|
464
495
|
let brandInfo = {};
|
|
465
496
|
if ( getbrand ) {
|
|
466
497
|
brandInfo.clientName = getbrand.clientName;
|
|
467
|
-
brandInfo.brandLogo = getchecklistsData[0].client_id+'/logo/brandLogo.png';
|
|
498
|
+
brandInfo.brandLogo = getchecklistsData[0].client_id + '/logo/brandLogo.png';
|
|
468
499
|
}
|
|
469
500
|
|
|
470
501
|
let getstore = await storeService.findOne( { id: getchecklistsData[0].store_id }, { storeProfile: 1 } );
|
|
@@ -472,7 +503,7 @@ export const getPDFCSVChecklistDetails = async ( req, res ) => {
|
|
|
472
503
|
getchecklistsData[0].city = getstore?.storeProfile?.city || '--';
|
|
473
504
|
getchecklistsData[0].state = getstore?.storeProfile?.state || '--';
|
|
474
505
|
let questions = [];
|
|
475
|
-
function processQuestion( question, section, questions, nested=false ) {
|
|
506
|
+
function processQuestion( question, section, questions, nested = false ) {
|
|
476
507
|
let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
|
|
477
508
|
if ( findExists && nested ) {
|
|
478
509
|
let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
|
|
@@ -542,3 +573,19 @@ export const getPDFCSVChecklistDetails = async ( req, res ) => {
|
|
|
542
573
|
};
|
|
543
574
|
|
|
544
575
|
|
|
576
|
+
export async function cancelDownload( req, res ) {
|
|
577
|
+
try {
|
|
578
|
+
let finddata = await downloadService.findOne( { _id: req.params.id, status: 'completed' } );
|
|
579
|
+
if ( finddata ) {
|
|
580
|
+
return res.sendError( 'Download Already Completed', 500 );
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
let update = await downloadService.updateOne( { _id: req.params.id }, { status: 'canceled' } );
|
|
584
|
+
if ( update ) {
|
|
585
|
+
return res.sendSuccess( 'Canceled Successfully' );
|
|
586
|
+
}
|
|
587
|
+
} catch ( error ) {
|
|
588
|
+
logger.error( { error: error, function: 'cancelDownload' } );
|
|
589
|
+
return res.sendError( error, 500 );
|
|
590
|
+
}
|
|
591
|
+
}
|