tango-app-api-report 3.3.7 → 3.4.0-beta.1
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
|
@@ -81,12 +81,25 @@ export async function updateReport( req, res ) {
|
|
|
81
81
|
const updateAck = await reportUpdate( {
|
|
82
82
|
_id: req.params?.id, fileType: req.body?.fileType, email: req.body?.email, clientId: req.body?.clientId,
|
|
83
83
|
} );
|
|
84
|
+
const postReport = await reportGetSingle( {
|
|
85
|
+
_id: req.params?.id,
|
|
86
|
+
} );
|
|
84
87
|
|
|
85
|
-
const user =
|
|
86
|
-
|
|
88
|
+
const user = req.user;
|
|
89
|
+
const oldData={
|
|
90
|
+
ReportName: previousReport?.fileName,
|
|
91
|
+
FileType: previousReport?.fileType,
|
|
92
|
+
ReceiversEmail: previousReport?.email.join( ', ' ),
|
|
93
|
+
};
|
|
94
|
+
const newData={
|
|
95
|
+
ReportName: postReport?.fileName,
|
|
96
|
+
FileType: postReport?.fileType,
|
|
97
|
+
ReceiversEmail: postReport?.email.join( ', ' ),
|
|
98
|
+
};
|
|
87
99
|
const logObj = {
|
|
88
100
|
clientId: req.body?.clientId,
|
|
89
101
|
userName: user?.userName,
|
|
102
|
+
userId: user?._id,
|
|
90
103
|
email: user?.email,
|
|
91
104
|
date: new Date(),
|
|
92
105
|
logType: 'configuration',
|
|
@@ -94,14 +107,14 @@ export async function updateReport( req, res ) {
|
|
|
94
107
|
changes: [ `The Report ${previousReport.fileName}.${previousReport.fileType}` ],
|
|
95
108
|
eventType: 'update',
|
|
96
109
|
showTo: [ 'tango' ],
|
|
97
|
-
current:
|
|
110
|
+
current: postReport,
|
|
98
111
|
previous: previousReport,
|
|
99
|
-
|
|
112
|
+
oldData: oldData,
|
|
113
|
+
newData: newData,
|
|
100
114
|
};
|
|
101
|
-
|
|
102
115
|
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
103
116
|
if ( updateAck ) {
|
|
104
|
-
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
117
|
+
return res.sendSuccess( { result: 'Updated Successfully' } );
|
|
105
118
|
}
|
|
106
119
|
} catch ( error ) {
|
|
107
120
|
logger.error( { error: error, message: req.params, function: 'updateReport' } );
|
|
@@ -112,30 +125,34 @@ export async function updateReport( req, res ) {
|
|
|
112
125
|
export async function deleteReport( req, res ) {
|
|
113
126
|
try {
|
|
114
127
|
const inputData = req.params;
|
|
128
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
115
129
|
const previousReport = await reportGetSingle( {
|
|
116
130
|
_id: inputData?.id,
|
|
117
131
|
} );
|
|
118
|
-
|
|
132
|
+
const client = previousReport?.clientId;
|
|
133
|
+
const changes =[ `The Report ${previousReport?.fileName}.${previousReport?.fileType} has been deleted` ];
|
|
134
|
+
|
|
135
|
+
await deleteOneReport( { _id: inputData?.id } );
|
|
136
|
+
|
|
119
137
|
const logObj = {
|
|
120
|
-
clientId:
|
|
121
|
-
userName: user?.userName,
|
|
122
|
-
email: user?.email,
|
|
138
|
+
clientId: client,
|
|
139
|
+
userName: req?.user?.userName,
|
|
140
|
+
email: req?.user?.email,
|
|
123
141
|
date: new Date(),
|
|
124
142
|
logType: 'configuration',
|
|
125
143
|
logSubType: 'reportConfig',
|
|
126
|
-
changes:
|
|
144
|
+
changes: changes,
|
|
127
145
|
eventType: 'delete',
|
|
128
146
|
showTo: [ 'tango' ],
|
|
129
|
-
current: req.body,
|
|
130
|
-
previous: previousReport,
|
|
131
|
-
|
|
132
147
|
};
|
|
133
148
|
|
|
134
149
|
|
|
135
150
|
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
136
151
|
return res.sendSuccess( { result: 'Report has been deleted successfully' } );
|
|
137
152
|
} catch ( error ) {
|
|
138
|
-
|
|
153
|
+
const err = error.message || 'Internal Server Error';
|
|
154
|
+
logger.error( { message: error, data: req.params, function: 'deleteReport' } );
|
|
155
|
+
return res.sendError( err, 500 );
|
|
139
156
|
}
|
|
140
157
|
}
|
|
141
158
|
|
|
@@ -281,7 +298,6 @@ export async function generateReport( req, res ) {
|
|
|
281
298
|
logType: 'report',
|
|
282
299
|
logSubType: 'generateReport',
|
|
283
300
|
logData: {
|
|
284
|
-
// clientName: req.report?.clientName,
|
|
285
301
|
fileDate: inputData.fileDate.split( '-' ).reverse().join( '-' ),
|
|
286
302
|
reportName: req.report?.reportConfigs?.reportName,
|
|
287
303
|
clientId: inputData.clientId,
|