2
0
mirror of https://github.com/Ride-The-Lightning/RTL synced 2024-11-15 18:13:00 +00:00
RTL/src/app/eclair/transactions/transactions.component.ts
ShahanaFarooqui 5a38585b71
Release 0.10.0 (#571)
Channel backup download file bug fix #536
Added macaroon authentication for Loop (#543)
Adding Label for Loop In & Loop Out #538
Fee Report & Routing Enhancements (#555)
Payments report #559
Transactions Report #357
Material table sorting bug fix #556
CL & ECL ng Routing #551 & Hocon Read Fix #560 (#561)
CLT & ECL Reports (#562)
UI Bug fixes for tables group sort, pagination, dialog and spinner close
Increased request body size #544 (#564)
App lock after 5 attempts #542 & DatePicker default adapter #532 (#566)
Upgade Angular 11 (#568)
Loop amount validation #569
Loop https document updates
2020-12-20 18:36:04 -05:00

56 lines
2.7 KiB
TypeScript

import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, ResolveEnd } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil, filter } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { faExchangeAlt, faChartPie } from '@fortawesome/free-solid-svg-icons';
import { LoggerService } from '../../shared/services/logger.service';
import * as fromRTLReducer from '../../store/rtl.reducers';
import { UserPersonaEnum } from '../../shared/services/consts-enums-functions';
@Component({
selector: 'rtl-ecl-transactions',
templateUrl: './transactions.component.html',
styleUrls: ['./transactions.component.scss']
})
export class ECLTransactionsComponent implements OnInit, OnDestroy {
faExchangeAlt = faExchangeAlt;
faChartPie = faChartPie;
currencyUnits = [];
balances = [{title: 'Local Capacity', dataValue: 0, tooltip: 'Amount you can send'}, {title: 'Remote Capacity', dataValue: 0, tooltip: 'Amount you can receive'}];
public links = [{link: 'payments', name: 'Payments'}, {link: 'invoices', name: 'Invoices'}, {link: 'queryroutes', name: 'Query Routes'}];
public activeLink = this.links[0].link;
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private router: Router) {}
ngOnInit() {
let linkFound = this.links.find(link => this.router.url.includes(link.link));
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
this.router.events.pipe(takeUntil(this.unSubs[0]), filter(e => e instanceof ResolveEnd))
.subscribe((value: ResolveEnd) => {
let linkFound = this.links.find(link => value.urlAfterRedirects.includes(link.link));
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
});
this.store.select('ecl')
.pipe(takeUntil(this.unSubs[1]))
.subscribe((rtlStore) => {
this.currencyUnits = rtlStore.nodeSettings.currencyUnits;
if(rtlStore.nodeSettings.userPersona === UserPersonaEnum.OPERATOR) {
this.balances = [{title: 'Local Capacity', dataValue: rtlStore.lightningBalance.localBalance, tooltip: 'Amount you can send'}, {title: 'Remote Capacity', dataValue: rtlStore.lightningBalance.remoteBalance, tooltip: 'Amount you can receive'}];
} else {
this.balances = [{title: 'Outbound Capacity', dataValue: rtlStore.lightningBalance.localBalance, tooltip: 'Amount you can send'}, {title: 'Inbound Capacity', dataValue: rtlStore.lightningBalance.remoteBalance, tooltip: 'Amount you can receive'}];
}
this.logger.info(rtlStore);
});
}
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.complete();
});
}
}