setup user email
#34
Merged
naeem.ullah
merged 1 commits from mazdak/setup-user-email into dev-pending-01-01-2026 3 weeks ago
@ -0,0 +1,28 @@
|
|||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
import { TransactionLog } from '../../models/user';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'transactionLogFilter',
|
||||||
|
standalone: true
|
||||||
|
})
|
||||||
|
export class TransactionLogFilterPipe implements PipeTransform {
|
||||||
|
transform(logs: TransactionLog[], searchText: string): TransactionLog[] {
|
||||||
|
if (!logs || !searchText) {
|
||||||
|
return logs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const search = searchText.toLowerCase();
|
||||||
|
|
||||||
|
return logs.filter(log =>
|
||||||
|
log.logId?.toString().toLowerCase().includes(search) ||
|
||||||
|
log.porOrgacode?.toLowerCase().includes(search) ||
|
||||||
|
log.transactionID?.toLowerCase().includes(search) ||
|
||||||
|
log.drMbmbkmsnumber?.toLowerCase().includes(search) ||
|
||||||
|
log.crMbmbkmsnumber?.toLowerCase().includes(search) ||
|
||||||
|
log.ppmPymdcode?.toLowerCase().includes(search) ||
|
||||||
|
log.sgtGntrdate?.toLowerCase().includes(search) ||
|
||||||
|
log.channelCode?.toLowerCase().includes(search) ||
|
||||||
|
log.createdAt?.toLowerCase().includes(search)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,24 +1,71 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { map, Observable } from 'rxjs';
|
import { BehaviorSubject, map, Observable } from 'rxjs';
|
||||||
import { URIKey } from '../../utils/uri-enums';
|
import { URIKey } from '../../utils/uri-enums';
|
||||||
import { HttpErrorResponse, HttpParams } from '@angular/common/http';
|
import { HttpErrorResponse, HttpParams } from '@angular/common/http';
|
||||||
import { HttpURIService } from '../../app.http.uri.service';
|
import { HttpURIService } from '../../app.http.uri.service';
|
||||||
|
import { TransactionLog } from '../../models/user';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class TransactionLogService {
|
export class TransactionLogService {
|
||||||
|
|
||||||
constructor(private httpUriService: HttpURIService) { }
|
private logsSubject = new BehaviorSubject<TransactionLog[]>([]);
|
||||||
|
private currentPageSubject = new BehaviorSubject<number>(1);
|
||||||
|
private totalCountSubject = new BehaviorSubject<number>(0);
|
||||||
|
private itemsPerPageSubject = new BehaviorSubject<number>(5);
|
||||||
|
|
||||||
getTransactionLogs(): Observable<any[]> {
|
logs$ = this.logsSubject.asObservable();
|
||||||
|
currentPage$ = this.currentPageSubject.asObservable();
|
||||||
|
totalCount$ = this.totalCountSubject.asObservable();
|
||||||
|
itemsPerPage$ = this.itemsPerPageSubject.asObservable();
|
||||||
|
|
||||||
|
constructor(private httpUriService: HttpURIService) {}
|
||||||
|
|
||||||
|
loadLogs(): void {
|
||||||
const params = new HttpParams();
|
const params = new HttpParams();
|
||||||
return this.httpUriService.requestGET(URIKey.TRANSACTION_LOGS, params).pipe(map((response: any) => {
|
this.httpUriService
|
||||||
if (!(response instanceof HttpErrorResponse)) {
|
.requestGET<any>(URIKey.TRANSACTION_LOGS, params)
|
||||||
return Array.isArray(response) ? response : [];
|
.subscribe({
|
||||||
|
next: (res) => {
|
||||||
|
const logs = Array.isArray(res) ? res : res?.data;
|
||||||
|
this.logsSubject.next(logs ?? []);
|
||||||
|
this.totalCountSubject.next(logs.length);
|
||||||
|
},
|
||||||
|
error: (err) => console.error(err)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setItemsPerPage(itemsPerPage: number): void {
|
||||||
|
this.itemsPerPageSubject.next(itemsPerPage);
|
||||||
|
this.currentPageSubject.next(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
nextPage(): void {
|
||||||
|
const totalPages = this.getTotalPages();
|
||||||
|
const currentPage = this.currentPageSubject.value;
|
||||||
|
if (currentPage < totalPages) {
|
||||||
|
this.currentPageSubject.next(currentPage + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return [];
|
|
||||||
})
|
previousPage(): void {
|
||||||
);
|
const currentPage = this.currentPageSubject.value;
|
||||||
|
if (currentPage > 1) {
|
||||||
|
this.currentPageSubject.next(currentPage - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
goToPage(page: number): void {
|
||||||
|
const totalPages = this.getTotalPages();
|
||||||
|
if (page > 0 && page <= totalPages) {
|
||||||
|
this.currentPageSubject.next(page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getTotalPages(): number {
|
||||||
|
const totalCount = this.totalCountSubject.value;
|
||||||
|
const itemsPerPage = this.itemsPerPageSubject.value;
|
||||||
|
return Math.ceil(totalCount / itemsPerPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue