From 700015756bac2e8c39bd824cb9cc61ffd2a9a987 Mon Sep 17 00:00:00 2001 From: Shahana Farooqui Date: Fri, 30 Aug 2019 22:05:27 -0400 Subject: [PATCH] Incomplete lazy load 7 Incomplete lazy load 7 --- common.js | 6 +- src/app/app.component.ts | 12 +-- src/app/app.module.ts | 7 +- src/app/clightning/cl-root.component.ts | 29 +++--- src/app/clightning/home/home.component.ts | 12 +-- .../channel-backup.component.ts | 16 ++-- .../channel-closed.component.ts | 12 +-- .../channel-manage.component.ts | 12 +-- .../channel-pending.component.ts | 16 ++-- src/app/lnd/home/home.component.ts | 12 +-- src/app/lnd/invoices/invoices.component.ts | 14 +-- src/app/lnd/lnd-root.component.ts | 6 +- .../channel-lookup.component.ts | 8 +- src/app/lnd/lookups/lookups.component.ts | 6 +- .../query-routes/query-routes.component.ts | 13 +-- .../send-receive/payments.component.ts | 16 ++-- src/app/lnd/peers/peers.component.ts | 12 +-- .../routing-peers/routing-peers.component.ts | 10 +-- .../switch/forwarding-history.component.ts | 10 +-- .../list-transactions.component.ts | 12 +-- .../send-receive-trans.component.ts | 16 ++-- .../lnd/unlock-lnd/unlock-lnd.component.ts | 8 +- .../confirmation-message.component.ts | 6 +- .../horizontal-navigation.component.ts | 12 +-- .../side-navigation.component.ts | 14 +-- .../navigation/top-menu/top-menu.component.ts | 16 ++-- .../server-config/server-config.component.ts | 16 ++-- .../settings-nav/settings-nav.component.ts | 16 ++-- .../components/signin/signin.component.ts | 14 +-- src/app/shared/models/RTLconfig.ts | 4 +- src/app/shared/models/clModels.ts | 52 +++++++++++ src/app/shared/models/lndModels.ts | 22 ++--- src/app/{shared => }/store/rtl.actions.ts | 41 +++++++-- src/app/{shared => }/store/rtl.effects.ts | 89 ++++++++++++++----- src/app/{shared => }/store/rtl.reducers.ts | 78 +++++++++++++--- 35 files changed, 413 insertions(+), 232 deletions(-) create mode 100644 src/app/shared/models/clModels.ts rename src/app/{shared => }/store/rtl.actions.ts (94%) rename src/app/{shared => }/store/rtl.effects.ts (94%) rename src/app/{shared => }/store/rtl.reducers.ts (84%) diff --git a/common.js b/common.js index e9a8bdd6..9e2501b3 100644 --- a/common.js +++ b/common.js @@ -34,8 +34,10 @@ common.setOptions = () => { json: true, form: '' }; - if(node.ln_implementation !== 'CLightning') { + if(node.ln_implementation.toLowerCase() !== 'clightning') { node.options.headers = {'Grpc-Metadata-macaroon': fs.readFileSync(node.macaroon_path + '/admin.macaroon').toString('hex')}; + } else { + node.options.headers = {'macaroon': fs.readFileSync(node.macaroon_path + '/access.macaroon').toString('hex')}; } }); // Options cannot be set before selected node initializes. Updating selected node's options separatly @@ -45,7 +47,7 @@ common.setOptions = () => { json: true, form: '' }; - if(common.selectedNode.ln_implementation !== 'CLightning') { + if(common.selectedNode.ln_implementation.toLowerCase() !== 'clightning') { common.selectedNode.options.headers = {'Grpc-Metadata-macaroon': fs.readFileSync(common.selectedNode.macaroon_path + '/admin.macaroon').toString('hex')}; } } catch(err) { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4eb836f5..79649c61 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -8,11 +8,11 @@ import { UserIdleService } from 'angular-user-idle'; import * as sha256 from 'sha256'; import { LoggerService } from './shared/services/logger.service'; -import { RTLConfiguration, Settings, Node } from './shared/models/RTLconfig'; +import { RTLConfiguration, Settings, LightningNode } from './shared/models/RTLconfig'; import { GetInfo } from './shared/models/lndModels'; -import * as RTLActions from './shared/store/rtl.actions'; -import * as fromRTLReducer from './shared/store/rtl.reducers'; +import * as RTLActions from './store/rtl.actions'; +import * as fromRTLReducer from './store/rtl.reducers'; @Component({ selector: 'rtl-app', @@ -22,7 +22,7 @@ import * as fromRTLReducer from './shared/store/rtl.reducers'; export class AppComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild('sideNavigation', { static: false }) sideNavigation: any; @ViewChild('settingSidenav', { static: true }) settingSidenav: any; - public selNode: Node; + public selNode: LightningNode; public settings: Settings; public information: GetInfo = {}; public flgLoading: Array = [true]; // 0: Info @@ -32,13 +32,13 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { public smallScreen = false; unsubs: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private actions$: Actions, + constructor(private logger: LoggerService, private store: Store, private actions$: Actions, private userIdle: UserIdleService, private router: Router, private activatedRoute: ActivatedRoute) {} ngOnInit() { this.store.dispatch(new RTLActions.FetchRTLConfig()); this.accessKey = this.readAccessKey(); - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsubs[0])) .subscribe(rtlStore => { this.selNode = rtlStore.selNode; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c643e637..4da847a8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,13 +23,14 @@ import { ThemeOverlay } from './shared/theme/overlay-container/theme-overlay'; import { AppComponent } from './app.component'; import { environment } from '../environments/environment'; -import { RTLRootReducer } from './shared/store/rtl.reducers'; -import { RTLEffects } from './shared/store/rtl.effects'; import { CommonService } from './shared/services/common.service'; import { LoggerService, ConsoleLoggerService } from './shared/services/logger.service'; import { AuthGuard } from './shared/services/auth.guard'; import { AuthInterceptor } from './shared/services/auth.interceptor'; +import { RTLReducer } from './store/rtl.reducers'; +import { RTLEffects } from './store/rtl.effects'; + @NgModule({ imports: [ BrowserModule, @@ -38,7 +39,7 @@ import { AuthInterceptor } from './shared/services/auth.interceptor'; PerfectScrollbarModule, routing, UserIdleModule.forRoot({idle: 60 * 60, timeout: 1, ping: null}), - StoreModule.forRoot({rtlRoot: RTLRootReducer}), + StoreModule.forRoot({rtl: RTLReducer}), EffectsModule.forRoot([RTLEffects]), !environment.production ? StoreDevtoolsModule.instrument() : [] ], diff --git a/src/app/clightning/cl-root.component.ts b/src/app/clightning/cl-root.component.ts index 0de9a988..3cc6af25 100644 --- a/src/app/clightning/cl-root.component.ts +++ b/src/app/clightning/cl-root.component.ts @@ -5,8 +5,8 @@ import { takeUntil, filter } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { Actions } from '@ngrx/effects'; -import * as RTLActions from '../shared/store/rtl.actions'; -import * as fromRTLReducer from '../shared/store/rtl.reducers'; +import * as RTLActions from '../store/rtl.actions'; +import * as fromRTLReducer from '../store/rtl.reducers'; @Component({ selector: 'rtl-cl-root', @@ -17,25 +17,26 @@ export class CLRootComponent implements OnInit, OnDestroy { unsubs: Array> = [new Subject(), new Subject()]; - constructor(private store: Store, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {} + constructor(private store: Store, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {} ngOnInit() { console.warn('CL ROOT') - this.store.dispatch(new RTLActions.FetchInfo()); this.router.navigate(['./home'], {relativeTo: this.activatedRoute}); - this.actions$.pipe(takeUntil(this.unsubs[0]), filter((action) => action.type === RTLActions.SET_INFO || action.type === RTLActions.INIT_APP_DATA)) - .subscribe((infoData: RTLActions.SetInfo | RTLActions.InitAppData) => { - if(infoData.type === RTLActions.SET_INFO && undefined !== infoData.payload.identity_pubkey) { - this.initializeRemainingData(); - } - if(infoData.type === RTLActions.INIT_APP_DATA) { - this.store.dispatch(new RTLActions.FetchInfo()); - } - }); + this.initializeRemainingData(); + // this.store.dispatch(new RTLActions.FetchCLInfo()); + // this.actions$.pipe(takeUntil(this.unsubs[0]), filter((action) => action.type === RTLActions.SET_CL_INFO || action.type === RTLActions.INIT_APP_DATA)) + // .subscribe((infoData: RTLActions.SetCLInfo | RTLActions.InitAppData) => { + // if(infoData.type === RTLActions.SET_CL_INFO && undefined !== infoData.payload.identity_pubkey) { + // this.initializeRemainingData(); + // } + // if(infoData.type === RTLActions.INIT_APP_DATA) { + // this.store.dispatch(new RTLActions.FetchCLInfo()); + // } + // }); } initializeRemainingData() { - this.store.dispatch(new RTLActions.FetchFees()); + this.store.dispatch(new RTLActions.FetchCLFees()); // this.store.dispatch(new RTLActions.FetchPeers()); // this.store.dispatch(new RTLActions.FetchBalance('channels')); // this.store.dispatch(new RTLActions.FetchNetwork()); diff --git a/src/app/clightning/home/home.component.ts b/src/app/clightning/home/home.component.ts index be1f3f33..82b42c74 100644 --- a/src/app/clightning/home/home.component.ts +++ b/src/app/clightning/home/home.component.ts @@ -5,9 +5,9 @@ import { Store } from '@ngrx/store'; import { LoggerService } from '../../shared/services/logger.service'; import { GetInfo, Fees } from '../../shared/models/lndModels'; -import { Node } from '../../shared/models/RTLconfig'; +import { LightningNode } from '../../shared/models/RTLconfig'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import * as fromRTLReducer from '../../store/rtl.reducers'; @Component({ selector: 'rtl-cl-home', @@ -15,18 +15,18 @@ import * as fromRTLReducer from '../../shared/store/rtl.reducers'; styleUrls: ['./home.component.scss'] }) export class CLHomeComponent implements OnInit, OnDestroy { - public selNode: Node; + public selNode: LightningNode; public fees: Fees; public information: GetInfo = {}; public flgLoading: Array = [true, true, true, true, true, true, true, true]; // 0: Info, 1: Fee, 2: Wallet, 3: Channel, 4: Network private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store) {} + constructor(private logger: LoggerService, private store: Store) {} ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchInfo') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/channels/channel-backup/channel-backup.component.ts b/src/app/lnd/channels/channel-backup/channel-backup.component.ts index 529e2d10..af0d30bc 100644 --- a/src/app/lnd/channels/channel-backup/channel-backup.component.ts +++ b/src/app/lnd/channels/channel-backup/channel-backup.component.ts @@ -7,13 +7,13 @@ import { Store } from '@ngrx/store'; import { Actions } from '@ngrx/effects'; import { MatTableDataSource, MatSort } from '@angular/material'; -import { Node } from '../../../shared/models/RTLconfig'; +import { LightningNode } from '../../../shared/models/RTLconfig'; import { Channel } from '../../../shared/models/lndModels'; import { LoggerService } from '../../../shared/services/logger.service'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-channel-backup', @@ -22,7 +22,7 @@ import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; }) export class ChannelBackupComponent implements OnInit, OnDestroy { @ViewChild(MatSort, { static: true }) sort: MatSort; - public selNode: Node; + public selNode: LightningNode; public displayedColumns = ['chan_id', 'backup', 'verify']; public selChannel: Channel; public channels: any; @@ -30,12 +30,12 @@ export class ChannelBackupComponent implements OnInit, OnDestroy { public flgSticky = false; private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions, private router: Router) {} + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions, private router: Router) {} ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { this.selNode = rtlStore.selNode; rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'Fetchchannels') { diff --git a/src/app/lnd/channels/channel-closed/channel-closed.component.ts b/src/app/lnd/channels/channel-closed/channel-closed.component.ts index 898bc50a..bcccee42 100644 --- a/src/app/lnd/channels/channel-closed/channel-closed.component.ts +++ b/src/app/lnd/channels/channel-closed/channel-closed.component.ts @@ -8,9 +8,9 @@ import { MatTableDataSource, MatSort } from '@angular/material'; import { ClosedChannel } from '../../../shared/models/lndModels'; import { LoggerService } from '../../../shared/services/logger.service'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-channel-closed', @@ -26,7 +26,7 @@ export class ChannelClosedComponent implements OnInit, OnDestroy { public flgSticky = false; private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['close_type', 'chan_id', 'settled_balance']; @@ -55,9 +55,9 @@ export class ChannelClosedComponent implements OnInit, OnDestroy { this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => { this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'closed'})); }); - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchChannels/closed') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/channels/channel-manage/channel-manage.component.ts b/src/app/lnd/channels/channel-manage/channel-manage.component.ts index 9bb8a7a8..09bcf427 100644 --- a/src/app/lnd/channels/channel-manage/channel-manage.component.ts +++ b/src/app/lnd/channels/channel-manage/channel-manage.component.ts @@ -10,9 +10,9 @@ import { MatTableDataSource, MatSort } from '@angular/material'; import { Channel, Peer, GetInfo } from '../../../shared/models/lndModels'; import { LoggerService } from '../../../shared/services/logger.service'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-channel-manage', @@ -42,7 +42,7 @@ export class ChannelManageComponent implements OnInit, OnDestroy { public redirectedWithPeer = false; private unsub: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private activatedRoute: ActivatedRoute) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private activatedRoute: ActivatedRoute) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['close', 'update', 'active', 'chan_id', 'remote_alias']; @@ -67,9 +67,9 @@ export class ChannelManageComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchChannels/all') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/channels/channel-pending/channel-pending.component.ts b/src/app/lnd/channels/channel-pending/channel-pending.component.ts index 7df35b98..4e841ebb 100644 --- a/src/app/lnd/channels/channel-pending/channel-pending.component.ts +++ b/src/app/lnd/channels/channel-pending/channel-pending.component.ts @@ -5,12 +5,12 @@ import { Store } from '@ngrx/store'; import { MatTableDataSource, MatSort } from '@angular/material'; import { Channel, GetInfo, PendingChannels } from '../../../shared/models/lndModels'; -import { Node } from '../../../shared/models/RTLconfig'; +import { LightningNode } from '../../../shared/models/RTLconfig'; import { LoggerService } from '../../../shared/services/logger.service'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-channel-pending', @@ -19,7 +19,7 @@ import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; }) export class ChannelPendingComponent implements OnInit, OnDestroy { @ViewChild(MatSort, { static: true }) sort: MatSort; - public selNode: Node; + public selNode: LightningNode; public selectedFilter = 0; public information: GetInfo = {}; public pendingChannels: PendingChannels = {}; @@ -50,7 +50,7 @@ export class ChannelPendingComponent implements OnInit, OnDestroy { public flgLoading: Array = [true]; private unsub: Array> = [new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) { switch (true) { case (window.innerWidth <= 415): this.displayedClosingColumns = ['remote_node_pub', 'local_balance', 'remote_balance']; @@ -96,9 +96,9 @@ export class ChannelPendingComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchChannels/pending') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/home/home.component.ts b/src/app/lnd/home/home.component.ts index 72c93602..684223ca 100644 --- a/src/app/lnd/home/home.component.ts +++ b/src/app/lnd/home/home.component.ts @@ -5,9 +5,9 @@ import { Store } from '@ngrx/store'; import { LoggerService } from '../../shared/services/logger.service'; import { GetInfo, NetworkInfo, Fees, Peer } from '../../shared/models/lndModels'; -import { Node } from '../../shared/models/RTLconfig'; +import { LightningNode } from '../../shared/models/RTLconfig'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import * as fromRTLReducer from '../../store/rtl.reducers'; @Component({ selector: 'rtl-home', @@ -15,7 +15,7 @@ import * as fromRTLReducer from '../../shared/store/rtl.reducers'; styleUrls: ['./home.component.scss'] }) export class HomeComponent implements OnInit, OnDestroy { - public selNode: Node; + public selNode: LightningNode; public fees: Fees; public information: GetInfo = {}; public remainder = 0; @@ -41,7 +41,7 @@ export class HomeComponent implements OnInit, OnDestroy { yAxisLabel = 'Balance'; colorScheme = {domain: ['#FFFFFF']}; - constructor(private logger: LoggerService, private store: Store) { + constructor(private logger: LoggerService, private store: Store) { switch (true) { case (window.innerWidth <= 730): this.view = [250, 352]; @@ -64,9 +64,9 @@ export class HomeComponent implements OnInit, OnDestroy { ngOnInit() { this.flgTotalCalculated = false; - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchInfo') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/invoices/invoices.component.ts b/src/app/lnd/invoices/invoices.component.ts index a5037b65..5645ef4f 100644 --- a/src/app/lnd/invoices/invoices.component.ts +++ b/src/app/lnd/invoices/invoices.component.ts @@ -6,13 +6,13 @@ import { Store } from '@ngrx/store'; import { Actions } from '@ngrx/effects'; import { MatTableDataSource, MatSort } from '@angular/material'; -import { Node } from '../../shared/models/RTLconfig'; +import { LightningNode } from '../../shared/models/RTLconfig'; import { GetInfo, Invoice } from '../../shared/models/lndModels'; import { LoggerService } from '../../shared/services/logger.service'; import { newlyAddedRowAnimation } from '../../shared/animation/row-animation'; -import * as RTLActions from '../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import * as RTLActions from '../../store/rtl.actions'; +import * as fromRTLReducer from '../../store/rtl.reducers'; @Component({ selector: 'rtl-invoices', @@ -22,7 +22,7 @@ import * as fromRTLReducer from '../../shared/store/rtl.reducers'; }) export class InvoicesComponent implements OnInit, OnDestroy { @ViewChild(MatSort, { static: true }) sort: MatSort; - public selNode: Node; + public selNode: LightningNode; public newlyAddedInvoiceMemo = ''; public newlyAddedInvoiceValue = 0; public flgAnimate = true; @@ -43,7 +43,7 @@ export class InvoicesComponent implements OnInit, OnDestroy { private lastOffset = -1; private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private actions$: Actions) { + constructor(private logger: LoggerService, private store: Store, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['settled', 'creation_date', 'memo', 'value']; @@ -66,9 +66,9 @@ export class InvoicesComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchInvoices') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/lnd-root.component.ts b/src/app/lnd/lnd-root.component.ts index e2a14a70..b9c400db 100644 --- a/src/app/lnd/lnd-root.component.ts +++ b/src/app/lnd/lnd-root.component.ts @@ -5,8 +5,8 @@ import { takeUntil, filter } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { Actions } from '@ngrx/effects'; -import * as RTLActions from '../shared/store/rtl.actions'; -import * as fromRTLReducer from '../shared/store/rtl.reducers'; +import * as RTLActions from '../store/rtl.actions'; +import * as fromRTLReducer from '../store/rtl.reducers'; @Component({ selector: 'rtl-lnd-root', @@ -16,7 +16,7 @@ import * as fromRTLReducer from '../shared/store/rtl.reducers'; export class LNDRootComponent implements OnInit, OnDestroy { unsubs: Array> = [new Subject(), new Subject()]; - constructor(private store: Store, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {} + constructor(private store: Store, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {} ngOnInit() { console.warn('LND ROOT') diff --git a/src/app/lnd/lookups/channel-lookup/channel-lookup.component.ts b/src/app/lnd/lookups/channel-lookup/channel-lookup.component.ts index 8e39ff24..f8b9b9aa 100644 --- a/src/app/lnd/lookups/channel-lookup/channel-lookup.component.ts +++ b/src/app/lnd/lookups/channel-lookup/channel-lookup.component.ts @@ -5,7 +5,7 @@ import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { ChannelEdge } from '../../../shared/models/lndModels'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-channel-lookup', @@ -18,16 +18,16 @@ export class ChannelLookupComponent implements OnInit { public node2_match = false; private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private store: Store) { } + constructor(private store: Store) { } ngOnInit() { if (undefined !== this.lookupResult && undefined !== this.lookupResult.last_update_str) { this.lookupResult.last_update_str = (this.lookupResult.last_update_str === '') ? '' : formatDate(this.lookupResult.last_update_str, 'MMM/dd/yy HH:mm:ss', 'en-US'); } - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { if (this.lookupResult.node1_pub === rtlStore.information.identity_pubkey) { this.node1_match = true; } diff --git a/src/app/lnd/lookups/lookups.component.ts b/src/app/lnd/lookups/lookups.component.ts index 79ae3cd9..641d38fc 100644 --- a/src/app/lnd/lookups/lookups.component.ts +++ b/src/app/lnd/lookups/lookups.component.ts @@ -6,8 +6,8 @@ import { Actions } from '@ngrx/effects'; import { LoggerService } from '../../shared/services/logger.service'; -import * as RTLActions from '../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import * as RTLActions from '../../store/rtl.actions'; +import * as fromRTLReducer from '../../store/rtl.reducers'; @Component({ selector: 'rtl-lookups', @@ -28,7 +28,7 @@ export class LookupsComponent implements OnInit, OnDestroy { public flgLoading: Array = [true]; private unSubs: Array> = [new Subject()]; - constructor(private logger: LoggerService, private store: Store, private actions$: Actions) {} + constructor(private logger: LoggerService, private store: Store, private actions$: Actions) {} ngOnInit() { this.actions$ diff --git a/src/app/lnd/payments/query-routes/query-routes.component.ts b/src/app/lnd/payments/query-routes/query-routes.component.ts index 8ec09760..93ff81cb 100644 --- a/src/app/lnd/payments/query-routes/query-routes.component.ts +++ b/src/app/lnd/payments/query-routes/query-routes.component.ts @@ -9,9 +9,9 @@ import { MatTableDataSource, MatSort } from '@angular/material'; import { Hop } from '../../../shared/models/lndModels'; import { LoggerService } from '../../../shared/services/logger.service'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-query-routes', @@ -28,7 +28,7 @@ export class QueryRoutesComponent implements OnInit, OnDestroy { public flgLoading: Array = [false]; // 0: peers private unSubs: Array> = [new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['hop_sequence', 'pubkey_alias', 'fee_msat']; @@ -51,11 +51,6 @@ export class QueryRoutesComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select('rtlRoot') - .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { - this.logger.info(rtlStore); - }); this.rtlEffects.setQueryRoutes .pipe(takeUntil(this.unSubs[1])) .subscribe(queryRoute => { diff --git a/src/app/lnd/payments/send-receive/payments.component.ts b/src/app/lnd/payments/send-receive/payments.component.ts index e35af829..dec55b9b 100644 --- a/src/app/lnd/payments/send-receive/payments.component.ts +++ b/src/app/lnd/payments/send-receive/payments.component.ts @@ -5,14 +5,14 @@ import { takeUntil, take } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { MatTableDataSource, MatSort } from '@angular/material'; -import { Node } from '../../../shared/models/RTLconfig'; +import { LightningNode } from '../../../shared/models/RTLconfig'; import { GetInfo, Payment, PayRequest } from '../../../shared/models/lndModels'; import { LoggerService } from '../../../shared/services/logger.service'; import { newlyAddedRowAnimation } from '../../../shared/animation/row-animation'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-payments', @@ -23,7 +23,7 @@ import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; export class PaymentsComponent implements OnInit, OnDestroy { @ViewChild(MatSort, { static: true }) sort: MatSort; @ViewChild('sendPaymentForm', { static: true }) form; - public selNode: Node; + public selNode: LightningNode; public newlyAddedPayment = ''; public flgAnimate = true; public flgLoading: Array = [true]; @@ -36,7 +36,7 @@ export class PaymentsComponent implements OnInit, OnDestroy { public flgSticky = false; private unsub: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['creation_date', 'fee', 'value']; @@ -59,9 +59,9 @@ export class PaymentsComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchPayments') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/peers/peers.component.ts b/src/app/lnd/peers/peers.component.ts index 3eeaed1b..5b40ba77 100644 --- a/src/app/lnd/peers/peers.component.ts +++ b/src/app/lnd/peers/peers.component.ts @@ -11,9 +11,9 @@ import { Peer, GetInfo } from '../../shared/models/lndModels'; import { LoggerService } from '../../shared/services/logger.service'; import { newlyAddedRowAnimation } from '../../shared/animation/row-animation'; -import { RTLEffects } from '../../shared/store/rtl.effects'; -import * as RTLActions from '../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../store/rtl.effects'; +import * as RTLActions from '../../store/rtl.actions'; +import * as fromRTLReducer from '../../store/rtl.reducers'; @Component({ selector: 'rtl-peers', @@ -33,7 +33,7 @@ export class PeersComponent implements OnInit, OnDestroy { public flgSticky = false; private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions, private router: Router) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions, private router: Router) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['detach', 'pub_key', 'alias']; @@ -56,9 +56,9 @@ export class PeersComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchPeers') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/routing-peers/routing-peers.component.ts b/src/app/lnd/routing-peers/routing-peers.component.ts index 2bef613a..573c2bd1 100644 --- a/src/app/lnd/routing-peers/routing-peers.component.ts +++ b/src/app/lnd/routing-peers/routing-peers.component.ts @@ -9,8 +9,8 @@ import { ForwardingEvent, RoutingPeers } from '../../shared/models/lndModels'; import { LoggerService } from '../../shared/services/logger.service'; import { CommonService } from '../../shared/services/common.service'; -import * as RTLActions from '../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import * as RTLActions from '../../store/rtl.actions'; +import * as fromRTLReducer from '../../store/rtl.reducers'; @Component({ selector: 'rtl-routing-peers', @@ -35,7 +35,7 @@ export class RoutingPeersComponent implements OnInit, OnDestroy { public flgSticky = false; private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private commonService: CommonService, private store: Store, private actions$: Actions) { + constructor(private logger: LoggerService, private commonService: CommonService, private store: Store, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['chan_id', 'events', 'total_amount']; @@ -62,9 +62,9 @@ export class RoutingPeersComponent implements OnInit, OnDestroy { this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => { this.onRoutingPeersFetch(); }); - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'GetForwardingHistory') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/switch/forwarding-history.component.ts b/src/app/lnd/switch/forwarding-history.component.ts index e6ac9d60..c862ffa2 100644 --- a/src/app/lnd/switch/forwarding-history.component.ts +++ b/src/app/lnd/switch/forwarding-history.component.ts @@ -9,8 +9,8 @@ import { MatTableDataSource, MatSort } from '@angular/material'; import { ForwardingEvent } from '../../shared/models/lndModels'; import { LoggerService } from '../../shared/services/logger.service'; -import * as RTLActions from '../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import * as RTLActions from '../../store/rtl.actions'; +import * as fromRTLReducer from '../../store/rtl.reducers'; @Component({ selector: 'rtl-forwarding-history', @@ -30,7 +30,7 @@ export class ForwardingHistoryComponent implements OnInit, OnDestroy { public flgSticky = false; private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private actions$: Actions) { + constructor(private logger: LoggerService, private store: Store, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['timestamp', 'amt_out', 'amt_in']; @@ -58,9 +58,9 @@ export class ForwardingHistoryComponent implements OnInit, OnDestroy { this.onForwardingHistoryFetch(); }); - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'GetForwardingHistory') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/transactions/list-transactions/list-transactions.component.ts b/src/app/lnd/transactions/list-transactions/list-transactions.component.ts index b26a9215..1273fd92 100644 --- a/src/app/lnd/transactions/list-transactions/list-transactions.component.ts +++ b/src/app/lnd/transactions/list-transactions/list-transactions.component.ts @@ -9,9 +9,9 @@ import { MatTableDataSource, MatSort } from '@angular/material'; import { Transaction } from '../../../shared/models/lndModels'; import { LoggerService } from '../../../shared/services/logger.service'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-list-transactions', @@ -26,7 +26,7 @@ export class ListTransactionsComponent implements OnInit, OnDestroy { public flgSticky = false; private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['dest_addresses', 'total_fees', 'amount']; @@ -54,9 +54,9 @@ export class ListTransactionsComponent implements OnInit, OnDestroy { this.store.dispatch(new RTLActions.FetchTransactions()); }); - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchTransactions') { this.flgLoading[0] = 'error'; diff --git a/src/app/lnd/transactions/send-receive/send-receive-trans.component.ts b/src/app/lnd/transactions/send-receive/send-receive-trans.component.ts index 96b2236b..a7278e86 100644 --- a/src/app/lnd/transactions/send-receive/send-receive-trans.component.ts +++ b/src/app/lnd/transactions/send-receive/send-receive-trans.component.ts @@ -3,15 +3,15 @@ import { Subject } from 'rxjs'; import { takeUntil, take } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { Node } from '../../../shared/models/RTLconfig'; +import { LightningNode } from '../../../shared/models/RTLconfig'; import { GetInfo, Balance, ChannelsTransaction, AddressType } from '../../../shared/models/lndModels'; import { RTLConfiguration } from '../../../shared/models/RTLconfig'; import { LoggerService } from '../../../shared/services/logger.service'; import * as sha256 from 'sha256'; -import { RTLEffects } from '../../../shared/store/rtl.effects'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-send-receive-trans', @@ -19,7 +19,7 @@ import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; styleUrls: ['./send-receive-trans.component.scss'] }) export class SendReceiveTransComponent implements OnInit, OnDestroy { - public selNode: Node; + public selNode: LightningNode; public appConfig: RTLConfiguration; public addressTypes = []; public flgLoadingWallet: Boolean | 'error' = true; @@ -33,12 +33,12 @@ export class SendReceiveTransComponent implements OnInit, OnDestroy { public flgCustomAmount = '1'; private unsub: Array> = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) {} + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) {} ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'FetchBalance/blockchain') { this.flgLoadingWallet = 'error'; diff --git a/src/app/lnd/unlock-lnd/unlock-lnd.component.ts b/src/app/lnd/unlock-lnd/unlock-lnd.component.ts index b3276d23..a94d0e4e 100644 --- a/src/app/lnd/unlock-lnd/unlock-lnd.component.ts +++ b/src/app/lnd/unlock-lnd/unlock-lnd.component.ts @@ -7,9 +7,9 @@ import { FormBuilder, FormGroup, Validators, ValidatorFn, AbstractControl, Valid import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; import { MatStepper } from '@angular/material'; -import { RTLEffects } from '../../shared/store/rtl.effects'; -import * as RTLActions from '../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../shared/store/rtl.reducers'; +import { RTLEffects } from '../../store/rtl.effects'; +import * as RTLActions from '../../store/rtl.actions'; +import * as fromRTLReducer from '../../store/rtl.reducers'; export const matchedPasswords: ValidatorFn = (control: FormGroup): ValidationErrors | null => { const initWalletPassword = control.get('initWalletPassword'); @@ -46,7 +46,7 @@ export class UnlockLNDComponent implements OnInit, OnDestroy { warnRes = true; private unsubs = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject()]; - constructor(private store: Store, private formBuilder: FormBuilder, private rtlEffects: RTLEffects, private router: Router) {} + constructor(private store: Store, private formBuilder: FormBuilder, private rtlEffects: RTLEffects, private router: Router) {} ngOnInit() { this.walletPassword = ''; diff --git a/src/app/shared/components/confirmation-message/confirmation-message.component.ts b/src/app/shared/components/confirmation-message/confirmation-message.component.ts index f6a3e5f1..3571019d 100644 --- a/src/app/shared/components/confirmation-message/confirmation-message.component.ts +++ b/src/app/shared/components/confirmation-message/confirmation-message.component.ts @@ -5,8 +5,8 @@ import { Store } from '@ngrx/store'; import { LoggerService } from '../../../shared/services/logger.service'; import { AlertData, InputData } from '../../../shared/models/alertData'; -import * as RTLActions from '../../../shared/store/rtl.actions'; -import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-confirmation-message', @@ -24,7 +24,7 @@ export class ConfirmationMessageComponent implements OnInit { public getInputs: Array = [{placeholder: '', inputType: 'text', inputValue: ''}]; constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: AlertData, private logger: LoggerService, - private store: Store) { } + private store: Store) { } ngOnInit() { this.flgShowInput = this.data.flgShowInput; diff --git a/src/app/shared/components/navigation/horizontal-navigation/horizontal-navigation.component.ts b/src/app/shared/components/navigation/horizontal-navigation/horizontal-navigation.component.ts index 32d5bf04..dbef0628 100644 --- a/src/app/shared/components/navigation/horizontal-navigation/horizontal-navigation.component.ts +++ b/src/app/shared/components/navigation/horizontal-navigation/horizontal-navigation.component.ts @@ -7,9 +7,9 @@ import { Actions } from '@ngrx/effects'; import { LoggerService } from '../../../services/logger.service'; import { MENU_DATA } from '../../../models/navMenu'; -import { RTLEffects } from '../../../store/rtl.effects'; -import * as RTLActions from '../../../store/rtl.actions'; -import * as fromRTLReducer from '../../../store/rtl.reducers'; +import { RTLEffects } from '../../../../store/rtl.effects'; +import * as RTLActions from '../../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../../store/rtl.reducers'; @Component({ selector: 'rtl-horizontal-navigation', @@ -23,13 +23,13 @@ export class HorizontalNavigationComponent implements OnInit { public numPendingChannels = 0; private unSubs = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private actions$: Actions, private rtlEffects: RTLEffects) { + constructor(private logger: LoggerService, private store: Store, private actions$: Actions, private rtlEffects: RTLEffects) { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { this.numPendingChannels = rtlStore.numberOfPendingChannels; if(rtlStore.selNode.lnImplementation.toLowerCase() === 'clightning') { this.menuNodes = MENU_DATA.CLChildren; diff --git a/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts b/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts index cffc2105..15a4ee86 100644 --- a/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts +++ b/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts @@ -9,14 +9,14 @@ import { environment } from '../../../../../environments/environment'; import { FlatTreeControl } from '@angular/cdk/tree'; import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; -import { Node, Settings } from '../../../models/RTLconfig'; +import { LightningNode, Settings } from '../../../models/RTLconfig'; import { LoggerService } from '../../../services/logger.service'; import { GetInfo, GetInfoChain } from '../../../models/lndModels'; import { MenuChildNode, FlatMenuNode, MENU_DATA } from '../../../models/navMenu'; -import { RTLEffects } from '../../../store/rtl.effects'; -import * as RTLActions from '../../../store/rtl.actions'; -import * as fromRTLReducer from '../../../store/rtl.reducers'; +import { RTLEffects } from '../../../../store/rtl.effects'; +import * as RTLActions from '../../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../../store/rtl.reducers'; @Component({ selector: 'rtl-side-navigation', @@ -25,7 +25,7 @@ import * as fromRTLReducer from '../../../store/rtl.reducers'; }) export class SideNavigationComponent implements OnInit, OnDestroy { @Output() ChildNavClicked = new EventEmitter(); - public selNode: Node; + public selNode: LightningNode; public settings: Settings; public version = ''; public information: GetInfo = {}; @@ -44,7 +44,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy { navMenus: MatTreeFlatDataSource; navMenusLogout: MatTreeFlatDataSource; - constructor(private logger: LoggerService, private store: Store, private actions$: Actions, private rtlEffects: RTLEffects, private router: Router, private activatedRoute: ActivatedRoute) { + constructor(private logger: LoggerService, private store: Store, private actions$: Actions, private rtlEffects: RTLEffects, private router: Router, private activatedRoute: ActivatedRoute) { this.version = environment.VERSION; if (MENU_DATA.LNDChildren[MENU_DATA.LNDChildren.length - 1].id === 200) { MENU_DATA.LNDChildren.pop(); @@ -61,7 +61,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unSubs[0])) .subscribe(rtlStore => { this.selNode = rtlStore.selNode; diff --git a/src/app/shared/components/navigation/top-menu/top-menu.component.ts b/src/app/shared/components/navigation/top-menu/top-menu.component.ts index 52dcafc1..879b6d11 100644 --- a/src/app/shared/components/navigation/top-menu/top-menu.component.ts +++ b/src/app/shared/components/navigation/top-menu/top-menu.component.ts @@ -4,14 +4,14 @@ import { takeUntil, filter } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { Actions } from '@ngrx/effects'; -import { Node } from '../../../models/RTLconfig'; +import { LightningNode } from '../../../models/RTLconfig'; import { LoggerService } from '../../../services/logger.service'; import { GetInfo, GetInfoChain } from '../../../models/lndModels'; import { environment } from '../../../../../environments/environment'; -import { RTLEffects } from '../../../store/rtl.effects'; -import * as fromRTLReducer from '../../../store/rtl.reducers'; -import * as RTLActions from '../../../store/rtl.actions'; +import { RTLEffects } from '../../../../store/rtl.effects'; +import * as fromRTLReducer from '../../../../store/rtl.reducers'; +import * as RTLActions from '../../../../store/rtl.actions'; @Component({ selector: 'rtl-top-menu', @@ -19,7 +19,7 @@ import * as RTLActions from '../../../store/rtl.actions'; styleUrls: ['./top-menu.component.scss'] }) export class TopMenuComponent implements OnInit, OnDestroy { - public selNode: Node; + public selNode: LightningNode; public version = ''; public information: GetInfo = {}; public informationChain: GetInfoChain = {}; @@ -27,14 +27,14 @@ export class TopMenuComponent implements OnInit, OnDestroy { public showLogout = false; private unSubs = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { this.version = environment.VERSION; } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { this.selNode = rtlStore.selNode; this.information = rtlStore.information; diff --git a/src/app/shared/components/server-config/server-config.component.ts b/src/app/shared/components/server-config/server-config.component.ts index 479aa6e0..7255445d 100644 --- a/src/app/shared/components/server-config/server-config.component.ts +++ b/src/app/shared/components/server-config/server-config.component.ts @@ -3,10 +3,10 @@ import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { Node } from '../../models/RTLconfig'; -import { RTLEffects } from '../../store/rtl.effects'; -import * as RTLActions from '../../store/rtl.actions'; -import * as fromRTLReducer from '../../store/rtl.reducers'; +import { LightningNode } from '../../models/RTLconfig'; +import { RTLEffects } from '../../../store/rtl.effects'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-server-config', @@ -14,7 +14,7 @@ import * as fromRTLReducer from '../../store/rtl.reducers'; styleUrls: ['./server-config.component.scss'] }) export class ServerConfigComponent implements OnInit, OnDestroy { - public selNode: Node; + public selNode: LightningNode; public selectedNodeType = 'rtl'; public showLND = false; public showBitcoind = false; @@ -22,12 +22,12 @@ export class ServerConfigComponent implements OnInit, OnDestroy { public fileFormat = 'INI'; private unsubs: Array> = [new Subject(), new Subject()]; - constructor(private store: Store, private rtlEffects: RTLEffects) {} + constructor(private store: Store, private rtlEffects: RTLEffects) {} ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { if (effectsErr.action === 'fetchConfig') { this.resetData(); diff --git a/src/app/shared/components/settings-nav/settings-nav.component.ts b/src/app/shared/components/settings-nav/settings-nav.component.ts index 4cfb58a5..779c38e8 100644 --- a/src/app/shared/components/settings-nav/settings-nav.component.ts +++ b/src/app/shared/components/settings-nav/settings-nav.component.ts @@ -3,12 +3,12 @@ import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { Node, RTLConfiguration } from '../../models/RTLconfig'; +import { LightningNode, RTLConfiguration } from '../../models/RTLconfig'; import { GetInfo } from '../../models/lndModels'; import { LoggerService } from '../../services/logger.service'; -import * as RTLActions from '../../store/rtl.actions'; -import * as fromRTLReducer from '../../store/rtl.reducers'; +import * as RTLActions from '../../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; @Component({ selector: 'rtl-settings-nav', @@ -16,7 +16,7 @@ import * as fromRTLReducer from '../../store/rtl.reducers'; styleUrls: ['./settings-nav.component.scss'] }) export class SettingsNavComponent implements OnInit, OnDestroy { - public selNode: Node; + public selNode: LightningNode; public information: GetInfo = {}; public menus = ['Vertical', 'Horizontal']; public menuTypes = ['Regular', 'Compact', 'Mini']; @@ -29,12 +29,12 @@ export class SettingsNavComponent implements OnInit, OnDestroy { unsubs: Array> = [new Subject(), new Subject()]; @Output('done') done: EventEmitter = new EventEmitter(); - constructor(private logger: LoggerService, private store: Store) {} + constructor(private logger: LoggerService, private store: Store) {} ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { this.appConfig = rtlStore.appConfig; this.selNode = rtlStore.selNode; this.selectedMenu = this.selNode.settings.menu; @@ -73,7 +73,7 @@ export class SettingsNavComponent implements OnInit, OnDestroy { this.done.emit(); } - onSelectionChange(selNodeValue: Node) { + onSelectionChange(selNodeValue: LightningNode) { this.selNode = selNodeValue; this.store.dispatch(new RTLActions.OpenSpinner('Updating Selected Node...')); this.store.dispatch(new RTLActions.SetSelelectedNode(selNodeValue)); diff --git a/src/app/shared/components/signin/signin.component.ts b/src/app/shared/components/signin/signin.component.ts index 70e81422..3860b2b0 100644 --- a/src/app/shared/components/signin/signin.component.ts +++ b/src/app/shared/components/signin/signin.component.ts @@ -4,10 +4,10 @@ import { takeUntil } from 'rxjs/operators'; import * as sha256 from 'sha256'; import { Store } from '@ngrx/store'; -import { Node } from '../../models/RTLconfig'; +import { LightningNode } from '../../models/RTLconfig'; import { LoggerService } from '../../services/logger.service'; -import * as fromRTLReducer from '../../store/rtl.reducers'; -import * as RTLActions from '../../store/rtl.actions'; +import * as fromRTLReducer from '../../../store/rtl.reducers'; +import * as RTLActions from '../../../store/rtl.actions'; @Component({ selector: 'rtl-signin', @@ -15,7 +15,7 @@ import * as RTLActions from '../../store/rtl.actions'; styleUrls: ['./signin.component.scss'] }) export class SigninComponent implements OnInit, OnDestroy { - public selNode: Node; + public selNode: LightningNode; public password = ''; public nodeAuthType = ''; public rtlSSO = 0; @@ -25,12 +25,12 @@ export class SigninComponent implements OnInit, OnDestroy { private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store) { } + constructor(private logger: LoggerService, private store: Store) { } ngOnInit() { - this.store.select('rtlRoot') + this.store.select('rtl') .pipe(takeUntil(this.unsub[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe((rtlStore) => { rtlStore.effectErrors.forEach(effectsErr => { this.logger.error(effectsErr); }); diff --git a/src/app/shared/models/RTLconfig.ts b/src/app/shared/models/RTLconfig.ts index 1de917fb..5e9d4e35 100644 --- a/src/app/shared/models/RTLconfig.ts +++ b/src/app/shared/models/RTLconfig.ts @@ -28,7 +28,7 @@ export class Authentication { ) { } } -export class Node { +export class LightningNode { constructor( public settings: Settings, public authentication: Authentication, @@ -42,6 +42,6 @@ export class RTLConfiguration { constructor( public selectedNodeIndex: number, public sso: SSO, - public nodes: Node[] + public nodes: LightningNode[] ) { } } diff --git a/src/app/shared/models/clModels.ts b/src/app/shared/models/clModels.ts new file mode 100644 index 00000000..2c8da088 --- /dev/null +++ b/src/app/shared/models/clModels.ts @@ -0,0 +1,52 @@ +// export interface GetInfoAddress { +// type?: string; +// address?: string; +// port?: number; +// } + +// export interface GetInfo { +// id?: string; +// alias?: string; +// color?: string; +// num_peers?: number; +// num_pending_channels?: number; +// num_active_channels?: number; +// num_inactive_channels?: number; +// address?: GetInfoAddress[]; +// binding?: GetInfoAddress[]; +// version?: string; +// blockheight?: number; +// network?: string; +// msatoshi_fees_collected?: number; +// fees_collected_msat?: string; +// } + +export interface GetInfoChain { + chain?: string; + network?: string; +} + +export interface GetInfoCL { + identity_pubkey?: string; + alias?: string; + num_pending_channels?: number; + num_active_channels?: number; + num_inactive_channels?: number; + num_peers?: number; + block_height?: number; + synced_to_chain?: boolean; + testnet?: boolean; + chains?: GetInfoChain[]; + version?: string; + currency_unit?: string; + smaller_currency_unit?: string; +} + +export interface FeesCL { + day_fee_sum?: number; + week_fee_sum?: number; + month_fee_sum?: number; + btc_day_fee_sum?: number; + btc_week_fee_sum?: number; + btc_month_fee_sum?: number; +} diff --git a/src/app/shared/models/lndModels.ts b/src/app/shared/models/lndModels.ts index 977958b5..4bd1c893 100644 --- a/src/app/shared/models/lndModels.ts +++ b/src/app/shared/models/lndModels.ts @@ -5,16 +5,16 @@ export interface AddressType { } export interface Balance { - btc_balance?: string; // For Channels Balance - balance?: string; // For Channels Balance - btc_pending_open_balance?: string; // For Channels Balance - pending_open_balance?: string; // For Channels Balance - btc_total_balance?: string; // For Blockchain Balance - total_balance?: string; // For Blockchain Balance - btc_confirmed_balance?: string; // For Blockchain Balance - confirmed_balance?: string; // For Blockchain Balance - btc_unconfirmed_balance?: string; // For Blockchain Balance - unconfirmed_balance?: string; // For Blockchain Balance + btc_balance?: string; + balance?: string; + btc_pending_open_balance?: string; + pending_open_balance?: string; + btc_total_balance?: string; + total_balance?: string; + btc_confirmed_balance?: string; + confirmed_balance?: string; + btc_unconfirmed_balance?: string; + unconfirmed_balance?: string; } export interface ChannelFeeReport { @@ -271,7 +271,7 @@ export interface PayRequest { export interface Peer { pub_key?: string; alias?: string; - address?: string; // host + address?: string; bytes_sent?: number; bytes_recv?: number; sat_sent?: string; diff --git a/src/app/shared/store/rtl.actions.ts b/src/app/store/rtl.actions.ts similarity index 94% rename from src/app/shared/store/rtl.actions.ts rename to src/app/store/rtl.actions.ts index f06c4e0d..2fb41f53 100644 --- a/src/app/shared/store/rtl.actions.ts +++ b/src/app/store/rtl.actions.ts @@ -1,11 +1,14 @@ +import { MatDialogConfig } from '@angular/material'; import { Action } from '@ngrx/store'; -import { RTLConfiguration, Settings, Node } from '../models/RTLconfig'; -import { ErrorPayload } from '../models/errorPayload'; + +import { GetInfoCL } from '../shared/models/clModels'; + +import { RTLConfiguration, Settings, LightningNode } from '../shared/models/RTLconfig'; +import { ErrorPayload } from '../shared/models/errorPayload'; import { GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, ListInvoices, Payment, GraphNode, AddressType, PayRequest, ChannelsTransaction, PendingChannels, ClosedChannel, Transaction, SwitchReq, SwitchRes, QueryRoutes -} from '../models/lndModels'; -import { MatDialogConfig } from '@angular/material'; +} from '../shared/models/lndModels'; export const RESET_STORE = 'RESET_STORE'; export const CLEAR_EFFECT_ERROR = 'CLEAR_EFFECT_ERROR'; @@ -86,6 +89,11 @@ export const SET_FORWARDING_HISTORY = 'SET_FORWARDING_HISTORY'; export const GET_QUERY_ROUTES = 'GET_QUERY_ROUTES'; export const SET_QUERY_ROUTES = 'SET_QUERY_ROUTES'; +export const FETCH_CL_INFO = 'FETCH_CL_INFO'; +export const SET_CL_INFO = 'SET_CL_INFO'; +export const FETCH_CL_FEES = 'FETCH_CL_FEES'; +export const SET_CL_FEES = 'SET_CL_FEES'; + export class ClearEffectError implements Action { readonly type = CLEAR_EFFECT_ERROR; constructor(public payload: string) {} // payload = errorAction @@ -126,7 +134,7 @@ export class CloseConfirmation implements Action { export class ResetStore implements Action { readonly type = RESET_STORE; - constructor(public payload: Node) {} + constructor(public payload: LightningNode) {} } export class FetchRTLConfig implements Action { @@ -145,7 +153,7 @@ export class SaveSettings implements Action { export class SetSelelectedNode implements Action { readonly type = SET_SELECTED_NODE; - constructor(public payload: Node) {} + constructor(public payload: LightningNode) {} } export class FetchInfo implements Action { @@ -456,6 +464,24 @@ export class InitAppData implements Action { readonly type = INIT_APP_DATA; } +export class FetchCLInfo implements Action { + readonly type = FETCH_CL_INFO; +} + +export class SetCLInfo implements Action { + readonly type = SET_CL_INFO; + constructor(public payload: GetInfoCL) {} +} + +export class FetchCLFees implements Action { + readonly type = FETCH_CL_FEES; +} + +export class SetCLFees implements Action { + readonly type = SET_CL_FEES; + constructor(public payload: {}) {} +} + export type RTLActions = ClearEffectError | EffectError | OpenSpinner | CloseSpinner | FetchRTLConfig | SetRTLConfig | SaveSettings | @@ -477,4 +503,5 @@ export type RTLActions = GetNewAddress | SetNewAddress | SetChannelTransaction | GenSeed | GenSeedResponse | InitWallet | InitWalletResponse | UnlockWallet | FetchConfig | ShowConfig | PeerLookup | ChannelLookup | InvoiceLookup | SetLookup | - IsAuthorized | IsAuthorizedRes | Signin | Signout | InitAppData; + IsAuthorized | IsAuthorizedRes | Signin | Signout | InitAppData | + FetchCLInfo | SetCLInfo | FetchCLFees | SetCLFees; diff --git a/src/app/shared/store/rtl.effects.ts b/src/app/store/rtl.effects.ts similarity index 94% rename from src/app/shared/store/rtl.effects.ts rename to src/app/store/rtl.effects.ts index 127bdcbc..301273fc 100644 --- a/src/app/shared/store/rtl.effects.ts +++ b/src/app/store/rtl.effects.ts @@ -1,5 +1,5 @@ import { Injectable, OnDestroy } from '@angular/core'; -import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Router } from '@angular/router'; import { Store } from '@ngrx/store'; import { Actions, Effect, ofType } from '@ngrx/effects'; @@ -8,14 +8,14 @@ import { map, mergeMap, catchError, take, withLatestFrom } from 'rxjs/operators' import { MatDialog } from '@angular/material'; -import { environment } from '../../../environments/environment'; -import { LoggerService } from '../services/logger.service'; -import { Settings } from '../models/RTLconfig'; -import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../models/lndModels'; +import { environment } from '../../environments/environment'; +import { LoggerService } from '../shared/services/logger.service'; +import { Settings } from '../shared/models/RTLconfig'; +import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../shared/models/lndModels'; -import { SpinnerDialogComponent } from '../components/spinner-dialog/spinner-dialog.component'; -import { AlertMessageComponent } from '../components/alert-message/alert-message.component'; -import { ConfirmationMessageComponent } from '../components/confirmation-message/confirmation-message.component'; +import { SpinnerDialogComponent } from '../shared/components/spinner-dialog/spinner-dialog.component'; +import { AlertMessageComponent } from '../shared/components/alert-message/alert-message.component'; +import { ConfirmationMessageComponent } from '../shared/components/confirmation-message/confirmation-message.component'; import * as RTLActions from './rtl.actions'; import * as fromRTLReducer from './rtl.reducers'; @@ -28,7 +28,7 @@ export class RTLEffects implements OnDestroy { constructor( private actions$: Actions, private httpClient: HttpClient, - private store: Store, + private store: Store, private logger: LoggerService, public dialog: MatDialog, private router: Router) { } @@ -117,8 +117,8 @@ export class RTLEffects implements OnDestroy { @Effect() infoFetch = this.actions$.pipe( ofType(RTLActions.FETCH_INFO), - withLatestFrom(this.store.select('rtlRoot')), - mergeMap(([action, store]: [RTLActions.FetchInfo, fromRTLReducer.State]) => { + withLatestFrom(this.store.select('rtl')), + mergeMap(([action, store]) => { this.store.dispatch(new RTLActions.ClearEffectError('FetchInfo')); return this.httpClient.get(environment.GETINFO_API) .pipe( @@ -670,8 +670,8 @@ export class RTLEffects implements OnDestroy { @Effect() sendPayment = this.actions$.pipe( ofType(RTLActions.SEND_PAYMENT), - withLatestFrom(this.store.select('rtlRoot')), - mergeMap(([action, store]: [RTLActions.SendPayment, fromRTLReducer.State]) => { + withLatestFrom(this.store.select('rtl')), + mergeMap(([action, store]: [RTLActions.SendPayment, any]) => { let queryHeaders = {}; if (action.payload[2]) { queryHeaders = {paymentDecoded: action.payload[1]}; @@ -1039,8 +1039,8 @@ export class RTLEffects implements OnDestroy { @Effect() isAuthorized = this.actions$.pipe( ofType(RTLActions.IS_AUTHORIZED), - withLatestFrom(this.store.select('rtlRoot')), - mergeMap(([action, store]: [RTLActions.IsAuthorized, fromRTLReducer.State]) => { + withLatestFrom(this.store.select('rtl')), + mergeMap(([action, store]: [RTLActions.IsAuthorized, any]) => { this.store.dispatch(new RTLActions.ClearEffectError('IsAuthorized')); return this.httpClient.post(environment.AUTHENTICATE_API, { password: action.payload }) .pipe( @@ -1076,8 +1076,8 @@ export class RTLEffects implements OnDestroy { @Effect({ dispatch: false }) authSignin = this.actions$.pipe( ofType(RTLActions.SIGNIN), - withLatestFrom(this.store.select('rtlRoot')), - mergeMap(([action, store]: [RTLActions.Signin, fromRTLReducer.State]) => { + withLatestFrom(this.store.select('rtl')), + mergeMap(([action, store]: [RTLActions.Signin, any]) => { this.store.dispatch(new RTLActions.ClearEffectError('Signin')); return this.httpClient.post(environment.AUTHENTICATE_API, { password: action.payload }) .pipe( @@ -1105,8 +1105,8 @@ export class RTLEffects implements OnDestroy { @Effect({ dispatch: false }) signOut = this.actions$.pipe( ofType(RTLActions.SIGNOUT), - withLatestFrom(this.store.select('rtlRoot')), - mergeMap(([action, store]: [RTLActions.Signout, fromRTLReducer.State]) => { + withLatestFrom(this.store.select('rtl')), + mergeMap(([action, store]) => { if (+store.appConfig.sso.rtlSSO) { window.location.href = store.appConfig.sso.logoutRedirectLink; } else { @@ -1231,13 +1231,14 @@ export class RTLEffects implements OnDestroy { this.logger.info(postRes); this.store.dispatch(new RTLActions.CloseSpinner()); if (sessionStorage.getItem('token')) { + this.store.dispatch(new RTLActions.ResetStore(action.payload)); if(action.payload.lnImplementation.toLowerCase() === 'clightning') { this.router.navigate(['/cl/home']); + return { type: RTLActions.FETCH_CL_INFO }; } else { this.router.navigate(['/lnd/home']); + return { type: RTLActions.FETCH_INFO }; } - this.store.dispatch(new RTLActions.ResetStore(action.payload)); - return { type: RTLActions.FETCH_INFO }; } else { return { type: RTLActions.OPEN_ALERT, @@ -1262,6 +1263,52 @@ export class RTLEffects implements OnDestroy { } )); + @Effect() + infoFetchCL = this.actions$.pipe( + ofType(RTLActions.FETCH_CL_INFO), + withLatestFrom(this.store.select('rtl')), + mergeMap(([action, store]) => { + this.store.dispatch(new RTLActions.ClearEffectError('FetchCLInfo')); + return this.httpClient.get(environment.GETINFO_API) + .pipe( + map((info) => { + this.logger.info(info); + sessionStorage.setItem('clUnlocked', 'true'); + return { + type: RTLActions.SET_CL_INFO, + payload: (undefined !== info) ? info : {} + }; + }), + catchError((err) => { + this.logger.error(err); + this.store.dispatch(new RTLActions.EffectError({ action: 'FetchCLInfo', code: err.status, message: err.error.error })); + return of(); + }) + ); + } + )); + + @Effect() + fetchFeesCL = this.actions$.pipe( + ofType(RTLActions.FETCH_CL_FEES), + mergeMap((action: RTLActions.FetchCLFees) => { + this.store.dispatch(new RTLActions.ClearEffectError('FetchCLFees')); + return this.httpClient.get(environment.FEES_API); + }), + map((fees) => { + this.logger.info(fees); + return { + type: RTLActions.SET_CL_FEES, + payload: (undefined !== fees) ? fees : {} + }; + }), + catchError((err: any) => { + this.logger.error(err); + this.store.dispatch(new RTLActions.EffectError({ action: 'FetchCLFees', code: err.status, message: err.error.error })); + return of(); + } + )); + SetToken(token: string) { if (token) { sessionStorage.setItem('lndUnlocked', 'true'); diff --git a/src/app/shared/store/rtl.reducers.ts b/src/app/store/rtl.reducers.ts similarity index 84% rename from src/app/shared/store/rtl.reducers.ts rename to src/app/store/rtl.reducers.ts index 802ce793..319d5abb 100644 --- a/src/app/shared/store/rtl.reducers.ts +++ b/src/app/store/rtl.reducers.ts @@ -1,14 +1,56 @@ -import * as RTLActions from './rtl.actions'; - -import { ErrorPayload } from '../models/errorPayload'; -import { RTLConfiguration, Node } from '../models/RTLconfig'; +import { ActionReducerMap } from '@ngrx/store'; +import { ErrorPayload } from '../shared/models/errorPayload'; +import { RTLConfiguration, LightningNode } from '../shared/models/RTLconfig'; import { GetInfo, GetInfoChain, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, ListInvoices, PendingChannels, ClosedChannel, Transaction, SwitchRes, QueryRoutes -} from '../models/lndModels'; +} from '../shared/models/lndModels'; +import { GetInfoCL, FeesCL } from '../shared/models/clModels'; + +import * as RTLActions from './rtl.actions'; + +// export interface RTLState { +// root: RootState, +// lnd: LNDState, +// cl: CLState +// } + +// export interface CLState { +// information: GetInfoCL; +// fees: FeesCL; +// } + +// export interface LNDState { +// information: GetInfo; +// peers: Peer[]; +// fees: Fees; +// networkInfo: NetworkInfo; +// channelBalance: Balance; +// blockchainBalance: Balance; +// allChannels: Channel[]; +// closedChannels: ClosedChannel[]; +// pendingChannels: PendingChannels; +// numberOfActiveChannels: number; +// numberOfInactiveChannels: number; +// numberOfPendingChannels: number; +// totalLocalBalance: number; +// totalRemoteBalance: number; +// totalInvoices: number; +// transactions: Transaction[]; +// payments: Payment[]; +// invoices: ListInvoices; +// forwardingHistory: SwitchRes; +// addressTypes: AddressType[]; +// } -export interface State { +// export interface RootState { +// effectErrors: ErrorPayload[]; +// selNode: LightningNode; +// appConfig: RTLConfiguration; +// } + +export interface RTLState { effectErrors: ErrorPayload[]; - selNode: Node; + selNode: LightningNode; appConfig: RTLConfiguration; information: GetInfo; peers: Peer[]; @@ -30,19 +72,21 @@ export interface State { invoices: ListInvoices; forwardingHistory: SwitchRes; addressTypes: AddressType[]; + CLinformation: GetInfoCL; + CLfees: FeesCL; } const initNodeSettings = { flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false }; const initNodeAuthentication = { nodeAuthType: 'CUSTOM', lndConfigPath: '', bitcoindConfigPath: '' }; -const initialState: State = { +const initialState: RTLState = { effectErrors: [], selNode: {settings: initNodeSettings, authentication: initNodeAuthentication}, appConfig: { selectedNodeIndex: -1, sso: { rtlSSO: 0, logoutRedirectLink: '/login' }, nodes: [{ settings: initNodeSettings, authentication: initNodeAuthentication}] - }, + }, // ROOT ENDS information: {}, peers: [], fees: {}, @@ -65,10 +109,12 @@ const initialState: State = { addressTypes: [ { addressId: '0', addressTp: 'p2wkh', addressDetails: 'Pay to witness key hash'}, { addressId: '1', addressTp: 'np2wkh', addressDetails: 'Pay to nested witness key hash (default)'} - ] + ], //LND ENDS + CLinformation: {}, + CLfees: {} }; -export function RTLRootReducer(state = initialState, action: RTLActions.RTLActions) { +export function RTLReducer(state = initialState, action: RTLActions.RTLActions) { switch (action.type) { case RTLActions.CLEAR_EFFECT_ERROR: const clearedEffectErrors = [...state.effectErrors]; @@ -283,6 +329,16 @@ export function RTLRootReducer(state = initialState, action: RTLActions.RTLActio ...state, forwardingHistory: action.payload }; + case RTLActions.SET_CL_INFO: + return { + ...state, + CLinformation: action.payload + }; + case RTLActions.SET_CL_FEES: + return { + ...state, + CLfees: action.payload + }; default: return state; }