|
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { TransactionLogService } from '../shared/services/transaction-log.service';
|
|
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
|
import { TranslateModule } from '@ngx-translate/core';
|
|
|
|
|
import { ExcelExportService } from '../shared/services/excel-export.service';
|
|
|
|
|
import { TRANSACTION_LOGS_FILE_NAME } from '../utils/app.constants';
|
|
|
|
|
import { pageSizeOptions } from '../utils/app.constants';
|
|
|
|
|
import { NgSelectModule } from '@ng-select/ng-select';
|
|
|
|
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
|
|
|
import { TransactionLogFilterPipe } from '../shared/pipes/transactionLogFilter.pipe';
|
|
|
|
|
import {TransactionLog} from "../models/user"
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-transaction-logs',
|
|
|
|
|
templateUrl: './transaction-logs.component.html',
|
|
|
|
|
providers: [TransactionLogService],
|
|
|
|
|
imports: [CommonModule, TranslateModule, NgSelectModule, FormsModule, ReactiveFormsModule, TransactionLogFilterPipe, ]
|
|
|
|
|
})
|
|
|
|
|
export class TransactionLogsComponent implements OnInit {
|
|
|
|
|
currentPage: number = 1;
|
|
|
|
|
totalCount: number = 0;
|
|
|
|
|
renewalDataExpanded: boolean = true;
|
|
|
|
|
pageSizeOptions = pageSizeOptions;
|
|
|
|
|
itemsPerPage: number = 5;
|
|
|
|
|
logs: TransactionLog[] = [];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
errorMessage: string = '';
|
|
|
|
|
searchText: string = '';
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private transactionLogService: TransactionLogService,
|
|
|
|
|
private excelExportService: ExcelExportService
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
get logs$(){
|
|
|
|
|
return this.transactionLogService.logs$;
|
|
|
|
|
}
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.transactionLogService.loadLogs();
|
|
|
|
|
|
|
|
|
|
this.transactionLogService.logs$.subscribe((logs: TransactionLog[]) => {
|
|
|
|
|
this.logs = logs;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.transactionLogService.currentPage$.subscribe((page) => {
|
|
|
|
|
this.currentPage = page;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.transactionLogService.totalCount$.subscribe((count) => {
|
|
|
|
|
this.totalCount = count;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.transactionLogService.itemsPerPage$.subscribe((size) => {
|
|
|
|
|
this.itemsPerPage = size;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSearch(value: string): void {
|
|
|
|
|
this.searchText = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get paginatedLogs(): TransactionLog[] {
|
|
|
|
|
const start = (this.currentPage - 1) * this.itemsPerPage;
|
|
|
|
|
const end = start + this.itemsPerPage;
|
|
|
|
|
return this.logs.slice(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exportDataInExcel(){
|
|
|
|
|
this.excelExportService.exportExcel(this.logs, TRANSACTION_LOGS_FILE_NAME)
|
|
|
|
|
}
|
|
|
|
|
getTotalPages(): number {
|
|
|
|
|
return this.transactionLogService.getTotalPages();
|
|
|
|
|
}
|
|
|
|
|
onPageSizeChange(pageSize: number): void {
|
|
|
|
|
this.transactionLogService.setItemsPerPage(pageSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextPage(): void {
|
|
|
|
|
this.transactionLogService.nextPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousPage(): void {
|
|
|
|
|
this.transactionLogService.previousPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|