feat: delete validation on admin at tindakna
This commit is contained in:
parent
e1a539325f
commit
3bf3c9e1eb
|
|
@ -84,30 +84,6 @@ export class AuditService {
|
|||
let bookmark = '';
|
||||
let processedCount = 0;
|
||||
|
||||
// try {
|
||||
// const intervalId = setInterval(() => {
|
||||
// processedCount++;
|
||||
// const progressData = {
|
||||
// status: 'RUNNING',
|
||||
// progress_count: processedCount,
|
||||
// };
|
||||
|
||||
// this.logger.log('Mengirim progres via WebSocket:', progressData);
|
||||
// // PANGGIL FUNGSI GATEWAY
|
||||
// this.auditGateway.sendProgress(progressData);
|
||||
|
||||
// if (processedCount >= BATCH_SIZE) {
|
||||
// clearInterval(intervalId);
|
||||
// const completeData = { status: 'COMPLETED' };
|
||||
// this.logger.log('Mengirim selesai via WebSocket:', completeData);
|
||||
// // PANGGIL FUNGSI GATEWAY
|
||||
// this.auditGateway.sendComplete(completeData);
|
||||
// }
|
||||
// }, 500);
|
||||
// } catch (error) {
|
||||
// console.error('Tes streaming GAGAL', error);
|
||||
// }
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
const pageResults = await this.logService.getLogsWithPagination(
|
||||
|
|
@ -135,15 +111,6 @@ export class AuditService {
|
|||
)
|
||||
).filter((record): record is AuditRecordPayload => record !== null);
|
||||
|
||||
// const records: AuditRecordPayload[] = [];
|
||||
// for (let index = 0; index < logs.length; index++) {
|
||||
// const record = await this.buildAuditRecord(logs[index], index);
|
||||
// if (record !== null) {
|
||||
// records.push(record);
|
||||
// }
|
||||
// await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
// }
|
||||
|
||||
if (records.length > 0) {
|
||||
await this.prisma.$transaction(
|
||||
records.map((record) =>
|
||||
|
|
@ -252,9 +219,8 @@ export class AuditService {
|
|||
}
|
||||
|
||||
let dbHash: string | null = null;
|
||||
//
|
||||
try {
|
||||
if (logId.startsWith('OBAT_')) {
|
||||
if (logId.startsWith('OBAT')) {
|
||||
const obatId = this.extractNumericId(logId);
|
||||
if (obatId !== null) {
|
||||
const obat = await this.obatService.getObatById(obatId);
|
||||
|
|
@ -302,9 +268,17 @@ export class AuditService {
|
|||
console.warn(`Failed to resolve related data for log ${logId}:`, err);
|
||||
}
|
||||
|
||||
const isNotTampered = dbHash
|
||||
? await this.compareData(blockchainHash, dbHash)
|
||||
: false;
|
||||
let isNotTampered = false;
|
||||
const eventType = logEntry.value.event?.split('_').at(-1);
|
||||
|
||||
if (eventType === 'deleted') {
|
||||
isNotTampered = true;
|
||||
console.log('Detected deleted event, marking as not tempered');
|
||||
} else {
|
||||
const hashesMatch =
|
||||
dbHash && (await this.compareData(blockchainHash, dbHash));
|
||||
isNotTampered = Boolean(hashesMatch);
|
||||
}
|
||||
|
||||
const result: ResultStatus = isNotTampered ? 'non_tampered' : 'tampered';
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ const formatCellValue = (item: T, columnKey: keyof T) => {
|
|||
if (segments.length >= 2 && segments[segments.length - 1] === "updated") {
|
||||
return "UPDATE";
|
||||
}
|
||||
|
||||
if (segments.length >= 2 && segments[segments.length - 1] === "deleted") {
|
||||
return "DELETE";
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -218,6 +218,8 @@ const fetchData = async () => {
|
|||
`/audit/trail${params.toString() ? `?${params.toString()}` : ""}`
|
||||
);
|
||||
|
||||
console.log("Audit Log Response:", response);
|
||||
|
||||
const apiResponse = response as any;
|
||||
pagination.totalCount.value = apiResponse.totalCount;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user