|
|
|
@ -9,7 +9,7 @@ import { MatSort } from '@angular/material/sort';
|
|
|
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
|
|
|
|
|
|
|
|
import { ListForwards, LocalFailedEvent } from '../../../shared/models/clnModels';
|
|
|
|
|
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, APICallStatusEnum, CLNFailReason, CLNForwardingEventsStatusEnum } from '../../../shared/services/consts-enums-functions';
|
|
|
|
|
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, APICallStatusEnum, CLNFailReason, 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';
|
|
|
|
@ -17,8 +17,9 @@ import { CommonService } from '../../../shared/services/common.service';
|
|
|
|
|
import { RTLState } from '../../../store/rtl.state';
|
|
|
|
|
import { openAlert } from '../../../store/rtl.actions';
|
|
|
|
|
import { getForwardingHistory } from '../../store/cln.actions';
|
|
|
|
|
import { localFailedForwardingHistory } from '../../store/cln.selector';
|
|
|
|
|
import { clnPageSettings, localFailedForwardingHistory } from '../../store/cln.selector';
|
|
|
|
|
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'rtl-cln-local-failed-history',
|
|
|
|
@ -33,6 +34,8 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
|
|
|
|
|
@ViewChild(MatSort, { static: false }) sort: MatSort | undefined;
|
|
|
|
|
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
|
|
|
|
|
public faExclamationTriangle = faExclamationTriangle;
|
|
|
|
|
public PAGE_ID = 'routing';
|
|
|
|
|
public tableSetting: TableSetting = { tableId: 'local_failed', recordsPerPage: PAGE_SIZE, sortBy: 'received_time', sortOrder: SortOrderEnum.DESCENDING };
|
|
|
|
|
public CLNFailReason = CLNFailReason;
|
|
|
|
|
public failedLocalEvents: any;
|
|
|
|
|
public errorMessage = '';
|
|
|
|
@ -50,20 +53,30 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
|
|
|
|
|
|
|
|
|
|
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 = ['received_time', 'in_channel', 'in_msatoshi', 'actions'];
|
|
|
|
|
} else if (this.screenSize === ScreenSizeEnum.SM || this.screenSize === ScreenSizeEnum.MD) {
|
|
|
|
|
this.displayedColumns = ['received_time', 'in_channel', 'in_msatoshi', 'actions'];
|
|
|
|
|
} else {
|
|
|
|
|
this.displayedColumns = ['received_time', 'in_channel', 'in_msatoshi', 'failreason', 'actions'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
|
|
|
|
this.router.onSameUrlNavigation = 'reload';
|
|
|
|
|
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.LOCAL_FAILED } }));
|
|
|
|
|
this.store.select(localFailedForwardingHistory).pipe(takeUntil(this.unSubs[0])).
|
|
|
|
|
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.select(localFailedForwardingHistory).pipe(takeUntil(this.unSubs[1])).
|
|
|
|
|
subscribe((lffhSeletor: { localFailedForwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }) => {
|
|
|
|
|
this.errorMessage = '';
|
|
|
|
|
this.apiCallStatus = lffhSeletor.apiCallStatus;
|
|
|
|
@ -105,13 +118,6 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
|
|
|
|
|
|
|
|
|
|
loadLocalfailedLocalEventsTable(forwardingEvents: LocalFailedEvent[]) {
|
|
|
|
|
this.failedLocalForwardingEvents = new MatTableDataSource<LocalFailedEvent>([...forwardingEvents]);
|
|
|
|
|
this.failedLocalForwardingEvents.filterPredicate = (event: LocalFailedEvent, fltr: string) => {
|
|
|
|
|
const newEvent = (event.received_time ? this.datePipe.transform(new Date(event.received_time * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') +
|
|
|
|
|
(event.in_channel_alias ? event.in_channel_alias.toLowerCase() : '') +
|
|
|
|
|
((event.failreason && this.CLNFailReason[event.failreason]) ? this.CLNFailReason[event.failreason].toLowerCase() : '') +
|
|
|
|
|
(event.in_msatoshi ? (event.in_msatoshi / 1000) : '');
|
|
|
|
|
return newEvent?.includes(fltr) || false;
|
|
|
|
|
};
|
|
|
|
|
this.failedLocalForwardingEvents.sort = this.sort;
|
|
|
|
|
this.failedLocalForwardingEvents.sortingDataAccessor = (data: LocalFailedEvent, sortHeaderId: string) => {
|
|
|
|
|
switch (sortHeaderId) {
|
|
|
|
@ -122,6 +128,14 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
|
|
|
|
|
return (data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
this.failedLocalForwardingEvents.sort?.sort({ id: this.tableSetting.sortBy, start: this.tableSetting.sortOrder, disableClear: true });
|
|
|
|
|
this.failedLocalForwardingEvents.filterPredicate = (event: LocalFailedEvent, fltr: string) => {
|
|
|
|
|
const newEvent = (event.received_time ? this.datePipe.transform(new Date(event.received_time * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') +
|
|
|
|
|
(event.in_channel_alias ? event.in_channel_alias.toLowerCase() : '') +
|
|
|
|
|
((event.failreason && this.CLNFailReason[event.failreason]) ? this.CLNFailReason[event.failreason].toLowerCase() : '') +
|
|
|
|
|
(event.in_msatoshi ? (event.in_msatoshi / 1000) : '');
|
|
|
|
|
return newEvent?.includes(fltr) || false;
|
|
|
|
|
};
|
|
|
|
|
this.failedLocalForwardingEvents.paginator = this.paginator;
|
|
|
|
|
this.applyFilter();
|
|
|
|
|
this.logger.info(this.failedLocalForwardingEvents);
|
|
|
|
|