tango-app-api-infra 3.0.17 → 3.0.19-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.19-dev",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"dayjs": "^1.11.10",
|
|
19
19
|
"dotenv": "^16.4.5",
|
|
20
20
|
"express": "^4.18.3",
|
|
21
|
+
"express-fileupload": "^1.5.0",
|
|
21
22
|
"handlebars": "^4.7.8",
|
|
22
23
|
"mongodb": "^6.4.0",
|
|
23
24
|
"nodemon": "^3.1.0",
|
|
24
|
-
"tango-api-schema": "^2.0.
|
|
25
|
-
"tango-app-api-middleware": "^1.0.
|
|
25
|
+
"tango-api-schema": "^2.0.56",
|
|
26
|
+
"tango-app-api-middleware": "^1.0.41-dev",
|
|
26
27
|
"winston": "^3.12.0",
|
|
27
28
|
"winston-daily-rotate-file": "^5.0.0"
|
|
28
29
|
},
|
|
@@ -422,7 +422,7 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
422
422
|
}
|
|
423
423
|
if ( req.body.export ) {
|
|
424
424
|
const exportdata = [];
|
|
425
|
-
|
|
425
|
+
storesList.forEach( ( element ) => {
|
|
426
426
|
exportdata.push( {
|
|
427
427
|
'CLIENT NAME': element.clientName,
|
|
428
428
|
'STORE ID': element.storeId,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
4
4
|
import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
|
|
5
5
|
import { updateOneStore } from '../services/store.service.js';
|
|
6
|
-
import { logger, fileUpload } from 'tango-app-api-middleware';
|
|
6
|
+
import { logger, fileUpload, signedUrl } from 'tango-app-api-middleware';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
8
|
export async function createTicket( req, res ) {
|
|
9
9
|
try {
|
|
@@ -96,7 +96,7 @@ export async function secondaryReason( req, res ) {
|
|
|
96
96
|
|
|
97
97
|
export async function updateTicketIssue( req, res ) {
|
|
98
98
|
try {
|
|
99
|
-
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity, 'ticketDetails.issueIdentifiedDate': new Date(), 'ticketDetails.issueIdentifiedBy': req.body.issueIdentifiedBy, 'ticketDetails.issueStatus': 'identified' } );
|
|
99
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity, 'ticketDetails.issueIdentifiedDate': new Date(), 'ticketDetails.issueIdentifiedBy': req.body.issueIdentifiedBy, 'ticketDetails.issueStatus': 'identified', 'status': 'inprogress' } );
|
|
100
100
|
if ( updateTicket ) {
|
|
101
101
|
res.sendSuccess( 'Ticket Updated Successfully' );
|
|
102
102
|
}
|
|
@@ -108,8 +108,21 @@ export async function updateTicketIssue( req, res ) {
|
|
|
108
108
|
|
|
109
109
|
export async function viewTicket( req, res ) {
|
|
110
110
|
try {
|
|
111
|
-
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketDetails: 1, basicDetails: 1, ticketActivity: 1 } );
|
|
112
|
-
if ( ticket ) {
|
|
111
|
+
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketDetails: 1, basicDetails: 1, ticketActivity: 1, createdAt: 1, attachments: 1 } );
|
|
112
|
+
if ( ticket.attachments && ticket.attachments.length > 0 ) {
|
|
113
|
+
for ( let index in ticket.attachments ) {
|
|
114
|
+
if ( ticket.attachments.hasOwnProperty( index ) ) {
|
|
115
|
+
let file = ticket.attachments[index];
|
|
116
|
+
let params = {
|
|
117
|
+
Bucket: 'tango-client-sandbox',
|
|
118
|
+
file_path: file.filePath,
|
|
119
|
+
};
|
|
120
|
+
let attachments = await signedUrl( params );
|
|
121
|
+
ticket.attachments[index].signedUrl = attachments;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
res.sendSuccess( ticket );
|
|
125
|
+
} else {
|
|
113
126
|
res.sendSuccess( ticket );
|
|
114
127
|
}
|
|
115
128
|
} catch ( error ) {
|
|
@@ -119,13 +132,17 @@ export async function viewTicket( req, res ) {
|
|
|
119
132
|
}
|
|
120
133
|
export async function AlertTicketReply( req, res ) {
|
|
121
134
|
try {
|
|
122
|
-
req.body.ticketActivity = req.body.ticketActivity.filter( ( data ) => data.
|
|
135
|
+
req.body.ticketActivity = req.body.ticketActivity.filter( ( data ) => data.actionType != 'statusCheck' );
|
|
123
136
|
req.body.ticketActivity.push( {
|
|
124
137
|
actionType: 'statusCheckReply',
|
|
125
|
-
actionBy: '
|
|
138
|
+
actionBy: 'User',
|
|
126
139
|
statusCheckReply: req.body.statusCheckReply,
|
|
127
140
|
hibernationDays: req.body.hibernationDays,
|
|
128
141
|
} );
|
|
142
|
+
req.body.ticketActivity.push( {
|
|
143
|
+
actionType: 'statusCheckMonitor',
|
|
144
|
+
actionBy: 'Tango',
|
|
145
|
+
} );
|
|
129
146
|
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity } );
|
|
130
147
|
if ( req.body.hibernationDays ) {
|
|
131
148
|
req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
|
|
@@ -139,15 +156,32 @@ export async function AlertTicketReply( req, res ) {
|
|
|
139
156
|
}
|
|
140
157
|
export async function uploadAttachments( req, res ) {
|
|
141
158
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
if ( req.files.img && req.files.img.length > 0 ) {
|
|
160
|
+
let attachments = [];
|
|
161
|
+
for ( let singleImg in req.files.img ) {
|
|
162
|
+
if ( req.files.img.hasOwnProperty( singleImg ) ) {
|
|
163
|
+
let params = {
|
|
164
|
+
Bucket: 'tango-client-sandbox',
|
|
165
|
+
Key: req.params.ticketId + '/',
|
|
166
|
+
ContentType: 'multipart/form-data',
|
|
167
|
+
body: req.files.img[singleImg].data,
|
|
168
|
+
fileName: req.files.img[singleImg].name,
|
|
169
|
+
};
|
|
170
|
+
let upload = await fileUpload( params );
|
|
171
|
+
if ( upload ) {
|
|
172
|
+
let getObject = {
|
|
173
|
+
fileName: req.files.img[singleImg].name,
|
|
174
|
+
filePath: req.params.ticketId + '/' + req.files.img[singleImg].name,
|
|
175
|
+
};
|
|
176
|
+
attachments.push( getObject );
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.params.ticketId }, { attachments: attachments } );
|
|
181
|
+
if ( updateTicket ) {
|
|
182
|
+
res.sendSuccess( 'Uploaded successfully' );
|
|
183
|
+
}
|
|
184
|
+
}
|
|
151
185
|
} catch ( error ) {
|
|
152
186
|
logger.error( { error: error, function: 'uploadAttachments' } );
|
|
153
187
|
return res.sendError( error, 500 );
|
|
@@ -142,7 +142,9 @@ export async function assigntoUser( req, res ) {
|
|
|
142
142
|
}
|
|
143
143
|
export async function updateRefreshTicket( req, res ) {
|
|
144
144
|
try {
|
|
145
|
-
|
|
145
|
+
for ( let ticket of req.body.TicketList ) {
|
|
146
|
+
await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket' } );
|
|
147
|
+
}
|
|
146
148
|
res.sendSuccess( 'updated Successfully' );
|
|
147
149
|
} catch ( error ) {
|
|
148
150
|
logger.error( { error: error, function: 'updateRefreshTicket' } );
|
|
@@ -5,6 +5,7 @@ import { findOneUser } from '../services/user.service.js';
|
|
|
5
5
|
import { aggregateStore } from '../services/store.service.js';
|
|
6
6
|
|
|
7
7
|
import mongoose from 'mongoose';
|
|
8
|
+
import dayjs from 'dayjs';
|
|
8
9
|
|
|
9
10
|
export async function userTakeTicket( req, res ) {
|
|
10
11
|
try {
|
|
@@ -38,7 +39,6 @@ export async function userTicketList( req, res ) {
|
|
|
38
39
|
],
|
|
39
40
|
},
|
|
40
41
|
} ];
|
|
41
|
-
|
|
42
42
|
if ( req.body.status != 'closed' ) {
|
|
43
43
|
query.push( {
|
|
44
44
|
$match: {
|
|
@@ -51,9 +51,7 @@ export async function userTicketList( req, res ) {
|
|
|
51
51
|
} else {
|
|
52
52
|
query.push( {
|
|
53
53
|
$match: {
|
|
54
|
-
$
|
|
55
|
-
{ createdAt: { $gte: new Date() } },
|
|
56
|
-
],
|
|
54
|
+
issueClosedDate: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
57
55
|
},
|
|
58
56
|
} );
|
|
59
57
|
}
|
|
@@ -155,6 +153,8 @@ export async function activeTicketList( req, res ) {
|
|
|
155
153
|
}, {
|
|
156
154
|
$project: {
|
|
157
155
|
storeId: '$basicDetails.storeId',
|
|
156
|
+
ticketId: 1,
|
|
157
|
+
storeName: '$basicDetails.storeName',
|
|
158
158
|
address: { $ifNull: [ '$basicDetails.address', '' ] },
|
|
159
159
|
status: 1,
|
|
160
160
|
},
|
|
@@ -268,9 +268,9 @@ export async function workHistory( req, res ) {
|
|
|
268
268
|
storeName: '$basicDetails.storeName',
|
|
269
269
|
clientId: '$basicDetails.clientId',
|
|
270
270
|
clientName: '$basicDetails.clientName',
|
|
271
|
-
issueDate: { $dateToString: { format: '%
|
|
272
|
-
issueClosedDate: { $dateToString: { format: '%
|
|
273
|
-
issueIdentifiedDate: { $dateToString: { format: '%
|
|
271
|
+
issueDate: { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
|
|
272
|
+
issueClosedDate: { $dateToString: { format: '%Y-%m-%d', date: '$issueClosedDate' } },
|
|
273
|
+
issueIdentifiedDate: { $dateToString: { format: '%Y-%m-%d', date: '$ticketDetails.issueIdentifiedDate' } },
|
|
274
274
|
ticketId: 1,
|
|
275
275
|
issueStatus: '$ticketDetails.issueStatus',
|
|
276
276
|
ticketType: '$ticketDetails.ticketType',
|
|
@@ -381,7 +381,6 @@ export async function storeInfraList( req, res ) {
|
|
|
381
381
|
$match: {
|
|
382
382
|
$and: [
|
|
383
383
|
{ clientId: { $in: req.body.clientId } },
|
|
384
|
-
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
385
384
|
],
|
|
386
385
|
},
|
|
387
386
|
},
|
|
@@ -420,6 +419,27 @@ export async function storeInfraList( req, res ) {
|
|
|
420
419
|
},
|
|
421
420
|
} );
|
|
422
421
|
}
|
|
422
|
+
if ( req.body.country && req.body.country.length > 0 ) {
|
|
423
|
+
query.push( {
|
|
424
|
+
$match: {
|
|
425
|
+
country: { $in: req.body.country },
|
|
426
|
+
},
|
|
427
|
+
} );
|
|
428
|
+
}
|
|
429
|
+
if ( req.body.state && req.body.state.length > 0 ) {
|
|
430
|
+
query.push( {
|
|
431
|
+
$match: {
|
|
432
|
+
state: { $in: req.body.state },
|
|
433
|
+
},
|
|
434
|
+
} );
|
|
435
|
+
}
|
|
436
|
+
if ( req.body.city && req.body.city.length > 0 ) {
|
|
437
|
+
query.push( {
|
|
438
|
+
$match: {
|
|
439
|
+
city: { $in: req.body.city },
|
|
440
|
+
},
|
|
441
|
+
} );
|
|
442
|
+
}
|
|
423
443
|
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
424
444
|
query.push( {
|
|
425
445
|
$match: {
|