|
|
|
@ -9,15 +9,16 @@ import { MatSort } from '@angular/material/sort';
|
|
|
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
|
|
|
|
|
|
|
|
import { ForwardingEvent, ListForwards } from '../../../shared/models/clnModels';
|
|
|
|
|
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, APICallStatusEnum, CLNForwardingEventsStatusEnum } from '../../../shared/services/consts-enums-functions';
|
|
|
|
|
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, APICallStatusEnum, CLNForwardingEventsStatusEnum, SortOrderEnum, CLN_DEFAULT_PAGE_SETTINGS } from '../../../shared/services/consts-enums-functions';
|
|
|
|
|
import { ApiCallStatusPayload } from '../../../shared/models/apiCallsPayload';
|
|
|
|
|
import { LoggerService } from '../../../shared/services/logger.service';
|
|
|
|
|
import { CommonService } from '../../../shared/services/common.service';
|
|
|
|
|
|
|
|
|
|
import { RTLState } from '../../../store/rtl.state';
|
|
|
|
|
import { openAlert } from '../../../store/rtl.actions';
|
|
|
|
|
import { forwardingHistory } from '../../store/cln.selector';
|
|
|
|
|
import { clnPageSettings, forwardingHistory } from '../../store/cln.selector';
|
|
|
|
|
import { getForwardingHistory } from '../../store/cln.actions';
|
|
|
|
|
import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'rtl-cln-forwarding-history',
|
|
|
|
@ -33,6 +34,8 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
|
|
|
|
|
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
|
|
|
|
|
@Input() eventsData = [];
|
|
|
|
|
@Input() filterValue = '';
|
|
|
|
|
public PAGE_ID = 'routing';
|
|
|
|
|
public tableSetting: TableSetting = { tableId: 'forwarding_history', recordsPerPage: PAGE_SIZE, sortBy: 'received_time', sortOrder: SortOrderEnum.DESCENDING };
|
|
|
|
|
public successfulEvents: ForwardingEvent[] = [];
|
|
|
|
|
public displayedColumns: any[] = [];
|
|
|
|
|
public forwardingHistoryEvents: any;
|
|
|
|
@ -48,24 +51,34 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
|
|
|
|
|
|
|
|
|
|
constructor(private logger: LoggerService, private commonService: CommonService, private store: Store<RTLState>, private datePipe: DatePipe, private router: Router) {
|
|
|
|
|
this.screenSize = this.commonService.getScreenSize();
|
|
|
|
|
if (this.screenSize === ScreenSizeEnum.XS) {
|
|
|
|
|
this.displayedColumns = ['in_msatoshi', 'out_msatoshi', 'actions'];
|
|
|
|
|
} else if (this.screenSize === ScreenSizeEnum.SM || this.screenSize === ScreenSizeEnum.MD) {
|
|
|
|
|
this.displayedColumns = ['received_time', 'in_msatoshi', 'out_msatoshi', 'fee', 'actions'];
|
|
|
|
|
} else {
|
|
|
|
|
this.displayedColumns = ['received_time', 'resolved_time', 'in_channel', 'out_channel', 'in_msatoshi', 'out_msatoshi', 'fee', 'actions'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
|
|
|
|
this.router.onSameUrlNavigation = 'reload';
|
|
|
|
|
this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])).
|
|
|
|
|
subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => {
|
|
|
|
|
this.errorMessage = '';
|
|
|
|
|
this.apiCallStatus = settings.apiCallStatus;
|
|
|
|
|
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
|
|
|
|
|
this.errorMessage = this.apiCallStatus.message || '';
|
|
|
|
|
}
|
|
|
|
|
this.tableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId) || CLN_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId)!;
|
|
|
|
|
if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) {
|
|
|
|
|
this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelectionSM));
|
|
|
|
|
} else {
|
|
|
|
|
this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelection));
|
|
|
|
|
}
|
|
|
|
|
this.displayedColumns.push('actions');
|
|
|
|
|
this.pageSize = this.tableSetting.recordsPerPage ? +this.tableSetting.recordsPerPage : PAGE_SIZE;
|
|
|
|
|
this.logger.info(this.displayedColumns);
|
|
|
|
|
});
|
|
|
|
|
this.store.pipe(take(1)).subscribe((state) => {
|
|
|
|
|
if (state.cln.apisCallStatus.FetchForwardingHistoryS.status === APICallStatusEnum.UN_INITIATED && !state.cln.forwardingHistory.listForwards?.length) {
|
|
|
|
|
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.SETTLED } }));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.store.select(forwardingHistory).pipe(takeUntil(this.unSubs[0])).
|
|
|
|
|
this.store.select(forwardingHistory).pipe(takeUntil(this.unSubs[1])).
|
|
|
|
|
subscribe((fhSeletor: { forwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }) => {
|
|
|
|
|
this.errorMessage = '';
|
|
|
|
|
this.apiCallStatus = fhSeletor.apiCallStatus;
|
|
|
|
@ -132,6 +145,7 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
|
|
|
|
|
this.forwardingHistoryEvents = new MatTableDataSource<ForwardingEvent>([...forwardingEvents]);
|
|
|
|
|
this.forwardingHistoryEvents.sort = this.sort;
|
|
|
|
|
this.forwardingHistoryEvents.sortingDataAccessor = (data: any, sortHeaderId: string) => ((data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null);
|
|
|
|
|
this.forwardingHistoryEvents.sort?.sort({ id: this.tableSetting.sortBy, start: this.tableSetting.sortOrder, disableClear: true });
|
|
|
|
|
this.forwardingHistoryEvents.filterPredicate = (event: ForwardingEvent, fltr: string) => {
|
|
|
|
|
const newEvent = (event.received_time ? this.datePipe.transform(new Date(event.received_time * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() + ' ' : '') +
|
|
|
|
|
(event.resolved_time ? this.datePipe.transform(new Date(event.resolved_time * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() + ' ' : '') +
|
|
|
|
|