From 39f9377365383324cf9fb83e69f991a9c9a57580 Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Fri, 26 Apr 2024 23:01:26 -0700 Subject: [PATCH] Incomplete: Services UI fix --- backend/controllers/shared/RTLConf.js | 4 +++ server/controllers/shared/RTLConf.ts | 4 +++ .../experimental-settings.component.ts | 25 ++------------ .../node-settings.component.html | 4 +-- .../node-settings/node-settings.component.ts | 29 ++++++++-------- .../boltz-service-settings.component.ts | 33 +++++-------------- .../loop-service-settings.component.ts | 28 +++------------- .../peerswap-service-settings.component.ts | 27 +-------------- .../app-settings/app-settings.component.html | 4 --- .../app-settings/app-settings.component.ts | 3 +- .../shared/services/consts-enums-functions.ts | 2 +- src/app/store/rtl.actions.ts | 2 +- src/app/store/rtl.effects.ts | 7 ++-- src/app/store/rtl.reducers.ts | 4 +-- 14 files changed, 52 insertions(+), 124 deletions(-) diff --git a/backend/controllers/shared/RTLConf.js b/backend/controllers/shared/RTLConf.js index 6a84e5d5..92ead7e5 100644 --- a/backend/controllers/shared/RTLConf.js +++ b/backend/controllers/shared/RTLConf.js @@ -219,12 +219,16 @@ export const updateNodeSettings = (req, res, next) => { const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index)); if (node && node.settings) { node.settings = req.body.settings; + node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath; + node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath; } try { fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8'); const selectedNode = common.findNode(req.session.selectedNode.index); if (selectedNode && selectedNode.settings) { selectedNode.settings = req.body.settings; + selectedNode.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath; + selectedNode.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath; common.replaceNode(req, selectedNode); } let responseNode = JSON.parse(JSON.stringify(common.selectedNode)); diff --git a/server/controllers/shared/RTLConf.ts b/server/controllers/shared/RTLConf.ts index 18cd486e..31e8fc36 100644 --- a/server/controllers/shared/RTLConf.ts +++ b/server/controllers/shared/RTLConf.ts @@ -225,12 +225,16 @@ export const updateNodeSettings = (req, res, next) => { const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index)); if (node && node.settings) { node.settings = req.body.settings; + node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath; + node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath; } try { fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8'); const selectedNode = common.findNode(req.session.selectedNode.index); if (selectedNode && selectedNode.settings) { selectedNode.settings = req.body.settings; + selectedNode.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath; + selectedNode.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath; common.replaceNode(req, selectedNode); } let responseNode = JSON.parse(JSON.stringify(common.selectedNode)); diff --git a/src/app/shared/components/node-config/experimental-settings/experimental-settings.component.ts b/src/app/shared/components/node-config/experimental-settings/experimental-settings.component.ts index 2b4ffae5..12cc05de 100644 --- a/src/app/shared/components/node-config/experimental-settings/experimental-settings.component.ts +++ b/src/app/shared/components/node-config/experimental-settings/experimental-settings.component.ts @@ -9,12 +9,9 @@ import { RTLState } from '../../../../store/rtl.state'; import { rootSelectedNode } from '../../../../store/rtl.selector'; import { Node } from '../../../models/RTLconfig'; import { updateNodeSettings } from '../../../../store/rtl.actions'; -import { setChildNodeSettingsLND } from '../../../../lnd/store/lnd.actions'; -import { setChildNodeSettingsCLN } from '../../../../cln/store/cln.actions'; -import { setChildNodeSettingsECL } from '../../../../eclair/store/ecl.actions'; import { DataService } from '../../../services/data.service'; import { CommonService } from '../../../services/common.service'; -import { ServicesEnum, UI_MESSAGES, LADS_POLICY } from '../../../services/consts-enums-functions'; +import { LADS_POLICY } from '../../../services/consts-enums-functions'; import { utxoBalances } from '../../../../cln/store/cln.selector'; import { Balance, FunderPolicy, LocalRemoteBalance, UTXO } from '../../../models/clnModels'; import { ApiCallStatusPayload } from '../../../models/apiCallsPayload'; @@ -91,25 +88,7 @@ export class ExperimentalSettingsComponent implements OnInit, OnDestroy { this.logger.info(this.selNode); this.selNode.settings.enableOffers = this.enableOffers; this.features[0].enabled = this.enableOffers; - // this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_SETTING, service: ServicesEnum.OFFERS, settings: { enableOffers: this.enableOffers } } })); - // this.store.dispatch(setChildNodeSettingsLND({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.enableOffers - // } - // })); - // this.store.dispatch(setChildNodeSettingsCLN({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.enableOffers - // } - // })); - // this.store.dispatch(setChildNodeSettingsECL({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.enableOffers - // } - // })); + this.store.dispatch(updateNodeSettings({ payload: this.selNode })); } onUpdateFundingPolicy() { diff --git a/src/app/shared/components/node-config/node-settings/node-settings.component.html b/src/app/shared/components/node-config/node-settings/node-settings.component.html index 4086cbcd..609e2342 100644 --- a/src/app/shared/components/node-config/node-settings/node-settings.component.html +++ b/src/app/shared/components/node-config/node-settings/node-settings.component.html @@ -31,10 +31,10 @@ Fiat conversion calls Blockchain.com API to get conversion rates.
- Enable Fiat Conversion + Enable Fiat Conversion Fiat Currency - + diff --git a/src/app/shared/components/node-config/node-settings/node-settings.component.ts b/src/app/shared/components/node-config/node-settings/node-settings.component.ts index cb74856e..9f301dfc 100644 --- a/src/app/shared/components/node-config/node-settings/node-settings.component.ts +++ b/src/app/shared/components/node-config/node-settings/node-settings.component.ts @@ -5,16 +5,13 @@ import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { faMoneyBillAlt, faPaintBrush, faInfoCircle, faExclamationTriangle, faEyeSlash } from '@fortawesome/free-solid-svg-icons'; -import { CURRENCY_UNITS, UserPersonaEnum, ScreenSizeEnum, FIAT_CURRENCY_UNITS, NODE_SETTINGS, UI_MESSAGES } from '../../../services/consts-enums-functions'; +import { UserPersonaEnum, ScreenSizeEnum, FIAT_CURRENCY_UNITS, NODE_SETTINGS, UI_MESSAGES } from '../../../services/consts-enums-functions'; import { Node, Settings } from '../../../models/RTLconfig'; import { LoggerService } from '../../../services/logger.service'; import { CommonService } from '../../../services/common.service'; import { RTLState } from '../../../../store/rtl.state'; import { rootSelectedNode } from '../../../../store/rtl.selector'; -import { updateNodeSettings, setSelectedNode, updateSelectedNodeSettings } from '../../../../store/rtl.actions'; -import { setChildNodeSettingsLND } from '../../../../lnd/store/lnd.actions'; -import { setChildNodeSettingsCLN } from '../../../../cln/store/cln.actions'; -import { setChildNodeSettingsECL } from '../../../../eclair/store/ecl.actions'; +import { updateNodeSettings, setSelectedNode } from '../../../../store/rtl.actions'; @Component({ selector: 'rtl-node-settings', @@ -67,14 +64,14 @@ export class NodeSettingsComponent implements OnInit, OnDestroy { }); } - onCurrencyChange(event: any) { - this.selNode.settings.currencyUnits = [...CURRENCY_UNITS, event.value]; - this.store.dispatch(updateSelectedNodeSettings({ payload: this.selNode })); - this.store.dispatch(setChildNodeSettingsLND({ payload: this.selNode })); - this.store.dispatch(setChildNodeSettingsCLN({ payload: this.selNode })); - this.store.dispatch(setChildNodeSettingsECL({ payload: this.selNode })); - // this.store.dispatch(updateNodeSettings({ payload: this.selNode })); - } + // onCurrencyChange(event: any) { + // if (this.selNode.settings.fiatConversion) { + // this.selNode.settings.currencyUnit = ''; + // } else { + // delete this.selNode.settings.currencyUnit; + // } + // this.store.dispatch(updateNodeSettings({ payload: this.selNode })); + // } toggleSettings(toggleField: string, event?: any) { this.selNode.settings[toggleField] = !this.selNode.settings[toggleField]; @@ -89,6 +86,12 @@ export class NodeSettingsComponent implements OnInit, OnDestroy { this.selNode.settings.themeMode = this.selectedThemeMode.id; } + onFiatConversionChange(event: any) { + if (!this.selNode.settings.fiatConversion) { + delete this.selNode.settings.currencyUnit; + } + } + onUpdateNodeSettings(): boolean | void { if (this.selNode.settings.fiatConversion && !this.selNode.settings.currencyUnit) { return true; diff --git a/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts b/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts index c5f29776..c30f39c4 100644 --- a/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts +++ b/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts @@ -3,15 +3,11 @@ import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { ServicesEnum, UI_MESSAGES } from '../../../../services/consts-enums-functions'; import { Node } from '../../../../models/RTLconfig'; import { LoggerService } from '../../../../services/logger.service'; import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; import { updateNodeSettings } from '../../../../../store/rtl.actions'; import { RTLState } from '../../../../../store/rtl.state'; -import { setChildNodeSettingsLND } from '../../../../../lnd/store/lnd.actions'; -import { setChildNodeSettingsCLN } from '../../../../../cln/store/cln.actions'; -import { setChildNodeSettingsECL } from '../../../../../eclair/store/ecl.actions'; import { rootSelectedNode } from '../../../../../store/rtl.selector'; @Component({ @@ -67,27 +63,14 @@ export class BoltzServiceSettingsComponent implements OnInit, OnDestroy { return true; } this.logger.info(this.selNode); - this.selNode.settings.boltzServerUrl = this.serverUrl; - this.selNode.authentication.boltzMacaroonPath = this.macaroonPath; - // this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_BOLTZ_SETTINGS, service: ServicesEnum.BOLTZ, settings: { enable: this.enableBoltz, serverUrl: this.serverUrl, macaroonPath: this.macaroonPath } } })); - // this.store.dispatch(setChildNodeSettingsLND({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.settings.enableOffers - // } - // })); - // this.store.dispatch(setChildNodeSettingsCLN({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.settings.enableOffers - // } - // })); - // this.store.dispatch(setChildNodeSettingsECL({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.settings.enableOffers - // } - // })); + if (!this.enableBoltz) { + delete this.selNode.settings.boltzServerUrl; + delete this.selNode.authentication.boltzMacaroonPath; + } else { + this.selNode.settings.boltzServerUrl = this.serverUrl; + this.selNode.authentication.boltzMacaroonPath = this.macaroonPath; + } + this.store.dispatch(updateNodeSettings({ payload: this.selNode })); } onReset() { diff --git a/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts b/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts index 6a3fa1fc..98b2f118 100644 --- a/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts +++ b/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts @@ -3,15 +3,11 @@ import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { ServicesEnum, UI_MESSAGES } from '../../../../services/consts-enums-functions'; import { Node } from '../../../../models/RTLconfig'; import { LoggerService } from '../../../../services/logger.service'; import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; import { updateNodeSettings } from '../../../../../store/rtl.actions'; import { RTLState } from '../../../../../store/rtl.state'; -import { setChildNodeSettingsLND } from '../../../../../lnd/store/lnd.actions'; -import { setChildNodeSettingsCLN } from '../../../../../cln/store/cln.actions'; -import { setChildNodeSettingsECL } from '../../../../../eclair/store/ecl.actions'; import { rootSelectedNode } from '../../../../../store/rtl.selector'; @Component({ @@ -56,26 +52,12 @@ export class LoopServiceSettingsComponent implements OnInit, OnDestroy { if (this.enableLoop && (!this.selNode.settings.swapServerUrl || this.selNode.settings.swapServerUrl.trim() === '' || !this.selNode.authentication.swapMacaroonPath || this.selNode.authentication.swapMacaroonPath.trim() === '')) { return true; } + if (!this.enableLoop) { + delete this.selNode.settings.swapServerUrl; + delete this.selNode.authentication.swapMacaroonPath; + } this.logger.info(this.selNode); - // this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_LOOP_SETTINGS, service: ServicesEnum.LOOP, settings: { enable: this.enableLoop, serverUrl: this.selNode.settings.swapServerUrl, macaroonPath: this.selNode.authentication.swapMacaroonPath } } })); - // this.store.dispatch(setChildNodeSettingsLND({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers - // } - // })); - // this.store.dispatch(setChildNodeSettingsCLN({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers - // } - // })); - // this.store.dispatch(setChildNodeSettingsECL({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers - // } - // })); + this.store.dispatch(updateNodeSettings({ payload: this.selNode })); } onReset() { diff --git a/src/app/shared/components/node-config/services-settings/peerswap-service-settings/peerswap-service-settings.component.ts b/src/app/shared/components/node-config/services-settings/peerswap-service-settings/peerswap-service-settings.component.ts index 3a81088f..89a2c1a6 100644 --- a/src/app/shared/components/node-config/services-settings/peerswap-service-settings/peerswap-service-settings.component.ts +++ b/src/app/shared/components/node-config/services-settings/peerswap-service-settings/peerswap-service-settings.component.ts @@ -3,15 +3,11 @@ import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { ServicesEnum, UI_MESSAGES } from '../../../../services/consts-enums-functions'; import { Node } from '../../../../models/RTLconfig'; import { LoggerService } from '../../../../services/logger.service'; import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; import { updateNodeSettings } from '../../../../../store/rtl.actions'; import { RTLState } from '../../../../../store/rtl.state'; -import { setChildNodeSettingsLND } from '../../../../../lnd/store/lnd.actions'; -import { setChildNodeSettingsCLN } from '../../../../../cln/store/cln.actions'; -import { setChildNodeSettingsECL } from '../../../../../eclair/store/ecl.actions'; import { rootSelectedNode } from '../../../../../store/rtl.selector'; @Component({ @@ -39,28 +35,7 @@ export class PeerswapServiceSettingsComponent implements OnInit, OnDestroy { } onUpdateService(): boolean | void { - // this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_PEERSWAP_SETTINGS, service: ServicesEnum.PEERSWAP, settings: { enablePeerswap: this.enablePeerswap } } })); - // this.store.dispatch(setChildNodeSettingsLND({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers, enablePeerswap: - // this.selNode.settings.enablePeerswap - // } - // })); - // this.store.dispatch(setChildNodeSettingsCLN({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers, enablePeerswap: - // this.selNode.settings.enablePeerswap - // } - // })); - // this.store.dispatch(setChildNodeSettingsECL({ - // payload: { - // userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, - // unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers, enablePeerswap: - // this.selNode.settings.enablePeerswap - // } - // })); + this.store.dispatch(updateNodeSettings({ payload: this.selNode })); } ngOnDestroy() { diff --git a/src/app/shared/components/settings/app-settings/app-settings.component.html b/src/app/shared/components/settings/app-settings/app-settings.component.html index 86b9720c..99d69fab 100644 --- a/src/app/shared/components/settings/app-settings/app-settings.component.html +++ b/src/app/shared/components/settings/app-settings/app-settings.component.html @@ -5,10 +5,6 @@ Default Node
-
- - The setting will apply after RTL server restarts. -
diff --git a/src/app/shared/components/settings/app-settings/app-settings.component.ts b/src/app/shared/components/settings/app-settings/app-settings.component.ts index c4a013d5..faf7e509 100644 --- a/src/app/shared/components/settings/app-settings/app-settings.component.ts +++ b/src/app/shared/components/settings/app-settings/app-settings.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { faWindowRestore, faPlus, faInfoCircle } from '@fortawesome/free-solid-svg-icons'; +import { faWindowRestore, faPlus } from '@fortawesome/free-solid-svg-icons'; import { RTLConfiguration } from '../../../models/RTLconfig'; import { LoggerService } from '../../../services/logger.service'; @@ -18,7 +18,6 @@ import { rootAppConfig } from '../../../../store/rtl.selector'; }) export class AppSettingsComponent implements OnInit, OnDestroy { - public faInfoCircle = faInfoCircle; public faWindowRestore = faWindowRestore; public faPlus = faPlus; public appConfig: RTLConfiguration; diff --git a/src/app/shared/services/consts-enums-functions.ts b/src/app/shared/services/consts-enums-functions.ts index 9ee5ff0b..3596b53c 100644 --- a/src/app/shared/services/consts-enums-functions.ts +++ b/src/app/shared/services/consts-enums-functions.ts @@ -419,7 +419,7 @@ export enum RTLActions { UPDATE_ROOT_NODE_SETTINGS = 'UPDATE_ROOT_NODE_SETTINGS', UPDATE_APPLICATION_SETTINGS = 'UPDATE_APPLICATION_SETTINGS', UPDATE_NODE_SETTINGS = 'UPDATE_NODE_SETTINGS', - UPDATE_SELECTED_NODE_SETTINGS = 'UPDATE_SELECTED_NODE_SETTINGS', + SET_SELECTED_NODE_SETTINGS = 'SET_SELECTED_NODE_SETTINGS', SET_NODE_DATA = 'SET_NODE_DATA', IS_AUTHORIZED = 'IS_AUTHORIZED', IS_AUTHORIZED_RES = 'IS_AUTHORIZED_RES', diff --git a/src/app/store/rtl.actions.ts b/src/app/store/rtl.actions.ts index bf8b78ac..debd15c9 100644 --- a/src/app/store/rtl.actions.ts +++ b/src/app/store/rtl.actions.ts @@ -46,7 +46,7 @@ export const setSelectedNode = createAction(RTLActions.SET_SELECTED_NODE, props< export const updateNodeSettings = createAction(RTLActions.UPDATE_NODE_SETTINGS, props<{ payload: Node }>()); -export const updateSelectedNodeSettings = createAction(RTLActions.UPDATE_SELECTED_NODE_SETTINGS, props<{ payload: Node }>()); +export const setSelectedNodeSettings = createAction(RTLActions.SET_SELECTED_NODE_SETTINGS, props<{ payload: Node }>()); export const updateApplicationSettings = createAction(RTLActions.UPDATE_APPLICATION_SETTINGS, props<{ payload: { showSnackBar: boolean, message: string, config: RTLConfiguration } }>()); diff --git a/src/app/store/rtl.effects.ts b/src/app/store/rtl.effects.ts index 0c976e9c..42c7107c 100644 --- a/src/app/store/rtl.effects.ts +++ b/src/app/store/rtl.effects.ts @@ -26,7 +26,7 @@ import { ErrorMessageComponent } from '../shared/components/data-modal/error-mes import { ShowPubkeyComponent } from '../shared/components/data-modal/show-pubkey/show-pubkey.component'; import { RTLState } from './rtl.state'; -import { resetRootStore, setNodeData, setSelectedNode, updateRootAPICallStatus, closeSpinner, openAlert, openSpinner, openSnackBar, fetchRTLConfig, closeAllDialogs, logout, updateSelectedNodeSettings } from './rtl.actions'; +import { resetRootStore, setNodeData, setSelectedNode, updateRootAPICallStatus, closeSpinner, openAlert, openSpinner, openSnackBar, fetchRTLConfig, closeAllDialogs, logout, setSelectedNodeSettings } from './rtl.actions'; import { fetchInfoLND, resetLNDStore, fetchPageSettings as fetchPageSettingsLND, setChildNodeSettingsLND } from '../lnd/store/lnd.actions'; import { fetchInfoCLN, resetCLNStore, fetchPageSettings as fetchPageSettingsCLN, setChildNodeSettingsCLN } from '../cln/store/cln.actions'; import { fetchInfoECL, resetECLStore, fetchPageSettings as fetchPageSettingsECL, setChildNodeSettingsECL } from '../eclair/store/ecl.actions'; @@ -249,13 +249,16 @@ export class RTLEffects implements OnDestroy { mergeMap((action: { type: string, payload: Node }) => { this.store.dispatch(openSpinner({ payload: UI_MESSAGES.UPDATE_NODE_SETTINGS })); this.store.dispatch(updateRootAPICallStatus({ payload: { action: 'updateNodeSettings', status: APICallStatusEnum.INITIATED } })); + if (!action.payload.settings.fiatConversion) { + delete action.payload.settings.currencyUnit; + } delete action.payload.settings.currencyUnits; return this.httpClient.post(API_END_POINTS.CONF_API + '/node', action.payload). pipe(map((updatedNode: Node) => { this.store.dispatch(updateRootAPICallStatus({ payload: { action: 'updateNodeSettings', status: APICallStatusEnum.COMPLETED } })); this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.UPDATE_NODE_SETTINGS })); updatedNode.settings.currencyUnits = [...CURRENCY_UNITS, (updatedNode.settings?.currencyUnit ? updatedNode.settings?.currencyUnit : '')]; - this.store.dispatch(updateSelectedNodeSettings({ payload: updatedNode })); + this.store.dispatch(setSelectedNodeSettings({ payload: updatedNode })); this.store.dispatch(setChildNodeSettingsLND({ payload: updatedNode })); this.store.dispatch(setChildNodeSettingsCLN({ payload: updatedNode })); this.store.dispatch(setChildNodeSettingsECL({ payload: updatedNode })); diff --git a/src/app/store/rtl.reducers.ts b/src/app/store/rtl.reducers.ts index 76d23cdf..36d8a5ea 100644 --- a/src/app/store/rtl.reducers.ts +++ b/src/app/store/rtl.reducers.ts @@ -1,7 +1,7 @@ import { createReducer, on } from '@ngrx/store'; import { initRootState } from './rtl.state'; -import { resetRootStore, setNodeData, setApplicationSettings, updateSelectedNodeSettings, updateRootAPICallStatus } from './rtl.actions'; +import { resetRootStore, setNodeData, setApplicationSettings, setSelectedNodeSettings, updateRootAPICallStatus } from './rtl.actions'; export const RootReducer = createReducer(initRootState, on(updateRootAPICallStatus, (state, { payload }) => { @@ -26,7 +26,7 @@ export const RootReducer = createReducer(initRootState, appConfig: state.appConfig, selNode: payload })), - on(updateSelectedNodeSettings, (state, { payload }) => ({ + on(setSelectedNodeSettings, (state, { payload }) => ({ ...state, selNode: payload })),