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.
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
5 years ago
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||
|
import { Subject } from 'rxjs';
|
||
|
import { takeUntil } from 'rxjs/operators';
|
||
|
import { Store } from '@ngrx/store';
|
||
|
import { faNetworkWired } from '@fortawesome/free-solid-svg-icons';
|
||
|
|
||
|
import { LoggerService } from '../../shared/services/logger.service';
|
||
|
import { GetInfo, NetworkInfo } from '../../shared/models/lndModels';
|
||
|
import { SelNodeChild } from '../../shared/models/RTLconfig';
|
||
|
|
||
|
import * as fromRTLReducer from '../../store/rtl.reducers';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'rtl-network-info',
|
||
|
templateUrl: './network-info.component.html',
|
||
|
styleUrls: ['./network-info.component.scss']
|
||
|
})
|
||
|
export class NetworkInfoComponent implements OnInit, OnDestroy {
|
||
|
public faNetworkWired = faNetworkWired;
|
||
|
public selNode: SelNodeChild = {};
|
||
|
public information: GetInfo = {};
|
||
|
public networkInfo: NetworkInfo = {};
|
||
|
public flgLoading: Array<Boolean | 'error'> = [true, true];
|
||
|
private unSubs: Array<Subject<void>> = [new Subject()];
|
||
|
|
||
|
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>) {}
|
||
|
|
||
|
ngOnInit() {
|
||
|
this.store.select('lnd')
|
||
|
.pipe(takeUntil(this.unSubs[0]))
|
||
|
.subscribe((rtlStore) => {
|
||
|
rtlStore.effectErrorsLnd.forEach(effectsErr => {
|
||
|
if (effectsErr.action === 'FetchInfo') {
|
||
|
this.flgLoading[0] = 'error';
|
||
|
}
|
||
|
if (effectsErr.action === 'FetchNetwork') {
|
||
|
this.flgLoading[1] = 'error';
|
||
|
}
|
||
|
});
|
||
|
this.selNode = rtlStore.nodeSettings;
|
||
|
this.information = rtlStore.information;
|
||
|
if (this.flgLoading[0] !== 'error') {
|
||
|
this.flgLoading[0] = (undefined !== this.information.identity_pubkey) ? false : true;
|
||
|
}
|
||
|
|
||
|
this.networkInfo = rtlStore.networkInfo;
|
||
|
if (this.flgLoading[1] !== 'error') {
|
||
|
this.flgLoading[1] = (undefined !== this.networkInfo.num_nodes) ? false : true;
|
||
|
}
|
||
|
|
||
|
this.logger.info(rtlStore);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
ngOnDestroy() {
|
||
|
this.unSubs.forEach(completeSub => {
|
||
|
completeSub.next();
|
||
|
completeSub.complete();
|
||
|
});
|
||
|
}
|
||
|
}
|