diff --git a/src/app/cln/routing/forwarding-history/forwarding-history.component.html b/src/app/cln/routing/forwarding-history/forwarding-history.component.html index 30a47bc6..9aa744a5 100644 --- a/src/app/cln/routing/forwarding-history/forwarding-history.component.html +++ b/src/app/cln/routing/forwarding-history/forwarding-history.component.html @@ -9,40 +9,60 @@
- - - - - - + + - - + + + + + + - - + + + + + + + + + + - - + + - - + + - - + + - - diff --git a/src/app/cln/routing/forwarding-history/forwarding-history.component.scss b/src/app/cln/routing/forwarding-history/forwarding-history.component.scss index 0ad983c7..cbb4c67a 100644 --- a/src/app/cln/routing/forwarding-history/forwarding-history.component.scss +++ b/src/app/cln/routing/forwarding-history/forwarding-history.component.scss @@ -1,3 +1,11 @@ +.mat-column-in_channel_alias, .mat-column-out_channel_alias, .mat-column-payment_hash { + flex: 0 0 15%; + width: 15%; + & .ellipsis-parent { + display: flex; + } +} + .mat-column-actions { min-height: 4.8rem; } diff --git a/src/app/cln/routing/forwarding-history/forwarding-history.component.ts b/src/app/cln/routing/forwarding-history/forwarding-history.component.ts index c1c58d42..5e5d8d89 100644 --- a/src/app/cln/routing/forwarding-history/forwarding-history.component.ts +++ b/src/app/cln/routing/forwarding-history/forwarding-history.component.ts @@ -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, 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([...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() + ' ' : '') + diff --git a/src/app/shared/models/clnModels.ts b/src/app/shared/models/clnModels.ts index bba941a7..7b738c70 100644 --- a/src/app/shared/models/clnModels.ts +++ b/src/app/shared/models/clnModels.ts @@ -279,6 +279,7 @@ export interface LocalFailedEvent { in_msat?: string; status?: string; received_time?: number; + resolved_time?: number; failcode?: number; failreason?: string; } diff --git a/src/app/shared/services/consts-enums-functions.ts b/src/app/shared/services/consts-enums-functions.ts index 071cb9ef..fe38b6fa 100644 --- a/src/app/shared/services/consts-enums-functions.ts +++ b/src/app/shared/services/consts-enums-functions.ts @@ -712,6 +712,20 @@ export const CLN_DEFAULT_PAGE_SETTINGS: PageSettingsCLN[] = [ { tableId: 'offer_bookmarks', recordsPerPage: PAGE_SIZE, sortBy: 'lastUpdatedAt', sortOrder: SortOrderEnum.DESCENDING, columnSelectionSM: ['lastUpdatedAt', 'amountMSat'], columnSelection: ['lastUpdatedAt', 'title', 'amountMSat', 'description'] } + ] }, + { pageId: 'routing', tables: [ + { tableId: 'forwarding_history', recordsPerPage: PAGE_SIZE, sortBy: 'received_time', sortOrder: SortOrderEnum.DESCENDING, + columnSelectionSM: ['received_time', 'in_msatoshi', 'out_msatoshi'], + columnSelection: ['received_time', 'resolved_time', 'in_channel_alias', 'out_channel_alias', 'in_msatoshi', 'out_msatoshi', 'fee'] } + // { tableId: 'routing_peers', recordsPerPage: PAGE_SIZE, sortBy: 'expires_at', sortOrder: SortOrderEnum.DESCENDING, + // columnSelectionSM: ['expires_at', 'msatoshi'], + // columnSelection: ['expires_at', 'paid_at', 'type', 'description', 'msatoshi', 'msatoshi_received'] }, + // { tableId: 'failed', recordsPerPage: PAGE_SIZE, sortBy: 'offer_id', sortOrder: SortOrderEnum.DESCENDING, + // columnSelectionSM: ['offer_id', 'single_use'], + // columnSelection: ['offer_id', 'single_use', 'used'] }, + // { tableId: 'local_failed', recordsPerPage: PAGE_SIZE, sortBy: 'lastUpdatedAt', sortOrder: SortOrderEnum.DESCENDING, + // columnSelectionSM: ['lastUpdatedAt', 'amountMSat'], + // columnSelection: ['lastUpdatedAt', 'title', 'amountMSat', 'description'] } ] } ]; @@ -755,5 +769,9 @@ export const CLN_TABLES_DEF = { offer_bookmarks: { maxColumns: 5, allowedColumns: ['lastUpdatedAt', 'title', 'amountMSat', 'description', 'vendor', 'bolt12'] + }, + forwarding_history: { + maxColumns: 8, + allowedColumns: ['received_time', 'resolved_time', 'in_channel', 'in_channel_alias', 'out_channel', 'out_channel_alias', 'payment_hash', 'in_msatoshi', 'out_msatoshi', 'fee'] } };
Status{{fhEvent?.status}} Received Time {{(fhEvent?.received_time * 1000) | date:'dd/MMM/y HH:mm'}} Resolved Time{{(fhEvent?.resolved_time * 1000) | date:'dd/MMM/y HH:mm'}}Resolved Time{{(fhEvent?.resolved_time * 1000) | date:'dd/MMM/y HH:mm'}} In Channel{{fhEvent?.in_channel_alias}}In Channel Id{{fhEvent?.in_channel}}In Channel +
+ {{fhEvent?.in_channel_alias}} +
+
Out Channel{{fhEvent?.out_channel_alias}}Out Channel Id{{fhEvent?.out_channel}}Out Channel +
+ {{fhEvent?.out_channel_alias}} +
+
Payment Hash +
+ {{fhEvent?.payment_hash}} +
+
Amount In (Sats){{fhEvent?.in_msatoshi/1000 | number:fhEvent?.in_msatoshi < 1000 ? '1.0-4' : '1.0-0'}}Amount In (Sats){{fhEvent?.in_msatoshi/1000 | number:fhEvent?.in_msatoshi < 1000 ? '1.0-4' : '1.0-0'}} Amount Out (Sats){{fhEvent?.out_msatoshi/1000 | number:fhEvent?.out_msatoshi < 1000 ? '1.0-4' : '1.0-0'}}Amount Out (Sats){{fhEvent?.out_msatoshi/1000 | number:fhEvent?.out_msatoshi < 1000 ? '1.0-4' : '1.0-0'}} Fee (mSat){{fhEvent?.fee | number}}Fee (mSat){{fhEvent?.fee | number}} +
@@ -50,7 +70,7 @@
+