tango-app-api-infra 3.1.21 → 3.1.23
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
|
@@ -6,12 +6,18 @@ import { findinfraReason } from '../services/infraReason.service.js';
|
|
|
6
6
|
import { aggregateClient, findClient } from '../services/client.service.js';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
8
|
import { getOpenSearchData } from 'tango-app-api-middleware';
|
|
9
|
+
import { aggregateUserAssignedStore, findUserAssignedStore } from '../services/userAssignedStore.service.js';
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
export async function infraCard( req, res ) {
|
|
11
13
|
try {
|
|
12
14
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
+
let storecountQuery ={ 'clientId': { $in: req.body.clientId }, 'createdAt': { $lte: date.end }, 'status': 'active' };
|
|
16
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
17
|
+
storecountQuery = { ...storecountQuery, ...{ storeId: { $in: req.body.permittedStores } } };
|
|
18
|
+
}
|
|
19
|
+
let storeCount = await countDocumentsStore( storecountQuery );
|
|
20
|
+
let yetToInstallQuery = [
|
|
15
21
|
{
|
|
16
22
|
$match: {
|
|
17
23
|
$and: [
|
|
@@ -22,18 +28,38 @@ export async function infraCard( req, res ) {
|
|
|
22
28
|
],
|
|
23
29
|
},
|
|
24
30
|
},
|
|
25
|
-
]
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
34
|
+
yetToInstallQuery.push(
|
|
35
|
+
{
|
|
36
|
+
$match: {
|
|
37
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
let yettoInstallCount = await aggregateTangoTicket( yetToInstallQuery );
|
|
26
43
|
storeCount = storeCount-yettoInstallCount.length;
|
|
27
|
-
let
|
|
44
|
+
let totalStoreQuery =[ {
|
|
28
45
|
$match: {
|
|
29
46
|
'$and': [
|
|
30
47
|
{ 'clientId': { $in: req.body.clientId } },
|
|
31
|
-
{ 'edge.firstFile': true },
|
|
32
48
|
{ 'status': 'active' },
|
|
33
49
|
{ 'createdAt': { $lte: date.end } },
|
|
34
50
|
],
|
|
35
51
|
},
|
|
36
|
-
} ]
|
|
52
|
+
} ];
|
|
53
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
54
|
+
totalStoreQuery.push(
|
|
55
|
+
{
|
|
56
|
+
$match: {
|
|
57
|
+
'storeId': { $in: req.body.permittedStores },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
let totalstores = await aggregateStore( totalStoreQuery );
|
|
37
63
|
let totalnumberstores = [];
|
|
38
64
|
for ( let store of totalstores ) {
|
|
39
65
|
totalnumberstores.push( store.storeId );
|
|
@@ -46,7 +72,6 @@ export async function infraCard( req, res ) {
|
|
|
46
72
|
{ status: { $ne: 'closed' } },
|
|
47
73
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
48
74
|
{ 'basicDetails.storeId': { $in: totalnumberstores } },
|
|
49
|
-
// { createdAt: { $gte: date.start } },
|
|
50
75
|
{ createdAt: { $lte: date.end } },
|
|
51
76
|
],
|
|
52
77
|
},
|
|
@@ -83,7 +108,6 @@ export async function infraCard( req, res ) {
|
|
|
83
108
|
{ 'ticketDetails.issueStatus': 'identified' },
|
|
84
109
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
85
110
|
{ 'basicDetails.storeId': { $in: totalnumberstores } },
|
|
86
|
-
// { createdAt: { $gte: date.start } },
|
|
87
111
|
{ createdAt: { $lte: date.end } },
|
|
88
112
|
],
|
|
89
113
|
},
|
|
@@ -178,7 +202,7 @@ export async function infraCard( req, res ) {
|
|
|
178
202
|
} );
|
|
179
203
|
res.sendSuccess( {
|
|
180
204
|
total: storeCount,
|
|
181
|
-
liveStoreCount: infraStoreCount.length > 0 ? storeCount - infraStoreCount[0].infraCount :
|
|
205
|
+
liveStoreCount: infraStoreCount.length > 0 ? storeCount - infraStoreCount[0].infraCount : storeCount,
|
|
182
206
|
infraStoreCount: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount : 0,
|
|
183
207
|
identifiedcount: infraStoreCount.length > 0 ? infraStoreCount[0].identifiedcount : 0,
|
|
184
208
|
notidentifiedcount: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount - infraStoreCount[0].identifiedcount : 0,
|
|
@@ -192,23 +216,22 @@ export async function infraCard( req, res ) {
|
|
|
192
216
|
export async function installationCard( req, res ) {
|
|
193
217
|
try {
|
|
194
218
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
195
|
-
let
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
let
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
let yettoInstallCount = await aggregateTangoTicket( [
|
|
219
|
+
let baseQuery = {
|
|
220
|
+
clientId: { $in: req.body.clientId },
|
|
221
|
+
createdAt: { $lte: date.end },
|
|
222
|
+
};
|
|
223
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
224
|
+
baseQuery = { ...baseQuery, ...{ storeId: { $in: req.body.permittedStores } } };
|
|
225
|
+
}
|
|
226
|
+
let onboardQuery = { ...baseQuery };
|
|
227
|
+
let installedQuery = { ...baseQuery, status: 'active' };
|
|
228
|
+
let deactiveQuery = { ...baseQuery, status: 'deactive' };
|
|
229
|
+
let onboardedCount = await countDocumentsStore( onboardQuery );
|
|
230
|
+
let installedCount = await countDocumentsStore( installedQuery );
|
|
231
|
+
let deactiveCount = await countDocumentsStore( deactiveQuery );
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
let ticketbaseQuery = [
|
|
212
235
|
{
|
|
213
236
|
$match: {
|
|
214
237
|
$and: [
|
|
@@ -219,16 +242,21 @@ export async function installationCard( req, res ) {
|
|
|
219
242
|
],
|
|
220
243
|
},
|
|
221
244
|
},
|
|
222
|
-
]
|
|
223
|
-
|
|
245
|
+
];
|
|
246
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
247
|
+
ticketbaseQuery.push(
|
|
248
|
+
{
|
|
249
|
+
$match: {
|
|
250
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
let yettoInstallCount = await aggregateTangoTicket( ticketbaseQuery );
|
|
256
|
+
let query = ticketbaseQuery;
|
|
257
|
+
query.push( {
|
|
224
258
|
$match: {
|
|
225
|
-
|
|
226
|
-
{ issueType: 'installation' },
|
|
227
|
-
{ 'status': { $ne: 'closed' } },
|
|
228
|
-
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
229
|
-
{ 'ticketDetails.issueStatus': 'identified' },
|
|
230
|
-
{ createdAt: { $lte: date.end } },
|
|
231
|
-
],
|
|
259
|
+
'ticketDetails.issueStatus': 'identified',
|
|
232
260
|
},
|
|
233
261
|
},
|
|
234
262
|
{
|
|
@@ -272,8 +300,8 @@ export async function installationCard( req, res ) {
|
|
|
272
300
|
issueIdentifiedBy: { $last: '$issueIdentifiedBy' },
|
|
273
301
|
primaryIssue: { $last: '$primaryIssue' },
|
|
274
302
|
},
|
|
275
|
-
}
|
|
276
|
-
|
|
303
|
+
} );
|
|
304
|
+
|
|
277
305
|
let installFailedCount = await aggregateTangoTicket( query );
|
|
278
306
|
|
|
279
307
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
@@ -323,8 +351,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
323
351
|
issueStatus = [ 'identified' ];
|
|
324
352
|
};
|
|
325
353
|
|
|
326
|
-
|
|
327
|
-
let totalstores = await aggregateStore( [ {
|
|
354
|
+
let totalStoreQuery = [ {
|
|
328
355
|
$match: {
|
|
329
356
|
'$and': [
|
|
330
357
|
{ 'clientId': { $in: req.body.clientId } },
|
|
@@ -332,7 +359,17 @@ export async function infraIssuesTable( req, res ) {
|
|
|
332
359
|
{ 'createdAt': { $lte: date.end } },
|
|
333
360
|
],
|
|
334
361
|
},
|
|
335
|
-
} ]
|
|
362
|
+
} ];
|
|
363
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
364
|
+
totalStoreQuery.push(
|
|
365
|
+
{
|
|
366
|
+
$match: {
|
|
367
|
+
'storeId': { $in: req.body.permittedStores },
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
let totalstores = await aggregateStore( totalStoreQuery );
|
|
336
373
|
let totalnumberstores = [];
|
|
337
374
|
for ( let store of totalstores ) {
|
|
338
375
|
totalnumberstores.push( store.storeId );
|
|
@@ -348,6 +385,15 @@ export async function infraIssuesTable( req, res ) {
|
|
|
348
385
|
],
|
|
349
386
|
},
|
|
350
387
|
} );
|
|
388
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
389
|
+
pendingquery.push(
|
|
390
|
+
{
|
|
391
|
+
$match: {
|
|
392
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
);
|
|
396
|
+
}
|
|
351
397
|
let pendingstorecount = await aggregateTangoTicket( pendingquery );
|
|
352
398
|
let installpendingticket = pendingstorecount.map( ( store ) => store.basicDetails.storeId );
|
|
353
399
|
|
|
@@ -439,6 +485,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
439
485
|
];
|
|
440
486
|
|
|
441
487
|
let storesQuery = [];
|
|
488
|
+
|
|
442
489
|
if ( req.body.infrafilterIssue == 'Total Stores' ) {
|
|
443
490
|
storesQuery.push( {
|
|
444
491
|
$match: {
|
|
@@ -461,7 +508,6 @@ export async function infraIssuesTable( req, res ) {
|
|
|
461
508
|
!infraissueStore.includes( data ) &&
|
|
462
509
|
!installpendingticket.includes( data ),
|
|
463
510
|
);
|
|
464
|
-
|
|
465
511
|
storesQuery.push(
|
|
466
512
|
{
|
|
467
513
|
$match: {
|
|
@@ -471,6 +517,28 @@ export async function infraIssuesTable( req, res ) {
|
|
|
471
517
|
},
|
|
472
518
|
},
|
|
473
519
|
);
|
|
520
|
+
|
|
521
|
+
if ( infraissueStore&&infraissueStore.length==0 ) {
|
|
522
|
+
storesQuery = [ {
|
|
523
|
+
$match: {
|
|
524
|
+
'$and': [
|
|
525
|
+
{ 'clientId': { $in: req.body.clientId } },
|
|
526
|
+
{ 'status': 'active' },
|
|
527
|
+
{ 'storeId': { $nin: installpendingticket } },
|
|
528
|
+
{ 'createdAt': { $lte: date.end } },
|
|
529
|
+
],
|
|
530
|
+
},
|
|
531
|
+
} ];
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
535
|
+
storesQuery.push(
|
|
536
|
+
{
|
|
537
|
+
$match: {
|
|
538
|
+
'storeId': { $in: req.body.permittedStores },
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
);
|
|
474
542
|
}
|
|
475
543
|
const excludedIssues = [ 'Identified Issues', 'Issues Not Identified', 'All Issues' ];
|
|
476
544
|
if ( req.body.infrafilterIssue && !excludedIssues.includes( req.body.infrafilterIssue ) ) {
|
|
@@ -628,6 +696,15 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
628
696
|
],
|
|
629
697
|
},
|
|
630
698
|
} );
|
|
699
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
700
|
+
query.push(
|
|
701
|
+
{
|
|
702
|
+
$match: {
|
|
703
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
);
|
|
707
|
+
}
|
|
631
708
|
if ( req.body.installtionfilterIssue == 'yettoInstallStores' ) {
|
|
632
709
|
query.push( { $match: { 'ticketDetails.issueStatus': 'notidentified' } } );
|
|
633
710
|
}
|
|
@@ -687,7 +764,15 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
687
764
|
},
|
|
688
765
|
);
|
|
689
766
|
let storesQuery = [];
|
|
690
|
-
|
|
767
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
768
|
+
storesQuery.push(
|
|
769
|
+
{
|
|
770
|
+
$match: {
|
|
771
|
+
'storeId': { $in: req.body.permittedStores },
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
);
|
|
775
|
+
}
|
|
691
776
|
if ( req.body.installtionfilterIssue == 'onboardedStores' ) {
|
|
692
777
|
storesQuery.push( {
|
|
693
778
|
$match: {
|
|
@@ -1017,7 +1102,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1017
1102
|
};
|
|
1018
1103
|
|
|
1019
1104
|
|
|
1020
|
-
let
|
|
1105
|
+
let totalStoreQuery = [ {
|
|
1021
1106
|
$match: {
|
|
1022
1107
|
'$and': [
|
|
1023
1108
|
{ 'clientId': { $in: req.body.clientId } },
|
|
@@ -1025,7 +1110,17 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1025
1110
|
{ 'createdAt': { $lte: date.end } },
|
|
1026
1111
|
],
|
|
1027
1112
|
},
|
|
1028
|
-
} ]
|
|
1113
|
+
} ];
|
|
1114
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1115
|
+
totalStoreQuery.push(
|
|
1116
|
+
{
|
|
1117
|
+
$match: {
|
|
1118
|
+
'storeId': { $in: req.body.permittedStores },
|
|
1119
|
+
},
|
|
1120
|
+
},
|
|
1121
|
+
);
|
|
1122
|
+
}
|
|
1123
|
+
let totalstores = await aggregateStore( totalStoreQuery );
|
|
1029
1124
|
let totalnumberstores = [];
|
|
1030
1125
|
for ( let store of totalstores ) {
|
|
1031
1126
|
totalnumberstores.push( store.storeId );
|
|
@@ -1041,6 +1136,15 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1041
1136
|
],
|
|
1042
1137
|
},
|
|
1043
1138
|
} );
|
|
1139
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1140
|
+
pendingquery.push(
|
|
1141
|
+
{
|
|
1142
|
+
$match: {
|
|
1143
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
1144
|
+
},
|
|
1145
|
+
},
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1044
1148
|
let pendingstorecount = await aggregateTangoTicket( pendingquery );
|
|
1045
1149
|
let installpendingticket = pendingstorecount.map( ( store ) => store.basicDetails.storeId );
|
|
1046
1150
|
|
|
@@ -1164,6 +1268,27 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1164
1268
|
},
|
|
1165
1269
|
},
|
|
1166
1270
|
);
|
|
1271
|
+
if ( infraissueStore&&infraissueStore.length==0 ) {
|
|
1272
|
+
storesQuery = [ {
|
|
1273
|
+
$match: {
|
|
1274
|
+
'$and': [
|
|
1275
|
+
{ 'clientId': { $in: req.body.clientId } },
|
|
1276
|
+
{ 'status': 'active' },
|
|
1277
|
+
{ 'storeId': { $nin: installpendingticket } },
|
|
1278
|
+
{ 'createdAt': { $lte: date.end } },
|
|
1279
|
+
],
|
|
1280
|
+
},
|
|
1281
|
+
} ];
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1285
|
+
storesQuery.push(
|
|
1286
|
+
{
|
|
1287
|
+
$match: {
|
|
1288
|
+
'storeId': { $in: req.body.permittedStores },
|
|
1289
|
+
},
|
|
1290
|
+
},
|
|
1291
|
+
);
|
|
1167
1292
|
}
|
|
1168
1293
|
const excludedIssues = [ 'Identified Issues', 'Issues Not Identified', 'All Issues' ];
|
|
1169
1294
|
if ( req.body.infrafilterIssue && !excludedIssues.includes( req.body.infrafilterIssue ) ) {
|
|
@@ -1278,6 +1403,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
1278
1403
|
for ( const store of storesList ) {
|
|
1279
1404
|
data.storeId = store.storeId;
|
|
1280
1405
|
data.storeName = store.storeName;
|
|
1406
|
+
data.clientName = store.clientName;
|
|
1281
1407
|
data.primaryIssue = store.primaryIssue;
|
|
1282
1408
|
let storedata = await downStoresCheck( data, inputData );
|
|
1283
1409
|
result.push( storedata[0] );
|
|
@@ -1363,6 +1489,9 @@ export async function ticketCountSplit( req, res ) {
|
|
|
1363
1489
|
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
1364
1490
|
|
|
1365
1491
|
];
|
|
1492
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1493
|
+
filter.push( { 'basicDetails.storeId': { $in: req.body.permittedStores } } );
|
|
1494
|
+
}
|
|
1366
1495
|
if ( req.user.userType === 'client' ) {
|
|
1367
1496
|
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1368
1497
|
}
|
|
@@ -1441,6 +1570,9 @@ export async function overViewTable( req, res ) {
|
|
|
1441
1570
|
'basicDetails.clientId': { $in: inputData.clientId },
|
|
1442
1571
|
},
|
|
1443
1572
|
];
|
|
1573
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1574
|
+
filter.push( { 'basicDetails.storeId': { $in: req.body.permittedStores } } );
|
|
1575
|
+
}
|
|
1444
1576
|
if ( req.user.userType === 'client' ) {
|
|
1445
1577
|
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1446
1578
|
}
|
|
@@ -1536,7 +1668,9 @@ export async function ticketCount( req, res ) {
|
|
|
1536
1668
|
},
|
|
1537
1669
|
|
|
1538
1670
|
];
|
|
1539
|
-
|
|
1671
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1672
|
+
filter.push( { 'basicDetails.storeId': { $in: req.body.permittedStores } } );
|
|
1673
|
+
}
|
|
1540
1674
|
if ( req.user.userType === 'client' ) {
|
|
1541
1675
|
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1542
1676
|
}
|
|
@@ -1598,3 +1732,108 @@ export async function ticketCount( req, res ) {
|
|
|
1598
1732
|
res.sendError( 'Internal Server Error', 500 );
|
|
1599
1733
|
}
|
|
1600
1734
|
};
|
|
1735
|
+
export async function checkPermission( req, res, next ) {
|
|
1736
|
+
try {
|
|
1737
|
+
let result =[];
|
|
1738
|
+
if ( req.user.role !== 'superadmin' && req.user.userType == 'client' ) {
|
|
1739
|
+
const assignedUser = await findUserAssignedStore( { userEmail: req.user.email } );
|
|
1740
|
+
if ( assignedUser.length == 0 ) {
|
|
1741
|
+
return res.sendSuccess( { result: [], count: 0 } );
|
|
1742
|
+
}
|
|
1743
|
+
switch ( assignedUser[0].assignedType ) {
|
|
1744
|
+
case 'store':
|
|
1745
|
+
const assignedUserQuery = [
|
|
1746
|
+
{
|
|
1747
|
+
$match: {
|
|
1748
|
+
userEmail: { $eq: req.user.email },
|
|
1749
|
+
},
|
|
1750
|
+
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
$group: {
|
|
1754
|
+
_id: null,
|
|
1755
|
+
storeList: { $push: '$assignedValue' },
|
|
1756
|
+
},
|
|
1757
|
+
},
|
|
1758
|
+
{
|
|
1759
|
+
$project: {
|
|
1760
|
+
storeList: 1,
|
|
1761
|
+
},
|
|
1762
|
+
},
|
|
1763
|
+
];
|
|
1764
|
+
result = await aggregateUserAssignedStore( assignedUserQuery );
|
|
1765
|
+
break;
|
|
1766
|
+
|
|
1767
|
+
case 'group':
|
|
1768
|
+
const assignedQuery = [
|
|
1769
|
+
{
|
|
1770
|
+
$match: {
|
|
1771
|
+
userEmail: { $eq: req.user.email },
|
|
1772
|
+
},
|
|
1773
|
+
|
|
1774
|
+
},
|
|
1775
|
+
{
|
|
1776
|
+
$project: {
|
|
1777
|
+
assignedValue: {
|
|
1778
|
+
$toObjectId: '$assignedValue',
|
|
1779
|
+
},
|
|
1780
|
+
},
|
|
1781
|
+
},
|
|
1782
|
+
{
|
|
1783
|
+
$lookup: {
|
|
1784
|
+
from: 'groups',
|
|
1785
|
+
let: { groupId: '$assignedValue' },
|
|
1786
|
+
pipeline: [
|
|
1787
|
+
{
|
|
1788
|
+
$match: {
|
|
1789
|
+
$expr: {
|
|
1790
|
+
$eq: [ '$_id', '$$groupId' ],
|
|
1791
|
+
},
|
|
1792
|
+
},
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
$project: {
|
|
1796
|
+
_id: 0,
|
|
1797
|
+
storeList: 1,
|
|
1798
|
+
},
|
|
1799
|
+
},
|
|
1800
|
+
], as: 'groups',
|
|
1801
|
+
},
|
|
1802
|
+
},
|
|
1803
|
+
{
|
|
1804
|
+
$unwind: {
|
|
1805
|
+
path: '$groups', preserveNullAndEmptyArrays: true,
|
|
1806
|
+
},
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
$unwind: {
|
|
1810
|
+
path: '$groups.storeList', preserveNullAndEmptyArrays: true,
|
|
1811
|
+
},
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
$group: {
|
|
1815
|
+
_id: null,
|
|
1816
|
+
stores: { $push: '$groups.storeList' },
|
|
1817
|
+
},
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
$project: {
|
|
1821
|
+
_id: 0,
|
|
1822
|
+
storeList: '$stores',
|
|
1823
|
+
},
|
|
1824
|
+
},
|
|
1825
|
+
];
|
|
1826
|
+
result = await aggregateUserAssignedStore( assignedQuery );
|
|
1827
|
+
break;
|
|
1828
|
+
}
|
|
1829
|
+
if ( result&&result.length>0 ) {
|
|
1830
|
+
const uniqueArray = [ ...new Set( result[0].storeList ) ];
|
|
1831
|
+
req.body.permittedStores =uniqueArray;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
next();
|
|
1835
|
+
} catch ( error ) {
|
|
1836
|
+
logger.error( { error: error, function: 'checkPermission' } );
|
|
1837
|
+
res.sendError( 'Internal Server Error', 500 );
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
@@ -14,6 +14,7 @@ import { findOneGroup } from '../services/group.service.js';
|
|
|
14
14
|
import htmlpdf from 'html-pdf-node';
|
|
15
15
|
import mongoose from 'mongoose';
|
|
16
16
|
import _ from 'lodash';
|
|
17
|
+
import { aggregateUserAssignedStore, findUserAssignedStore } from '../services/userAssignedStore.service.js';
|
|
17
18
|
import { aggregateCamera } from '../services/camera.service.js';
|
|
18
19
|
export async function createTicket( req, res ) {
|
|
19
20
|
try {
|
|
@@ -72,7 +73,6 @@ export async function createTicket( req, res ) {
|
|
|
72
73
|
downtimetotal = 0;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
console.log( req.body );
|
|
76
76
|
let create = await createTangoTicket( req.body );
|
|
77
77
|
let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
|
|
78
78
|
const attachments = null;
|
|
@@ -242,11 +242,11 @@ export async function updateTicketIssue( req, res ) {
|
|
|
242
242
|
if ( req.body.issueType === 'infra' ) {
|
|
243
243
|
let client = await findOneClient( { clientId: req.body.basicDetails.clientId } );
|
|
244
244
|
let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
|
|
245
|
-
|
|
245
|
+
|
|
246
246
|
query = { ...query, 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
|
|
250
250
|
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, query );
|
|
251
251
|
|
|
252
252
|
if ( req.body.ticketDetails.ticketType === 'refreshticket' ) {
|
|
@@ -937,50 +937,61 @@ function inWords( num ) {
|
|
|
937
937
|
export async function allCounts( req, res ) {
|
|
938
938
|
try {
|
|
939
939
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
940
|
-
let countQuery=[
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
940
|
+
let countQuery=[];
|
|
941
|
+
|
|
942
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
943
|
+
countQuery.push(
|
|
944
|
+
{
|
|
945
|
+
$match: {
|
|
946
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
947
|
+
},
|
|
948
|
+
},
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
countQuery.push( {
|
|
953
|
+
$match: {
|
|
954
|
+
$and: [
|
|
955
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
956
|
+
{ createdAt: { $gte: date.start } },
|
|
957
|
+
{ createdAt: { $lte: date.end } },
|
|
958
|
+
],
|
|
959
|
+
},
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
$project: {
|
|
963
|
+
issueType: 1,
|
|
964
|
+
installationCount: {
|
|
965
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'installation' ] } ] }, 1, 0,
|
|
947
966
|
],
|
|
948
967
|
},
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
},
|
|
957
|
-
infraCount: {
|
|
958
|
-
$cond: [ { $and: [ { $eq: [ '$issueType', 'infra' ] } ] }, 1, 0,
|
|
959
|
-
],
|
|
960
|
-
},
|
|
961
|
-
datamismatchCount: {
|
|
962
|
-
$cond: [ { $or: [ { $eq: [ '$issueType', 'highcount' ] }, { $eq: [ '$issueType', 'lowcount' ] } ] }, 1, 0,
|
|
963
|
-
],
|
|
968
|
+
infraCount: {
|
|
969
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'infra' ] } ] }, 1, 0,
|
|
970
|
+
],
|
|
971
|
+
},
|
|
972
|
+
datamismatchCount: {
|
|
973
|
+
$cond: [ { $or: [ { $eq: [ '$issueType', 'highcount' ] }, { $eq: [ '$issueType', 'lowcount' ] } ] }, 1, 0,
|
|
974
|
+
],
|
|
964
975
|
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
},
|
|
976
|
+
},
|
|
977
|
+
matCount: {
|
|
978
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'mat' ] } ] }, 1, 0,
|
|
979
|
+
],
|
|
970
980
|
},
|
|
971
981
|
},
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
$group: {
|
|
985
|
+
_id: null,
|
|
986
|
+
installationCount: { $sum: '$installationCount' },
|
|
987
|
+
infraCount: { $sum: '$infraCount' },
|
|
988
|
+
datamismatchCount: { $sum: '$datamismatchCount' },
|
|
989
|
+
matCount: { $sum: '$matCount' },
|
|
979
990
|
|
|
980
991
|
|
|
981
|
-
},
|
|
982
992
|
},
|
|
983
|
-
|
|
993
|
+
} );
|
|
994
|
+
|
|
984
995
|
|
|
985
996
|
if ( req.user.userType === 'client' ) {
|
|
986
997
|
countQuery.forEach( ( item ) => {
|
|
@@ -1022,6 +1033,15 @@ export async function infraTable( req, res ) {
|
|
|
1022
1033
|
},
|
|
1023
1034
|
} );
|
|
1024
1035
|
}
|
|
1036
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1037
|
+
query.push(
|
|
1038
|
+
{
|
|
1039
|
+
$match: {
|
|
1040
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
1041
|
+
},
|
|
1042
|
+
},
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1025
1045
|
query.push( {
|
|
1026
1046
|
$match: {
|
|
1027
1047
|
$and: [
|
|
@@ -1272,21 +1292,37 @@ export async function infraTable( req, res ) {
|
|
|
1272
1292
|
let result = await aggregateTangoTicket( query );
|
|
1273
1293
|
if ( req.body.export && result.length > 0 ) {
|
|
1274
1294
|
const exportdata = [];
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1295
|
+
if ( req.user.userType ==='tango' ) {
|
|
1296
|
+
result.forEach( ( element ) => {
|
|
1297
|
+
exportdata.push( {
|
|
1298
|
+
'Ticket ID': element.ticketId,
|
|
1299
|
+
'Created Date': dayjs( element.issueDate ).format( 'DD MMM, YYYY' ),
|
|
1300
|
+
'Brand Name': element.clientName,
|
|
1301
|
+
'Brand ID': element.clientId,
|
|
1302
|
+
'Store Name': element.storeName,
|
|
1303
|
+
'Store ID': element.storeId,
|
|
1304
|
+
'Resloved By': element.userName,
|
|
1305
|
+
'Status': element.status,
|
|
1306
|
+
'Primary Issues': element.primaryIssue,
|
|
1307
|
+
'Secondary Issues': element.secondaryIssue,
|
|
1308
|
+
'Comment': element.otherscomment ? element.otherscomment : ( element.commentText?element.commentText:'-' ),
|
|
1309
|
+
} );
|
|
1288
1310
|
} );
|
|
1289
|
-
}
|
|
1311
|
+
} else {
|
|
1312
|
+
result.forEach( ( element ) => {
|
|
1313
|
+
exportdata.push( {
|
|
1314
|
+
'Ticket ID': element.ticketId,
|
|
1315
|
+
'Created Date': dayjs( element.issueDate ).format( 'DD MMM, YYYY' ),
|
|
1316
|
+
'Store Name': element.storeName,
|
|
1317
|
+
'Store ID': element.storeId,
|
|
1318
|
+
'Status': element.status,
|
|
1319
|
+
'Primary Issues': element.primaryIssue,
|
|
1320
|
+
'Secondary Issues': element.secondaryIssue,
|
|
1321
|
+
'Comment': element.otherscomment ? element.otherscomment : ( element.commentText?element.commentText:'-' ),
|
|
1322
|
+
} );
|
|
1323
|
+
} );
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1290
1326
|
await download( exportdata, res );
|
|
1291
1327
|
return;
|
|
1292
1328
|
}
|
|
@@ -1311,6 +1347,15 @@ export async function installationTable( req, res ) {
|
|
|
1311
1347
|
},
|
|
1312
1348
|
} );
|
|
1313
1349
|
}
|
|
1350
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1351
|
+
query.push(
|
|
1352
|
+
{
|
|
1353
|
+
$match: {
|
|
1354
|
+
'basicDetails.storeId': { $in: req.body.permittedStores },
|
|
1355
|
+
},
|
|
1356
|
+
},
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1314
1359
|
|
|
1315
1360
|
query.push( {
|
|
1316
1361
|
$match: {
|
|
@@ -1553,20 +1598,34 @@ export async function installationTable( req, res ) {
|
|
|
1553
1598
|
|
|
1554
1599
|
if ( req.body.export && result.length > 0 ) {
|
|
1555
1600
|
const exportdata = [];
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1601
|
+
if ( req.user.userType ==='tango' ) {
|
|
1602
|
+
result.forEach( ( element ) => {
|
|
1603
|
+
exportdata.push( {
|
|
1604
|
+
'Ticket ID': element.ticketId,
|
|
1605
|
+
'Created Date': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
|
|
1606
|
+
'Brand Name': element.clientName,
|
|
1607
|
+
'Brand ID': element.clientId,
|
|
1608
|
+
'Store Name': element.storeName,
|
|
1609
|
+
'Store ID': element.storeId,
|
|
1610
|
+
'Installed By': element.userName,
|
|
1611
|
+
'Deployed Status': element.installationStatus,
|
|
1612
|
+
'Primary Issues': element.primaryIssue=='-'?'Issue not identified':element.primaryIssue,
|
|
1613
|
+
'Secondary Issues': element.secondaryIssue,
|
|
1614
|
+
} );
|
|
1568
1615
|
} );
|
|
1569
|
-
}
|
|
1616
|
+
} else {
|
|
1617
|
+
result.forEach( ( element ) => {
|
|
1618
|
+
exportdata.push( {
|
|
1619
|
+
'Ticket ID': element.ticketId,
|
|
1620
|
+
'Created Date': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
|
|
1621
|
+
'Store Name': element.storeName,
|
|
1622
|
+
'Store ID': element.storeId,
|
|
1623
|
+
'Deployed Status': element.installationStatus,
|
|
1624
|
+
'Primary Issues': element.primaryIssue=='-'?'Issue not identified':element.primaryIssue,
|
|
1625
|
+
'Secondary Issues': element.secondaryIssue,
|
|
1626
|
+
} );
|
|
1627
|
+
} );
|
|
1628
|
+
}
|
|
1570
1629
|
await download( exportdata, res );
|
|
1571
1630
|
return;
|
|
1572
1631
|
}
|
|
@@ -1798,6 +1857,11 @@ export async function dataMismatchTable( req, res ) {
|
|
|
1798
1857
|
},
|
|
1799
1858
|
|
|
1800
1859
|
];
|
|
1860
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1861
|
+
countFilter.push(
|
|
1862
|
+
{ 'basicDetails.storeId': { $in: req.body.permittedStores } },
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1801
1865
|
|
|
1802
1866
|
if ( req.user.userType === 'client' ) {
|
|
1803
1867
|
countFilter.push( { 'dataMismatch.showToClient': true } );
|
|
@@ -1863,7 +1927,11 @@ export async function dataMismatchTable( req, res ) {
|
|
|
1863
1927
|
{ 'basicDetails.clientId': { $in: inputData.clientId } },
|
|
1864
1928
|
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
1865
1929
|
];
|
|
1866
|
-
|
|
1930
|
+
if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
|
|
1931
|
+
filter.push(
|
|
1932
|
+
{ 'basicDetails.storeId': { $in: req.body.permittedStores } },
|
|
1933
|
+
);
|
|
1934
|
+
}
|
|
1867
1935
|
if ( req.user.userType === 'client' ) {
|
|
1868
1936
|
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1869
1937
|
}
|
|
@@ -2067,3 +2135,109 @@ export async function dataMismatchTable( req, res ) {
|
|
|
2067
2135
|
res.sendError( 'Internal Server Error', 500 );
|
|
2068
2136
|
}
|
|
2069
2137
|
};
|
|
2138
|
+
|
|
2139
|
+
export async function checkPermission( req, res, next ) {
|
|
2140
|
+
try {
|
|
2141
|
+
let result =[];
|
|
2142
|
+
if ( req.user.role !== 'superadmin' && req.user.userType == 'client' ) {
|
|
2143
|
+
const assignedUser = await findUserAssignedStore( { userEmail: req.user.email } );
|
|
2144
|
+
if ( assignedUser.length == 0 ) {
|
|
2145
|
+
return res.sendSuccess( { result: [], count: 0 } );
|
|
2146
|
+
}
|
|
2147
|
+
switch ( assignedUser[0].assignedType ) {
|
|
2148
|
+
case 'store':
|
|
2149
|
+
const assignedUserQuery = [
|
|
2150
|
+
{
|
|
2151
|
+
$match: {
|
|
2152
|
+
userEmail: { $eq: req.user.email },
|
|
2153
|
+
},
|
|
2154
|
+
|
|
2155
|
+
},
|
|
2156
|
+
{
|
|
2157
|
+
$group: {
|
|
2158
|
+
_id: null,
|
|
2159
|
+
storeList: { $push: '$assignedValue' },
|
|
2160
|
+
},
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
$project: {
|
|
2164
|
+
storeList: 1,
|
|
2165
|
+
},
|
|
2166
|
+
},
|
|
2167
|
+
];
|
|
2168
|
+
result = await aggregateUserAssignedStore( assignedUserQuery );
|
|
2169
|
+
break;
|
|
2170
|
+
|
|
2171
|
+
case 'group':
|
|
2172
|
+
const assignedQuery = [
|
|
2173
|
+
{
|
|
2174
|
+
$match: {
|
|
2175
|
+
userEmail: { $eq: req.user.email },
|
|
2176
|
+
},
|
|
2177
|
+
|
|
2178
|
+
},
|
|
2179
|
+
{
|
|
2180
|
+
$project: {
|
|
2181
|
+
assignedValue: {
|
|
2182
|
+
$toObjectId: '$assignedValue',
|
|
2183
|
+
},
|
|
2184
|
+
},
|
|
2185
|
+
},
|
|
2186
|
+
{
|
|
2187
|
+
$lookup: {
|
|
2188
|
+
from: 'groups',
|
|
2189
|
+
let: { groupId: '$assignedValue' },
|
|
2190
|
+
pipeline: [
|
|
2191
|
+
{
|
|
2192
|
+
$match: {
|
|
2193
|
+
$expr: {
|
|
2194
|
+
$eq: [ '$_id', '$$groupId' ],
|
|
2195
|
+
},
|
|
2196
|
+
},
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
$project: {
|
|
2200
|
+
_id: 0,
|
|
2201
|
+
storeList: 1,
|
|
2202
|
+
},
|
|
2203
|
+
},
|
|
2204
|
+
], as: 'groups',
|
|
2205
|
+
},
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
$unwind: {
|
|
2209
|
+
path: '$groups', preserveNullAndEmptyArrays: true,
|
|
2210
|
+
},
|
|
2211
|
+
},
|
|
2212
|
+
{
|
|
2213
|
+
$unwind: {
|
|
2214
|
+
path: '$groups.storeList', preserveNullAndEmptyArrays: true,
|
|
2215
|
+
},
|
|
2216
|
+
},
|
|
2217
|
+
{
|
|
2218
|
+
$group: {
|
|
2219
|
+
_id: null,
|
|
2220
|
+
stores: { $push: '$groups.storeList' },
|
|
2221
|
+
},
|
|
2222
|
+
},
|
|
2223
|
+
{
|
|
2224
|
+
$project: {
|
|
2225
|
+
_id: 0,
|
|
2226
|
+
storeList: '$stores',
|
|
2227
|
+
},
|
|
2228
|
+
},
|
|
2229
|
+
];
|
|
2230
|
+
result = await aggregateUserAssignedStore( assignedQuery );
|
|
2231
|
+
break;
|
|
2232
|
+
}
|
|
2233
|
+
if ( result&&result.length>0 ) {
|
|
2234
|
+
const uniqueArray = [ ...new Set( result[0].storeList ) ];
|
|
2235
|
+
req.body.permittedStores =uniqueArray;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
next();
|
|
2239
|
+
} catch ( error ) {
|
|
2240
|
+
logger.error( { error: error, function: 'checkPermission' } );
|
|
2241
|
+
res.sendError( 'Internal Server Error', 500 );
|
|
2242
|
+
}
|
|
2243
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
4
|
-
import { infraCard, installationCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores, ticketCountSplit, overViewTable, ticketCount } from '../controllers/clientInfra.controller.js';
|
|
4
|
+
import { infraCard, installationCard, checkPermission, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores, ticketCountSplit, overViewTable, ticketCount } from '../controllers/clientInfra.controller.js';
|
|
5
5
|
|
|
6
6
|
export const clientInfraRouter = express.Router();
|
|
7
7
|
|
|
@@ -9,19 +9,19 @@ export const clientInfraRouter = express.Router();
|
|
|
9
9
|
clientInfraRouter.post( '/infraCard', isAllowedSessionHandler, authorize( {
|
|
10
10
|
userType: [ 'client', 'tango' ], access: [
|
|
11
11
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
12
|
-
} ), infraCard );
|
|
12
|
+
} ), checkPermission, infraCard );
|
|
13
13
|
clientInfraRouter.post( '/infraIssuesTable', isAllowedSessionHandler, authorize( {
|
|
14
14
|
userType: [ 'client', 'tango' ], access: [
|
|
15
15
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
16
|
-
} ), infraIssuesTable );
|
|
16
|
+
} ), checkPermission, infraIssuesTable );
|
|
17
17
|
clientInfraRouter.post( '/installationCard', isAllowedSessionHandler, authorize( {
|
|
18
18
|
userType: [ 'client', 'tango' ], access: [
|
|
19
19
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
20
|
-
} ), installationCard );
|
|
20
|
+
} ), checkPermission, installationCard );
|
|
21
21
|
clientInfraRouter.post( '/InstallationIssuesTable', isAllowedSessionHandler, authorize( {
|
|
22
22
|
userType: [ 'client', 'tango' ], access: [
|
|
23
23
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
24
|
-
} ), InstallationIssuesTable );
|
|
24
|
+
} ), checkPermission, InstallationIssuesTable );
|
|
25
25
|
clientInfraRouter.post( '/hourWiseDownClients', isAllowedSessionHandler, authorize( {
|
|
26
26
|
userType: [ 'client', 'tango' ], access: [
|
|
27
27
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
@@ -29,17 +29,17 @@ clientInfraRouter.post( '/hourWiseDownClients', isAllowedSessionHandler, authori
|
|
|
29
29
|
clientInfraRouter.post( '/hourWiseDownstores', isAllowedSessionHandler, authorize( {
|
|
30
30
|
userType: [ 'client', 'tango' ], access: [
|
|
31
31
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
32
|
-
} ), hourWiseDownstores );
|
|
32
|
+
} ), checkPermission, hourWiseDownstores );
|
|
33
33
|
|
|
34
34
|
clientInfraRouter.post( '/ticket-count', isAllowedSessionHandler, authorize( {
|
|
35
35
|
userType: [ 'client', 'tango' ], access: [
|
|
36
36
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
37
|
-
} ), ticketCount );
|
|
37
|
+
} ), checkPermission, ticketCount );
|
|
38
38
|
clientInfraRouter.post( '/ticket-count-split', isAllowedSessionHandler, authorize( {
|
|
39
39
|
userType: [ 'client', 'tango' ], access: [
|
|
40
40
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
41
|
-
} ), ticketCountSplit );
|
|
41
|
+
} ), checkPermission, ticketCountSplit );
|
|
42
42
|
clientInfraRouter.post( '/overview-table', isAllowedSessionHandler, authorize( {
|
|
43
43
|
userType: [ 'client', 'tango' ], access: [
|
|
44
44
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
45
|
-
} ), overViewTable );
|
|
45
|
+
} ), checkPermission, overViewTable );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler, authorize, validate } from 'tango-app-api-middleware';
|
|
4
4
|
import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, validateTicketstatus, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
5
|
-
import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable, removeAttachment,
|
|
5
|
+
import { createTicket, bulkcreateTicket, checkPermission, updateStatus, createReason, PrimaryReasons, matTable, removeAttachment,
|
|
6
6
|
secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments, getInfraIssues,
|
|
7
7
|
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, allCounts, infraTable, dataMismatchTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
8
8
|
import { getInfraIssueValid } from '../dtos/infra.dtos.js';
|
|
@@ -63,15 +63,15 @@ infraRouter.post( '/invoice', invoice );
|
|
|
63
63
|
infraRouter.post( '/allCounts', isAllowedSessionHandler, authorize( {
|
|
64
64
|
userType: [ 'client', 'tango' ], access: [
|
|
65
65
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
66
|
-
} ), allCounts );
|
|
66
|
+
} ), checkPermission, allCounts );
|
|
67
67
|
infraRouter.post( '/infraTable', isAllowedSessionHandler, authorize( {
|
|
68
68
|
userType: [ 'client', 'tango' ], access: [
|
|
69
69
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
70
|
-
} ), infraTable );
|
|
70
|
+
} ), checkPermission, infraTable );
|
|
71
71
|
infraRouter.post( '/installationTable', isAllowedSessionHandler, authorize( {
|
|
72
72
|
userType: [ 'client', 'tango' ], access: [
|
|
73
73
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
74
|
-
} ), installationTable );
|
|
74
|
+
} ), checkPermission, installationTable );
|
|
75
75
|
infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
|
|
76
76
|
userType: [ 'client', 'tango' ], access: [
|
|
77
77
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
@@ -79,7 +79,7 @@ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
|
|
|
79
79
|
infraRouter.post( '/dataMismatchTable', isAllowedSessionHandler, authorize( {
|
|
80
80
|
userType: [ 'client', 'tango' ], access: [
|
|
81
81
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
82
|
-
} ), dataMismatchTable );
|
|
82
|
+
} ), checkPermission, dataMismatchTable );
|
|
83
83
|
infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
|
|
84
84
|
userType: [ 'client', 'tango' ], access: [
|
|
85
85
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
|