tango-app-api-infra 3.0.54-dev → 3.0.55-dev

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-infra",
3
- "version": "3.0.54-dev",
3
+ "version": "3.0.55-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "mongodb": "^6.4.0",
26
26
  "nodemon": "^3.1.0",
27
27
  "tango-api-schema": "^2.0.90",
28
- "tango-app-api-middleware": "^3.1.3",
28
+ "tango-app-api-middleware": "^1.0.60-dev",
29
29
  "winston": "^3.12.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
31
31
  },
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
5
5
  import { updateOneStore, findStore } from '../services/store.service.js';
6
6
  import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, appConfig } from 'tango-app-api-middleware';
@@ -75,7 +75,7 @@ export async function createTicket( req, res ) {
75
75
  let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${req.body.basicDetails.storeId}`;
76
76
 
77
77
  const html = htmlContent( { ...req.body, Uidomain: Uidomain, domain: appConfig.url.apiDomain, date: dayjs( req.body.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp } );
78
- if ( req.body.emailAlert&&req.body.spocEmail&&req.body.issueType == 'infra'&&isValidEmail( req.body.spocEmail ) ) {
78
+ if ( req.body.emailAlert && req.body.spocEmail && req.body.issueType == 'infra' && isValidEmail( req.body.spocEmail ) ) {
79
79
  await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
80
80
  }
81
81
  if ( create ) {
@@ -621,3 +621,55 @@ function inWords( num ) {
621
621
 
622
622
  return str.toLowerCase().split( ' ' ).map( ( word ) => word.charAt( 0 ).toUpperCase() + word.slice( 1 ) ).join( ' ' );
623
623
  }
624
+
625
+
626
+ export async function infraTable( req, res ) {
627
+ try {
628
+ let query = [];
629
+
630
+ query.push( {
631
+ $match: {
632
+ $and: [
633
+ { issueType: 'infra' },
634
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
635
+ { createdAt: { $gte: date.start } },
636
+ { createdAt: { $lte: date.end } },
637
+ ],
638
+ },
639
+ } );
640
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
641
+ query.push( {
642
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
643
+ } );
644
+ }
645
+ let count = await aggregateTangoTicket( query );
646
+ if ( req.body.limit && req.body.offset && !req.body.export ) {
647
+ query.push(
648
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
649
+ { $limit: Number( req.body.limit ) },
650
+ );
651
+ }
652
+ let result = await aggregateTangoTicket( query );
653
+ if ( req.body.export && result.length > 0 ) {
654
+ const exportdata = [];
655
+ result.forEach( ( element ) => {
656
+ exportdata.push( {
657
+
658
+ } );
659
+ } );
660
+ await download( exportdata, res );
661
+ return;
662
+ }
663
+ if ( result.length > 0 ) {
664
+ res.sendSuccess( {
665
+ count: count.length,
666
+ result: result,
667
+ } );
668
+ } else {
669
+ res.sendError( 'no data', 204 );
670
+ }
671
+ } catch ( error ) {
672
+ logger.error( { error: error, function: 'infraTable' } );
673
+ return res.sendError( error, 500 );
674
+ }
675
+ }
@@ -697,12 +697,14 @@ export async function camAngleChangeReport( req, res ) {
697
697
  content: buffer,
698
698
  contentType: 'application/xlsx', // e.g., 'application/pdf'
699
699
  };
700
- let subject ='Camera Angle Modified';
700
+ let subject =`Camera Angle Modified - ${formattedPreviousDay}`;
701
701
  let html = `<div>We wanted to inform you that the camera angle in your stores has been adjusted recently.</div>`;
702
702
  let result = await sendEmailWithSES( req.body.toMail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
703
703
  if ( result ) {
704
704
  res.sendSuccess( 'Email send successfully' );
705
705
  }
706
+ } else {
707
+ res.sendSuccess( 'No changes in camera Angle' );
706
708
  }
707
709
  } catch ( error ) {
708
710
  logger.error( { error: error, function: 'camAngleChangeList' } );
@@ -4,7 +4,7 @@ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
4
4
  import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
5
  import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
6
6
  secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
7
- updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice } from '../controllers/infra.controllers.js';
7
+ updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable } from '../controllers/infra.controllers.js';
8
8
 
9
9
 
10
10
  export const infraRouter = express.Router();
@@ -55,3 +55,7 @@ infraRouter.post( '/saveInfraEmailConfig', isAllowedSessionHandler, authorize( {
55
55
  { featureName: 'settings', name: 'configuration', permissions: [ 'isEdit', 'isView' ] } ],
56
56
  } ), saveInfraEmailConfig );
57
57
  infraRouter.post( '/invoice', invoice );
58
+ infraRouter.post( '/infraTable', isAllowedSessionHandler, authorize( {
59
+ userType: [ 'client', 'tango' ], access: [
60
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
61
+ } ), infraTable );