From 0dd25df9828231ee956b4f73b65fea6379e5353a Mon Sep 17 00:00:00 2001 From: Shahana Farooqui Date: Sat, 24 Aug 2019 18:19:34 -0400 Subject: [PATCH] Incomplete lazy load 6 Incomplete lazy load 6 --- src/app/app.component.ts | 14 +- src/app/clightning/cl-root.component.ts | 14 +- src/app/clightning/home/home.component.html | 202 ------------------ src/app/clightning/home/home.component.ts | 92 +------- src/app/lnd/lnd-root.component.ts | 2 +- .../horizontal-navigation.component.ts | 4 +- .../side-navigation.component.ts | 16 +- src/app/shared/store/rtl.effects.ts | 6 +- 8 files changed, 28 insertions(+), 322 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5782dbf0..4eb836f5 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -59,14 +59,12 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { this.flgLoading[0] = false; } }); - this.actions$ - .pipe( - takeUntil(this.unsubs[1]), - filter((action) => action.type === RTLActions.SET_RTL_CONFIG) - ).subscribe((actionPayload: (RTLActions.SetRTLConfig)) => { - if (actionPayload.type === RTLActions.SET_RTL_CONFIG) { + this.actions$.pipe(takeUntil(this.unsubs[1]), + filter((action) => action.type === RTLActions.SET_RTL_CONFIG)) + .subscribe((action: (RTLActions.SetRTLConfig)) => { + if (action.type === RTLActions.SET_RTL_CONFIG) { if (!sessionStorage.getItem('token')) { - if (+actionPayload.payload.sso.rtlSSO) { + if (+action.payload.sso.rtlSSO) { this.store.dispatch(new RTLActions.Signin(sha256(this.accessKey))); } else { this.router.navigate([this.appConfig.sso.logoutRedirectLink]); @@ -79,7 +77,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { this.settingSidenav.toggle(); // To dynamically update the width to 100% after side nav is closed setTimeout(() => { this.settingSidenav.toggle(); }, 100); } - } + } }); this.userIdle.startWatching(); this.userIdle.onTimerStart().subscribe(count => {}); diff --git a/src/app/clightning/cl-root.component.ts b/src/app/clightning/cl-root.component.ts index 8341d750..0de9a988 100644 --- a/src/app/clightning/cl-root.component.ts +++ b/src/app/clightning/cl-root.component.ts @@ -35,14 +35,14 @@ export class CLRootComponent implements OnInit, OnDestroy { } initializeRemainingData() { - this.store.dispatch(new RTLActions.FetchPeers()); - this.store.dispatch(new RTLActions.FetchBalance('channels')); this.store.dispatch(new RTLActions.FetchFees()); - this.store.dispatch(new RTLActions.FetchNetwork()); - this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'all'})); - this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'pending'})); - this.store.dispatch(new RTLActions.FetchInvoices({num_max_invoices: 25, reversed: true})); - this.store.dispatch(new RTLActions.FetchPayments()); + // this.store.dispatch(new RTLActions.FetchPeers()); + // this.store.dispatch(new RTLActions.FetchBalance('channels')); + // this.store.dispatch(new RTLActions.FetchNetwork()); + // this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'all'})); + // this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'pending'})); + // this.store.dispatch(new RTLActions.FetchInvoices({num_max_invoices: 25, reversed: true})); + // this.store.dispatch(new RTLActions.FetchPayments()); } ngOnDestroy() { diff --git a/src/app/clightning/home/home.component.html b/src/app/clightning/home/home.component.html index 9d66881f..056c5617 100644 --- a/src/app/clightning/home/home.component.html +++ b/src/app/clightning/home/home.component.html @@ -1,85 +1,3 @@ -
-
- - - -
Wallet Balance
-
-
- - - account_balance_wallet - - -

{{BTCtotalBalance | number}} {{information?.currency_unit}}

-

{{totalBalance | number}} {{information?.smaller_currency_unit}}

-
-
- - -
-
-
- - - -
Peers
-
-
- - - group - -

{{totalPeers | number}}

- -

0

-
-
- - -
-
-
- - - -
Channel Balance
-
-
- - - linear_scale - - -

{{BTCchannelBalance | number}} {{information?.currency_unit}}

-

{{channelBalance | number}} {{information?.smaller_currency_unit}}

-
-
- - -
-
-
- - - -
Chain Sync Status
-
-
- - - sync - - check_circle - - cancel - - - - -
-
-
@@ -111,127 +29,7 @@ - - - -
Channel Status
-
-
- -
- - Active -

{{activeChannels}}

- -
- - Inactive -

{{inactiveChannels}}

- -
- - Pending -

{{pendingChannels}}

- -
-
- - -
-
-
- - - -
Local-Remote Channel Capacity
-
-
- -
-
- - -
-
- - -
-
-
-
- - - -
Network Information
-
-
- -
- - Network Capacity ({{information?.currency_unit}}) - {{networkInfo?.btc_total_network_capacity | number}} - Network Capacity ({{information?.smaller_currency_unit}}) - {{networkInfo?.total_network_capacity | number}} - - - - Number of Nodes - {{networkInfo?.num_nodes | number}} - - - - Number of Channels - {{networkInfo?.num_channels | number}} - - - - Max Out Degree - {{networkInfo?.max_out_degree | number}} - - - - Avg Out Degree - {{networkInfo?.avg_out_degree | number:'1.0-2'}} - - - - Max Channel Size ({{information?.currency_unit}}) - Max Channel Size ({{information?.smaller_currency_unit}}) - {{networkInfo?.btc_max_channel_size | number}} - {{networkInfo?.max_channel_size | number}} - - - - Avg Channel Size ({{information?.currency_unit}}) - Avg Channel Size ({{information?.smaller_currency_unit}}) - {{networkInfo?.btc_avg_channel_size | number}} - {{networkInfo?.avg_channel_size | number:'1.0-2'}} - - - - Min Channel Size ({{information?.currency_unit}}) - Min Channel Size ({{information?.smaller_currency_unit}}) - {{networkInfo?.btc_min_channel_size | number}} - {{networkInfo?.min_channel_size | number}} - - -
- - -
-
-

Sats

diff --git a/src/app/clightning/home/home.component.ts b/src/app/clightning/home/home.component.ts index ce40292a..be1f3f33 100644 --- a/src/app/clightning/home/home.component.ts +++ b/src/app/clightning/home/home.component.ts @@ -4,7 +4,7 @@ import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { LoggerService } from '../../shared/services/logger.service'; -import { GetInfo, NetworkInfo, Fees, Peer } from '../../shared/models/lndModels'; +import { GetInfo, Fees } from '../../shared/models/lndModels'; import { Node } from '../../shared/models/RTLconfig'; import * as fromRTLReducer from '../../shared/store/rtl.reducers'; @@ -18,52 +18,12 @@ export class CLHomeComponent implements OnInit, OnDestroy { public selNode: Node; public fees: Fees; public information: GetInfo = {}; - public remainder = 0; - public totalPeers = -1; - public totalBalance = ''; - public channelBalance = ''; - public BTCtotalBalance = ''; - public BTCchannelBalance = ''; - public networkInfo: NetworkInfo = {}; 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()]; - public channels: any; - public position = 'below'; - public activeChannels = 0; - public inactiveChannels = 0; - public pendingChannels = 0; - public peers: Peer[] = []; - barPadding = 0; - maxBalanceValue = 0; - totalBalances = [...[{'name': 'Local Balance', 'value': 0}, {'name': 'Remote Balance', 'value': 0}]]; - flgTotalCalculated = false; - view = []; - yAxisLabel = 'Balance'; - colorScheme = {domain: ['#FFFFFF']}; - constructor(private logger: LoggerService, private store: Store) { - switch (true) { - case (window.innerWidth <= 730): - this.view = [250, 352]; - break; - case (window.innerWidth > 415 && window.innerWidth <= 730): - this.view = [280, 352]; - break; - case (window.innerWidth > 730 && window.innerWidth <= 1024): - this.view = [300, 352]; - break; - case (window.innerWidth > 1024 && window.innerWidth <= 1280): - this.view = [350, 352]; - break; - default: - this.view = [300, 352]; - break; - } - Object.assign(this, this.totalBalances); - } + constructor(private logger: LoggerService, private store: Store) {} ngOnInit() { - this.flgTotalCalculated = false; this.store.select('rtlRoot') .pipe(takeUntil(this.unsub[0])) .subscribe((rtlStore: fromRTLReducer.State) => { @@ -74,19 +34,6 @@ export class CLHomeComponent implements OnInit, OnDestroy { if (effectsErr.action === 'FetchFees') { this.flgLoading[1] = 'error'; } - if (effectsErr.action === 'FetchBalance/blockchain') { - this.flgLoading[2] = 'error'; - } - if (effectsErr.action === 'FetchBalance/channels') { - this.flgLoading[3] = 'error'; - } - if (effectsErr.action === 'FetchNetwork') { - this.flgLoading[4] = 'error'; - } - if (effectsErr.action === 'FetchChannels/all') { - this.flgLoading[5] = 'error'; - this.flgLoading[6] = 'error'; - } }); this.selNode = rtlStore.selNode; this.information = rtlStore.information; @@ -99,41 +46,6 @@ export class CLHomeComponent implements OnInit, OnDestroy { this.flgLoading[1] = (undefined !== this.fees.day_fee_sum) ? false : true; } - this.totalBalance = rtlStore.blockchainBalance.total_balance; - this.BTCtotalBalance = rtlStore.blockchainBalance.btc_total_balance; - if (this.flgLoading[2] !== 'error') { - this.flgLoading[2] = ('' !== this.totalBalance) ? false : true; - } - - this.channelBalance = rtlStore.channelBalance.balance; - this.BTCchannelBalance = rtlStore.channelBalance.btc_balance; - if (this.flgLoading[3] !== 'error') { - this.flgLoading[3] = ('' !== this.channelBalance) ? false : true; - } - - this.networkInfo = rtlStore.networkInfo; - if (this.flgLoading[4] !== 'error') { - this.flgLoading[4] = (undefined !== this.networkInfo.num_nodes) ? false : true; - } - - this.totalBalances = [...[{'name': 'Local Balance', 'value': +rtlStore.totalLocalBalance}, {'name': 'Remote Balance', 'value': +rtlStore.totalRemoteBalance}]]; - this.maxBalanceValue = (rtlStore.totalLocalBalance > rtlStore.totalRemoteBalance) ? rtlStore.totalLocalBalance : rtlStore.totalRemoteBalance; - if (rtlStore.totalLocalBalance >= 0 && rtlStore.totalRemoteBalance >= 0) { - this.flgTotalCalculated = true; - if (this.flgLoading[5] !== 'error') { - this.flgLoading[5] = false; - } - } - - this.activeChannels = rtlStore.numberOfActiveChannels; - this.inactiveChannels = rtlStore.numberOfInactiveChannels; - this.pendingChannels = (undefined !== rtlStore.pendingChannels.pending_open_channels) ? rtlStore.pendingChannels.pending_open_channels.length : 0; - if (rtlStore.totalLocalBalance >= 0 && rtlStore.totalRemoteBalance >= 0 && this.flgLoading[6] !== 'error') { - this.flgLoading[6] = false; - } - - this.totalPeers = (rtlStore.peers !== null) ? rtlStore.peers.length : 0; - this.logger.info(rtlStore); }); } diff --git a/src/app/lnd/lnd-root.component.ts b/src/app/lnd/lnd-root.component.ts index 6aa205fa..e2a14a70 100644 --- a/src/app/lnd/lnd-root.component.ts +++ b/src/app/lnd/lnd-root.component.ts @@ -34,9 +34,9 @@ export class LNDRootComponent implements OnInit, OnDestroy { } initializeRemainingData() { + this.store.dispatch(new RTLActions.FetchFees()); this.store.dispatch(new RTLActions.FetchPeers()); this.store.dispatch(new RTLActions.FetchBalance('channels')); - this.store.dispatch(new RTLActions.FetchFees()); this.store.dispatch(new RTLActions.FetchNetwork()); this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'all'})); this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'pending'})); 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 98609ecf..32d5bf04 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 @@ -31,8 +31,8 @@ export class HorizontalNavigationComponent implements OnInit { .pipe(takeUntil(this.unSubs[0])) .subscribe((rtlStore: fromRTLReducer.State) => { this.numPendingChannels = rtlStore.numberOfPendingChannels; - if(+rtlStore.selNode.index === 1) { - this.menuNodes = MENU_DATA.LNDChildren; + if(rtlStore.selNode.lnImplementation.toLowerCase() === 'clightning') { + this.menuNodes = MENU_DATA.CLChildren; } else { this.menuNodes = MENU_DATA.LNDChildren; } 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 9a9d9eda..cffc2105 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 @@ -63,7 +63,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy { ngOnInit() { this.store.select('rtlRoot') .pipe(takeUntil(this.unSubs[0])) - .subscribe((rtlStore: fromRTLReducer.State) => { + .subscribe(rtlStore => { this.selNode = rtlStore.selNode; this.settings = this.selNode.settings; this.information = rtlStore.information; @@ -91,18 +91,16 @@ export class SideNavigationComponent implements OnInit, OnDestroy { if (window.innerWidth <= 414) { this.smallScreen = true; } - if(+this.selNode.index === 1) { - this.navMenus.data = MENU_DATA.LNDChildren; - } else { + if(this.selNode && this.selNode.lnImplementation && this.selNode.lnImplementation.toLowerCase() === 'clightning') { this.navMenus.data = MENU_DATA.CLChildren; + } else { + this.navMenus.data = MENU_DATA.LNDChildren; } this.logger.info(rtlStore); }); - this.actions$ - .pipe( - takeUntil(this.unSubs[2]), - filter((action) => action.type === RTLActions.SIGNOUT) - ).subscribe(() => { + this.actions$.pipe(takeUntil(this.unSubs[2]), + filter((action) => action.type === RTLActions.SIGNOUT)) + .subscribe((action: RTLActions.Signout) => { this.showLogout = false; }); } diff --git a/src/app/shared/store/rtl.effects.ts b/src/app/shared/store/rtl.effects.ts index 0e8dc37c..127bdcbc 100644 --- a/src/app/shared/store/rtl.effects.ts +++ b/src/app/shared/store/rtl.effects.ts @@ -1231,10 +1231,10 @@ export class RTLEffects implements OnDestroy { this.logger.info(postRes); this.store.dispatch(new RTLActions.CloseSpinner()); if (sessionStorage.getItem('token')) { - if(+action.payload.index === 1) { - this.router.navigate(['/lnd/home']); - } else { + if(action.payload.lnImplementation.toLowerCase() === 'clightning') { this.router.navigate(['/cl/home']); + } else { + this.router.navigate(['/lnd/home']); } this.store.dispatch(new RTLActions.ResetStore(action.payload)); return { type: RTLActions.FETCH_INFO };