tango-app-api-infra 3.1.9 → 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 +1 -1
- package/src/controllers/clientInfra.controller.js +3 -8
- package/src/controllers/employeeTraning.controller.js +0 -4
- package/src/controllers/infra.controllers.js +13 -2
- 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
|
@@ -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 }, 'edge.firstFile': true,status:
|
|
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
|
],
|
|
@@ -151,14 +150,10 @@ export async function installationCard( req, res ) {
|
|
|
151
150
|
let onboardedCount = await countDocumentsStore( {
|
|
152
151
|
'$and': [
|
|
153
152
|
{ 'clientId': { $in: req.body.clientId } },
|
|
154
|
-
{ $or: [
|
|
155
|
-
{ 'edge.firstFile': true },
|
|
156
|
-
{ 'edge.firstFile': false },
|
|
157
|
-
] },
|
|
158
153
|
],
|
|
159
154
|
} );
|
|
160
155
|
let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
|
|
161
|
-
|
|
156
|
+
'edge.firstFile': true, 'status': 'active' } );
|
|
162
157
|
|
|
163
158
|
let yettoInstallCount = await aggregateTangoTicket( [
|
|
164
159
|
{
|
|
@@ -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( {
|
|
@@ -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 ) {
|