tango-app-api-audit 3.4.3-alpha.19 → 3.4.3-alpha.20
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
|
@@ -4569,7 +4569,19 @@ export async function auditViewLogs( req, res ) {
|
|
|
4569
4569
|
};
|
|
4570
4570
|
const logs = await getOpenSearchData( parsedOpenSearch.auditLog, logsQuery );
|
|
4571
4571
|
if ( logs.body.hits.hits.length > 0 ) {
|
|
4572
|
-
|
|
4572
|
+
if ( logs.body.hits.hits[0]._source.logSubType == 'auditDone' ) {
|
|
4573
|
+
const convertedTime = await convertTimestampToDateTime( logs.body.hits.hits[0]._source.logData.endTime );
|
|
4574
|
+
logData.push( {
|
|
4575
|
+
...logs.body.hits.hits[0]._source, // Spread the _source object
|
|
4576
|
+
time: convertedTime, // Add the converted time
|
|
4577
|
+
} );
|
|
4578
|
+
} else {
|
|
4579
|
+
const convertedTime = await convertTimestampToDateTime( logs.body.hits.hits[0]._source.createdAt );
|
|
4580
|
+
logData.push( {
|
|
4581
|
+
...logs.body.hits.hits[0]._source, // Spread the _source object
|
|
4582
|
+
time: convertedTime, // Add the converted time
|
|
4583
|
+
} );
|
|
4584
|
+
}
|
|
4573
4585
|
return res.sendSuccess( logData );
|
|
4574
4586
|
} else {
|
|
4575
4587
|
return res.sendError( 'No Record Inserted', 204 );
|
|
@@ -4581,3 +4593,24 @@ export async function auditViewLogs( req, res ) {
|
|
|
4581
4593
|
}
|
|
4582
4594
|
}
|
|
4583
4595
|
|
|
4596
|
+
export async function convertTimestampToDateTime( timestamp ) {
|
|
4597
|
+
// Check if the timestamp is too large (nanoseconds), then convert it to milliseconds
|
|
4598
|
+
if ( timestamp > 9999999999999 ) {
|
|
4599
|
+
timestamp = Math.floor( timestamp / 1000 ); // Convert to milliseconds if needed
|
|
4600
|
+
}
|
|
4601
|
+
|
|
4602
|
+
// Create a new Date object
|
|
4603
|
+
const date = new Date( timestamp );
|
|
4604
|
+
|
|
4605
|
+
// Format the date and time components
|
|
4606
|
+
const year = date.getFullYear();
|
|
4607
|
+
const month = ( '0' + ( date.getMonth() + 1 ) ).slice( -2 ); // Months are zero-based
|
|
4608
|
+
const day = ( '0' + date.getDate() ).slice( -2 );
|
|
4609
|
+
|
|
4610
|
+
const hours = ( '0' + date.getHours() ).slice( -2 );
|
|
4611
|
+
const minutes = ( '0' + date.getMinutes() ).slice( -2 );
|
|
4612
|
+
const seconds = ( '0' + date.getSeconds() ).slice( -2 );
|
|
4613
|
+
|
|
4614
|
+
// Return formatted date and time string
|
|
4615
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
4616
|
+
}
|