tango-app-api-infra 3.1.8 → 3.1.10
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 +2 -2
- package/src/controllers/clientInfra.controller.js +12 -7
- package/src/controllers/employeeTraning.controller.js +0 -4
- package/src/controllers/infra.controllers.js +13 -2
- package/src/controllers/internalInfra.controller.js +5 -7
- package/src/controllers/userInfra.controller.js +0 -1
- package/src/routes/infra.routes.js +2 -2
- package/src/validations/infra.validation.js +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-infra",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.10",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"html-pdf-node": "^1.0.8",
|
|
25
25
|
"mongodb": "^6.4.0",
|
|
26
26
|
"nodemon": "^3.1.0",
|
|
27
|
-
"tango-api-schema": "^2.0.
|
|
27
|
+
"tango-api-schema": "^2.0.94",
|
|
28
28
|
"tango-app-api-middleware": "^3.1.7",
|
|
29
29
|
"winston": "^3.12.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -10,13 +10,12 @@ import { getOpenSearchData } from 'tango-app-api-middleware';
|
|
|
10
10
|
export async function infraCard( req, res ) {
|
|
11
11
|
try {
|
|
12
12
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
13
|
-
let storeCount = await countDocumentsStore( { clientId: { $in: req.body.clientId }, status: 'active' } );
|
|
13
|
+
let storeCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'edge.firstFile': true, 'status': 'active' } );
|
|
14
14
|
let infraStoreCount = await aggregateTangoTicket( [
|
|
15
15
|
{
|
|
16
16
|
$match: {
|
|
17
17
|
$and: [
|
|
18
18
|
{ issueType: 'infra' },
|
|
19
|
-
{ status: { $ne: 'closed' } },
|
|
20
19
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
21
20
|
{ createdAt: { $gte: date.start } },
|
|
22
21
|
{ createdAt: { $lte: date.end } },
|
|
@@ -46,13 +45,13 @@ export async function infraCard( req, res ) {
|
|
|
46
45
|
},
|
|
47
46
|
},
|
|
48
47
|
] );
|
|
48
|
+
|
|
49
49
|
let query = [ {
|
|
50
50
|
$match: {
|
|
51
51
|
$and: [
|
|
52
52
|
{ issueType: 'infra' },
|
|
53
53
|
{ 'ticketDetails.issueStatus': 'identified' },
|
|
54
54
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
55
|
-
{ 'ticketDetails.issueStatus': 'identified' },
|
|
56
55
|
{ createdAt: { $gte: date.start } },
|
|
57
56
|
{ createdAt: { $lte: date.end } },
|
|
58
57
|
],
|
|
@@ -148,8 +147,13 @@ export async function infraCard( req, res ) {
|
|
|
148
147
|
}
|
|
149
148
|
export async function installationCard( req, res ) {
|
|
150
149
|
try {
|
|
151
|
-
let onboardedCount = await countDocumentsStore( {
|
|
152
|
-
|
|
150
|
+
let onboardedCount = await countDocumentsStore( {
|
|
151
|
+
'$and': [
|
|
152
|
+
{ 'clientId': { $in: req.body.clientId } },
|
|
153
|
+
],
|
|
154
|
+
} );
|
|
155
|
+
let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
|
|
156
|
+
'edge.firstFile': true, 'status': 'active' } );
|
|
153
157
|
|
|
154
158
|
let yettoInstallCount = await aggregateTangoTicket( [
|
|
155
159
|
{
|
|
@@ -250,7 +254,7 @@ export async function installationCard( req, res ) {
|
|
|
250
254
|
infraIssues: response,
|
|
251
255
|
} );
|
|
252
256
|
} catch ( error ) {
|
|
253
|
-
logger.error( { error: error, function: '
|
|
257
|
+
logger.error( { error: error, function: 'installationCard' } );
|
|
254
258
|
return res.sendError( error, 500 );
|
|
255
259
|
}
|
|
256
260
|
}
|
|
@@ -681,6 +685,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
681
685
|
let query = [ {
|
|
682
686
|
$match: {
|
|
683
687
|
clientId: req.body.clientId,
|
|
688
|
+
status: 'active',
|
|
684
689
|
},
|
|
685
690
|
},
|
|
686
691
|
{
|
|
@@ -783,7 +788,7 @@ function downStoresCheck( data, inputData ) {
|
|
|
783
788
|
const average = sum / streamwiseDowntime.length;
|
|
784
789
|
obj[obj.startTime + '-' + obj.endTime] = Math.round( average );
|
|
785
790
|
} else {
|
|
786
|
-
obj[obj.startTime + '-' + obj.endTime] =
|
|
791
|
+
obj[obj.startTime + '-' + obj.endTime] = '';
|
|
787
792
|
}
|
|
788
793
|
|
|
789
794
|
timewise.push( obj );
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
3
3
|
import { logger } from 'tango-app-api-middleware';
|
|
4
4
|
export async function createTicket( req, res ) {
|
|
5
|
-
console.log( req.body );
|
|
6
5
|
try {
|
|
7
6
|
let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': req.body.storeId } );
|
|
8
7
|
if ( ticketExist ) {
|
|
@@ -12,7 +11,6 @@ export async function createTicket( req, res ) {
|
|
|
12
11
|
req.body.issueDate = new Date( req.body.Date );
|
|
13
12
|
req.body.ticketId = 'TE_MAT_' + new Date().valueOf();
|
|
14
13
|
let create = await createTangoTicket( req.body );
|
|
15
|
-
console.log( create );
|
|
16
14
|
if ( create ) {
|
|
17
15
|
res.sendSuccess( 'Ticket Created Successfully' );
|
|
18
16
|
}
|
|
@@ -23,7 +21,6 @@ export async function createTicket( req, res ) {
|
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
export async function updatecomment( req, res ) {
|
|
26
|
-
console.log( req.body );
|
|
27
24
|
try {
|
|
28
25
|
if ( req.body.comment != '' ) {
|
|
29
26
|
req.body.ticketActivity.push( {
|
|
@@ -44,7 +41,6 @@ export async function updatecomment( req, res ) {
|
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
export async function activityLog( req, res ) {
|
|
47
|
-
console.log( req.body );
|
|
48
44
|
try {
|
|
49
45
|
res.sendSuccess( req.body );
|
|
50
46
|
} catch ( error ) {
|
|
@@ -642,7 +642,8 @@ export async function infraTable( req, res ) {
|
|
|
642
642
|
{ createdAt: { $lte: date.end } },
|
|
643
643
|
],
|
|
644
644
|
},
|
|
645
|
-
},
|
|
645
|
+
},
|
|
646
|
+
{
|
|
646
647
|
$project: {
|
|
647
648
|
storeId: '$basicDetails.storeId',
|
|
648
649
|
clientId: '$basicDetails.clientId',
|
|
@@ -724,7 +725,7 @@ export async function infraTable( req, res ) {
|
|
|
724
725
|
},
|
|
725
726
|
{
|
|
726
727
|
$group: {
|
|
727
|
-
_id: '$
|
|
728
|
+
_id: '$storeId',
|
|
728
729
|
storeId: { $first: '$storeId' },
|
|
729
730
|
clientId: { $first: '$clientId' },
|
|
730
731
|
ticketId: { $first: '$ticketId' },
|
|
@@ -739,6 +740,11 @@ export async function infraTable( req, res ) {
|
|
|
739
740
|
secondaryIssue: { $last: '$secondaryIssue' },
|
|
740
741
|
},
|
|
741
742
|
},
|
|
743
|
+
{
|
|
744
|
+
$sort: {
|
|
745
|
+
ticketId: -1,
|
|
746
|
+
},
|
|
747
|
+
},
|
|
742
748
|
);
|
|
743
749
|
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
744
750
|
query.push( {
|
|
@@ -976,6 +982,11 @@ export async function installationTable( req, res ) {
|
|
|
976
982
|
secondaryIssue: { $last: '$secondaryIssue' },
|
|
977
983
|
},
|
|
978
984
|
},
|
|
985
|
+
{
|
|
986
|
+
$sort: {
|
|
987
|
+
ticketId: -1,
|
|
988
|
+
},
|
|
989
|
+
},
|
|
979
990
|
);
|
|
980
991
|
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
981
992
|
query.push( {
|
|
@@ -527,18 +527,17 @@ export async function infraReportSent( req, res ) {
|
|
|
527
527
|
exportdata.push( {
|
|
528
528
|
'Client ID': element.basicDetails.clientId,
|
|
529
529
|
'Client Name': element.basicDetails.clientName,
|
|
530
|
-
'Created Date & Time': dayjs( element.createdAt ).format( 'YYYY-MM-DD HH:mm A' ),
|
|
531
|
-
'Store ID': element.basicDetails.
|
|
532
|
-
'Store Name': element.basicDetails.
|
|
530
|
+
'Ticket Created Date & Time': dayjs( element.createdAt ).format( 'YYYY-MM-DD HH:mm A' ),
|
|
531
|
+
'Store ID': element.basicDetails.storeId,
|
|
532
|
+
'Store Name': element.basicDetails.storeName,
|
|
533
533
|
'Issue ': element.primaryIssue,
|
|
534
534
|
'Secondary Issue': element.secondaryIssue,
|
|
535
|
-
'Issue Date & Time': dayjs( element.date ).format( 'YYYY-MM-DD' ),
|
|
536
535
|
'Status ': element.status,
|
|
537
536
|
'Responded By': clientuser && clientuser.userName ? clientuser.userName : '-',
|
|
538
537
|
'Resolved By': tangouser && tangouser.userName ? tangouser.userName : '-',
|
|
539
|
-
'Closed Date & Time': element.issueClosedDate ? dayjs( element.issueClosedDate ).format( 'YYYY-MM-DD HH:mm A' ) : '-',
|
|
538
|
+
'Ticket Closed Date & Time': element.issueClosedDate ? dayjs( element.issueClosedDate ).format( 'YYYY-MM-DD HH:mm A' ) : '-',
|
|
540
539
|
'Latest Comment': '',
|
|
541
|
-
'Activity Log': ''
|
|
540
|
+
'Activity Log': `${appConfig.url.domain+'/manage/stores/infra-ticket?storeId='+element.basicDetails.storeId}`,
|
|
542
541
|
} );
|
|
543
542
|
}
|
|
544
543
|
|
|
@@ -611,7 +610,6 @@ export async function infraReportSent( req, res ) {
|
|
|
611
610
|
const result = await sendEmailWithSES( req.body.email, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
|
|
612
611
|
res.sendSuccess( result );
|
|
613
612
|
}
|
|
614
|
-
res.sendSuccess( result );
|
|
615
613
|
} catch ( error ) {
|
|
616
614
|
logger.error( { error: error, function: 'infraReportSent' } );
|
|
617
615
|
res.sendError( error, 500 );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
4
|
-
import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
4
|
+
import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, validateTicketstatus, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
5
5
|
import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable,
|
|
6
6
|
secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
|
|
7
7
|
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
@@ -29,7 +29,7 @@ infraRouter.post( '/secondaryReason', isAllowedSessionHandler, authorize( {
|
|
|
29
29
|
infraRouter.post( '/updateTicketIssue', isAllowedSessionHandler, authorize( {
|
|
30
30
|
userType: [ 'client', 'tango' ], access: [
|
|
31
31
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isEdit' ] } ],
|
|
32
|
-
} ), ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
|
|
32
|
+
} ), ticketExists, validateTicketstatus, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
|
|
33
33
|
infraRouter.post( '/viewTicket', isAllowedSessionHandler, authorize( {
|
|
34
34
|
userType: [ 'client', 'tango' ], access: [
|
|
35
35
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
@@ -184,12 +184,45 @@ export async function ticketExists( req, res, next ) {
|
|
|
184
184
|
req.body.basicDetails = Ticket.basicDetails;
|
|
185
185
|
req.body.ticketDetails = Ticket.ticketDetails;
|
|
186
186
|
req.body.ticketActivity = Ticket.ticketActivity;
|
|
187
|
+
req.body.status = Ticket.status;
|
|
188
|
+
|
|
187
189
|
next();
|
|
188
190
|
} catch ( error ) {
|
|
189
191
|
logger.error( { error: error, function: 'ticketExists' } );
|
|
190
192
|
return res.sendError( error, 500 );
|
|
191
193
|
}
|
|
192
194
|
};
|
|
195
|
+
|
|
196
|
+
export async function validateTicketstatus( req, res, next ) {
|
|
197
|
+
try {
|
|
198
|
+
if ( req.body.issueType == 'infra' ) {
|
|
199
|
+
if ( req.body.secondary.length>0 ) {
|
|
200
|
+
if ( req.body.status == 'closed' ) {
|
|
201
|
+
return res.sendSuccess( 'Ticket already closed' );
|
|
202
|
+
}
|
|
203
|
+
console.log( req.body.ticketDetails );
|
|
204
|
+
|
|
205
|
+
if ( req.body.ticketDetails.ticketType==='firsttimeticket'&&req.body.ticketDetails.issueStatus==='identified' ) {
|
|
206
|
+
return res.sendSuccess( 'Ticket already Addressed' );
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
if ( req.body.primary == 'Application Issues' ) {
|
|
210
|
+
if ( req.body.status == 'closed' ) {
|
|
211
|
+
return res.sendSuccess( 'Ticket already closed' );
|
|
212
|
+
}
|
|
213
|
+
if ( req.body.ticketDetails.ticketType==='firsttimeticket'&&req.body.ticketDetails.issueStatus==='identified' ) {
|
|
214
|
+
return res.sendSuccess( 'Ticket already Addressed' );
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
next();
|
|
220
|
+
} catch ( error ) {
|
|
221
|
+
logger.error( { error: error, function: 'validateTicket' } );
|
|
222
|
+
return res.sendError( error, 500 );
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
193
226
|
export async function infraReasonExists( req, res, next ) {
|
|
194
227
|
try {
|
|
195
228
|
if ( req.body.primary && req.body.secondary && req.body.secondary.length ) {
|