Cln forwards pagination (#1033)

List Forwards Pagination
List Forwards Backward Compatibility
pull/1037/head
ShahanaFarooqui 2 years ago committed by GitHub
parent 976b6f0e27
commit 7d8a8a15d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,7 +108,7 @@ export const listForwards = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwards?status=' + req.query.status;
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwards?status=' + (req.query.status ? req.query.status : 'settled');
request.get(options).then((body) => {
if (body && body.length > 0) {
body = common.sortDescByKey(body, 'received_time');
@ -147,10 +147,12 @@ export const listForwardsPaginated = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
const { status, maxLen, offset } = req.query;
const { status, maxLen, offset, sortBy, sortOrder } = req.query;
let queryStr = '?status=' + (status ? status : 'settled');
queryStr = queryStr + '&maxLen=' + (maxLen ? maxLen : '10');
queryStr = queryStr + '&offset=' + (offset ? offset : '0');
queryStr = sortBy ? (queryStr + '&sortBy=' + sortBy) : (queryStr + '');
queryStr = sortOrder ? (queryStr + '&sortOrder=' + sortOrder) : (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) => {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -13,6 +13,5 @@
<style>@font-face{font-family:Roboto;src:url(Roboto-Thin.f7a95c9c5999532c.woff2) format("woff2"),url(Roboto-Thin.c13c157cb81e8ebb.woff) format("woff");font-weight:100;font-style:normal}@font-face{font-family:Roboto;src:url(Roboto-ThinItalic.b0e084abf689f393.woff2) format("woff2"),url(Roboto-ThinItalic.1111028df6cea564.woff) format("woff");font-weight:100;font-style:italic}@font-face{font-family:Roboto;src:url(Roboto-Light.0e01b6cd13b3857f.woff2) format("woff2"),url(Roboto-Light.603ca9a537b88428.woff) format("woff");font-weight:300;font-style:normal}@font-face{font-family:Roboto;src:url(Roboto-LightItalic.232ef4b20215f720.woff2) format("woff2"),url(Roboto-LightItalic.1b5e142f787151c8.woff) format("woff");font-weight:300;font-style:italic}@font-face{font-family:Roboto;src:url(Roboto-Regular.475ba9e4e2d63456.woff2) format("woff2"),url(Roboto-Regular.bcefbfee882bc1cb.woff) format("woff");font-weight:400;font-style:normal}@font-face{font-family:Roboto;src:url(Roboto-RegularItalic.e3a9ebdaac06bbc4.woff2) format("woff2"),url(Roboto-RegularItalic.0668fae6af0cf8c2.woff) format("woff");font-weight:400;font-style:italic}@font-face{font-family:Roboto;src:url(Roboto-Medium.457532032ceb0168.woff2) format("woff2"),url(Roboto-Medium.6e1ae5f0b324a0aa.woff) format("woff");font-weight:500;font-style:normal}@font-face{font-family:Roboto;src:url(Roboto-MediumItalic.872f7060602d55d2.woff2) format("woff2"),url(Roboto-MediumItalic.e06fb533801cbb08.woff) format("woff");font-weight:500;font-style:italic}@font-face{font-family:Roboto;src:url(Roboto-Bold.447291a88c067396.woff2) format("woff2"),url(Roboto-Bold.fc482e6133cf5e26.woff) format("woff");font-weight:700;font-style:normal}@font-face{font-family:Roboto;src:url(Roboto-BoldItalic.1b15168ef6fa4e16.woff2) format("woff2"),url(Roboto-BoldItalic.e26ba339b06f09f7.woff) format("woff");font-weight:700;font-style:italic}@font-face{font-family:Roboto;src:url(Roboto-Black.2eaa390d458c877d.woff2) format("woff2"),url(Roboto-Black.b25f67ad8583da68.woff) format("woff");font-weight:900;font-style:normal}@font-face{font-family:Roboto;src:url(Roboto-BlackItalic.7dc03ee444552bc5.woff2) format("woff2"),url(Roboto-BlackItalic.c8dc642467cb3099.woff) format("woff");font-weight:900;font-style:italic}html{width:100%;height:99%;line-height:1.5;overflow-x:hidden;font-family:Roboto,sans-serif!important;font-size:62.5%}body{box-sizing:border-box;height:100%;margin:0;overflow:hidden}*{margin:0;padding:0}</style><link rel="stylesheet" href="styles.2872d180f488fe2c.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.2872d180f488fe2c.css"></noscript></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.4044bb587d7fc143.js" type="module"></script><script src="polyfills.c0773154203456c6.js" type="module"></script><script src="main.e9a1704f9917b7a1.js" type="module"></script>
<script src="runtime.fbeff23f8e48c7e1.js" type="module"></script><script src="polyfills.c0773154203456c6.js" type="module"></script><script src="main.ef66d4dabef499fe.js" type="module"></script>
</body></html>

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
(()=>{"use strict";var e,v={},g={};function r(e){var n=g[e];if(void 0!==n)return n.exports;var t=g[e]={id:e,loaded:!1,exports:{}};return v[e].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}r.m=v,e=[],r.O=(n,t,f,o)=>{if(!t){var a=1/0;for(i=0;i<e.length;i++){for(var[t,f,o]=e[i],s=!0,u=0;u<t.length;u++)(!1&o||a>=o)&&Object.keys(r.O).every(b=>r.O[b](t[u]))?t.splice(u--,1):(s=!1,o<a&&(a=o));if(s){e.splice(i--,1);var d=f();void 0!==d&&(n=d)}}return n}o=o||0;for(var i=e.length;i>0&&e[i-1][2]>o;i--)e[i]=e[i-1];e[i]=[t,f,o]},r.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return r.d(n,{a:n}),n},r.d=(e,n)=>{for(var t in n)r.o(n,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((n,t)=>(r.f[t](e,n),n),[])),r.u=e=>e+"."+{564:"b5140a859bf1234a",636:"f1aaa7338619caeb",893:"355edadcb4ce94f4",924:"ff524ffae95c311b"}[e]+".js",r.miniCssF=e=>{},r.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={},n="RTLApp:";r.l=(t,f,o,i)=>{if(e[t])e[t].push(f);else{var a,s;if(void 0!==o)for(var u=document.getElementsByTagName("script"),d=0;d<u.length;d++){var l=u[d];if(l.getAttribute("src")==t||l.getAttribute("data-webpack")==n+o){a=l;break}}a||(s=!0,(a=document.createElement("script")).type="module",a.charset="utf-8",a.timeout=120,r.nc&&a.setAttribute("nonce",r.nc),a.setAttribute("data-webpack",n+o),a.src=r.tu(t)),e[t]=[f];var c=(m,b)=>{a.onerror=a.onload=null,clearTimeout(p);var h=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),h&&h.forEach(_=>_(b)),m)return m(b)},p=setTimeout(c.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=c.bind(null,a.onerror),a.onload=c.bind(null,a.onload),s&&document.head.appendChild(a)}}})(),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:n=>n},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("angular#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="",(()=>{var e={666:0};r.f.j=(f,o)=>{var i=r.o(e,f)?e[f]:void 0;if(0!==i)if(i)o.push(i[2]);else if(666!=f){var a=new Promise((l,c)=>i=e[f]=[l,c]);o.push(i[2]=a);var s=r.p+r.u(f),u=new Error;r.l(s,l=>{if(r.o(e,f)&&(0!==(i=e[f])&&(e[f]=void 0),i)){var c=l&&("load"===l.type?"missing":l.type),p=l&&l.target&&l.target.src;u.message="Loading chunk "+f+" failed.\n("+c+": "+p+")",u.name="ChunkLoadError",u.type=c,u.request=p,i[1](u)}},"chunk-"+f,f)}else e[f]=0},r.O.j=f=>0===e[f];var n=(f,o)=>{var u,d,[i,a,s]=o,l=0;if(i.some(p=>0!==e[p])){for(u in a)r.o(a,u)&&(r.m[u]=a[u]);if(s)var c=s(r)}for(f&&f(o);l<i.length;l++)r.o(e,d=i[l])&&e[d]&&e[d][0](),e[d]=0;return r.O(c)},t=self.webpackChunkRTLApp=self.webpackChunkRTLApp||[];t.forEach(n.bind(null,0)),t.push=n.bind(null,t.push.bind(t))})()})();

@ -96,7 +96,7 @@ export const listForwards = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Channel List Forwards..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwards?status=' + req.query.status;
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listForwards?status=' + (req.query.status ? req.query.status : 'settled');
request.get(options).then((body) => {
if (body && body.length > 0) { body = common.sortDescByKey(body, 'received_time'); }
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Forwarding History Received For Status' + req.query.status, data: body });
@ -131,10 +131,12 @@ export const listForwardsPaginated = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Paginated List Forwards..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
const { status, maxLen, offset } = req.query;
const { status, maxLen, offset, sortBy, sortOrder } = req.query;
let queryStr = '?status=' + (status ? status : 'settled');
queryStr = queryStr + '&maxLen=' + (maxLen ? maxLen : '10');
queryStr = queryStr + '&offset=' + (offset ? offset : '0');
queryStr = sortBy ? (queryStr + '&sortBy=' + sortBy) : (queryStr + '');
queryStr = sortOrder ? (queryStr + '&sortOrder=' + sortOrder) : (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) => {

@ -1,17 +1,18 @@
import { Component, OnInit, OnDestroy, HostListener } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { takeUntil, withLatestFrom } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { ForwardingEvent, ListForwards } from '../../../shared/models/clnModels';
import { APICallStatusEnum, MONTHS, ReportBy, ScreenSizeEnum, SCROLL_RANGES } from '../../../shared/services/consts-enums-functions';
import { ForwardingEvent, GetInfo, ListForwards } from '../../../shared/models/clnModels';
import { APICallStatusEnum, CLNForwardingEventsStatusEnum, MONTHS, ReportBy, ScreenSizeEnum, SCROLL_RANGES } 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 { fadeIn } from '../../../shared/animation/opacity-animation';
import { RTLState } from '../../../store/rtl.state';
import { forwardingHistory } from '../../store/cln.selector';
import { clnNodeInformation, forwardingHistory } from '../../store/cln.selector';
import { DataService } from '../../../shared/services/data.service';
@Component({
selector: 'rtl-cln-routing-report',
@ -46,21 +47,33 @@ export class CLNRoutingReportComponent implements OnInit, OnDestroy {
public apiCallStatusEnum = APICallStatusEnum;
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
constructor(private logger: LoggerService, private commonService: CommonService, private store: Store<RTLState>) { }
constructor(private logger: LoggerService, private commonService: CommonService, private store: Store<RTLState>, private dataService: DataService) { }
ngOnInit() {
this.screenSize = this.commonService.getScreenSize();
this.showYAxisLabel = !(this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM);
this.store.select(forwardingHistory).pipe(takeUntil(this.unSubs[0])).
subscribe((fhSeletor: { forwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }) => {
this.errorMessage = '';
this.apiCallStatus = fhSeletor.apiCallStatus;
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
this.errorMessage = (typeof (this.apiCallStatus.message) === 'object') ? JSON.stringify(this.apiCallStatus.message) : this.apiCallStatus.message;
this.store.select(forwardingHistory).pipe(takeUntil(this.unSubs[0]),
withLatestFrom(this.store.select(clnNodeInformation))).
subscribe(([fhSeletor, nodeInfo]: [{ forwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }, GetInfo]) => {
if (fhSeletor.forwardingHistory.status === CLNForwardingEventsStatusEnum.SETTLED && (fhSeletor.apiCallStatus.status === APICallStatusEnum.COMPLETED || fhSeletor.apiCallStatus.status === APICallStatusEnum.ERROR)) {
if (nodeInfo.api_version && this.commonService.isVersionCompatible(nodeInfo.api_version, '0.7.3')) {
this.dataService.getForwardingHistory('CLN', '', '', CLNForwardingEventsStatusEnum.SETTLED).pipe(takeUntil(this.unSubs[0])).
subscribe((response: ForwardingEvent[]) => {
this.events = response || [];
this.filterForwardingEvents(this.startDate, this.endDate);
this.logger.info(response);
});
} else {
this.errorMessage = '';
this.apiCallStatus = fhSeletor.apiCallStatus;
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
this.errorMessage = (typeof (this.apiCallStatus.message) === 'object') ? JSON.stringify(this.apiCallStatus.message) : this.apiCallStatus.message;
}
this.events = fhSeletor.forwardingHistory.listForwards || [];
this.filterForwardingEvents(this.startDate, this.endDate);
this.logger.info(fhSeletor);
}
}
this.events = fhSeletor.forwardingHistory.listForwards || [];
this.filterForwardingEvents(this.startDate, this.endDate);
this.logger.info(fhSeletor);
});
this.commonService.containerSizeUpdated.pipe(takeUntil(this.unSubs[1])).subscribe((CONTAINER_SIZE) => {
switch (this.screenSize) {

@ -2,13 +2,13 @@ import { Component, OnInit, ViewChild, OnDestroy, AfterViewInit } from '@angular
import { Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { takeUntil, withLatestFrom } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { MatPaginator, MatPaginatorIntl, PageEvent } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ForwardingEvent, ListForwards } from '../../../shared/models/clnModels';
import { ForwardingEvent, GetInfo, ListForwards } from '../../../shared/models/clnModels';
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, APICallStatusEnum, CLNForwardingEventsStatusEnum } from '../../../shared/services/consts-enums-functions';
import { ApiCallStatusPayload } from '../../../shared/models/apiCallsPayload';
import { LoggerService } from '../../../shared/services/logger.service';
@ -17,7 +17,7 @@ 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 { failedForwardingHistory } from '../../store/cln.selector';
import { clnNodeInformation, failedForwardingHistory } from '../../store/cln.selector';
@Component({
selector: 'rtl-cln-failed-history',
@ -31,6 +31,8 @@ export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, On
@ViewChild(MatSort, { static: false }) sort: MatSort | undefined;
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
public flgCompatible = true;
public information: GetInfo = {};
public failedEvents: any;
public errorMessage = '';
public displayedColumns: any[] = [];
@ -65,8 +67,11 @@ export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, On
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.FAILED, maxLen: this.pageSize, offset: 0 } }));
this.store.select(failedForwardingHistory).pipe(takeUntil(this.unSubs[0])).
subscribe((ffhSeletor: { failedForwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }) => {
this.store.select(failedForwardingHistory).pipe(takeUntil(this.unSubs[0]),
withLatestFrom(this.store.select(clnNodeInformation))).
subscribe(([ffhSeletor, nodeInfo]: [{ failedForwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }, GetInfo]) => {
this.information = nodeInfo;
this.flgCompatible = (this.information.api_version) ? this.commonService.isVersionCompatible(this.information.api_version, '0.7.3') : true;
this.errorMessage = '';
this.apiCallStatus = ffhSeletor.apiCallStatus;
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
@ -76,7 +81,11 @@ export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, On
this.indexOffset = ffhSeletor.failedForwardingHistory.offset;
this.failedEvents = ffhSeletor.failedForwardingHistory.listForwards || [];
if (this.failedEvents.length > 0 && this.sort && this.paginator) {
this.loadFailedEventsTable(this.failedEvents);
if (this.flgCompatible) {
this.loadFailedEventsTable(this.failedEvents);
} else {
this.loadFailedEventsTable(this.failedEvents.slice(0, this.pageSize));
}
}
this.logger.info(ffhSeletor);
});
@ -84,7 +93,11 @@ export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, On
ngAfterViewInit() {
if (this.failedEvents.length > 0) {
this.loadFailedEventsTable(this.failedEvents);
if (this.flgCompatible) {
this.loadFailedEventsTable(this.failedEvents);
} else {
this.loadFailedEventsTable(this.failedEvents.slice(0, this.pageSize));
}
}
}
@ -146,7 +159,11 @@ export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, On
} else {
this.indexOffset = event.pageIndex * this.pageSize;
}
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.FAILED, maxLen: this.pageSize, offset: this.indexOffset } }));
if (this.flgCompatible) {
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.FAILED, maxLen: this.pageSize, offset: this.indexOffset } }));
} else {
this.loadFailedEventsTable(this.failedEvents.slice(this.indexOffset, (this.indexOffset + this.pageSize)));
}
}
ngOnDestroy() {

@ -1,13 +1,13 @@
import { Component, OnInit, OnChanges, ViewChild, OnDestroy, SimpleChanges, Input, AfterViewInit } from '@angular/core';
import { DatePipe } from '@angular/common';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { takeUntil, withLatestFrom } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { MatPaginator, MatPaginatorIntl, PageEvent } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ForwardingEvent, ListForwards } from '../../../shared/models/clnModels';
import { ForwardingEvent, GetInfo, ListForwards } from '../../../shared/models/clnModels';
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, APICallStatusEnum, CLNForwardingEventsStatusEnum } from '../../../shared/services/consts-enums-functions';
import { ApiCallStatusPayload } from '../../../shared/models/apiCallsPayload';
import { LoggerService } from '../../../shared/services/logger.service';
@ -15,7 +15,7 @@ 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 { clnNodeInformation, forwardingHistory } from '../../store/cln.selector';
import { getForwardingHistory } from '../../store/cln.actions';
@Component({
@ -32,6 +32,8 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
@Input() eventsData = [];
@Input() filterValue = '';
public flgCompatible = true;
public information: GetInfo = {};
public successfulEvents = [];
public displayedColumns: any[] = [];
public forwardingHistoryEvents: any;
@ -62,8 +64,11 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
}
ngOnInit() {
this.store.select(forwardingHistory).pipe(takeUntil(this.unSubs[0])).
subscribe((fhSeletor: { forwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }) => {
this.store.select(forwardingHistory).pipe(takeUntil(this.unSubs[0]),
withLatestFrom(this.store.select(clnNodeInformation))).
subscribe(([fhSeletor, nodeInfo]: [{ forwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }, GetInfo]) => {
this.information = nodeInfo;
this.flgCompatible = (this.information.api_version) ? this.commonService.isVersionCompatible(this.information.api_version, '0.7.3') : true;
this.errorMessage = '';
this.apiCallStatus = fhSeletor.apiCallStatus;
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
@ -74,7 +79,11 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
this.indexOffset = fhSeletor.forwardingHistory.offset;
this.successfulEvents = fhSeletor.forwardingHistory.listForwards || [];
if (this.successfulEvents.length > 0 && this.sort && this.paginator) {
this.loadForwardingEventsTable(this.successfulEvents);
if (this.flgCompatible) {
this.loadForwardingEventsTable(this.successfulEvents);
} else {
this.loadForwardingEventsTable(this.successfulEvents.slice(0, this.pageSize));
}
}
this.logger.info(fhSeletor);
}
@ -83,7 +92,11 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
ngAfterViewInit() {
if (this.successfulEvents.length > 0) {
this.loadForwardingEventsTable(this.successfulEvents);
if (this.flgCompatible) {
this.loadForwardingEventsTable(this.successfulEvents);
} else {
this.loadForwardingEventsTable(this.successfulEvents.slice(0, this.pageSize));
}
}
}
@ -92,8 +105,11 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
this.apiCallStatus = { status: APICallStatusEnum.COMPLETED, action: 'FetchForwardingHistory' };
this.eventsData = changes.eventsData.currentValue;
this.successfulEvents = this.eventsData;
this.indexOffset = 0;
this.totalForwardedTransactions = this.eventsData.length;
if (this.paginator) { this.paginator.firstPage(); }
if (!changes.eventsData.firstChange) {
this.loadForwardingEventsTable(this.successfulEvents);
this.loadForwardingEventsTable(this.successfulEvents.slice(0, this.pageSize));
}
}
if (changes.filterValue && !changes.filterValue.firstChange) {
@ -158,7 +174,11 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
} else {
this.indexOffset = event.pageIndex * this.pageSize;
}
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.SETTLED, maxLen: this.pageSize, offset: this.indexOffset } }));
if (this.flgCompatible) {
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.SETTLED, maxLen: this.pageSize, offset: this.indexOffset } }));
} else {
this.loadForwardingEventsTable(this.successfulEvents.slice(this.indexOffset, (this.indexOffset + this.pageSize)));
}
}
ngOnDestroy() {

@ -2,13 +2,13 @@ import { Component, OnInit, ViewChild, OnDestroy, AfterViewInit } from '@angular
import { Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { takeUntil, withLatestFrom } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { MatPaginator, MatPaginatorIntl, PageEvent } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ListForwards, LocalFailedEvent } from '../../../shared/models/clnModels';
import { GetInfo, 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 { ApiCallStatusPayload } from '../../../shared/models/apiCallsPayload';
import { LoggerService } from '../../../shared/services/logger.service';
@ -17,7 +17,7 @@ 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 { clnNodeInformation, localFailedForwardingHistory } from '../../store/cln.selector';
@Component({
selector: 'rtl-cln-local-failed-history',
@ -31,6 +31,8 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
@ViewChild(MatSort, { static: false }) sort: MatSort | undefined;
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
public flgCompatible = true;
public information: GetInfo = {};
public CLNFailReason = CLNFailReason;
public failedLocalEvents: any;
public errorMessage = '';
@ -66,8 +68,11 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.LOCAL_FAILED, maxLen: this.pageSize, offset: 0 } }));
this.store.select(localFailedForwardingHistory).pipe(takeUntil(this.unSubs[0])).
subscribe((lffhSeletor: { localFailedForwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }) => {
this.store.select(localFailedForwardingHistory).pipe(takeUntil(this.unSubs[0]),
withLatestFrom(this.store.select(clnNodeInformation))).
subscribe(([lffhSeletor, nodeInfo]: [{ localFailedForwardingHistory: ListForwards, apiCallStatus: ApiCallStatusPayload }, GetInfo]) => {
this.information = nodeInfo;
this.flgCompatible = (this.information.api_version) ? this.commonService.isVersionCompatible(this.information.api_version, '0.7.3') : true;
this.errorMessage = '';
this.apiCallStatus = lffhSeletor.apiCallStatus;
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
@ -77,7 +82,11 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
this.indexOffset = lffhSeletor.localFailedForwardingHistory.offset;
this.failedLocalEvents = lffhSeletor.localFailedForwardingHistory.listForwards || [];
if (this.failedLocalEvents.length > 0 && this.sort && this.paginator) {
this.loadLocalfailedLocalEventsTable(this.failedLocalEvents);
if (this.flgCompatible) {
this.loadLocalfailedLocalEventsTable(this.failedLocalEvents);
} else {
this.loadLocalfailedLocalEventsTable(this.failedLocalEvents.slice(0, this.pageSize));
}
}
this.logger.info(lffhSeletor);
});
@ -85,7 +94,11 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
ngAfterViewInit() {
if (this.failedLocalEvents.length > 0) {
this.loadLocalfailedLocalEventsTable(this.failedLocalEvents);
if (this.flgCompatible) {
this.loadLocalfailedLocalEventsTable(this.failedLocalEvents);
} else {
this.loadLocalfailedLocalEventsTable(this.failedLocalEvents.slice(0, this.pageSize));
}
}
}
@ -147,7 +160,11 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni
} else {
this.indexOffset = event.pageIndex * this.pageSize;
}
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.LOCAL_FAILED, maxLen: this.pageSize, offset: this.indexOffset } }));
if (this.flgCompatible) {
this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.LOCAL_FAILED, maxLen: this.pageSize, offset: this.indexOffset } }));
} else {
this.loadLocalfailedLocalEventsTable(this.failedLocalEvents.slice(this.indexOffset, (this.indexOffset + this.pageSize)));
}
}
ngOnDestroy() {

@ -3,7 +3,7 @@ import { createAction, props } from '@ngrx/store';
import { CLNActions, CLNForwardingEventsStatusEnum } from '../../shared/services/consts-enums-functions';
import { ApiCallStatusPayload } from '../../shared/models/apiCallsPayload';
import { SelNodeChild } from '../../shared/models/RTLconfig';
import { GetInfo, Fees, Peer, Payment, QueryRoutes, Channel, FeeRates, Invoice, ListInvoices, OnChain, UTXO, SaveChannel, GetNewAddress, DetachPeer, UpdateChannel, CloseChannel, SendPayment, GetQueryRoutes, ChannelLookup, OfferInvoice, Offer, OfferBookmark, ListForwards, FetchListForwards } from '../../shared/models/clnModels';
import { GetInfo, Fees, Peer, Payment, QueryRoutes, Channel, FeeRates, Invoice, ListInvoices, OnChain, UTXO, SaveChannel, GetNewAddress, DetachPeer, UpdateChannel, CloseChannel, SendPayment, GetQueryRoutes, ChannelLookup, OfferInvoice, Offer, OfferBookmark, ListForwards, FetchListForwards, LocalFailedEvent, ForwardingEvent } from '../../shared/models/clnModels';
export const updateCLAPICallStatus = createAction(CLNActions.UPDATE_API_CALL_STATUS_CLN, props<{ payload: ApiCallStatusPayload }>());
@ -83,7 +83,7 @@ export const setLookup = createAction(CLNActions.SET_LOOKUP_CLN, props<{ payload
export const getForwardingHistory = createAction(CLNActions.GET_FORWARDING_HISTORY_CLN, props<{ payload: FetchListForwards }>());
export const setForwardingHistory = createAction(CLNActions.SET_FORWARDING_HISTORY_CLN, props<{ payload: { status: CLNForwardingEventsStatusEnum, response: ListForwards } }>());
export const setForwardingHistory = createAction(CLNActions.SET_FORWARDING_HISTORY_CLN, props<{ payload: ListForwards }>());
export const fetchInvoices = createAction(CLNActions.FETCH_INVOICES_CLN, props<{ payload: { num_max_invoices?: number, index_offset?: number, reversed?: boolean } }>());

@ -4,7 +4,7 @@ import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Subject, of } from 'rxjs';
import { map, mergeMap, catchError, takeUntil } from 'rxjs/operators';
import { map, mergeMap, catchError, takeUntil, withLatestFrom } from 'rxjs/operators';
import { Location } from '@angular/common';
import { environment, API_URL } from '../../../environments/environment';
@ -14,13 +14,13 @@ import { SessionService } from '../../shared/services/session.service';
import { WebSocketClientService } from '../../shared/services/web-socket.service';
import { ErrorMessageComponent } from '../../shared/components/data-modal/error-message/error-message.component';
import { CLNInvoiceInformationComponent } from '../transactions/invoices/invoice-information-modal/invoice-information.component';
import { GetInfo, Fees, Balance, LocalRemoteBalance, Payment, FeeRates, ListInvoices, Invoice, Peer, OnChain, QueryRoutes, SaveChannel, GetNewAddress, DetachPeer, UpdateChannel, CloseChannel, SendPayment, GetQueryRoutes, ChannelLookup, FetchInvoices, Channel, OfferInvoice, Offer, ListForwards, FetchListForwards } from '../../shared/models/clnModels';
import { GetInfo, Fees, Balance, LocalRemoteBalance, Payment, FeeRates, ListInvoices, Invoice, Peer, OnChain, QueryRoutes, SaveChannel, GetNewAddress, DetachPeer, UpdateChannel, CloseChannel, SendPayment, GetQueryRoutes, ChannelLookup, FetchInvoices, Channel, OfferInvoice, Offer, ListForwards, FetchListForwards, ForwardingEvent, LocalFailedEvent } from '../../shared/models/clnModels';
import { AlertTypeEnum, APICallStatusEnum, UI_MESSAGES, CLNWSEventTypeEnum, CLNActions, RTLActions, CLNForwardingEventsStatusEnum } from '../../shared/services/consts-enums-functions';
import { closeAllDialogs, closeSpinner, logout, openAlert, openSnackBar, openSpinner, setApiUrl, setNodeData } from '../../store/rtl.actions';
import { RTLState } from '../../store/rtl.state';
import { addUpdateOfferBookmark, fetchBalance, fetchChannels, fetchFeeRates, fetchFees, fetchInvoices, fetchLocalRemoteBalance, fetchPayments, fetchPeers, fetchUTXOs, getForwardingHistory, setLookup, setPeers, setQueryRoutes, updateCLAPICallStatus, updateInvoice, setOfferInvoice, sendPaymentStatus } from './cln.actions';
import { allAPIsCallStatus } from './cln.selector';
import { addUpdateOfferBookmark, fetchBalance, fetchChannels, fetchFeeRates, fetchFees, fetchInvoices, fetchLocalRemoteBalance, fetchPayments, fetchPeers, fetchUTXOs, getForwardingHistory, setLookup, setPeers, setQueryRoutes, updateCLAPICallStatus, updateInvoice, setOfferInvoice, sendPaymentStatus, setForwardingHistory } from './cln.actions';
import { allAPIsCallStatus, clnNodeInformation } from './cln.selector';
import { ApiCallsListCL } from '../../shared/models/apiCallsPayload';
import { CLNOfferInformationComponent } from '../transactions/offers/offer-information-modal/offer-information.component';
@ -654,20 +654,51 @@ export class CLNEffects implements OnDestroy {
fetchForwardingHistoryCL = createEffect(() => this.actions.pipe(
ofType(CLNActions.GET_FORWARDING_HISTORY_CLN),
mergeMap((action: { type: string, payload: FetchListForwards }) => {
withLatestFrom(this.store.select(clnNodeInformation)),
mergeMap(([action, nodeInfo]: [{ type: string, payload: FetchListForwards }, GetInfo]) => {
const status = (action.payload.status) ? action.payload.status : 'settled';
const maxLen = (action.payload.maxLen) ? action.payload.maxLen : 100;
const maxLen = (action.payload.maxLen) ? action.payload.maxLen : 10;
const offset = (action.payload.offset) ? action.payload.offset : 0;
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).pipe(
const isNewerVersion = (nodeInfo.api_version) ? this.commonService.isVersionCompatible(nodeInfo.api_version, '0.7.3') : false;
let listForwardsUrl = '';
if (isNewerVersion) {
listForwardsUrl = this.CHILD_API_URL + environment.CHANNELS_API + '/listForwardsPaginated?status=' + status + '&maxLen=' + maxLen + '&offset=' + offset + '&sortBy=received_time&sortOrder=DESC';
} else {
listForwardsUrl = this.CHILD_API_URL + environment.CHANNELS_API + '/listForwards?status=' + status;
}
return this.httpClient.get(listForwardsUrl).pipe(
map((fhRes: ListForwards) => {
this.logger.info(fhRes);
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'FetchForwardingHistory' + statusInitial, status: APICallStatusEnum.COMPLETED } }));
return {
type: CLNActions.SET_FORWARDING_HISTORY_CLN,
payload: { status: status, response: fhRes }
};
if (!isNewerVersion) {
const filteredLocalFailedEvents: LocalFailedEvent[] = [];
const filteredFailedEvents: ForwardingEvent[] = [];
const filteredSuccessfulEvents: ForwardingEvent[] = [];
(<any[]>fhRes).forEach((event: ForwardingEvent | LocalFailedEvent) => {
if (event.status === CLNForwardingEventsStatusEnum.SETTLED) {
filteredSuccessfulEvents.push(event);
} else if (event.status === CLNForwardingEventsStatusEnum.FAILED) {
filteredFailedEvents.push(event);
} else if (event.status === CLNForwardingEventsStatusEnum.LOCAL_FAILED) {
filteredLocalFailedEvents.push(event);
}
});
if (action.payload.status === CLNForwardingEventsStatusEnum.FAILED) {
this.store.dispatch(setForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.FAILED, offset: offset, maxLen: maxLen, totalForwards: filteredFailedEvents.length, listForwards: filteredFailedEvents } }));
} else if (action.payload.status === CLNForwardingEventsStatusEnum.LOCAL_FAILED) {
this.store.dispatch(setForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.LOCAL_FAILED, offset: offset, maxLen: maxLen, totalForwards: filteredLocalFailedEvents.length, listForwards: filteredLocalFailedEvents } }));
} else if (action.payload.status === CLNForwardingEventsStatusEnum.SETTLED) {
this.store.dispatch(setForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.SETTLED, offset: offset, maxLen: maxLen, totalForwards: filteredSuccessfulEvents.length, listForwards: filteredSuccessfulEvents } }));
}
return { type: RTLActions.VOID };
} else {
return {
type: CLNActions.SET_FORWARDING_HISTORY_CLN,
payload: fhRes
};
}
}),
catchError((err: any) => {
this.handleErrorWithAlert('FetchForwardingHistory' + statusInitial, UI_MESSAGES.NO_SPINNER, 'Get ' + status + ' Forwarding History Failed', this.CHILD_API_URL + environment.CHANNELS_API + '/listForwardsPaginated?status=' + status, err);

@ -109,26 +109,26 @@ export const CLNReducer = createReducer(initCLNState,
})),
on(setForwardingHistory, (state, { payload }) => {
const storedChannels = [...state.activeChannels, ...state.pendingChannels, ...state.inactiveChannels];
const forwardsWithAlias = mapAliases(payload.response.listForwards, storedChannels);
payload.response.listForwards = forwardsWithAlias;
const forwardsWithAlias = mapAliases(payload.listForwards, storedChannels);
payload.listForwards = forwardsWithAlias;
switch (payload.status) {
case CLNForwardingEventsStatusEnum.SETTLED:
const modifiedFeeWithTxCount = state.fees;
modifiedFeeWithTxCount.totalTxCount = payload.response.totalForwards | 0;
modifiedFeeWithTxCount.totalTxCount = payload.totalForwards | 0;
return {
...state,
fees: modifiedFeeWithTxCount,
forwardingHistory: payload.response
forwardingHistory: payload
};
case CLNForwardingEventsStatusEnum.FAILED:
return {
...state,
failedForwardingHistory: payload.response
failedForwardingHistory: payload
};
case CLNForwardingEventsStatusEnum.LOCAL_FAILED:
return {
...state,
localFailedForwardingHistory: payload.response
localFailedForwardingHistory: payload
};
default:
return { ...state };

@ -78,7 +78,7 @@ export class RoutingReportComponent implements OnInit, OnDestroy {
this.errorMessage = UI_MESSAGES.GET_FORWARDING_HISTORY;
const startDateInSeconds = Math.round(start.getTime() / 1000).toString();
const endDateInSeconds = Math.round(end.getTime() / 1000).toString();
this.dataService.getForwardingHistory(startDateInSeconds, endDateInSeconds).
this.dataService.getForwardingHistory('LND', startDateInSeconds, endDateInSeconds).
pipe(takeUntil(this.unSubs[2])).subscribe({
next: (res) => {
this.errorMessage = '';

@ -1,4 +1,4 @@
import { PaymentTypes } from '../services/consts-enums-functions';
import { CLNForwardingEventsStatusEnum, PaymentTypes } from '../services/consts-enums-functions';
export enum feeRateStyle {
KB = 'KB',
@ -284,6 +284,7 @@ export interface LocalFailedEvent {
}
export interface ListForwards {
status?: CLNForwardingEventsStatusEnum;
offset?: number;
maxLen?: number;
totalForwards?: number;

@ -16,7 +16,9 @@ import { fetchTransactions, fetchUTXOs } from '../../lnd/store/lnd.actions';
import { RTLState } from '../../store/rtl.state';
import { allChannels } from '../../lnd/store/lnd.selector';
import { LookupNode } from '../models/clnModels';
import { Channel as ChannelCLN } from '../models/clnModels';
import { channels } from '../../cln/store/cln.selector';
import { ApiCallStatusPayload } from '../models/apiCallsPayload';
@Injectable()
export class DataService implements OnDestroy {
@ -211,11 +213,11 @@ export class DataService implements OnDestroy {
}));
}
getForwardingHistory(start: string, end: string) {
return this.lnImplementationUpdated.pipe(first((val) => val !== null), mergeMap((updatedLnImplementation) => {
getForwardingHistory(implementation: string, start: string, end: string, status?: string) {
if (implementation === 'LND') {
const queryHeaders: SwitchReq = { end_time: end, start_time: start };
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.GET_FORWARDING_HISTORY }));
return this.httpClient.post(this.APIUrl + '/' + updatedLnImplementation + environment.SWITCH_API, queryHeaders).pipe(
return this.httpClient.post(this.APIUrl + '/lnd' + environment.SWITCH_API, queryHeaders).pipe(
takeUntil(this.unSubs[7]),
withLatestFrom(this.store.select(allChannels)),
mergeMap(([res, allChannelsSelector]: [any, { channels: Channel[], pendingChannels: PendingChannels, closedChannels: ClosedChannel[] }]) => {
@ -257,17 +259,33 @@ export class DataService implements OnDestroy {
return of(res);
}),
catchError((err) => {
this.handleErrorWithAlert('getForwardingHistoryData', UI_MESSAGES.GET_FORWARDING_HISTORY, 'Forwarding History Failed', this.APIUrl + '/' + updatedLnImplementation + environment.SWITCH_API, err);
this.handleErrorWithAlert('getForwardingHistoryData', UI_MESSAGES.GET_FORWARDING_HISTORY, 'Forwarding History Failed', this.APIUrl + '/lnd' + environment.SWITCH_API, err);
return throwError(() => new Error(this.extractErrorMessage(err)));
}));
}));
} else if (implementation === 'CLN') {
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.GET_FORWARDING_HISTORY }));
return this.httpClient.get(this.APIUrl + '/cln' + environment.CHANNELS_API + '/listForwards?status=' + status).pipe(
takeUntil(this.unSubs[8]),
withLatestFrom(this.store.select(channels)),
mergeMap(([res, channelsSelector]: [any, { activeChannels: ChannelCLN[], pendingChannels: ChannelCLN[], inactiveChannels: ChannelCLN[], apiCallStatus: ApiCallStatusPayload }]) => {
const forwardsWithAlias = this.mapAliases(res, [...channelsSelector.activeChannels, ...channelsSelector.pendingChannels, ...channelsSelector.inactiveChannels]);
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.GET_FORWARDING_HISTORY }));
return of(forwardsWithAlias);
}),
catchError((err) => {
this.handleErrorWithAlert('getForwardingHistoryData', UI_MESSAGES.GET_FORWARDING_HISTORY, 'Forwarding History Failed', this.APIUrl + '/cln' + environment.CHANNELS_API + '/listForwards?status=' + status + '&start=' + start + '&end=' + end, err);
return throwError(() => new Error(this.extractErrorMessage(err)));
}));
} else {
return of({});
}
}
listNetworkNodes(queryParams: string = '') {
return this.lnImplementationUpdated.pipe(first((val) => val !== null), mergeMap((updatedLnImplementation) => {
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.LIST_NETWORK_NODES }));
return this.httpClient.get(this.APIUrl + '/' + updatedLnImplementation + environment.NETWORK_API + '/listNodes' + queryParams).pipe(
takeUntil(this.unSubs[8]),
takeUntil(this.unSubs[9]),
mergeMap((res) => {
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.LIST_NETWORK_NODES }));
return of(res);
@ -283,7 +301,7 @@ export class DataService implements OnDestroy {
return this.lnImplementationUpdated.pipe(first((val) => val !== null), mergeMap((updatedLnImplementation) => {
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.GET_LIST_CONFIGS }));
return this.httpClient.get(this.APIUrl + '/' + updatedLnImplementation + environment.UTILITY_API + '/listConfigs').pipe(
takeUntil(this.unSubs[9]),
takeUntil(this.unSubs[10]),
mergeMap((res) => {
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.GET_LIST_CONFIGS }));
return of(res);
@ -300,7 +318,7 @@ export class DataService implements OnDestroy {
const postParams = policy ? { policy: policy, policy_mod: policyMod, lease_fee_base_msat: leaseFeeBaseMsat, lease_fee_basis: leaseFeeBasis, channel_fee_max_base_msat: channelFeeMaxBaseMsat, channel_fee_max_proportional_thousandths: channelFeeMaxProportional } : null;
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.GET_FUNDER_POLICY }));
return this.httpClient.post(this.APIUrl + '/' + updatedLnImplementation + environment.CHANNELS_API + '/funderUpdate', postParams).pipe(
takeUntil(this.unSubs[10]),
takeUntil(this.unSubs[11]),
map((res) => {
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.GET_FUNDER_POLICY }));
if (postParams) {
@ -315,6 +333,35 @@ export class DataService implements OnDestroy {
}));
}
mapAliases = (payload: any, storedChannels: ChannelCLN[]) => {
if (payload && payload.length > 0) {
payload.forEach((fhEvent, i) => {
if (storedChannels && storedChannels.length > 0) {
for (let idx = 0; idx < storedChannels.length; idx++) {
if (storedChannels[idx].short_channel_id && storedChannels[idx].short_channel_id === fhEvent.in_channel) {
fhEvent.in_channel_alias = storedChannels[idx].alias ? storedChannels[idx].alias : fhEvent.in_channel;
if (fhEvent.out_channel_alias) { return; }
}
if (storedChannels[idx].short_channel_id && storedChannels[idx].short_channel_id.toString() === fhEvent.out_channel) {
fhEvent.out_channel_alias = storedChannels[idx].alias ? storedChannels[idx].alias : fhEvent.out_channel;
if (fhEvent.in_channel_alias) { return; }
}
if (idx === storedChannels.length - 1) {
if (!fhEvent.in_channel_alias) { fhEvent.in_channel_alias = fhEvent.in_channel ? fhEvent.in_channel : '-'; }
if (!fhEvent.out_channel_alias) { fhEvent.out_channel_alias = fhEvent.out_channel ? fhEvent.out_channel : '-'; }
}
}
} else {
fhEvent.in_channel_alias = fhEvent.in_channel ? fhEvent.in_channel : '-';
fhEvent.out_channel_alias = fhEvent.out_channel ? fhEvent.out_channel : '-';
}
});
} else {
payload = [];
}
return payload;
};
extractErrorMessage(err: any, genericErrorMessage: string = 'Unknown Error.') {
return this.titleCasePipe.transform(
(err.error.text && typeof err.error.text === 'string' && err.error.text.includes('<!DOCTYPE html><html lang="en">')) ? 'API Route Does Not Exist.' :

Loading…
Cancel
Save