Forwarding events pagination incomplete 2

Forwarding events pagination incomplete
This commit is contained in:
Shahana Farooqui 2022-05-23 20:57:22 -04:00 committed by ShahanaFarooqui
parent 1580c296cd
commit 3a9c436c32
14 changed files with 47 additions and 34 deletions

View File

@ -58,7 +58,9 @@ Ensure that the follow values are correct per your config:
```
{
"multiPass": <password required for accessing RTL>,
"port": "3000",
"defaultNodeIndex": 1,
"SSO": {
"rtlSSO": 0,
"rtlCookiePath": "",
@ -83,8 +85,7 @@ Ensure that the follow values are correct per your config:
"lnServerUrl": "https://<cl-rest api server ip address>:3001"
}
}
],
"multiPass": <password required for accessing RTL>
]
}
```
### <a name="start"></a>Start the server and access the app

View File

@ -53,7 +53,9 @@ Ensure that the follow values are correct per your config:
```
{
"multiPass": <password required for accessing RTL>,
"port": "3000",
"defaultNodeIndex": 1,
"SSO": {
"rtlSSO": 0,
"rtlCookiePath": "",
@ -78,8 +80,7 @@ Ensure that the follow values are correct per your config:
"lnServerUrl": "http://<eclair api server ip address>:port"
}
}
],
"multiPass": "<password required for accessing RTL>"
]
}
```
### <a name="start"></a>Start the server and access the app

View File

@ -155,7 +155,7 @@ export const listForwardsPaginated = (req, res, next) => {
queryStr = req.query.reverse ? (queryStr + '&reverse=' + req.query.reverse) : '';
queryStr = queryStr.replace('&', '?');
}
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwardsFilter' + queryStr;
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwardsPaginated' + queryStr;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Paginated Forwarding History url' + options.url });
request.get(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Paginated Forwarding History Received For Status' + req.query.status, data: body });

View File

@ -139,7 +139,7 @@ export const listForwardsPaginated = (req, res, next) => {
queryStr = req.query.reverse ? (queryStr + '&reverse=' + req.query.reverse) : '';
queryStr = queryStr.replace('&', '?');
}
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwardsFilter' + queryStr;
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwardsPaginated' + queryStr;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Paginated Forwarding History url' + options.url });
request.get(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Paginated Forwarding History Received For Status' + req.query.status, data: body });

View File

@ -24,7 +24,7 @@ import { failedForwardingHistory } from '../../store/cln.selector';
templateUrl: './failed-transactions.component.html',
styleUrls: ['./failed-transactions.component.scss'],
providers: [
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Failed Events') }
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Failed events') }
]
})
export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, OnDestroy {
@ -118,7 +118,6 @@ export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, On
this.failedForwardingEvents = new MatTableDataSource<ForwardingEvent>([...forwardingEvents]);
this.failedForwardingEvents.sort = this.sort;
this.failedForwardingEvents.sortingDataAccessor = (data: any, sortHeaderId: string) => ((data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null);
this.failedForwardingEvents.paginator = this.paginator;
this.failedForwardingEvents.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() : '') +

View File

@ -70,7 +70,7 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
this.errorMessage = (typeof (this.apiCallStatus.message) === 'object') ? JSON.stringify(this.apiCallStatus.message) : this.apiCallStatus.message;
}
if (this.eventsData.length <= 0) {
if (this.eventsData.length <= 0 && fhSeletor.forwardingHistory.listForwards) {
this.totalForwardedTransactions = fhSeletor.forwardingHistory.totalEvents;
this.firstOffset = fhSeletor.forwardingHistory.firstIndexOffset;
this.lastOffset = fhSeletor.forwardingHistory.lastIndexOffset;
@ -130,7 +130,6 @@ 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.paginator = this.paginator;
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() + ' ' : '') +

View File

@ -24,7 +24,7 @@ import { localFailedForwardingHistory } from '../../store/cln.selector';
templateUrl: './local-failed-transactions.component.html',
styleUrls: ['./local-failed-transactions.component.scss'],
providers: [
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Local Failed Events') }
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Local failed events') }
]
})
export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewInit, OnDestroy {
@ -128,7 +128,6 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
return (data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null;
}
};
this.failedLocalForwardingEvents.paginator = this.paginator;
this.applyFilter();
this.logger.info(this.failedLocalForwardingEvents);
}
@ -151,14 +150,15 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
reverse = true;
index_offset = 0;
} else if (event.pageIndex < event.previousPageIndex) {
reverse = false;
index_offset = this.lastOffset;
} else if (event.pageIndex > event.previousPageIndex && (event.length > ((event.pageIndex + 1) * event.pageSize))) {
reverse = true;
index_offset = this.lastOffset;
} else if (event.pageIndex > event.previousPageIndex) {
reverse = true;
if (event.length <= (event.pageIndex + 1) * event.pageSize) {
index_offset = this.totalLocalFailedTransactions - (event.pageIndex * event.pageSize);
} else {
index_offset = this.firstOffset;
} else if (event.length <= ((event.pageIndex + 1) * event.pageSize)) {
reverse = false;
index_offset = 0;
}
}
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.LOCAL_FAILED, maxLen: event.pageSize, offset: index_offset, reverse: reverse } }));
}

View File

@ -659,18 +659,22 @@ export class CLNEffects implements OnDestroy {
const maxLen = (action.payload.maxLen) ? action.payload.maxLen : 100;
const offset = (action.payload.offset) ? action.payload.offset : 0;
const reverse = (action.payload.reverse) ? action.payload.reverse : false;
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'FetchForwardingHistory' + status, status: APICallStatusEnum.INITIATED } }));
const statusInitial = status.charAt(0).toUpperCase();
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'FetchForwardingHistory' + statusInitial, status: APICallStatusEnum.INITIATED } }));
return this.httpClient.get(this.CHILD_API_URL + environment.CHANNELS_API + '/listForwardsPaginated?status=' + status + '&maxLen=' + maxLen + '&offset=' + offset + '&reverse=' + reverse).pipe(
map((fhRes: ListForwards) => {
this.logger.info(fhRes);
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'FetchForwardingHistory' + status, status: APICallStatusEnum.COMPLETED } }));
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'FetchForwardingHistory' + statusInitial, status: APICallStatusEnum.COMPLETED } }));
if (reverse && offset === 0) {
fhRes['totalEvents'] = +fhRes.lastIndexOffset | 0;
}
return {
type: CLNActions.SET_FORWARDING_HISTORY_CLN,
payload: { status: status, response: fhRes }
};
}),
catchError((err: any) => {
this.handleErrorWithAlert('FetchForwardingHistory' + status, UI_MESSAGES.NO_SPINNER, 'Get ' + status + ' Forwarding History Failed', this.CHILD_API_URL + environment.CHANNELS_API + '/listForwardsPaginated?status=' + status, err);
this.handleErrorWithAlert('FetchForwardingHistory' + statusInitial, UI_MESSAGES.NO_SPINNER, 'Get ' + status + ' Forwarding History Failed', this.CHILD_API_URL + environment.CHANNELS_API + '/listForwardsPaginated?status=' + status, err);
return of({ type: RTLActions.VOID });
})
);

View File

@ -113,19 +113,28 @@ export const CLNReducer = createReducer(initCLNState,
payload.response.listForwards = forwardsWithAlias;
switch (payload.status) {
case CLNForwardingEventsStatusEnum.SETTLED:
if (!payload.response.totalEvents) {
payload.response.totalEvents = state.forwardingHistory.totalEvents | 0;
}
const modifiedFeeWithTxCount = state.fees;
modifiedFeeWithTxCount.totalTxCount = payload.response.totalEvents | 0;
return {
...state,
fee: modifiedFeeWithTxCount,
fees: modifiedFeeWithTxCount,
forwardingHistory: payload.response
};
case CLNForwardingEventsStatusEnum.FAILED:
if (!payload.response.totalEvents) {
payload.response.totalEvents = state.failedForwardingHistory.totalEvents;
}
return {
...state,
failedForwardingHistory: payload.response
};
case CLNForwardingEventsStatusEnum.LOCAL_FAILED:
if (!payload.response.totalEvents) {
payload.response.totalEvents = state.localFailedForwardingHistory.totalEvents;
}
return {
...state,
localFailedForwardingHistory: payload.response

View File

@ -17,13 +17,13 @@ export const utxos = createSelector(clnState, (state: CLNState) => ({ utxos: sta
export const channels = createSelector(clnState, (state: CLNState) => ({ activeChannels: state.activeChannels, pendingChannels: state.pendingChannels, inactiveChannels: state.inactiveChannels, apiCallStatus: state.apisCallStatus.FetchChannels }));
export const balance = createSelector(clnState, (state: CLNState) => ({ balance: state.balance, apiCallStatus: state.apisCallStatus.FetchBalance }));
export const localRemoteBalance = createSelector(clnState, (state: CLNState) => ({ localRemoteBalance: state.localRemoteBalance, apiCallStatus: state.apisCallStatus.FetchLocalRemoteBalance }));
export const forwardingHistory = createSelector(clnState, (state: CLNState) => ({ forwardingHistory: state.forwardingHistory, apiCallStatus: state.apisCallStatus.FetchForwardingHistory }));
export const failedForwardingHistory = createSelector(clnState, (state: CLNState) => ({ failedForwardingHistory: state.failedForwardingHistory, apiCallStatus: state.apisCallStatus.FetchFailedForwardingHistory }));
export const localFailedForwardingHistory = createSelector(clnState, (state: CLNState) => ({ localFailedForwardingHistory: state.localFailedForwardingHistory, apiCallStatus: state.apisCallStatus.FetchLocalFailedForwardingHistory }));
export const forwardingHistory = createSelector(clnState, (state: CLNState) => ({ forwardingHistory: state.forwardingHistory, apiCallStatus: state.apisCallStatus.FetchForwardingHistoryS }));
export const failedForwardingHistory = createSelector(clnState, (state: CLNState) => ({ failedForwardingHistory: state.failedForwardingHistory, apiCallStatus: state.apisCallStatus.FetchForwardingHistoryF }));
export const localFailedForwardingHistory = createSelector(clnState, (state: CLNState) => ({ localFailedForwardingHistory: state.localFailedForwardingHistory, apiCallStatus: state.apisCallStatus.FetchForwardingHistoryL }));
export const nodeInfoAndNodeSettingsAndBalance = createSelector(clnState, (state: CLNState) => ({ information: state.information, nodeSettings: state.nodeSettings, balance: state.balance }));
export const nodeInfoAndBalanceAndNumPeers = createSelector(clnState, (state: CLNState) => ({ information: state.information, balance: state.balance, numPeers: state.peers.length }));
export const nodeInfoAndBalance = createSelector(clnState, (state: CLNState) => ({ information: state.information, balance: state.balance }));
export const nodeInfoAndNodeSettingsAndAPIsStatus = createSelector(clnState, (state: CLNState) => ({ information: state.information, nodeSettings: state.nodeSettings, apisCallStatus: [state.apisCallStatus.FetchInfo, state.apisCallStatus.FetchForwardingHistory] }));
export const nodeInfoAndNodeSettingsAndAPIsStatus = createSelector(clnState, (state: CLNState) => ({ information: state.information, nodeSettings: state.nodeSettings, apisCallStatus: [state.apisCallStatus.FetchInfo, state.apisCallStatus.FetchForwardingHistoryS] }));
export const offers = createSelector(clnState, (state: CLNState) => ({ offers: state.offers, apiCallStatus: state.apisCallStatus.FetchOffers }));
export const offerBookmarks = createSelector(clnState, (state: CLNState) => ({ offersBookmarks: state.offersBookmarks, apiCallStatus: state.apisCallStatus.FetchOfferBookmarks }));
export const getoffer = (bolt12Str) => createSelector(clnState, (state: CLNState) => (state.offers.find((offer: Offer) => offer.bolt12 === bolt12Str)));

View File

@ -39,9 +39,9 @@ export const initCLNState: CLNState = {
FetchPeers: { status: APICallStatusEnum.UN_INITIATED },
FetchUTXOs: { status: APICallStatusEnum.UN_INITIATED },
FetchPayments: { status: APICallStatusEnum.UN_INITIATED },
FetchForwardingHistory: { status: APICallStatusEnum.UN_INITIATED },
FetchFailedForwardingHistory: { status: APICallStatusEnum.UN_INITIATED },
FetchLocalFailedForwardingHistory: { status: APICallStatusEnum.UN_INITIATED },
FetchForwardingHistoryS: { status: APICallStatusEnum.UN_INITIATED },
FetchForwardingHistoryF: { status: APICallStatusEnum.UN_INITIATED },
FetchForwardingHistoryL: { status: APICallStatusEnum.UN_INITIATED },
FetchOffers: { status: APICallStatusEnum.UN_INITIATED },
FetchOfferBookmarks: { status: APICallStatusEnum.UN_INITIATED }
},

View File

@ -41,7 +41,6 @@ export class CLNTransactionsComponent implements OnInit, OnDestroy {
subscribe({
next: (value: ResolveEnd | Event) => {
const linkFound = this.links.find((link) => (<ResolveEnd>value).urlAfterRedirects.includes(link.link));
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
this.routerUrl = (<ResolveEnd>value).urlAfterRedirects;
}

View File

@ -54,9 +54,9 @@ export interface ApiCallsListCL {
FetchPeers: ApiCallStatusPayload;
FetchUTXOs: ApiCallStatusPayload;
FetchPayments: ApiCallStatusPayload;
FetchForwardingHistory: ApiCallStatusPayload;
FetchFailedForwardingHistory: ApiCallStatusPayload;
FetchLocalFailedForwardingHistory: ApiCallStatusPayload;
FetchForwardingHistoryS: ApiCallStatusPayload;
FetchForwardingHistoryF: ApiCallStatusPayload;
FetchForwardingHistoryL: ApiCallStatusPayload;
FetchOffers: ApiCallStatusPayload;
FetchOfferBookmarks: ApiCallStatusPayload;
}

View File

@ -626,6 +626,7 @@ export const LADS_POLICY = [
];
export enum CLNForwardingEventsStatusEnum {
OFFERED = 'offered',
SETTLED = 'settled',
FAILED = 'failed',
LOCAL_FAILED = 'local_failed'