You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
4 years ago
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||
|
import { Subject } from 'rxjs';
|
||
|
import { takeUntil } from 'rxjs/operators';
|
||
|
import { Store } from '@ngrx/store';
|
||
|
import { Actions } from '@ngrx/effects';
|
||
|
import { faUsers, faChartPie } from '@fortawesome/free-solid-svg-icons';
|
||
|
|
||
|
import { SelNodeChild } from '../../shared/models/RTLconfig';
|
||
|
import * as fromRTLReducer from '../../store/rtl.reducers';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'rtl-cl-peers-channels',
|
||
|
templateUrl: './peers-channels.component.html',
|
||
|
styleUrls: ['./peers-channels.component.scss']
|
||
|
})
|
||
|
export class CLPeersChannelsComponent implements OnInit, OnDestroy {
|
||
|
public selNode: SelNodeChild = {};
|
||
|
public activePeers = 0;
|
||
|
public activeChannels = 0;
|
||
|
public faUsers = faUsers;
|
||
|
public faChartPie = faChartPie;
|
||
|
public balances = [{title: 'Total Balance', dataValue: 0}, {title: 'Confirmed', dataValue: 0}, {title: 'Unconfirmed', dataValue: 0}];
|
||
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
||
|
|
||
|
constructor(private store: Store<fromRTLReducer.RTLState>, private actions$: Actions) {}
|
||
|
|
||
|
ngOnInit() {
|
||
|
this.store.select('cl')
|
||
|
.pipe(takeUntil(this.unSubs[1]))
|
||
|
.subscribe((rtlStore) => {
|
||
|
this.selNode = rtlStore.nodeSettings;
|
||
|
this.activePeers = (rtlStore.peers && rtlStore.peers.length) ? rtlStore.peers.length : 0;
|
||
|
this.activeChannels = rtlStore.information.num_active_channels;
|
||
|
this.balances = [{title: 'Total Balance', dataValue: rtlStore.balance.totalBalance || 0}, {title: 'Confirmed', dataValue: rtlStore.balance.confBalance}, {title: 'Unconfirmed', dataValue: rtlStore.balance.unconfBalance}];
|
||
|
});
|
||
|
}
|
||
|
|
||
|
ngOnDestroy() {
|
||
|
this.unSubs.forEach(completeSub => {
|
||
|
completeSub.next();
|
||
|
completeSub.complete();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|