tango-app-api-infra 3.0.36-dev → 3.0.38-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.
|
|
3
|
+
"version": "3.0.38-dev",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"handlebars": "^4.7.8",
|
|
23
23
|
"mongodb": "^6.4.0",
|
|
24
24
|
"nodemon": "^3.1.0",
|
|
25
|
-
"tango-api-schema": "^2.0.
|
|
25
|
+
"tango-api-schema": "^2.0.69",
|
|
26
26
|
"tango-app-api-middleware": "^1.0.52-dev",
|
|
27
27
|
"winston": "^3.12.0",
|
|
28
28
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -4,6 +4,8 @@ import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../
|
|
|
4
4
|
import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
|
|
5
5
|
import { updateOneStore } from '../services/store.service.js';
|
|
6
6
|
import { logger, fileUpload, signedUrl } from 'tango-app-api-middleware';
|
|
7
|
+
import { aggregateUser, updateOneUser } from '../services/user.service.js';
|
|
8
|
+
import { updateoneClient } from '../services/client.service.js';
|
|
7
9
|
import dayjs from 'dayjs';
|
|
8
10
|
export async function createTicket( req, res ) {
|
|
9
11
|
try {
|
|
@@ -300,3 +302,117 @@ export async function uploadAttachments( req, res ) {
|
|
|
300
302
|
return res.sendError( error, 500 );
|
|
301
303
|
}
|
|
302
304
|
}
|
|
305
|
+
|
|
306
|
+
export async function emailUserList( req, res ) {
|
|
307
|
+
try {
|
|
308
|
+
let inputData = req.body;
|
|
309
|
+
let query = [
|
|
310
|
+
{
|
|
311
|
+
$match: {
|
|
312
|
+
userType: 'client',
|
|
313
|
+
clientId: inputData.clientId,
|
|
314
|
+
...( inputData.role ) ? { role: inputData.role } : {},
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
$lookup: {
|
|
319
|
+
from: 'userAssignedStore',
|
|
320
|
+
let: { email: '$email' },
|
|
321
|
+
pipeline: [
|
|
322
|
+
{
|
|
323
|
+
$match: {
|
|
324
|
+
$expr: {
|
|
325
|
+
$and: [
|
|
326
|
+
{ $eq: [ '$userEmail', '$$email' ] },
|
|
327
|
+
],
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
$group: {
|
|
334
|
+
_id: null,
|
|
335
|
+
storeList: { $push: '$assignedValue' },
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
$project: {
|
|
340
|
+
|
|
341
|
+
assignedStore: { $size: '$storeList' },
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
], as: 'assigned',
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
$unwind: { path: '$assigned', preserveNullAndEmptyArrays: true },
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
$project: {
|
|
352
|
+
userName: 1,
|
|
353
|
+
email: 1,
|
|
354
|
+
role: 1,
|
|
355
|
+
emailAlert: 1,
|
|
356
|
+
infraAlert: { $ifNull: [ '$emailAlert.infra', false ] },
|
|
357
|
+
assigned: { $ifNull: [ '$assigned.assignedStore', 0 ] },
|
|
358
|
+
isActive: 1,
|
|
359
|
+
mobileNumber: 1,
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
];
|
|
364
|
+
if ( req.body.searchValue && req.body.searchValue != '' ) {
|
|
365
|
+
query.push( {
|
|
366
|
+
$match: {
|
|
367
|
+
$or: [
|
|
368
|
+
{ userName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
369
|
+
{ email: { $regex: req.body.searchValue, $options: 'i' } },
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
} );
|
|
373
|
+
}
|
|
374
|
+
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
375
|
+
query.push( {
|
|
376
|
+
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
377
|
+
} );
|
|
378
|
+
}
|
|
379
|
+
const count = await aggregateUser( query );
|
|
380
|
+
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
381
|
+
query.push(
|
|
382
|
+
{ $skip: ( req.body.offset - 1 ) * req.body.limit },
|
|
383
|
+
{ $limit: Number( req.body.limit ) },
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
const result = await aggregateUser( query );
|
|
387
|
+
res.sendSuccess( { count: count.length, result: result } );
|
|
388
|
+
} catch ( error ) {
|
|
389
|
+
logger.error( { error: error, function: 'emailUserList' } );
|
|
390
|
+
return res.sendError( error, 500 );
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
export async function saveInfraEmailConfig( req, res ) {
|
|
394
|
+
try {
|
|
395
|
+
let inputData = req.body;
|
|
396
|
+
|
|
397
|
+
let clientupdate = await updateoneClient( { clientId: inputData.clientId }, {
|
|
398
|
+
'ticketConfigs.infraReport': {
|
|
399
|
+
start: inputData.start,
|
|
400
|
+
end: inputData.end,
|
|
401
|
+
},
|
|
402
|
+
} );
|
|
403
|
+
console.log( clientupdate );
|
|
404
|
+
if ( inputData.userList && inputData.userList.length > 0 ) {
|
|
405
|
+
for ( let user of inputData.userList ) {
|
|
406
|
+
await updateOneUser( { email: user.email }, {
|
|
407
|
+
emailAlert: {
|
|
408
|
+
infra: user.infraAlert,
|
|
409
|
+
},
|
|
410
|
+
} );
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
res.sendSuccess( 'Updated Successfully' );
|
|
414
|
+
} catch ( error ) {
|
|
415
|
+
logger.error( { error: error, function: 'emailUserList' } );
|
|
416
|
+
return res.sendError( error, 500 );
|
|
417
|
+
}
|
|
418
|
+
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
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
|
-
import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
|
|
5
|
+
import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
|
|
6
|
+
secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
|
|
7
|
+
updateInstallationTicket, emailUserList, saveInfraEmailConfig } from '../controllers/infra.controllers.js';
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
export const infraRouter = express.Router();
|
|
@@ -44,5 +46,11 @@ infraRouter.post( '/updateInstallationTicket', isAllowedSessionHandler, authoriz
|
|
|
44
46
|
userType: [ 'client', 'tango' ], access: [
|
|
45
47
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
|
|
46
48
|
} ), ticketExists, updateInstallationTicket );
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
infraRouter.post( '/emailUserList', isAllowedSessionHandler, authorize( {
|
|
50
|
+
userType: [ 'client', 'tango' ], access: [
|
|
51
|
+
{ featureName: 'settings', name: 'configuration', permissions: [ 'isView' ] } ],
|
|
52
|
+
} ), emailUserList );
|
|
53
|
+
infraRouter.post( '/saveInfraEmailConfig', isAllowedSessionHandler, authorize( {
|
|
54
|
+
userType: [ 'client', 'tango' ], access: [
|
|
55
|
+
{ featureName: 'settings', name: 'configuration', permissions: [ 'isEdit', 'isView' ] } ],
|
|
56
|
+
} ), saveInfraEmailConfig );
|
|
@@ -16,3 +16,6 @@ export async function findClientwithpagination( query, project ) {
|
|
|
16
16
|
export async function aggregateClient( query ) {
|
|
17
17
|
return await dataModel.clientModel.aggregate( query );
|
|
18
18
|
}
|
|
19
|
+
export async function updateoneClient( query, data ) {
|
|
20
|
+
return await dataModel.clientModel.updateOne( query, { $set: data } );
|
|
21
|
+
}
|
|
@@ -5,3 +5,9 @@ export async function findOneUser( query, project ) {
|
|
|
5
5
|
return await dataModel.userModel.findOne( query, project );
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export async function aggregateUser( query ) {
|
|
9
|
+
return await dataModel.userModel.aggregate( query );
|
|
10
|
+
}
|
|
11
|
+
export async function updateOneUser( query, data ) {
|
|
12
|
+
return await dataModel.userModel.updateOne( query, { $set: data } );
|
|
13
|
+
}
|