tango-app-api-trax 1.0.0-alpha-task.132 → 1.0.0-alpha-task.133

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": "1.0.0-alpha-task.132",
3
+ "version": "1.0.0-alpha-task.133",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -279,6 +279,7 @@ export const downloadList = async ( req, res ) => {
279
279
  findAndQuery.push(
280
280
  { client_id: requestData.clientId },
281
281
  { createdBy: new mongoose.Types.ObjectId( requestData.createdBy ) },
282
+ { status: { $ne: 'canceled' } },
282
283
  );
283
284
 
284
285
  findQuery.push( { $match: { $and: findAndQuery } } );
@@ -418,6 +419,8 @@ export const getChecklistFromZipId = async ( req, res ) => {
418
419
  resultData.previewType = getzipdata.previewType || '';
419
420
  resultData.answerType = getzipdata.answerType || '';
420
421
  resultData.insertType = getzipdata.insertType;
422
+ resultData.status = getzipdata.status;
423
+
421
424
  return res.sendSuccess( resultData );
422
425
  } else {
423
426
  let getchecklistsQuery = {};
@@ -440,6 +443,7 @@ export const getChecklistFromZipId = async ( req, res ) => {
440
443
  resultData.fileType = getzipdata.fileType;
441
444
  resultData.questions = getzipdata.questions;
442
445
  resultData.insertType = getzipdata.insertType;
446
+ resultData.status = getzipdata.status;
443
447
  return res.sendSuccess( resultData );
444
448
  }
445
449
  } else {
@@ -566,3 +570,14 @@ export const getPDFCSVChecklistDetails = async ( req, res ) => {
566
570
  };
567
571
 
568
572
 
573
+ export async function cancelDownload( req, res ) {
574
+ try {
575
+ let update = await downloadService.updateOne( { _id: req.params.id }, { status: 'canceled' } );
576
+ if ( update ) {
577
+ return res.sendSuccess( 'Canceled Successfully' );
578
+ }
579
+ } catch ( error ) {
580
+ logger.error( { error: error, function: 'cancelDownload' } );
581
+ return res.sendError( error, 500 );
582
+ }
583
+ }
@@ -435,11 +435,11 @@ export async function approvalstatus( req, res ) {
435
435
  try {
436
436
  let Approver = await ApproverModel.find( { checkListId: req.body.checklistId } );
437
437
  if ( Approver.length === 0 ) {
438
- return res.sendError( 'No Content', 204 );
438
+ return res.sendSuccess( 'suceess' );
439
439
  }
440
440
  let filterApprover = Approver.filter( ( data ) => data.userEmail=== req.user.email );
441
441
  if ( filterApprover.length === 0 ) {
442
- return res.sendError( 'No Content', 204 );
442
+ return res.sendSuccess( 'suceess' );
443
443
  }
444
444
 
445
445
 
@@ -200,7 +200,8 @@ export async function startChecklist( req, res ) {
200
200
  store_id: getBeforeChecklist[0].store_id,
201
201
  storeName: getBeforeChecklist[0].storeName,
202
202
  action: 'started',
203
- checklistId: getBeforeChecklist[0].checkListId,
203
+ checklistId: getBeforeChecklist[0].sourceCheckList_id,
204
+ processedChecklistId: getBeforeChecklist[0]._id,
204
205
  checkListName: getBeforeChecklist[0].checkListName,
205
206
  checkListType: getBeforeChecklist[0].checkListType,
206
207
  client_id: req.user.clientId,
@@ -1346,7 +1347,8 @@ async function updateOpenSearch( user, data ) {
1346
1347
  store_id: getchecklist[0].store_id,
1347
1348
  storeName: getchecklist[0].storeName,
1348
1349
  action: 'OpenSearch insert Triggered',
1349
- checklistId: getchecklist[0].checkListId,
1350
+ checklistId: getchecklist[0].sourceCheckList_id,
1351
+ processedChecklistId: getchecklist[0]._id,
1350
1352
  checkListName: getchecklist[0].checkListName,
1351
1353
  checkListType: getchecklist[0].checkListType,
1352
1354
  client_id: user.clientId,
@@ -1366,7 +1368,8 @@ async function updateOpenSearch( user, data ) {
1366
1368
  store_id: getchecklist[0].store_id,
1367
1369
  storeName: getchecklist[0].storeName,
1368
1370
  action: 'OpenSearch inserted Successfully',
1369
- checklistId: getchecklist[0].checkListId,
1371
+ checklistId: getchecklist[0].sourceCheckList_id,
1372
+ processedChecklistId: getchecklist[0]._id,
1370
1373
  checkListName: getchecklist[0].checkListName,
1371
1374
  checkListType: getchecklist[0].checkListType,
1372
1375
  client_id: user.clientId,
@@ -1393,7 +1396,8 @@ async function updateOpenSearchTask( user, data ) {
1393
1396
  store_id: getchecklist[0].store_id,
1394
1397
  storeName: getchecklist[0].storeName,
1395
1398
  action: 'OpenSearch insert Triggered',
1396
- checklistId: getchecklist[0].checkListId,
1399
+ checklistId: getchecklist[0].sourceCheckList_id,
1400
+ processedChecklistId: getchecklist[0]._id,
1397
1401
  checkListName: getchecklist[0].checkListName,
1398
1402
  checkListType: getchecklist[0].checkListType,
1399
1403
  client_id: user.clientId,
@@ -1413,7 +1417,8 @@ async function updateOpenSearchTask( user, data ) {
1413
1417
  store_id: getchecklist[0].store_id,
1414
1418
  storeName: getchecklist[0].storeName,
1415
1419
  action: 'OpenSearch inserted Successfully',
1416
- checklistId: getchecklist[0].checkListId,
1420
+ checklistId: getchecklist[0].sourceCheckList_id,
1421
+ processedChecklistId: getchecklist[0]._id,
1417
1422
  checkListName: getchecklist[0].checkListName,
1418
1423
  checkListType: getchecklist[0].checkListType,
1419
1424
  client_id: user.clientId,
@@ -10,6 +10,7 @@ import {
10
10
  downloadUpdate,
11
11
  getChecklistFromZipId,
12
12
  getPDFCSVChecklistDetails,
13
+ cancelDownload,
13
14
  } from '../controllers/download.controller.js';
14
15
 
15
16
  downloadRouter
@@ -17,7 +18,8 @@ downloadRouter
17
18
  .post( '/downloadList', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [] } ] } ), validate( downloadValidationDtos.validateDownloadListParams ), downloadList )
18
19
  .post( '/downloadUpdate', downloadUpdate ) // isAllowedInternalAPIHandler,
19
20
  .get( '/getChecklistFromZipId', getChecklistFromZipId ) // isAllowedInternalAPIHandler,
20
- .post( '/getChecklistDetails', getPDFCSVChecklistDetails );
21
+ .post( '/getChecklistDetails', getPDFCSVChecklistDetails )
22
+ .put( '/cancelDownload/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [] } ] } ), cancelDownload );
21
23
 
22
24
 
23
25
  export default downloadRouter;