tango-app-api-infra 3.0.13 → 3.0.15
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 +3 -3
- package/src/controllers/clientInfra.controller.js +282 -19
- package/src/controllers/infra.controllers.js +12 -8
- package/src/controllers/internalInfra.controller.js +5 -5
- package/src/controllers/storeInfra.controlller.js +6 -6
- package/src/controllers/userInfra.controller.js +145 -24
- package/src/routes/clientInfra.routes.js +8 -7
- package/src/routes/infra.routes.js +7 -6
- package/src/routes/storeInfra.routes.js +5 -4
- package/src/routes/userInfra.routes.js +6 -5
- package/src/validations/infra.validation.js +36 -16
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.15",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"handlebars": "^4.7.8",
|
|
21
21
|
"mongodb": "^6.4.0",
|
|
22
22
|
"nodemon": "^3.1.0",
|
|
23
|
-
"tango-api-schema": "^2.0.
|
|
24
|
-
"tango-app-api-middleware": "^1.0.
|
|
23
|
+
"tango-api-schema": "^2.0.44",
|
|
24
|
+
"tango-app-api-middleware": "^1.0.21",
|
|
25
25
|
"winston": "^3.12.0",
|
|
26
26
|
"winston-daily-rotate-file": "^5.0.0"
|
|
27
27
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { countDocumentsStore, findStorewithpagination } from '../services/store.service.js';
|
|
3
|
-
import { logger } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, download } from 'tango-app-api-middleware';
|
|
4
4
|
import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
|
|
5
5
|
import { findinfraReason } from '../services/infraReason.service.js';
|
|
6
6
|
import { findClientwithpagination } from '../services/client.service.js';
|
|
@@ -13,15 +13,20 @@ export async function infraCard( req, res ) {
|
|
|
13
13
|
let infraStoreCount = await aggregateTangoTicket( [
|
|
14
14
|
{
|
|
15
15
|
$match: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
$and: [
|
|
17
|
+
{ issueType: 'infra' },
|
|
18
|
+
{ 'status': { $ne: 'closed' } },
|
|
19
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
20
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
21
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
22
|
+
],
|
|
18
23
|
},
|
|
19
24
|
},
|
|
20
25
|
{
|
|
21
26
|
$project: {
|
|
22
27
|
storeId: '$basicDetails.storeId',
|
|
23
28
|
identifiedcount: {
|
|
24
|
-
$cond: [ { $eq: [ '$
|
|
29
|
+
$cond: [ { $eq: [ '$ticketDetails.issueStatus', 'identified' ] }, 1, 0 ],
|
|
25
30
|
},
|
|
26
31
|
},
|
|
27
32
|
},
|
|
@@ -42,17 +47,24 @@ export async function infraCard( req, res ) {
|
|
|
42
47
|
] );
|
|
43
48
|
let query = [ {
|
|
44
49
|
$match: {
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
$and: [
|
|
51
|
+
{ issueType: 'infra' },
|
|
52
|
+
{ 'status': { $ne: 'closed' } },
|
|
53
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
54
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
55
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
56
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
57
|
+
],
|
|
47
58
|
},
|
|
48
59
|
},
|
|
49
60
|
{
|
|
50
61
|
$project: {
|
|
51
62
|
ticketId: 1,
|
|
52
|
-
issueStatus: '$
|
|
63
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
64
|
+
issueIdentifiedBy: '$ticketDetails.issueIdentifiedBy',
|
|
53
65
|
primaryIssue: {
|
|
54
66
|
$filter: {
|
|
55
|
-
input: '$
|
|
67
|
+
input: '$ticketActivity',
|
|
56
68
|
as: 'item',
|
|
57
69
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
58
70
|
},
|
|
@@ -74,10 +86,20 @@ export async function infraCard( req, res ) {
|
|
|
74
86
|
ticketId: 1,
|
|
75
87
|
issueStatus: 1,
|
|
76
88
|
ticketType: 1,
|
|
89
|
+
issueIdentifiedBy: 1,
|
|
77
90
|
primaryIssue: '$primaryIssue.reasons.primaryIssue',
|
|
78
91
|
},
|
|
79
92
|
},
|
|
80
93
|
];
|
|
94
|
+
if ( req.body.filter&&req.body.filter.length>0 ) {
|
|
95
|
+
query.push(
|
|
96
|
+
{
|
|
97
|
+
$match: {
|
|
98
|
+
issueIdentifiedBy: { $in: req.body.filter },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
}
|
|
81
103
|
let ticketList = await aggregateTangoTicket( query );
|
|
82
104
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
83
105
|
const categoryCounts = {};
|
|
@@ -114,13 +136,116 @@ export async function infraCard( req, res ) {
|
|
|
114
136
|
return res.sendError( error, 500 );
|
|
115
137
|
}
|
|
116
138
|
}
|
|
139
|
+
export async function installationCard( req, res ) {
|
|
140
|
+
try {
|
|
141
|
+
let onboardedCount = await countDocumentsStore( { clientId: { $in: req.body.clientId } } );
|
|
142
|
+
let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'edge.deployed': true } );
|
|
117
143
|
|
|
118
|
-
|
|
144
|
+
let yettoInstallCount = await aggregateTangoTicket( [
|
|
145
|
+
{
|
|
146
|
+
$match: {
|
|
147
|
+
$and: [
|
|
148
|
+
{ issueType: 'installation' },
|
|
149
|
+
{ 'status': { $ne: 'closed' } },
|
|
150
|
+
{ 'ticketDetails.issueStatus': 'notidentified' },
|
|
151
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
152
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
] );
|
|
157
|
+
let query = [ {
|
|
158
|
+
$match: {
|
|
159
|
+
$and: [
|
|
160
|
+
{ issueType: 'installation' },
|
|
161
|
+
{ 'status': { $ne: 'closed' } },
|
|
162
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
163
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
164
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
$project: {
|
|
170
|
+
ticketId: 1,
|
|
171
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
172
|
+
issueIdentifiedBy: '$ticketDetails.issueIdentifiedBy',
|
|
173
|
+
primaryIssue: {
|
|
174
|
+
$filter: {
|
|
175
|
+
input: '$ticketActivity',
|
|
176
|
+
as: 'item',
|
|
177
|
+
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
$unwind: {
|
|
184
|
+
path: '$primaryIssue', preserveNullAndEmptyArrays: true,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
$unwind: {
|
|
189
|
+
path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
$project: {
|
|
194
|
+
ticketId: 1,
|
|
195
|
+
issueStatus: 1,
|
|
196
|
+
ticketType: 1,
|
|
197
|
+
issueIdentifiedBy: 1,
|
|
198
|
+
primaryIssue: '$primaryIssue.reasons.primaryIssue',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
let installFailedCount = await aggregateTangoTicket( query );
|
|
203
|
+
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
204
|
+
const categoryCounts = {};
|
|
205
|
+
let response;
|
|
206
|
+
if ( installFailedCount.length > 0 ) {
|
|
207
|
+
installFailedCount.forEach( ( item ) => {
|
|
208
|
+
const categoryName = item.primaryIssue;
|
|
209
|
+
if ( categoryCounts[categoryName] ) {
|
|
210
|
+
categoryCounts[categoryName]++;
|
|
211
|
+
} else {
|
|
212
|
+
categoryCounts[categoryName] = 1;
|
|
213
|
+
}
|
|
214
|
+
} );
|
|
215
|
+
response = issueList.map( ( category ) => ( {
|
|
216
|
+
name: category.name,
|
|
217
|
+
count: categoryCounts[category.name] || 0,
|
|
218
|
+
} ) );
|
|
219
|
+
} else {
|
|
220
|
+
response = issueList.map( ( category ) => ( {
|
|
221
|
+
name: category.name,
|
|
222
|
+
count: 0,
|
|
223
|
+
} ) );
|
|
224
|
+
}
|
|
225
|
+
res.sendSuccess( {
|
|
226
|
+
onboardedStoresCount: onboardedCount,
|
|
227
|
+
installedStoresCount: installedCount,
|
|
228
|
+
yettoInstallCount: yettoInstallCount.length,
|
|
229
|
+
installFailedCount: installFailedCount.length,
|
|
230
|
+
infraIssues: response,
|
|
231
|
+
} );
|
|
232
|
+
} catch ( error ) {
|
|
233
|
+
logger.error( { error: error, function: 'infraCard' } );
|
|
234
|
+
return res.sendError( error, 500 );
|
|
235
|
+
}
|
|
236
|
+
}
|
|
119
237
|
export async function infraIssuesTable( req, res ) {
|
|
120
238
|
try {
|
|
121
239
|
let query = [ {
|
|
122
240
|
$match: {
|
|
123
|
-
|
|
241
|
+
$and: [
|
|
242
|
+
{ issueType: 'infra' },
|
|
243
|
+
{ status: { $ne: 'closed' } },
|
|
244
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
245
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
246
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
247
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
248
|
+
],
|
|
124
249
|
},
|
|
125
250
|
},
|
|
126
251
|
{
|
|
@@ -129,11 +254,11 @@ export async function infraIssuesTable( req, res ) {
|
|
|
129
254
|
storeName: '$basicDetails.storeName',
|
|
130
255
|
status: 1,
|
|
131
256
|
createdAt: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
|
|
132
|
-
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$
|
|
257
|
+
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$ticketDetails.issueIdentifiedDate' } },
|
|
133
258
|
issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
|
|
134
259
|
primaryIssue: {
|
|
135
260
|
$filter: {
|
|
136
|
-
input: '$
|
|
261
|
+
input: '$ticketActivity',
|
|
137
262
|
as: 'item',
|
|
138
263
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
139
264
|
},
|
|
@@ -149,7 +274,13 @@ export async function infraIssuesTable( req, res ) {
|
|
|
149
274
|
$unwind: {
|
|
150
275
|
path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
|
|
151
276
|
},
|
|
152
|
-
},
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
$unwind: {
|
|
280
|
+
path: '$primaryIssue.reasons.secondaryIssue', preserveNullAndEmptyArrays: true,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
{
|
|
153
284
|
$project: {
|
|
154
285
|
storeId: 1,
|
|
155
286
|
storeName: 1,
|
|
@@ -157,9 +288,46 @@ export async function infraIssuesTable( req, res ) {
|
|
|
157
288
|
issueIdentifiedDate: { $ifNull: [ '$issueIdentifiedDate', '-' ] },
|
|
158
289
|
issueClosedDate: { $ifNull: [ '$issueClosedDate', '-' ] },
|
|
159
290
|
status: 1,
|
|
160
|
-
|
|
291
|
+
primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
|
|
292
|
+
secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
$group: {
|
|
297
|
+
_id: '$storeId',
|
|
298
|
+
storeId: { $first: '$storeId' },
|
|
299
|
+
storeName: { $first: '$storeName' },
|
|
300
|
+
createdAt: { $first: '$createdAt' },
|
|
301
|
+
issueIdentifiedDate: { $first: '$issueIdentifiedDate' },
|
|
302
|
+
issueClosedDate: { $first: '$issueClosedDate' },
|
|
303
|
+
status: { $first: '$status' },
|
|
304
|
+
primaryIssue: { $first: '$primaryIssue' },
|
|
305
|
+
secondaryIssue: { $first: '$secondaryIssue' },
|
|
161
306
|
},
|
|
162
|
-
}
|
|
307
|
+
},
|
|
308
|
+
];
|
|
309
|
+
if ( req.body.filterIssue && req.body.filterIssue != '' ) {
|
|
310
|
+
query.push( {
|
|
311
|
+
$match: {
|
|
312
|
+
primaryIssue: req.body.filterIssue,
|
|
313
|
+
},
|
|
314
|
+
} );
|
|
315
|
+
}
|
|
316
|
+
if ( req.body.searchValue && req.body.searchValue != '' ) {
|
|
317
|
+
query.push( {
|
|
318
|
+
$match: {
|
|
319
|
+
$or: [
|
|
320
|
+
{ storeId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
321
|
+
{ storeName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
} );
|
|
325
|
+
}
|
|
326
|
+
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
327
|
+
query.push( {
|
|
328
|
+
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
329
|
+
} );
|
|
330
|
+
}
|
|
163
331
|
let count = await aggregateTangoTicket( query );
|
|
164
332
|
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
165
333
|
query.push(
|
|
@@ -168,17 +336,112 @@ export async function infraIssuesTable( req, res ) {
|
|
|
168
336
|
);
|
|
169
337
|
}
|
|
170
338
|
let result = await aggregateTangoTicket( query );
|
|
339
|
+
if ( req.body.export ) {
|
|
340
|
+
const exportdata = [];
|
|
341
|
+
result.forEach( ( element ) => {
|
|
342
|
+
exportdata.push( {
|
|
343
|
+
'STORE ID': element.storeId,
|
|
344
|
+
'STORE NAME': element.storeName,
|
|
345
|
+
'STATUS': element.status,
|
|
346
|
+
'CITY': element.city,
|
|
347
|
+
'STATE': element.state,
|
|
348
|
+
'COUNTRY': element.country,
|
|
349
|
+
'SPOC EMAIL': element.spocEmail,
|
|
350
|
+
'SPOC CONTACT': element.spocContact,
|
|
351
|
+
'DOWNTIME': element.downTime,
|
|
352
|
+
'STATUS DETAIL': element.statusDetail,
|
|
353
|
+
} );
|
|
354
|
+
} );
|
|
355
|
+
await download( exportdata, res );
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if ( result.length > 0 ) {
|
|
359
|
+
res.sendSuccess( {
|
|
360
|
+
count: count.length,
|
|
361
|
+
result: result,
|
|
362
|
+
} );
|
|
363
|
+
} else {
|
|
364
|
+
res.sendError( 'no data', 204 );
|
|
365
|
+
}
|
|
366
|
+
} catch ( error ) {
|
|
367
|
+
logger.error( { error: error, function: 'infraIssuesTable' } );
|
|
368
|
+
return res.sendError( error, 500 );
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
export async function InstallationIssuesTable( req, res ) {
|
|
372
|
+
try {
|
|
373
|
+
let query = [
|
|
374
|
+
{
|
|
375
|
+
$match: {
|
|
376
|
+
$and: [
|
|
377
|
+
{ issueType: 'installation' },
|
|
378
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
379
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
380
|
+
// { createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
$project: {
|
|
386
|
+
createdAt: 1,
|
|
387
|
+
clientName: '$basicDetails.clientName',
|
|
388
|
+
storeId: '$basicDetails.storeId',
|
|
389
|
+
storeName: '$basicDetails.storeName',
|
|
390
|
+
status: 1,
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
];
|
|
394
|
+
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
395
|
+
query.push( {
|
|
396
|
+
$match: {
|
|
397
|
+
$or: [
|
|
398
|
+
{ storeId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
399
|
+
{ storeName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
400
|
+
{ clientName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
401
|
+
{ status: { $regex: req.body.searchValue, $options: 'i' } },
|
|
402
|
+
],
|
|
403
|
+
},
|
|
404
|
+
} );
|
|
405
|
+
}
|
|
406
|
+
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
407
|
+
query.push( {
|
|
408
|
+
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
409
|
+
} );
|
|
410
|
+
}
|
|
411
|
+
let count = await aggregateTangoTicket( query );
|
|
412
|
+
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
413
|
+
query.push(
|
|
414
|
+
{ $skip: ( req.body.offset - 1 ) * req.body.limit },
|
|
415
|
+
{ $limit: Number( req.body.limit ) },
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
let storesList = await aggregateTangoTicket( query );
|
|
419
|
+
if ( storesList.length == 0 ) {
|
|
420
|
+
return res.sendError( 'no data', 204 );
|
|
421
|
+
}
|
|
422
|
+
if ( req.body.export ) {
|
|
423
|
+
const exportdata = [];
|
|
424
|
+
infrastoreList.forEach( ( element ) => {
|
|
425
|
+
exportdata.push( {
|
|
426
|
+
'CLIENT NAME': element.clientName,
|
|
427
|
+
'STORE ID': element.storeId,
|
|
428
|
+
'STORE NAME': element.storeName,
|
|
429
|
+
'STATUS': element.status,
|
|
430
|
+
} );
|
|
431
|
+
} );
|
|
432
|
+
await download( exportdata, res );
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
171
435
|
res.sendSuccess( {
|
|
172
436
|
count: count.length,
|
|
173
|
-
result:
|
|
437
|
+
result: storesList,
|
|
174
438
|
} );
|
|
175
439
|
} catch ( error ) {
|
|
176
|
-
logger.error( { error: error, function: '
|
|
440
|
+
logger.error( { error: error, function: 'InstallationIssuesTable' } );
|
|
177
441
|
return res.sendError( error, 500 );
|
|
178
442
|
}
|
|
179
443
|
}
|
|
180
444
|
|
|
181
|
-
|
|
182
445
|
export async function hourWiseDownClients( req, res ) {
|
|
183
446
|
try {
|
|
184
447
|
let inputData = req.body;
|
|
@@ -245,7 +508,7 @@ export async function livecountCheck( data, inputData ) {
|
|
|
245
508
|
timewise.push( obj );
|
|
246
509
|
}
|
|
247
510
|
const mergedData = {
|
|
248
|
-
|
|
511
|
+
clientName: data.clientName,
|
|
249
512
|
};
|
|
250
513
|
timewise.forEach( ( obj ) => {
|
|
251
514
|
for ( const key in obj ) {
|
|
@@ -6,14 +6,17 @@ import { logger } from 'tango-app-api-middleware';
|
|
|
6
6
|
export async function createTicket( req, res ) {
|
|
7
7
|
try {
|
|
8
8
|
req.body.issueDate = new Date( req.body.Date );
|
|
9
|
-
req.body.
|
|
9
|
+
req.body.ticketDetails.filesCount = req.body.filesCount;
|
|
10
10
|
if ( req.body.issueType == 'infra' ) {
|
|
11
11
|
req.body.ticketId = 'TE_INF_' + new Date().valueOf();
|
|
12
|
-
req.body.
|
|
12
|
+
req.body.ticketActivity = [ {
|
|
13
13
|
actionType: 'defaultInfra',
|
|
14
14
|
actionBy: 'Tango',
|
|
15
15
|
} ];
|
|
16
16
|
}
|
|
17
|
+
if ( req.body.issueType == 'installation' ) {
|
|
18
|
+
req.body.ticketId = 'TE_INS_' + new Date().valueOf();
|
|
19
|
+
}
|
|
17
20
|
let create = await createTangoTicket( req.body );
|
|
18
21
|
if ( create ) {
|
|
19
22
|
res.sendSuccess( 'Ticket Created Successfully' );
|
|
@@ -27,7 +30,7 @@ export async function createTicket( req, res ) {
|
|
|
27
30
|
export async function updateStatus( req, res ) {
|
|
28
31
|
try {
|
|
29
32
|
if ( req.body.status == 'inprogress' ) {
|
|
30
|
-
req.body.
|
|
33
|
+
req.body.ticketActivity.push( {
|
|
31
34
|
actionType: 'statusChange',
|
|
32
35
|
actionBy: 'User',
|
|
33
36
|
} );
|
|
@@ -91,7 +94,7 @@ export async function secondaryReason( req, res ) {
|
|
|
91
94
|
|
|
92
95
|
export async function updateTicketIssue( req, res ) {
|
|
93
96
|
try {
|
|
94
|
-
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { '
|
|
97
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity, 'ticketDetails.issueIdentifiedDate': new Date(), 'ticketDetails.issueIdentifiedBy': req.body.issueIdentifiedBy, 'ticketDetails.issueStatus': 'identified' } );
|
|
95
98
|
if ( updateTicket ) {
|
|
96
99
|
res.sendSuccess( 'Ticket Updated Successfully' );
|
|
97
100
|
}
|
|
@@ -103,7 +106,7 @@ export async function updateTicketIssue( req, res ) {
|
|
|
103
106
|
|
|
104
107
|
export async function viewTicket( req, res ) {
|
|
105
108
|
try {
|
|
106
|
-
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1,
|
|
109
|
+
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketActivity: 1 } );
|
|
107
110
|
if ( ticket ) {
|
|
108
111
|
res.sendSuccess( ticket );
|
|
109
112
|
}
|
|
@@ -114,11 +117,12 @@ export async function viewTicket( req, res ) {
|
|
|
114
117
|
}
|
|
115
118
|
export async function AlertTicketReply( req, res ) {
|
|
116
119
|
try {
|
|
117
|
-
req.body.
|
|
118
|
-
req.body.
|
|
120
|
+
req.body.ticketActivity = req.body.ticketActivity.filter( ( data ) => data.action !='statusCheck' );
|
|
121
|
+
req.body.ticketActivity.push( {
|
|
119
122
|
actionType: 'statusCheckReply',
|
|
120
123
|
actionBy: 'Tango',
|
|
121
|
-
|
|
124
|
+
statusCheckReply: req.body.statusCheckReply,
|
|
125
|
+
hibernationDays: req.body.hibernationDays,
|
|
122
126
|
} );
|
|
123
127
|
} catch ( error ) {
|
|
124
128
|
logger.error( { error: error, function: 'AlertTicketReply' } );
|
|
@@ -112,7 +112,7 @@ export async function downStoresList( req, res ) {
|
|
|
112
112
|
}
|
|
113
113
|
export async function openTicketList( req, res ) {
|
|
114
114
|
try {
|
|
115
|
-
let openTicketList = await findTangoTicket( { status: { $ne: 'closed' } }, { ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1,
|
|
115
|
+
let openTicketList = await findTangoTicket( { status: { $ne: 'closed' } }, { ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1, ticketDetails: 1 } );
|
|
116
116
|
if ( openTicketList.length ) {
|
|
117
117
|
res.sendSuccess( {
|
|
118
118
|
count: openTicketList.length,
|
|
@@ -129,7 +129,7 @@ export async function openTicketList( req, res ) {
|
|
|
129
129
|
|
|
130
130
|
export async function assigntoUser( req, res ) {
|
|
131
131
|
try {
|
|
132
|
-
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { '
|
|
132
|
+
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketDetails.assigntoUser': true } );
|
|
133
133
|
res.sendSuccess( 'assigntoUser Successfully' );
|
|
134
134
|
} catch ( error ) {
|
|
135
135
|
logger.error( { error: error, function: 'assigntoUser' } );
|
|
@@ -138,7 +138,7 @@ export async function assigntoUser( req, res ) {
|
|
|
138
138
|
}
|
|
139
139
|
export async function updateRefreshTicket( req, res ) {
|
|
140
140
|
try {
|
|
141
|
-
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { '
|
|
141
|
+
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketDetails.ticketType': 'refreshticket' } );
|
|
142
142
|
res.sendSuccess( 'updated Successfully' );
|
|
143
143
|
} catch ( error ) {
|
|
144
144
|
logger.error( { error: error, function: 'updateRefreshTicket' } );
|
|
@@ -150,7 +150,7 @@ export async function closeTicket( req, res ) {
|
|
|
150
150
|
for ( let ticket of req.body.TicketList ) {
|
|
151
151
|
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
152
152
|
if ( ticket.status == 'closed' ) {
|
|
153
|
-
getTicket.
|
|
153
|
+
getTicket.ticketActivity.push( {
|
|
154
154
|
actionType: 'dataRecived',
|
|
155
155
|
actionBy: 'Tango',
|
|
156
156
|
} );
|
|
@@ -158,7 +158,7 @@ export async function closeTicket( req, res ) {
|
|
|
158
158
|
await updateOneTangoTicket( { ticketId: ticket.ticketId },
|
|
159
159
|
{
|
|
160
160
|
status: ticket.status,
|
|
161
|
-
|
|
161
|
+
ticketActivity: getTicket.ticketActivity,
|
|
162
162
|
issueClosedDate: new Date(),
|
|
163
163
|
},
|
|
164
164
|
);
|
|
@@ -18,11 +18,11 @@ export async function storeTicketList( req, res ) {
|
|
|
18
18
|
Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
19
19
|
issueClosedDate: 1,
|
|
20
20
|
ticketId: 1,
|
|
21
|
-
issueStatus: '$
|
|
22
|
-
ticketType: '$
|
|
21
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
22
|
+
ticketType: '$ticketDetails.ticketType',
|
|
23
23
|
primaryIssue: {
|
|
24
24
|
$filter: {
|
|
25
|
-
input: '$
|
|
25
|
+
input: '$ticketActivity',
|
|
26
26
|
as: 'item',
|
|
27
27
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
28
28
|
},
|
|
@@ -73,16 +73,16 @@ export async function storeTicketcard( req, res ) {
|
|
|
73
73
|
let query = [ {
|
|
74
74
|
$match: {
|
|
75
75
|
'basicDetails.storeId': req.body.storeId,
|
|
76
|
-
'
|
|
76
|
+
'ticketDetails.issueStatus': 'identified',
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
$project: {
|
|
81
81
|
ticketId: 1,
|
|
82
|
-
issueStatus: '$
|
|
82
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
83
83
|
primaryIssue: {
|
|
84
84
|
$filter: {
|
|
85
|
-
input: '$
|
|
85
|
+
input: '$ticketActivity',
|
|
86
86
|
as: 'item',
|
|
87
87
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
88
88
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { findOneTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
|
|
3
|
-
import { logger } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, download } from 'tango-app-api-middleware';
|
|
4
4
|
import { findOneUser } from '../services/user.service.js';
|
|
5
5
|
import { aggregateStore } from '../services/store.service.js';
|
|
6
6
|
|
|
@@ -8,9 +8,14 @@ import mongoose from 'mongoose';
|
|
|
8
8
|
|
|
9
9
|
export async function userTakeTicket( req, res ) {
|
|
10
10
|
try {
|
|
11
|
-
let userTicket =
|
|
11
|
+
let userTicket = '';
|
|
12
|
+
if ( req.body.issueType == 'infra' ) {
|
|
13
|
+
userTicket = await findOneTangoTicket( { 'status': { $ne: 'closed' }, 'issueType': 'infra', 'ticketDetails.assigntoUser': true, 'ticketDetails.addressingUser': { $exists: false } } );
|
|
14
|
+
} else if ( req.body.issueType == 'installation' ) {
|
|
15
|
+
userTicket = await findOneTangoTicket( { 'status': { $ne: 'closed' }, 'issueType': 'installation', 'ticketDetails.addressingUser': { $exists: false } } );
|
|
16
|
+
}
|
|
12
17
|
if ( userTicket ) {
|
|
13
|
-
let assignTicket = await updateOneTangoTicket( { ticketId: userTicket.ticketId }, { '
|
|
18
|
+
let assignTicket = await updateOneTangoTicket( { ticketId: userTicket.ticketId }, { 'ticketDetails.addressingUser': req.body.userId } );
|
|
14
19
|
if ( assignTicket ) {
|
|
15
20
|
res.sendSuccess( 'Ticket Assigned Successfully' );
|
|
16
21
|
}
|
|
@@ -26,20 +31,44 @@ export async function userTicketList( req, res ) {
|
|
|
26
31
|
try {
|
|
27
32
|
let query = [ {
|
|
28
33
|
$match: {
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
$and: [
|
|
35
|
+
{ 'status': req.body.status },
|
|
36
|
+
{ issueType: req.body.issueType },
|
|
37
|
+
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
38
|
+
],
|
|
31
39
|
},
|
|
32
|
-
}
|
|
33
|
-
|
|
40
|
+
} ];
|
|
41
|
+
|
|
42
|
+
if ( req.body.status != 'closed' ) {
|
|
43
|
+
query.push( {
|
|
44
|
+
$match: {
|
|
45
|
+
$and: [
|
|
46
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
47
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
} );
|
|
51
|
+
} else {
|
|
52
|
+
query.push( {
|
|
53
|
+
$match: {
|
|
54
|
+
$and: [
|
|
55
|
+
{ createdAt: { $gte: new Date() } },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
} );
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
query.push( {
|
|
34
63
|
$project: {
|
|
35
64
|
storeId: '$basicDetails.storeId',
|
|
36
65
|
Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
37
66
|
ticketId: 1,
|
|
38
|
-
issueStatus: '$
|
|
39
|
-
ticketType: '$
|
|
67
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
68
|
+
ticketType: '$ticketDetails.ticketType',
|
|
40
69
|
primaryIssue: {
|
|
41
70
|
$filter: {
|
|
42
|
-
input: '$
|
|
71
|
+
input: '$ticketActivity',
|
|
43
72
|
as: 'item',
|
|
44
73
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
45
74
|
},
|
|
@@ -64,7 +93,7 @@ export async function userTicketList( req, res ) {
|
|
|
64
93
|
ticketType: 1,
|
|
65
94
|
infraIssue: '$primaryIssue.reasons.primaryIssue',
|
|
66
95
|
},
|
|
67
|
-
}
|
|
96
|
+
} );
|
|
68
97
|
let ticketList = await aggregateTangoTicket( query );
|
|
69
98
|
if ( ticketList.length ) {
|
|
70
99
|
res.sendSuccess( {
|
|
@@ -86,8 +115,8 @@ export async function basicDetails( req, res ) {
|
|
|
86
115
|
if ( !user ) {
|
|
87
116
|
return res.sendError( 'User Not Found', 500 );
|
|
88
117
|
}
|
|
89
|
-
let infraCount = await countDocumentsTangoTicket( { '
|
|
90
|
-
let installationCount = await countDocumentsTangoTicket( { '
|
|
118
|
+
let infraCount = await countDocumentsTangoTicket( { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ), 'issueType': 'infra' } );
|
|
119
|
+
let installationCount = await countDocumentsTangoTicket( { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ), 'issueType': 'installation' } );
|
|
91
120
|
res.sendSuccess( {
|
|
92
121
|
userName: user.userName,
|
|
93
122
|
userType: user.userType,
|
|
@@ -108,8 +137,12 @@ export async function workHistory( req, res ) {
|
|
|
108
137
|
try {
|
|
109
138
|
let query = [ {
|
|
110
139
|
$match: {
|
|
111
|
-
|
|
112
|
-
|
|
140
|
+
$and: [
|
|
141
|
+
{ 'status': 'closed' },
|
|
142
|
+
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
143
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
144
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
145
|
+
],
|
|
113
146
|
},
|
|
114
147
|
},
|
|
115
148
|
{
|
|
@@ -120,12 +153,13 @@ export async function workHistory( req, res ) {
|
|
|
120
153
|
clientName: '$basicDetails.clientName',
|
|
121
154
|
issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
122
155
|
issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
|
|
156
|
+
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$ticketDetails.issueIdentifiedDate' } },
|
|
123
157
|
ticketId: 1,
|
|
124
|
-
issueStatus: '$
|
|
125
|
-
ticketType: '$
|
|
158
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
159
|
+
ticketType: '$ticketDetails.ticketType',
|
|
126
160
|
primaryIssue: {
|
|
127
161
|
$filter: {
|
|
128
|
-
input: '$
|
|
162
|
+
input: '$ticketActivity',
|
|
129
163
|
as: 'item',
|
|
130
164
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
131
165
|
},
|
|
@@ -148,6 +182,7 @@ export async function workHistory( req, res ) {
|
|
|
148
182
|
clientId: 1,
|
|
149
183
|
clientName: 1,
|
|
150
184
|
issueDate: 1,
|
|
185
|
+
issueIdentifiedDate: 1,
|
|
151
186
|
issueClosedDate: 1,
|
|
152
187
|
ticketId: 1,
|
|
153
188
|
issueStatus: 1,
|
|
@@ -155,6 +190,25 @@ export async function workHistory( req, res ) {
|
|
|
155
190
|
infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '' ] },
|
|
156
191
|
},
|
|
157
192
|
} ];
|
|
193
|
+
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
194
|
+
query.push( {
|
|
195
|
+
$match: {
|
|
196
|
+
$or: [
|
|
197
|
+
{ storeId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
198
|
+
{ storeName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
199
|
+
{ clientId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
200
|
+
{ clientName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
201
|
+
{ ticketId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
202
|
+
{ infraIssue: { $regex: req.body.searchValue, $options: 'i' } },
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
} );
|
|
206
|
+
}
|
|
207
|
+
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
208
|
+
query.push( {
|
|
209
|
+
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
210
|
+
} );
|
|
211
|
+
}
|
|
158
212
|
let count = await aggregateTangoTicket( query );
|
|
159
213
|
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
160
214
|
query.push(
|
|
@@ -163,6 +217,28 @@ export async function workHistory( req, res ) {
|
|
|
163
217
|
);
|
|
164
218
|
}
|
|
165
219
|
let result = await aggregateTangoTicket( query );
|
|
220
|
+
if ( req.body.export ) {
|
|
221
|
+
const exportdata = [];
|
|
222
|
+
result.forEach( ( element ) => {
|
|
223
|
+
exportdata.push( {
|
|
224
|
+
'CREATED ON': element.createdAt,
|
|
225
|
+
'TICKET ID': element.ticketId,
|
|
226
|
+
'STORE ID': element.storeId,
|
|
227
|
+
'STORE NAME': element.storeName,
|
|
228
|
+
'CLIENT ID': element.clientId,
|
|
229
|
+
'CLIENT NAME': element.clientName,
|
|
230
|
+
'CREATED STATUS': element.status,
|
|
231
|
+
'ISSUE IDENTIFIED DATE': element.issueIdentifiedDate,
|
|
232
|
+
'CLOSED ON': element.issueClosedDate,
|
|
233
|
+
'STATUS': element.status,
|
|
234
|
+
} );
|
|
235
|
+
} );
|
|
236
|
+
await download( exportdata, res );
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if ( result.length == 0 ) {
|
|
240
|
+
return res.sendError( 'no data', 204 );
|
|
241
|
+
}
|
|
166
242
|
res.sendSuccess( {
|
|
167
243
|
count: count.length,
|
|
168
244
|
result: result,
|
|
@@ -179,7 +255,10 @@ export async function storeInfraList( req, res ) {
|
|
|
179
255
|
let query = [
|
|
180
256
|
{
|
|
181
257
|
$match: {
|
|
182
|
-
|
|
258
|
+
$and: [
|
|
259
|
+
{ clientId: { $in: req.body.clientId } },
|
|
260
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
261
|
+
],
|
|
183
262
|
},
|
|
184
263
|
},
|
|
185
264
|
{
|
|
@@ -205,12 +284,33 @@ export async function storeInfraList( req, res ) {
|
|
|
205
284
|
city: { $first: '$storeProfile.city' },
|
|
206
285
|
state: { $first: '$storeProfile.state' },
|
|
207
286
|
country: { $first: '$storeProfile.country' },
|
|
208
|
-
|
|
287
|
+
spocEmail: { $first: { $ifNull: [ '$spocDetails.email', '' ] } },
|
|
209
288
|
spocContact: { $first: { $ifNull: [ '$spocDetails.contact', '' ] } },
|
|
210
289
|
},
|
|
211
290
|
},
|
|
212
291
|
];
|
|
213
|
-
|
|
292
|
+
if ( req.body.storeId && req.body.storeId.length>0 ) {
|
|
293
|
+
query.push( {
|
|
294
|
+
$match: {
|
|
295
|
+
storeId: { $in: req.body.storeId },
|
|
296
|
+
},
|
|
297
|
+
} );
|
|
298
|
+
}
|
|
299
|
+
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
300
|
+
query.push( {
|
|
301
|
+
$match: {
|
|
302
|
+
$or: [
|
|
303
|
+
{ storeId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
304
|
+
{ storeName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
} );
|
|
308
|
+
}
|
|
309
|
+
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
310
|
+
query.push( {
|
|
311
|
+
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
312
|
+
} );
|
|
313
|
+
}
|
|
214
314
|
let count = await aggregateStore( query );
|
|
215
315
|
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
216
316
|
query.push(
|
|
@@ -219,6 +319,9 @@ export async function storeInfraList( req, res ) {
|
|
|
219
319
|
);
|
|
220
320
|
}
|
|
221
321
|
let storesList = await aggregateStore( query );
|
|
322
|
+
if ( storesList.length == 0 ) {
|
|
323
|
+
return res.sendError( 'no data', 204 );
|
|
324
|
+
}
|
|
222
325
|
let infrastoreList = [];
|
|
223
326
|
for ( let store of storesList ) {
|
|
224
327
|
store.downTime = 'NA';
|
|
@@ -228,15 +331,33 @@ export async function storeInfraList( req, res ) {
|
|
|
228
331
|
} else {
|
|
229
332
|
if ( store.status == 'active' ) {
|
|
230
333
|
store.status = 'Live';
|
|
231
|
-
store.statusDetail='Connected';
|
|
334
|
+
store.statusDetail = 'Connected';
|
|
232
335
|
} else {
|
|
233
|
-
store.statusDetail='Disconnected';
|
|
336
|
+
store.statusDetail = 'Disconnected';
|
|
234
337
|
store.status = 'Deactivated';
|
|
235
338
|
}
|
|
236
339
|
}
|
|
237
|
-
|
|
238
340
|
infrastoreList.push( store );
|
|
239
341
|
}
|
|
342
|
+
if ( req.body.export ) {
|
|
343
|
+
const exportdata = [];
|
|
344
|
+
infrastoreList.forEach( ( element ) => {
|
|
345
|
+
exportdata.push( {
|
|
346
|
+
'STORE ID': element.storeId,
|
|
347
|
+
'STORE NAME': element.storeName,
|
|
348
|
+
'STATUS': element.status,
|
|
349
|
+
'CITY': element.city,
|
|
350
|
+
'STATE': element.state,
|
|
351
|
+
'COUNTRY': element.country,
|
|
352
|
+
'SPOC EMAIL': element.spocEmail,
|
|
353
|
+
'SPOC CONTACT': element.spocContact,
|
|
354
|
+
'DOWNTIME': element.downTime,
|
|
355
|
+
'STATUS DETAIL': element.statusDetail,
|
|
356
|
+
} );
|
|
357
|
+
} );
|
|
358
|
+
await download( exportdata, res );
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
240
361
|
res.sendSuccess( {
|
|
241
362
|
count: count.length,
|
|
242
363
|
result: infrastoreList,
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { infraCard, infraIssuesTable, hourWiseDownClients, hourWiseDownstores } from '../controllers/clientInfra.controller.js';
|
|
3
|
+
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
4
|
+
import { infraCard, installationCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores } from '../controllers/clientInfra.controller.js';
|
|
6
5
|
|
|
7
6
|
export const clientInfraRouter = express.Router();
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
clientInfraRouter.post( '/infraCard', infraCard );
|
|
11
|
-
clientInfraRouter.post( '/infraIssuesTable', infraIssuesTable );
|
|
12
|
-
clientInfraRouter.post( '/
|
|
13
|
-
clientInfraRouter.post( '/
|
|
9
|
+
clientInfraRouter.post( '/infraCard', isAllowedSessionHandler, infraCard );
|
|
10
|
+
clientInfraRouter.post( '/infraIssuesTable', isAllowedSessionHandler, infraIssuesTable );
|
|
11
|
+
clientInfraRouter.post( '/installationCard', isAllowedSessionHandler, installationCard );
|
|
12
|
+
clientInfraRouter.post( '/InstallationIssuesTable', isAllowedSessionHandler, InstallationIssuesTable );
|
|
13
|
+
clientInfraRouter.post( '/hourWiseDownClients', isAllowedSessionHandler, hourWiseDownClients );
|
|
14
|
+
clientInfraRouter.post( '/hourWiseDownstores', isAllowedSessionHandler, hourWiseDownstores );
|
|
14
15
|
|
|
15
16
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
|
+
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
4
|
import { validateDetails, validateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
4
5
|
import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply } from '../controllers/infra.controllers.js';
|
|
5
6
|
|
|
@@ -7,12 +8,12 @@ import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReas
|
|
|
7
8
|
export const infraRouter = express.Router();
|
|
8
9
|
|
|
9
10
|
infraRouter.post( '/createTicket', validateDetails, validateTicket, createTicket );
|
|
10
|
-
infraRouter.post( '/updateStatus', ticketExists, updateStatus );
|
|
11
|
+
infraRouter.post( '/updateStatus', isAllowedSessionHandler, ticketExists, updateStatus );
|
|
11
12
|
infraRouter.post( '/createReason', createReason );
|
|
12
|
-
infraRouter.get( '/PrimaryReasons', PrimaryReasons );
|
|
13
|
-
infraRouter.post( '/secondaryReason', secondaryReason );
|
|
14
|
-
infraRouter.post( '/updateTicketIssue', ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
|
|
15
|
-
infraRouter.post( '/viewTicket', ticketExists, viewTicket );
|
|
16
|
-
infraRouter.post( '/AlertTicketReply', ticketExists, AlertTicketReply );
|
|
13
|
+
infraRouter.get( '/PrimaryReasons', isAllowedSessionHandler, PrimaryReasons );
|
|
14
|
+
infraRouter.post( '/secondaryReason', isAllowedSessionHandler, secondaryReason );
|
|
15
|
+
infraRouter.post( '/updateTicketIssue', isAllowedSessionHandler, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
|
|
16
|
+
infraRouter.post( '/viewTicket', isAllowedSessionHandler, ticketExists, viewTicket );
|
|
17
|
+
infraRouter.post( '/AlertTicketReply', isAllowedSessionHandler, ticketExists, AlertTicketReply );
|
|
17
18
|
|
|
18
19
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
|
+
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
4
|
import { storeTicketList, storeTicketcard, edgeAppLogTable, viewedgeAppLog } from '../controllers/storeInfra.controlller.js';
|
|
4
5
|
export const storeInfraRouter = express.Router();
|
|
5
6
|
|
|
6
|
-
storeInfraRouter.post( '/storeTicketList', storeTicketList );
|
|
7
|
-
storeInfraRouter.post( '/storeTicketcard', storeTicketcard );
|
|
8
|
-
storeInfraRouter.post( '/edgeAppLogTable', edgeAppLogTable );
|
|
9
|
-
storeInfraRouter.post( '/viewedgeAppLog', viewedgeAppLog );
|
|
7
|
+
storeInfraRouter.post( '/storeTicketList', isAllowedSessionHandler, storeTicketList );
|
|
8
|
+
storeInfraRouter.post( '/storeTicketcard', isAllowedSessionHandler, storeTicketcard );
|
|
9
|
+
storeInfraRouter.post( '/edgeAppLogTable', isAllowedSessionHandler, edgeAppLogTable );
|
|
10
|
+
storeInfraRouter.post( '/viewedgeAppLog', isAllowedSessionHandler, viewedgeAppLog );
|
|
10
11
|
|
|
11
12
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
+
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
2
3
|
import { userTakeTicket, userTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
3
4
|
|
|
4
5
|
export const userInfraRouter = express.Router();
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
userInfraRouter.post( '/userTakeTicket', userTakeTicket );
|
|
8
|
-
userInfraRouter.post( '/userTicketList', userTicketList );
|
|
9
|
-
userInfraRouter.post( '/basicDetails', basicDetails );
|
|
10
|
-
userInfraRouter.post( '/workHistory', workHistory );
|
|
11
|
-
userInfraRouter.post( '/storeInfraList', storeInfraList );
|
|
8
|
+
userInfraRouter.post( '/userTakeTicket', isAllowedSessionHandler, userTakeTicket );
|
|
9
|
+
userInfraRouter.post( '/userTicketList', isAllowedSessionHandler, userTicketList );
|
|
10
|
+
userInfraRouter.post( '/basicDetails', isAllowedSessionHandler, basicDetails );
|
|
11
|
+
userInfraRouter.post( '/workHistory', isAllowedSessionHandler, workHistory );
|
|
12
|
+
userInfraRouter.post( '/storeInfraList', isAllowedSessionHandler, storeInfraList );
|
|
12
13
|
|
|
13
14
|
|
|
@@ -21,9 +21,16 @@ export async function validateDetails( req, res, next ) {
|
|
|
21
21
|
clientId: store.clientId,
|
|
22
22
|
clientName: client.clientName,
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
|
|
25
|
+
if ( req.body.issueType == 'infra' ) {
|
|
26
|
+
req.body.ticketDetails = {
|
|
27
|
+
ticketRefreshTime: dayjs().add( client.ticketConfigs.refreshAlert, 'days' ),
|
|
28
|
+
};
|
|
29
|
+
} else if ( req.body.issueType == 'installation' ) {
|
|
30
|
+
req.body.ticketDetails = {
|
|
31
|
+
ticketRefreshTime: dayjs().add( client.ticketConfigs.installationReAssign, 'days' ),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
next();
|
|
29
36
|
} catch ( error ) {
|
|
@@ -34,14 +41,27 @@ export async function validateDetails( req, res, next ) {
|
|
|
34
41
|
|
|
35
42
|
export async function validateTicket( req, res, next ) {
|
|
36
43
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if ( req.body.issueType == 'infra' ) {
|
|
45
|
+
let Ticket = await findOneTangoTicket(
|
|
46
|
+
{
|
|
47
|
+
'basicDetails.storeId': req.body.basicDetails.storeId,
|
|
48
|
+
'issueType': 'infra',
|
|
49
|
+
'issueDate': new Date( req.body.Date ),
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
if ( Ticket ) {
|
|
53
|
+
return res.sendSuccess( 'Ticket Already Exists for the day' );
|
|
54
|
+
}
|
|
55
|
+
} else if ( req.body.issueType == 'installation' ) {
|
|
56
|
+
let Ticket = await findOneTangoTicket(
|
|
57
|
+
{
|
|
58
|
+
'basicDetails.storeId': req.body.basicDetails.storeId,
|
|
59
|
+
'issueType': req.body.issueType,
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
if ( Ticket ) {
|
|
63
|
+
return res.sendSuccess( 'Ticket Already Exists' );
|
|
64
|
+
}
|
|
45
65
|
}
|
|
46
66
|
next();
|
|
47
67
|
} catch ( error ) {
|
|
@@ -60,7 +80,7 @@ export async function ticketExists( req, res, next ) {
|
|
|
60
80
|
return res.sendError( 'Ticket Not Found', 204 );
|
|
61
81
|
}
|
|
62
82
|
req.body.basicDetails = Ticket.basicDetails;
|
|
63
|
-
req.body.
|
|
83
|
+
req.body.ticketActivity = Ticket.ticketActivity;
|
|
64
84
|
next();
|
|
65
85
|
} catch ( error ) {
|
|
66
86
|
logger.error( { error: error, function: 'ticketExists' } );
|
|
@@ -95,7 +115,7 @@ export async function infraReasonExists( req, res, next ) {
|
|
|
95
115
|
secondaryIsssue: [ ...resolveSteps ],
|
|
96
116
|
} );
|
|
97
117
|
}
|
|
98
|
-
req.body.
|
|
118
|
+
req.body.ticketActivity.push( {
|
|
99
119
|
actionType: 'issueUpdate',
|
|
100
120
|
actionBy: 'User',
|
|
101
121
|
comment: req.body.comment,
|
|
@@ -125,7 +145,7 @@ export async function InfrastepstoResolve( req, res, next ) {
|
|
|
125
145
|
} );
|
|
126
146
|
}
|
|
127
147
|
|
|
128
|
-
req.body.
|
|
148
|
+
req.body.ticketActivity.push( {
|
|
129
149
|
actionType: 'stepsToResolve',
|
|
130
150
|
actionBy: 'Tango',
|
|
131
151
|
reasons: steptoReslove.map( ( item ) => ( {
|
|
@@ -148,7 +168,7 @@ export async function InfraAlert( req, res, next ) {
|
|
|
148
168
|
if ( req.body.hibernationDays ) {
|
|
149
169
|
req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
|
|
150
170
|
await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
|
|
151
|
-
req.body.
|
|
171
|
+
req.body.ticketActivity.push( {
|
|
152
172
|
actionType: 'statusCheckReply',
|
|
153
173
|
actionBy: 'Tango',
|
|
154
174
|
hibernationDays: req.body.hibernationDays,
|
|
@@ -157,7 +177,7 @@ export async function InfraAlert( req, res, next ) {
|
|
|
157
177
|
} else {
|
|
158
178
|
let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );
|
|
159
179
|
let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
|
|
160
|
-
req.body.
|
|
180
|
+
req.body.ticketActivity.push( {
|
|
161
181
|
actionType: 'statusCheck',
|
|
162
182
|
actionBy: 'Tango',
|
|
163
183
|
statusCheckAlertTime: statusCheckAlertTime,
|