Lazy Load Completed

Lazy Load Completed
pull/209/head
Shahana Farooqui 5 years ago
parent b413992708
commit 108527d94c

@ -4,7 +4,7 @@ root = true
[*] [*]
charset = utf-8 charset = utf-8
indent_style = tab indent_style = tab
indent_size = 2 indent_size = 1
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true

@ -7,7 +7,7 @@ exports.updateSelectedNode = (req, res, next) => {
const selNodeIndex = req.body.selNodeIndex; const selNodeIndex = req.body.selNodeIndex;
common.selectedNode = common.findNode(selNodeIndex); common.selectedNode = common.findNode(selNodeIndex);
logger.info({fileName: 'RTLConf', msg: 'Selected Node Updated To: ' + JSON.stringify(common.selectedNode.ln_node)}); logger.info({fileName: 'RTLConf', msg: 'Selected Node Updated To: ' + JSON.stringify(common.selectedNode.ln_node)});
res.status(200).json({status: 'Selected Node Updated!'}); res.status(200).json({status: 'Selected Node Updated To: ' + JSON.stringify(common.selectedNode.ln_node) + '!'});
}; };
exports.getRTLConfig = (req, res, next) => { exports.getRTLConfig = (req, res, next) => {

@ -23,52 +23,77 @@ export class CLEffects implements OnDestroy {
private store: Store<fromRTLReducer.RTLState>, private store: Store<fromRTLReducer.RTLState>,
private logger: LoggerService) { } private logger: LoggerService) { }
@Effect() @Effect()
infoFetchCL = this.actions$.pipe( infoFetchCL = this.actions$.pipe(
ofType(RTLActions.FETCH_CL_INFO), ofType(RTLActions.FETCH_CL_INFO),
withLatestFrom(this.store.select('root')), withLatestFrom(this.store.select('root')),
mergeMap(([action, store]) => { mergeMap(([action, store]) => {
this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLInfo')); this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLInfo'));
return this.httpClient.get<GetInfoCL>(this.CHILD_API_URL + environment.GETINFO_API) return this.httpClient.get<GetInfoCL>(this.CHILD_API_URL + environment.GETINFO_API)
.pipe( .pipe(
map((info) => { map((info) => {
this.logger.info(info); this.logger.info(info);
sessionStorage.setItem('clUnlocked', 'true'); let chainObj = {chain: '', network: ''};
return { if (info.network === 'testnet') {
type: RTLActions.SET_CL_INFO, chainObj.chain = 'Bitcoin';
payload: (undefined !== info) ? info : {} chainObj.network = 'Testnet';
}; } else if (info.network === 'bitcoin') {
}), chainObj.chain = 'Bitcoin';
catchError((err) => { chainObj.network = 'Mainnet';
this.logger.error(err); } else if (info.network === 'litecoin') {
this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLInfo', code: err.status, message: err.error.error })); chainObj.chain = 'Litecoin';
return of(); chainObj.network = 'Mainnet';
}) } else if (info.network === 'litecoin-testnet') {
); chainObj.chain = 'Litecoin';
} chainObj.network = 'Testnet';
)); }
sessionStorage.setItem('clUnlocked', 'true');
const node_data = {
identity_pubkey: info.id,
alias: info.alias,
testnet: (info.network === 'testnet' || info.network === 'litecoin-testnet') ? true : false,
chains: [chainObj],
version: info.version,
currency_unit: 'BTC',
smaller_currency_unit: 'Sats',
numberOfPendingChannels: info.num_pending_channels
};
this.store.dispatch(new RTLActions.SetNodeData(node_data));
return {
type: RTLActions.SET_CL_INFO,
payload: (undefined !== info) ? info : {}
};
}),
catchError((err) => {
this.logger.error(err);
this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLInfo', code: err.status, message: err.error.error }));
return of();
})
);
}
));
@Effect() @Effect()
fetchFeesCL = this.actions$.pipe( fetchFeesCL = this.actions$.pipe(
ofType(RTLActions.FETCH_CL_FEES), ofType(RTLActions.FETCH_CL_FEES),
mergeMap((action: RTLActions.FetchCLFees) => { mergeMap((action: RTLActions.FetchCLFees) => {
this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLFees')); this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLFees'));
return this.httpClient.get<FeesCL>(this.CHILD_API_URL + environment.FEES_API); return this.httpClient.get<FeesCL>(this.CHILD_API_URL + environment.FEES_API);
}), }),
map((fees) => { map((fees) => {
this.logger.info(fees); this.logger.info(fees);
return { return {
type: RTLActions.SET_CL_FEES, type: RTLActions.SET_CL_FEES,
payload: (undefined !== fees) ? fees : {} payload: (undefined !== fees) ? fees : {}
}; };
}), }),
catchError((err: any) => { catchError((err: any) => {
this.logger.error(err); this.logger.error(err);
this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLFees', code: err.status, message: err.error.error })); this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLFees', code: err.status, message: err.error.error }));
return of(); return of();
} }
)); ));
ngOnDestroy() {} ngOnDestroy() { }
} }

@ -38,7 +38,8 @@ export function CLReducer(state = initCLState, action: RTLActions.RTLActions) {
}; };
case RTLActions.RESET_CL_STORE: case RTLActions.RESET_CL_STORE:
return { return {
...initCLState ...initCLState,
nodeSettings: action.payload,
}; };
case RTLActions.SET_CL_INFO: case RTLActions.SET_CL_INFO:
return { return {

@ -19,15 +19,15 @@ export class LNDRootComponent implements OnInit, OnDestroy {
constructor(private store: Store<fromRTLReducer.RTLState>, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {} constructor(private store: Store<fromRTLReducer.RTLState>, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {}
ngOnInit() { ngOnInit() {
this.store.dispatch(new RTLActions.FetchLndInfo()); this.store.dispatch(new RTLActions.FetchInfo());
this.router.navigate(['./home'], {relativeTo: this.activatedRoute}); this.router.navigate(['./home'], {relativeTo: this.activatedRoute});
this.actions$.pipe(takeUntil(this.unsubs[0]), filter((action) => action.type === RTLActions.SET_LND_INFO || action.type === RTLActions.INIT_APP_DATA)) this.actions$.pipe(takeUntil(this.unsubs[0]), filter((action) => action.type === RTLActions.SET_INFO || action.type === RTLActions.INIT_APP_DATA))
.subscribe((infoData: RTLActions.SetLndInfo | RTLActions.InitAppData) => { .subscribe((infoData: RTLActions.SetInfo | RTLActions.InitAppData) => {
if(infoData.type === RTLActions.SET_LND_INFO && undefined !== infoData.payload.identity_pubkey) { if(infoData.type === RTLActions.SET_INFO && undefined !== infoData.payload.identity_pubkey) {
this.initializeRemainingData(); this.initializeRemainingData();
} }
if(infoData.type === RTLActions.INIT_APP_DATA) { if(infoData.type === RTLActions.INIT_APP_DATA) {
this.store.dispatch(new RTLActions.FetchLndInfo()); this.store.dispatch(new RTLActions.FetchInfo());
} }
}); });
} }

@ -10,7 +10,7 @@ import { MatDialog } from '@angular/material';
import { environment, API_URL } from '../../../environments/environment'; import { environment, API_URL } from '../../../environments/environment';
import { LoggerService } from '../../shared/services/logger.service'; import { LoggerService } from '../../shared/services/logger.service';
import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../../shared/models/lndModels'; import { GetInfo, GetInfoChain, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../../shared/models/lndModels';
import * as RTLActions from '../../store/rtl.actions'; import * as RTLActions from '../../store/rtl.actions';
import * as fromRTLReducer from '../../store/rtl.reducers'; import * as fromRTLReducer from '../../store/rtl.reducers';
@ -32,7 +32,7 @@ export class LNDEffects implements OnDestroy {
@Effect() @Effect()
infoFetch = this.actions$.pipe( infoFetch = this.actions$.pipe(
ofType(RTLActions.FETCH_LND_INFO), ofType(RTLActions.FETCH_INFO),
withLatestFrom(this.store.select('root')), withLatestFrom(this.store.select('root')),
mergeMap(([action, store]) => { mergeMap(([action, store]) => {
this.store.dispatch(new RTLActions.ClearEffectErrorLnd('FetchInfo')); this.store.dispatch(new RTLActions.ClearEffectErrorLnd('FetchInfo'));
@ -45,13 +45,39 @@ export class LNDEffects implements OnDestroy {
this.logger.info('Redirecting to Unlock'); this.logger.info('Redirecting to Unlock');
this.router.navigate(['/lnd/unlocklnd']); this.router.navigate(['/lnd/unlocklnd']);
return { return {
type: RTLActions.SET_LND_INFO, type: RTLActions.SET_INFO,
payload: {} payload: {}
}; };
} else { } else {
sessionStorage.setItem('lndUnlocked', 'true'); sessionStorage.setItem('lndUnlocked', 'true');
if (undefined !== info.chains) {
if (typeof info.chains[0] === 'string') {
info.smaller_currency_unit = (info.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats';
info.currency_unit = (info.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC';
} else if (typeof info.chains[0] === 'object' && info.chains[0].hasOwnProperty('chain')) {
const getInfoChain = <GetInfoChain>info.chains[0];
info.smaller_currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats';
info.currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC';
}
info.version = (undefined === info.version) ? '' : info.version.split(' ')[0];
} else {
info.smaller_currency_unit = 'Sats';
info.currency_unit = 'BTC';
info.version = (undefined === info.version) ? '' : info.version.split(' ')[0];
}
const node_data = {
identity_pubkey: info.identity_pubkey,
alias: info.alias,
testnet: info.testnet,
chains: info.chains,
version: info.version,
currency_unit: info.currency_unit,
smaller_currency_unit: info.smaller_currency_unit,
numberOfPendingChannels: info.num_pending_channels
};
this.store.dispatch(new RTLActions.SetNodeData(node_data));
return { return {
type: RTLActions.SET_LND_INFO, type: RTLActions.SET_INFO,
payload: (undefined !== info) ? info : {} payload: (undefined !== info) ? info : {}
}; };
} }
@ -480,9 +506,26 @@ export class LNDEffects implements OnDestroy {
map((channels: any) => { map((channels: any) => {
this.logger.info(channels); this.logger.info(channels);
if (action.payload.routeParam === 'pending') { if (action.payload.routeParam === 'pending') {
let pendingChannels = -1;
if (channels) {
pendingChannels = 0;
if (channels.pending_closing_channels) {
pendingChannels = pendingChannels + channels.pending_closing_channels.length;
}
if (channels.pending_force_closing_channels) {
pendingChannels = pendingChannels + channels.pending_force_closing_channels.length;
}
if (channels.pending_open_channels) {
pendingChannels = pendingChannels + channels.pending_open_channels.length;
}
if (channels.waiting_close_channels) {
pendingChannels = pendingChannels + channels.waiting_close_channels.length;
}
}
this.store.dispatch(new RTLActions.SetNodePendingChannelsData(pendingChannels));
return { return {
type: RTLActions.SET_PENDING_CHANNELS, type: RTLActions.SET_PENDING_CHANNELS,
payload: (undefined !== channels) ? channels : {} payload: (undefined !== channels) ? { channels: channels, pendingChannels: pendingChannels } : {channels: {}, pendingChannels: pendingChannels}
}; };
} else if (action.payload.routeParam === 'closed') { } else if (action.payload.routeParam === 'closed') {
return { return {

@ -1,7 +1,7 @@
import { SelNodeChild } from '../../shared/models/RTLconfig'; import { SelNodeChild } from '../../shared/models/RTLconfig';
import { ErrorPayload } from '../../shared/models/errorPayload'; import { ErrorPayload } from '../../shared/models/errorPayload';
import { import {
GetInfo, GetInfoChain, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, ListInvoices, PendingChannels, ClosedChannel, Transaction, SwitchRes, QueryRoutes GetInfo, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, ListInvoices, PendingChannels, ClosedChannel, Transaction, SwitchRes, QueryRoutes
} from '../../shared/models/lndModels'; } from '../../shared/models/lndModels';
import * as RTLActions from '../../store/rtl.actions'; import * as RTLActions from '../../store/rtl.actions';
@ -79,24 +79,10 @@ export function LNDReducer(state = initLNDState, action: RTLActions.RTLActions)
}; };
case RTLActions.RESET_LND_STORE: case RTLActions.RESET_LND_STORE:
return { return {
...initLNDState ...initLNDState,
nodeSettings: action.payload,
}; };
case RTLActions.SET_LND_INFO: case RTLActions.SET_INFO:
if (undefined !== action.payload.chains) {
if (typeof action.payload.chains[0] === 'string') {
action.payload.smaller_currency_unit = (action.payload.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats';
action.payload.currency_unit = (action.payload.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC';
} else if (typeof action.payload.chains[0] === 'object' && action.payload.chains[0].hasOwnProperty('chain')) {
const getInfoChain = <GetInfoChain>action.payload.chains[0];
action.payload.smaller_currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats';
action.payload.currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC';
}
action.payload.version = (undefined === action.payload.version) ? '' : action.payload.version.split(' ')[0];
} else {
action.payload.smaller_currency_unit = 'Sats';
action.payload.currency_unit = 'BTC';
action.payload.version = (undefined === action.payload.version) ? '' : action.payload.version.split(' ')[0];
}
return { return {
...state, ...state,
information: action.payload information: action.payload
@ -141,26 +127,10 @@ export function LNDReducer(state = initLNDState, action: RTLActions.RTLActions)
closedChannels: action.payload, closedChannels: action.payload,
}; };
case RTLActions.SET_PENDING_CHANNELS: case RTLActions.SET_PENDING_CHANNELS:
let pendingChannels = -1;
if (action.payload) {
pendingChannels = 0;
if (action.payload.pending_closing_channels) {
pendingChannels = pendingChannels + action.payload.pending_closing_channels.length;
}
if (action.payload.pending_force_closing_channels) {
pendingChannels = pendingChannels + action.payload.pending_force_closing_channels.length;
}
if (action.payload.pending_open_channels) {
pendingChannels = pendingChannels + action.payload.pending_open_channels.length;
}
if (action.payload.waiting_close_channels) {
pendingChannels = pendingChannels + action.payload.waiting_close_channels.length;
}
}
return { return {
...state, ...state,
pendingChannels: action.payload, pendingChannels: action.payload.channels,
numberOfPendingChannels: pendingChannels, numberOfPendingChannels: action.payload.pendingChannels,
}; };
case RTLActions.SET_CHANNELS: case RTLActions.SET_CHANNELS:
let localBal = 0, remoteBal = 0, activeChannels = 0, inactiveChannels = 0; let localBal = 0, remoteBal = 0, activeChannels = 0, inactiveChannels = 0;

@ -3,7 +3,7 @@ import { Action } from '@ngrx/store';
import { GetInfoCL } from '../shared/models/clModels'; import { GetInfoCL } from '../shared/models/clModels';
import { RTLConfiguration, Settings, LightningNode } from '../shared/models/RTLconfig'; import { RTLConfiguration, Settings, LightningNode, GetInfoRoot, SelNodeChild } from '../shared/models/RTLconfig';
import { ErrorPayload } from '../shared/models/errorPayload'; import { ErrorPayload } from '../shared/models/errorPayload';
import { import {
GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, ListInvoices, Payment, GraphNode, AddressType, GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, ListInvoices, Payment, GraphNode, AddressType,
@ -11,14 +11,8 @@ import {
} from '../shared/models/lndModels'; } from '../shared/models/lndModels';
export const RESET_ROOT_STORE = 'RESET_ROOT_STORE'; export const RESET_ROOT_STORE = 'RESET_ROOT_STORE';
export const RESET_LND_STORE = 'RESET_LND_STORE';
export const RESET_CL_STORE = 'RESET_CL_STORE';
export const CLEAR_EFFECT_ERROR_ROOT = 'CLEAR_EFFECT_ERROR_ROOT'; export const CLEAR_EFFECT_ERROR_ROOT = 'CLEAR_EFFECT_ERROR_ROOT';
export const EFFECT_ERROR_ROOT = 'EFFECT_ERROR_ROOT'; export const EFFECT_ERROR_ROOT = 'EFFECT_ERROR_ROOT';
export const CLEAR_EFFECT_ERROR_LND = 'CLEAR_EFFECT_ERROR_LND';
export const EFFECT_ERROR_LND = 'EFFECT_ERROR_LND';
export const CLEAR_EFFECT_ERROR_CL = 'CLEAR_EFFECT_ERROR_CL';
export const EFFECT_ERROR_CL = 'EFFECT_ERROR_CL';
export const OPEN_SPINNER = 'OPEN_SPINNER'; export const OPEN_SPINNER = 'OPEN_SPINNER';
export const CLOSE_SPINNER = 'CLOSE_SPINNER'; export const CLOSE_SPINNER = 'CLOSE_SPINNER';
export const OPEN_ALERT = 'OPEN_ALERT'; export const OPEN_ALERT = 'OPEN_ALERT';
@ -31,8 +25,14 @@ export const FETCH_RTL_CONFIG = 'FETCH_RTL_CONFIG';
export const SET_RTL_CONFIG = 'SET_RTL_CONFIG'; export const SET_RTL_CONFIG = 'SET_RTL_CONFIG';
export const SAVE_SETTINGS = 'SAVE_SETTINGS'; export const SAVE_SETTINGS = 'SAVE_SETTINGS';
export const SET_SELECTED_NODE = 'SET_SELECTED_NODE'; export const SET_SELECTED_NODE = 'SET_SELECTED_NODE';
export const FETCH_LND_INFO = 'FETCH_LND_INFO'; export const SET_NODE_DATA = 'SET_NODE_DATA';
export const SET_LND_INFO = 'SET_LND_INFO'; export const SET_NODE_PENDING_CHANNELS_DATA = 'SET_NODE_PENDING_CHANNELS_DATA';
export const RESET_LND_STORE = 'RESET_LND_STORE';
export const CLEAR_EFFECT_ERROR_LND = 'CLEAR_EFFECT_ERROR_LND';
export const EFFECT_ERROR_LND = 'EFFECT_ERROR_LND';
export const FETCH_INFO = 'FETCH_INFO';
export const SET_INFO = 'SET_INFO';
export const FETCH_PEERS = 'FETCH_PEERS'; export const FETCH_PEERS = 'FETCH_PEERS';
export const SET_PEERS = 'SET_PEERS'; export const SET_PEERS = 'SET_PEERS';
export const SAVE_NEW_PEER = 'SAVE_NEW_PEER'; export const SAVE_NEW_PEER = 'SAVE_NEW_PEER';
@ -99,6 +99,9 @@ export const FETCH_CL_INFO = 'FETCH_CL_INFO';
export const SET_CL_INFO = 'SET_CL_INFO'; export const SET_CL_INFO = 'SET_CL_INFO';
export const FETCH_CL_FEES = 'FETCH_CL_FEES'; export const FETCH_CL_FEES = 'FETCH_CL_FEES';
export const SET_CL_FEES = 'SET_CL_FEES'; export const SET_CL_FEES = 'SET_CL_FEES';
export const RESET_CL_STORE = 'RESET_CL_STORE';
export const CLEAR_EFFECT_ERROR_CL = 'CLEAR_EFFECT_ERROR_CL';
export const EFFECT_ERROR_CL = 'EFFECT_ERROR_CL';
export class ClearEffectErrorRoot implements Action { export class ClearEffectErrorRoot implements Action {
readonly type = CLEAR_EFFECT_ERROR_ROOT; readonly type = CLEAR_EFFECT_ERROR_ROOT;
@ -165,10 +168,12 @@ export class ResetRootStore implements Action {
export class ResetLNDStore implements Action { export class ResetLNDStore implements Action {
readonly type = RESET_LND_STORE; readonly type = RESET_LND_STORE;
constructor(public payload: SelNodeChild) {}
} }
export class ResetCLStore implements Action { export class ResetCLStore implements Action {
readonly type = RESET_CL_STORE; readonly type = RESET_CL_STORE;
constructor(public payload: SelNodeChild) {}
} }
export class FetchRTLConfig implements Action { export class FetchRTLConfig implements Action {
@ -190,12 +195,22 @@ export class SetSelelectedNode implements Action {
constructor(public payload: LightningNode) {} constructor(public payload: LightningNode) {}
} }
export class FetchLndInfo implements Action { export class SetNodeData implements Action {
readonly type = FETCH_LND_INFO; readonly type = SET_NODE_DATA;
constructor(public payload: GetInfoRoot) {}
}
export class SetNodePendingChannelsData implements Action {
readonly type = SET_NODE_PENDING_CHANNELS_DATA;
constructor(public payload: number) {}
}
export class FetchInfo implements Action {
readonly type = FETCH_INFO;
} }
export class SetLndInfo implements Action { export class SetInfo implements Action {
readonly type = SET_LND_INFO; readonly type = SET_INFO;
constructor(public payload: GetInfo) {} constructor(public payload: GetInfo) {}
} }
@ -283,7 +298,7 @@ export class UpdateChannels implements Action {
export class SetPendingChannels implements Action { export class SetPendingChannels implements Action {
readonly type = SET_PENDING_CHANNELS; readonly type = SET_PENDING_CHANNELS;
constructor(public payload: PendingChannels) {} constructor(public payload: {channels: PendingChannels, pendingChannels: number}) {}
} }
export class SetClosedChannels implements Action { export class SetClosedChannels implements Action {
@ -521,7 +536,7 @@ export type RTLActions =
OpenSpinner | CloseSpinner | FetchRTLConfig | SetRTLConfig | SaveSettings | OpenSpinner | CloseSpinner | FetchRTLConfig | SetRTLConfig | SaveSettings |
OpenAlert | CloseAlert | OpenConfirmation | CloseConfirmation | OpenAlert | CloseAlert | OpenConfirmation | CloseConfirmation |
ResetRootStore | ResetLNDStore | ResetCLStore | ResetRootStore | ResetLNDStore | ResetCLStore |
SetSelelectedNode | FetchLndInfo | SetLndInfo | SetSelelectedNode | SetNodeData | SetNodePendingChannelsData | FetchInfo | SetInfo |
FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer | FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer |
AddInvoice | SaveNewInvoice | GetForwardingHistory | SetForwardingHistory | AddInvoice | SaveNewInvoice | GetForwardingHistory | SetForwardingHistory |
FetchFees | SetFees | FetchFees | SetFees |

@ -10,7 +10,7 @@ import { MatDialog } from '@angular/material';
import { environment, API_URL } from '../../environments/environment'; import { environment, API_URL } from '../../environments/environment';
import { LoggerService } from '../shared/services/logger.service'; import { LoggerService } from '../shared/services/logger.service';
import { Settings } from '../shared/models/RTLconfig'; import { Settings, RTLConfiguration } from '../shared/models/RTLconfig';
import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../shared/models/lndModels'; import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../shared/models/lndModels';
import { SpinnerDialogComponent } from '../shared/components/spinner-dialog/spinner-dialog.component'; import { SpinnerDialogComponent } from '../shared/components/spinner-dialog/spinner-dialog.component';
@ -92,9 +92,10 @@ export class RTLEffects implements OnDestroy {
this.store.dispatch(new RTLActions.ClearEffectErrorRoot('FetchRTLConfig')); this.store.dispatch(new RTLActions.ClearEffectErrorRoot('FetchRTLConfig'));
return this.httpClient.get(environment.CONF_API + '/rtlconf'); return this.httpClient.get(environment.CONF_API + '/rtlconf');
}), }),
map((rtlConfig: any) => { map((rtlConfig: RTLConfiguration) => {
this.logger.info(rtlConfig); this.logger.info(rtlConfig);
if (+rtlConfig.sso.rtlSSO) { this.store.dispatch(new RTLActions.Signout()); } if (+rtlConfig.sso.rtlSSO) { this.store.dispatch(new RTLActions.Signout()); }
this.store.dispatch(new RTLActions.SetSelelectedNode(rtlConfig.nodes.find(node => +node.index === rtlConfig.selectedNodeIndex)))
return { return {
type: RTLActions.SET_RTL_CONFIG, type: RTLActions.SET_RTL_CONFIG,
payload: rtlConfig payload: rtlConfig
@ -246,18 +247,19 @@ export class RTLEffects implements OnDestroy {
this.logger.info(postRes); this.logger.info(postRes);
this.store.dispatch(new RTLActions.CloseSpinner()); this.store.dispatch(new RTLActions.CloseSpinner());
if (sessionStorage.getItem('token')) { if (sessionStorage.getItem('token')) {
let selNode = { channelBackupPath: action.payload.settings.channelBackupPath, satsToBTC: action.payload.settings.satsToBTC };
this.store.dispatch(new RTLActions.ResetRootStore(action.payload)); this.store.dispatch(new RTLActions.ResetRootStore(action.payload));
this.store.dispatch(new RTLActions.ResetLNDStore()); this.store.dispatch(new RTLActions.ResetLNDStore(selNode));
this.store.dispatch(new RTLActions.ResetCLStore()); this.store.dispatch(new RTLActions.ResetCLStore(selNode));
if(action.payload.lnImplementation.toLowerCase() === 'clightning') { if(action.payload.lnImplementation.toLowerCase() === 'clightning') {
this.router.navigate(['/cl/home']); this.router.navigate(['/cl/home']);
this.CHILD_API_URL = API_URL + '/cl'; this.CHILD_API_URL = API_URL + '/cl';
return { type: RTLActions.FETCH_CL_INFO }; return { type: RTLActions.FETCH_CL_INFO };
} else { } else {
this.router.navigate(['/lnd/home']); this.router.navigate(['/lnd/home']);
this.CHILD_API_URL = API_URL + '/lnd'; this.CHILD_API_URL = API_URL + '/lnd';
this.store.dispatch(new RTLActions.FetchLndInfo()); this.store.dispatch(new RTLActions.FetchInfo());
return { type: RTLActions.FETCH_LND_INFO }; return { type: RTLActions.FETCH_INFO };
} }
} else { } else {
return { return {

@ -13,7 +13,7 @@ export interface RootState {
nodeData: GetInfoRoot nodeData: GetInfoRoot
} }
const initNodeSettings = { flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false }; const initNodeSettings = { flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false, channelBackupPath: '' };
const initNodeAuthentication = { nodeAuthType: 'CUSTOM', lndConfigPath: '', bitcoindConfigPath: '' }; const initNodeAuthentication = { nodeAuthType: 'CUSTOM', lndConfigPath: '', bitcoindConfigPath: '' };
const initRootState: RootState = { const initRootState: RootState = {
@ -24,7 +24,7 @@ const initRootState: RootState = {
sso: { rtlSSO: 0, logoutRedirectLink: '/login' }, sso: { rtlSSO: 0, logoutRedirectLink: '/login' },
nodes: [{ settings: initNodeSettings, authentication: initNodeAuthentication}] nodes: [{ settings: initNodeSettings, authentication: initNodeAuthentication}]
}, },
nodeData: { identity_pubkey: 'abc', alias: 'xyz', testnet: true, chains: [{chain: "bitcoin", network: "testnet"}], version: 'v0', currency_unit: 'BTC', smaller_currency_unit: 'SATS', numberOfPendingChannels: -1 } nodeData: {}
}; };
export function RootReducer(state = initRootState, action: RTLActions.RTLActions) { export function RootReducer(state = initRootState, action: RTLActions.RTLActions) {
@ -57,10 +57,21 @@ export function RootReducer(state = initRootState, action: RTLActions.RTLActions
...state, ...state,
selNode: action.payload selNode: action.payload
}; };
case RTLActions.SET_NODE_DATA:
return {
...state,
nodeData: action.payload
};
case RTLActions.SET_NODE_PENDING_CHANNELS_DATA:
const newNodeData = state.nodeData;
newNodeData.numberOfPendingChannels = action.payload;
return {
...state,
nodeData: newNodeData
};
case RTLActions.SET_RTL_CONFIG: case RTLActions.SET_RTL_CONFIG:
return { return {
...state, ...state,
selNode: action.payload.nodes.find(node => +node.index === action.payload.selectedNodeIndex),
appConfig: action.payload appConfig: action.payload
}; };
default: default:

Loading…
Cancel
Save