tango-app-api-infra 3.1.2 → 3.1.3
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
|
@@ -9,7 +9,7 @@ import { join } from 'path';
|
|
|
9
9
|
import handlebars from 'handlebars';
|
|
10
10
|
dayjs.extend( utc );
|
|
11
11
|
dayjs.extend( timezone );
|
|
12
|
-
import { sendEmailWithSES } from 'tango-app-api-middleware';
|
|
12
|
+
import { sendEmailWithSES, signedUrl } from 'tango-app-api-middleware';
|
|
13
13
|
import { createClient, findClient, aggregateClient, findOneClient } from '../services/client.service.js';
|
|
14
14
|
import { createStore, findStore, updateOneStore, findOneStore } from '../services/store.service.js';
|
|
15
15
|
import { findTangoTicket, findOneTangoTicket, countDocumentsTangoTicket, aggregateTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
@@ -202,7 +202,7 @@ export async function updateRefreshTicket( req, res ) {
|
|
|
202
202
|
let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
|
|
203
203
|
let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
|
|
204
204
|
const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primary: primaryIssue, storeName: getTicket.basicDetails.storeName, hibernation: '', spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
|
|
205
|
-
if ( getclient.ticketConfigs.emailAlert&&spocEmail && isValidEmail( spocEmail ) ) {
|
|
205
|
+
if ( getclient.ticketConfigs.emailAlert && spocEmail && isValidEmail( spocEmail ) ) {
|
|
206
206
|
await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -285,7 +285,7 @@ export async function closeTicket( req, res ) {
|
|
|
285
285
|
let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
|
|
286
286
|
let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
|
|
287
287
|
const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primaryIssue: primaryIssue, storeName: getTicket.basicDetails.storeName, spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD HH:mm' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
|
|
288
|
-
if ( getclient.ticketConfigs.emailAlert&& spocEmail && isValidEmail( spocEmail ) ) {
|
|
288
|
+
if ( getclient.ticketConfigs.emailAlert && spocEmail && isValidEmail( spocEmail ) ) {
|
|
289
289
|
await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
290
290
|
}
|
|
291
291
|
}
|
|
@@ -630,3 +630,110 @@ export async function spocmailchange() {
|
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
export async function camAngleChangeReport( req, res ) {
|
|
636
|
+
try {
|
|
637
|
+
const currentDate = dayjs();
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
const previousDay = currentDate.subtract( 1, 'day' );
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
const formattedPreviousDay = previousDay.format( 'DD-MM-YYYY' );
|
|
644
|
+
const angleChange = await getOpenSearchData( 'camera-angle-change',
|
|
645
|
+
{
|
|
646
|
+
'query': {
|
|
647
|
+
'bool': {
|
|
648
|
+
'must': [
|
|
649
|
+
{
|
|
650
|
+
'term': {
|
|
651
|
+
'date.keyword': formattedPreviousDay,
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
'term': {
|
|
656
|
+
'client_id.keyword': req.body.clientId,
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
],
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
} );
|
|
663
|
+
if ( angleChange.body.hits.hits.length > 0 ) {
|
|
664
|
+
const exportdata = [];
|
|
665
|
+
|
|
666
|
+
for ( let camera of angleChange.body.hits.hits ) {
|
|
667
|
+
let result = camera._source;
|
|
668
|
+
|
|
669
|
+
if ( result && result.cameraAngleChangeStatus && result.camera_info.length > 0 ) {
|
|
670
|
+
for ( let stream of result.camera_info ) {
|
|
671
|
+
let params = {
|
|
672
|
+
Bucket: appConfig.cloud.aws.bucket.cameraAngle,
|
|
673
|
+
file_path: stream.path,
|
|
674
|
+
};
|
|
675
|
+
let Image = await signedUrl( params );
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
let findStore = await findOneStore( { storeId: result.store_id } );
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
exportdata.push( {
|
|
682
|
+
'Store Name': findStore.storeName,
|
|
683
|
+
'Store Code': findStore.storeId,
|
|
684
|
+
'Date Changed': formattedPreviousDay,
|
|
685
|
+
'ImageURL': {
|
|
686
|
+
url: Image,
|
|
687
|
+
label: 'Angle changed Image',
|
|
688
|
+
},
|
|
689
|
+
} );
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
let buffer = await download( exportdata );
|
|
694
|
+
|
|
695
|
+
let attachments = {
|
|
696
|
+
filename: `Camera angle change- ${formattedPreviousDay}.xlsx`,
|
|
697
|
+
content: buffer,
|
|
698
|
+
contentType: 'application/xlsx', // e.g., 'application/pdf'
|
|
699
|
+
};
|
|
700
|
+
let subject ='Camera Angle Modified';
|
|
701
|
+
let html = `<div>We wanted to inform you that the camera angle in your stores has been adjusted recently.</div>`;
|
|
702
|
+
let result = await sendEmailWithSES( req.body.toMail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
703
|
+
if ( result ) {
|
|
704
|
+
res.sendSuccess( 'Email send successfully' );
|
|
705
|
+
}
|
|
706
|
+
} else {
|
|
707
|
+
res.sendSuccess( 'No changes' );
|
|
708
|
+
}
|
|
709
|
+
} catch ( error ) {
|
|
710
|
+
logger.error( { error: error, function: 'camAngleChangeList' } );
|
|
711
|
+
res.sendError( error, 500 );
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
export async function download( data ) {
|
|
717
|
+
const wb = new xl.Workbook();
|
|
718
|
+
const ws = wb.addWorksheet( 'Worksheet Name' );
|
|
719
|
+
const headers = Object.keys( data[0] );
|
|
720
|
+
|
|
721
|
+
for ( let i = 0; i < headers.length; i++ ) {
|
|
722
|
+
ws.cell( 1, i + 1 ).string( headers[i] );
|
|
723
|
+
};
|
|
724
|
+
for ( let i = 0; i < data.length; i++ ) {
|
|
725
|
+
const dataRow = data[i];
|
|
726
|
+
for ( let j = 0; j < headers.length; j++ ) {
|
|
727
|
+
const header = headers[j];
|
|
728
|
+
const value = dataRow[header];
|
|
729
|
+
|
|
730
|
+
if ( typeof value === 'object' && value.hasOwnProperty( 'label' ) && value.hasOwnProperty( 'url' ) ) {
|
|
731
|
+
ws.cell( i + 2, j + 1 ).link( value.url );
|
|
732
|
+
ws.cell( i + 2, j + 1 ).string( value.label );
|
|
733
|
+
} else {
|
|
734
|
+
ws.cell( i + 2, j + 1 ).string( value?.toString() );
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return await wb.writeToBuffer();
|
|
739
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import {
|
|
4
4
|
migrateClient, migrateStores, basicList, clientList, setTicketTime, downStoresList,
|
|
5
|
-
openTicketList, assigntoUser, updateRefreshTicket, closeTicket, spocmailchange, emailUserList, infraReportSent,
|
|
5
|
+
openTicketList, assigntoUser, updateRefreshTicket, closeTicket, camAngleChangeReport, spocmailchange, emailUserList, infraReportSent,
|
|
6
6
|
} from '../controllers/internalInfra.controller.js';
|
|
7
7
|
|
|
8
8
|
export const internalInfraRouter = express.Router();
|
|
@@ -20,5 +20,6 @@ internalInfraRouter.post( '/closeTicket', closeTicket );
|
|
|
20
20
|
internalInfraRouter.get( '/emailUserList', emailUserList );
|
|
21
21
|
internalInfraRouter.post( '/infraReportSent', infraReportSent );
|
|
22
22
|
internalInfraRouter.post( '/spocmailchange', spocmailchange );
|
|
23
|
+
internalInfraRouter.post( '/camAngleChangeReport', camAngleChangeReport );
|
|
23
24
|
|
|
24
25
|
|