@ -1,12 +1,13 @@
import { Component , OnInit , OnDestroy } from '@angular/core' ;
import { Component , OnInit , OnDestroy } from '@angular/core' ;
import { ActivatedRoute } from '@angular/router' ;
import { Subject } from 'rxjs' ;
import { Subject } from 'rxjs' ;
import { takeUntil } from 'rxjs/operators' ;
import { takeUntil } from 'rxjs/operators' ;
import { Store } from '@ngrx/store' ;
import { Store } from '@ngrx/store' ;
import { faTools } from '@fortawesome/free-solid-svg-icons' ;
import { faTools } from '@fortawesome/free-solid-svg-icons' ;
import { ConfigSettingsNode } from '../../models/RTLconfig' ;
import { ConfigSettingsNode , RTLConfiguration } from '../../models/RTLconfig' ;
import * as fromRTLReducer from '../../../store/rtl.reducers' ;
import * as fromRTLReducer from '../../../store/rtl.reducers' ;
import { ActivatedRoute } from '@angular/router ';
import * as RTLActions from '../../../store/rtl.actions ';
@Component ( {
@Component ( {
selector : 'rtl-settings' ,
selector : 'rtl-settings' ,
@ -18,8 +19,10 @@ export class SettingsComponent implements OnInit, OnDestroy{
public showLnConfig = false ;
public showLnConfig = false ;
public showBitcoind = false ;
public showBitcoind = false ;
public selNode : ConfigSettingsNode ;
public selNode : ConfigSettingsNode ;
public appConfig : RTLConfiguration ;
public lnImplementationStr = '' ;
public lnImplementationStr = '' ;
public loadTab = 'appSettings' ;
public loadTab = 'appSettings' ;
public initializeNodeData = false ;
private unSubs : Array < Subject < void > > = [ new Subject ( ) , new Subject ( ) ] ;
private unSubs : Array < Subject < void > > = [ new Subject ( ) , new Subject ( ) ] ;
constructor ( private store : Store < fromRTLReducer.RTLState > , private activatedRoute : ActivatedRoute ) { }
constructor ( private store : Store < fromRTLReducer.RTLState > , private activatedRoute : ActivatedRoute ) { }
@ -29,12 +32,14 @@ export class SettingsComponent implements OnInit, OnDestroy{
. pipe ( takeUntil ( this . unSubs [ 0 ] ) )
. pipe ( takeUntil ( this . unSubs [ 0 ] ) )
. subscribe ( data = > {
. subscribe ( data = > {
this . loadTab = window . history . state . loadTab ? window . history . state . loadTab : 'appSettings' ;
this . loadTab = window . history . state . loadTab ? window . history . state . loadTab : 'appSettings' ;
this . initializeNodeData = window . history . state . initializeNodeData ? window . history.state.initializeNodeData : false ;
} ) ;
} ) ;
this . store . select ( 'root' )
this . store . select ( 'root' )
. pipe ( takeUntil ( this . unSubs [ 1 ] ) )
. pipe ( takeUntil ( this . unSubs [ 1 ] ) )
. subscribe ( ( rtlStore ) = > {
. subscribe ( ( rtlStore ) = > {
this . showLnConfig = false ;
this . showLnConfig = false ;
this . showBitcoind = false ;
this . showBitcoind = false ;
this . appConfig = rtlStore . appConfig ;
this . selNode = rtlStore . selNode ;
this . selNode = rtlStore . selNode ;
this . lnImplementationStr = this . selNode . lnImplementation . toUpperCase ( ) === 'CLT' ? 'C-Lightning Config' : 'LND Config' ;
this . lnImplementationStr = this . selNode . lnImplementation . toUpperCase ( ) === 'CLT' ? 'C-Lightning Config' : 'LND Config' ;
if ( this . selNode . authentication && this . selNode . authentication . configPath && this . selNode . authentication . configPath . trim ( ) !== '' ) {
if ( this . selNode . authentication && this . selNode . authentication . configPath && this . selNode . authentication . configPath . trim ( ) !== '' ) {
@ -47,6 +52,9 @@ export class SettingsComponent implements OnInit, OnDestroy{
}
}
ngOnDestroy() {
ngOnDestroy() {
if ( this . initializeNodeData ) {
this . store . dispatch ( new RTLActions . SetSelelectedNode ( { lnNode : this.selNode , isInitialSetup : true } ) ) ;
}
this . unSubs . forEach ( completeSub = > {
this . unSubs . forEach ( completeSub = > {
completeSub . next ( ) ;
completeSub . next ( ) ;
completeSub . complete ( ) ;
completeSub . complete ( ) ;