|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
|
|
|
|
import { LoggerService } from '../../shared/services/logger.service';
|
|
|
|
import { GetInfo, Fees } from '../../shared/models/lndModels';
|
|
|
|
import { LightningNode } from '../../shared/models/RTLconfig';
|
|
|
|
|
|
|
|
import * as fromRTLReducer from '../../store/rtl.reducers';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'rtl-cl-home',
|
|
|
|
templateUrl: './home.component.html',
|
|
|
|
styleUrls: ['./home.component.scss']
|
|
|
|
})
|
|
|
|
export class CLHomeComponent implements OnInit, OnDestroy {
|
|
|
|
public selNode: LightningNode;
|
|
|
|
public fees: Fees;
|
|
|
|
public information: GetInfo = {};
|
|
|
|
public flgLoading: Array<Boolean | 'error'> = [true, true, true, true, true, true, true, true]; // 0: Info, 1: Fee, 2: Wallet, 3: Channel, 4: Network
|
|
|
|
private unsub: Array<Subject<void>> = [new Subject(), new Subject(), new Subject()];
|
|
|
|
|
|
|
|
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.store.select('rtl')
|
|
|
|
.pipe(takeUntil(this.unsub[0]))
|
|
|
|
.subscribe((rtlStore) => {
|
|
|
|
rtlStore.effectErrors.forEach(effectsErr => {
|
|
|
|
if (effectsErr.action === 'FetchInfo') {
|
|
|
|
this.flgLoading[0] = 'error';
|
|
|
|
}
|
|
|
|
if (effectsErr.action === 'FetchFees') {
|
|
|
|
this.flgLoading[1] = 'error';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.selNode = rtlStore.selNode;
|
|
|
|
this.information = rtlStore.information;
|
|
|
|
if (this.flgLoading[0] !== 'error') {
|
|
|
|
this.flgLoading[0] = (undefined !== this.information.identity_pubkey) ? false : true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.fees = rtlStore.fees;
|
|
|
|
if (this.flgLoading[1] !== 'error') {
|
|
|
|
this.flgLoading[1] = (undefined !== this.fees.day_fee_sum) ? false : true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.logger.info(rtlStore);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.unsub.forEach(completeSub => {
|
|
|
|
completeSub.next();
|
|
|
|
completeSub.complete();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|