From 8986fb67711a429658e751cc23a70d55629a98a4 Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Wed, 19 Oct 2022 22:30:40 -0700 Subject: [PATCH] LND Services Page Layout --- src/app/app.routing.ts | 20 +--- .../liquidity-ads-list.component.ts | 4 +- .../utxo-tables/utxos/utxos.component.ts | 4 +- .../channel-open-table.component.ts | 4 +- .../channel-pending-table.component.ts | 4 +- .../peers-channels/peers/peers.component.ts | 4 +- .../transactions-report.component.ts | 4 +- .../failed-transactions.component.ts | 4 +- .../forwarding-history.component.ts | 4 +- .../local-failed-transactions.component.ts | 4 +- .../routing-peers/routing-peers.component.ts | 4 +- src/app/cln/store/cln.actions.ts | 10 +- src/app/cln/store/cln.effects.ts | 4 +- src/app/cln/store/cln.reducers.ts | 4 +- src/app/cln/store/cln.state.ts | 4 +- .../lightning-invoices-table.component.ts | 4 +- .../offer-bookmarks-table.component.ts | 4 +- .../offers-table/offers-table.component.ts | 4 +- .../payments/lightning-payments.component.ts | 4 +- .../channel-pending-table.component.html | 16 ++- src/app/lnd/store/lnd.actions.ts | 7 ++ src/app/lnd/store/lnd.effects.ts | 49 +++++++- src/app/lnd/store/lnd.reducers.ts | 29 ++++- src/app/lnd/store/lnd.selector.ts | 1 + src/app/lnd/store/lnd.state.ts | 6 +- .../loop/swaps/swaps.component.html | 54 +++++---- .../loop/swaps/swaps.component.scss | 8 ++ .../ln-services/loop/swaps/swaps.component.ts | 42 ++++--- .../peerswap/peerswap.component.html | 16 --- .../peerswap/peerswap.component.scss | 0 .../peerswap/peerswap.component.spec.ts | 52 --------- .../peerswap/peerswap.component.ts | 41 ------- .../swap-peers/swap-peers.component.html | 1 - .../swap-peers/swap-peers.component.scss | 0 .../swap-peers/swap-peers.component.spec.ts | 35 ------ .../swap-peers/swap-peers.component.ts | 22 ---- .../swaps-cancelled.component.html | 1 - .../swaps-cancelled.component.scss | 0 .../swaps-cancelled.component.spec.ts | 35 ------ .../swaps-cancelled.component.ts | 22 ---- .../peerswap/swaps-in/swaps-in.component.html | 1 - .../peerswap/swaps-in/swaps-in.component.scss | 0 .../swaps-in/swaps-in.component.spec.ts | 35 ------ .../peerswap/swaps-in/swaps-in.component.ts | 22 ---- .../swaps-out/swaps-out.component.html | 1 - .../swaps-out/swaps-out.component.scss | 0 .../swaps-out/swaps-out.component.spec.ts | 35 ------ .../peerswap/swaps-out/swaps-out.component.ts | 22 ---- .../page-settings/page-settings.component.ts | 110 ++++++++++++++---- src/app/shared/models/apiCallsPayload.ts | 1 + src/app/shared/models/pageSettings.ts | 2 +- .../shared/services/consts-enums-functions.ts | 42 ++++++- src/app/shared/shared.module.ts | 19 +-- 53 files changed, 340 insertions(+), 485 deletions(-) delete mode 100755 src/app/shared/components/ln-services/peerswap/peerswap.component.html delete mode 100755 src/app/shared/components/ln-services/peerswap/peerswap.component.scss delete mode 100755 src/app/shared/components/ln-services/peerswap/peerswap.component.spec.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/peerswap.component.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.html delete mode 100755 src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.scss delete mode 100755 src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.spec.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.html delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.scss delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.spec.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.html delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.scss delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.spec.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.html delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.scss delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.spec.ts delete mode 100755 src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.ts diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index b14b534e..d16abc03 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -21,12 +21,6 @@ import { NotFoundComponent } from './shared/components/not-found/not-found.compo import { ErrorComponent } from './shared/components/error/error.component'; import { AuthGuard } from './shared/services/auth.guard'; import { ExperimentalSettingsComponent } from './shared/components/node-config/experimental-settings/experimental-settings.component'; -import { PeerswapComponent } from './shared/components/ln-services/peerswap/peerswap.component'; -import { PeerswapServiceSettingsComponent } from './shared/components/node-config/services-settings/peerswap-service-settings/peerswap-service-settings.component'; -import { SwapPeersComponent } from './shared/components/ln-services/peerswap/swap-peers/swap-peers.component'; -import { PeerswapsOutComponent } from './shared/components/ln-services/peerswap/swaps-out/swaps-out.component'; -import { PeerswapsInComponent } from './shared/components/ln-services/peerswap/swaps-in/swaps-in.component'; -import { PeerswapsCancelledComponent } from './shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component'; export const routes: Routes = [ { path: '', pathMatch: 'full', redirectTo: 'login' }, @@ -50,8 +44,7 @@ export const routes: Routes = [ path: 'services', component: ServicesSettingsComponent, canActivate: [AuthGuard], children: [ { path: '', pathMatch: 'full', redirectTo: 'loop' }, { path: 'loop', component: LoopServiceSettingsComponent, canActivate: [AuthGuard] }, - { path: 'boltz', component: BoltzServiceSettingsComponent, canActivate: [AuthGuard] }, - { path: 'peerswap', component: PeerswapServiceSettingsComponent, canActivate: [AuthGuard] } + { path: 'boltz', component: BoltzServiceSettingsComponent, canActivate: [AuthGuard] } ] }, { path: 'experimental', component: ExperimentalSettingsComponent, canActivate: [AuthGuard] }, @@ -64,16 +57,7 @@ export const routes: Routes = [ { path: 'loop', pathMatch: 'full', redirectTo: 'loop/loopout' }, { path: 'loop/:selTab', component: LoopComponent }, { path: 'boltz', pathMatch: 'full', redirectTo: 'boltz/swapout' }, - { path: 'boltz/:selTab', component: BoltzRootComponent }, - { - path: 'peerswap', component: PeerswapComponent, canActivate: [AuthGuard], children: [ - { path: '', pathMatch: 'full', redirectTo: 'peers' }, - { path: 'peers', component: SwapPeersComponent, canActivate: [AuthGuard] }, - { path: 'psout', component: PeerswapsOutComponent, canActivate: [AuthGuard] }, - { path: 'psin', component: PeerswapsInComponent, canActivate: [AuthGuard] }, - { path: 'pscancelled', component: PeerswapsCancelledComponent, canActivate: [AuthGuard] } - ] - } + { path: 'boltz/:selTab', component: BoltzRootComponent } ] }, { path: 'help', component: HelpComponent }, diff --git a/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.ts b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.ts index 552fa90a..d6fbb5f8 100644 --- a/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.ts +++ b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.ts @@ -20,7 +20,7 @@ import { RTLEffects } from '../../../store/rtl.effects'; import { CLNOpenLiquidityChannelComponent } from '../open-liquidity-channel-modal/open-liquidity-channel-modal.component'; import { clnPageSettings, nodeInfoAndNodeSettingsAndBalance } from '../../store/cln.selector'; import { DecimalPipe } from '@angular/common'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-liquidity-ads-list', @@ -69,7 +69,7 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy { ngOnInit(): void { this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/on-chain/utxo-tables/utxos/utxos.component.ts b/src/app/cln/on-chain/utxo-tables/utxos/utxos.component.ts index 7f8f2ce0..fccc241b 100644 --- a/src/app/cln/on-chain/utxo-tables/utxos/utxos.component.ts +++ b/src/app/cln/on-chain/utxo-tables/utxos/utxos.component.ts @@ -16,7 +16,7 @@ import { CommonService } from '../../../../shared/services/common.service'; import { RTLState } from '../../../../store/rtl.state'; import { openAlert } from '../../../../store/rtl.actions'; import { clnPageSettings, utxos } from '../../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-on-chain-utxos', @@ -56,7 +56,7 @@ export class CLNOnChainUtxosComponent implements OnInit, AfterViewInit, OnDestro this.router.onSameUrlNavigation = 'reload'; this.tableSetting.tableId = this.isDustUTXO ? 'dust_utxos' : 'utxos'; this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts b/src/app/cln/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts index 5c3215a1..8f844986 100644 --- a/src/app/cln/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts +++ b/src/app/cln/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts @@ -22,7 +22,7 @@ import { openAlert, openConfirmation } from '../../../../../store/rtl.actions'; import { RTLState } from '../../../../../store/rtl.state'; import { channelLookup, closeChannel, updateChannel } from '../../../../store/cln.actions'; import { channels, clnPageSettings, nodeInfoAndBalanceAndNumPeers } from '../../../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-channel-open-table', @@ -72,7 +72,7 @@ export class CLNChannelOpenTableComponent implements OnInit, AfterViewInit, OnDe this.logger.info(infoBalNumpeersSelector); }); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[1])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts b/src/app/cln/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts index c6be99aa..1f9b82a8 100644 --- a/src/app/cln/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts +++ b/src/app/cln/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts @@ -20,7 +20,7 @@ import { openAlert, openConfirmation } from '../../../../../store/rtl.actions'; import { RTLState } from '../../../../../store/rtl.state'; import { closeChannel } from '../../../../store/cln.actions'; import { channels, clnPageSettings, nodeInfoAndBalanceAndNumPeers } from '../../../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-channel-pending-table', @@ -74,7 +74,7 @@ export class CLNChannelPendingTableComponent implements OnInit, AfterViewInit, O this.logger.info(infoBalNumpeersSelector); }); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[1])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/peers-channels/peers/peers.component.ts b/src/app/cln/peers-channels/peers/peers.component.ts index fc62b3cb..b33e3155 100644 --- a/src/app/cln/peers-channels/peers/peers.component.ts +++ b/src/app/cln/peers-channels/peers/peers.component.ts @@ -22,7 +22,7 @@ import { RTLState } from '../../../store/rtl.state'; import { openAlert, openConfirmation } from '../../../store/rtl.actions'; import { detachPeer } from '../../store/cln.actions'; import { clnPageSettings, nodeInfoAndBalance, peers } from '../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-peers', @@ -67,7 +67,7 @@ export class CLNPeersComponent implements OnInit, AfterViewInit, OnDestroy { this.availableBalance = infoBalSelector.balance.totalBalance || 0; }); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[1])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/reports/transactions/transactions-report.component.ts b/src/app/cln/reports/transactions/transactions-report.component.ts index fb676b03..617d6960 100644 --- a/src/app/cln/reports/transactions/transactions-report.component.ts +++ b/src/app/cln/reports/transactions/transactions-report.component.ts @@ -12,7 +12,7 @@ import { RTLState } from '../../../store/rtl.state'; import { payments, listInvoices, clnPageSettings } from '../../store/cln.selector'; import { ApiCallStatusPayload } from '../../../shared/models/apiCallsPayload'; import { LoggerService } from '../../../shared/services/logger.service'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-transactions-report', @@ -53,7 +53,7 @@ export class CLNTransactionsReportComponent implements OnInit, OnDestroy { this.screenSize = this.commonService.getScreenSize(); this.showYAxisLabel = !(this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { if (settings.apiCallStatus.status === APICallStatusEnum.ERROR) { if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) { this.displayedColumns = ['date', 'amount_paid', 'amount_received']; diff --git a/src/app/cln/routing/failed-transactions/failed-transactions.component.ts b/src/app/cln/routing/failed-transactions/failed-transactions.component.ts index 9e43000f..4af76c2c 100644 --- a/src/app/cln/routing/failed-transactions/failed-transactions.component.ts +++ b/src/app/cln/routing/failed-transactions/failed-transactions.component.ts @@ -19,7 +19,7 @@ import { openAlert } from '../../../store/rtl.actions'; import { getForwardingHistory } from '../../store/cln.actions'; import { clnPageSettings, failedForwardingHistory } from '../../store/cln.selector'; import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-failed-history', @@ -59,7 +59,7 @@ export class CLNFailedTransactionsComponent implements OnInit, AfterViewInit, On this.router.onSameUrlNavigation = 'reload'; this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.FAILED } })); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/routing/forwarding-history/forwarding-history.component.ts b/src/app/cln/routing/forwarding-history/forwarding-history.component.ts index 6df76b76..0d30e23c 100644 --- a/src/app/cln/routing/forwarding-history/forwarding-history.component.ts +++ b/src/app/cln/routing/forwarding-history/forwarding-history.component.ts @@ -18,7 +18,7 @@ import { RTLState } from '../../../store/rtl.state'; import { openAlert } from '../../../store/rtl.actions'; import { clnPageSettings, forwardingHistory } from '../../store/cln.selector'; import { getForwardingHistory } from '../../store/cln.actions'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-forwarding-history', @@ -58,7 +58,7 @@ export class CLNForwardingHistoryComponent implements OnInit, OnChanges, AfterVi this.router.routeReuseStrategy.shouldReuseRoute = () => false; this.router.onSameUrlNavigation = 'reload'; this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/routing/local-failed-transactions/local-failed-transactions.component.ts b/src/app/cln/routing/local-failed-transactions/local-failed-transactions.component.ts index f2e3179d..4b0e1d8d 100644 --- a/src/app/cln/routing/local-failed-transactions/local-failed-transactions.component.ts +++ b/src/app/cln/routing/local-failed-transactions/local-failed-transactions.component.ts @@ -19,7 +19,7 @@ import { openAlert } from '../../../store/rtl.actions'; import { getForwardingHistory } from '../../store/cln.actions'; import { clnPageSettings, localFailedForwardingHistory } from '../../store/cln.selector'; import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-local-failed-history', @@ -60,7 +60,7 @@ export class CLNLocalFailedTransactionsComponent implements OnInit, AfterViewIni this.router.onSameUrlNavigation = 'reload'; this.store.dispatch(getForwardingHistory({ payload: { status: CLNForwardingEventsStatusEnum.LOCAL_FAILED } })); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/routing/routing-peers/routing-peers.component.ts b/src/app/cln/routing/routing-peers/routing-peers.component.ts index 586656b4..c312e9de 100644 --- a/src/app/cln/routing/routing-peers/routing-peers.component.ts +++ b/src/app/cln/routing/routing-peers/routing-peers.component.ts @@ -14,7 +14,7 @@ import { CommonService } from '../../../shared/services/common.service'; import { RTLState } from '../../../store/rtl.state'; import { clnPageSettings, forwardingHistory } from '../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; import { getForwardingHistory } from '../../store/cln.actions'; @Component({ @@ -61,7 +61,7 @@ export class CLNRoutingPeersComponent implements OnInit, OnChanges, AfterViewIni } }); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/store/cln.actions.ts b/src/app/cln/store/cln.actions.ts index bfc19668..a9467a35 100644 --- a/src/app/cln/store/cln.actions.ts +++ b/src/app/cln/store/cln.actions.ts @@ -3,8 +3,8 @@ import { createAction, props } from '@ngrx/store'; import { CLNActions } from '../../shared/services/consts-enums-functions'; import { ApiCallStatusPayload } from '../../shared/models/apiCallsPayload'; import { SelNodeChild } from '../../shared/models/RTLconfig'; -import { GetInfo, Fees, Peer, Payment, QueryRoutes, Channel, FeeRates, Invoice, ListInvoices, OnChain, UTXO, SaveChannel, GetNewAddress, DetachPeer, UpdateChannel, CloseChannel, SendPayment, GetQueryRoutes, ChannelLookup, OfferInvoice, Offer, OfferBookmark, ListForwards, FetchListForwards, LocalFailedEvent, ForwardingEvent } from '../../shared/models/clnModels'; -import { PageSettingsCLN } from '../../shared/models/pageSettings'; +import { GetInfo, Fees, Peer, Payment, QueryRoutes, Channel, FeeRates, Invoice, ListInvoices, OnChain, UTXO, SaveChannel, GetNewAddress, DetachPeer, UpdateChannel, CloseChannel, SendPayment, GetQueryRoutes, ChannelLookup, OfferInvoice, Offer, OfferBookmark, ListForwards, FetchListForwards } from '../../shared/models/clnModels'; +import { PageSettings } from '../../shared/models/pageSettings'; export const updateCLAPICallStatus = createAction(CLNActions.UPDATE_API_CALL_STATUS_CLN, props<{ payload: ApiCallStatusPayload }>()); @@ -12,11 +12,11 @@ export const resetCLStore = createAction(CLNActions.RESET_CLN_STORE, props<{ pay export const setChildNodeSettingsCL = createAction(CLNActions.SET_CHILD_NODE_SETTINGS_CLN, props<{ payload: SelNodeChild }>()); -export const fetchPageSettingsCL = createAction(CLNActions.FETCH_PAGE_SETTINGS_CLN); +export const fetchPageSettings = createAction(CLNActions.FETCH_PAGE_SETTINGS_CLN); -export const setPageSettings = createAction(CLNActions.SET_PAGE_SETTINGS_CLN, props<{ payload: PageSettingsCLN[] }>()); +export const setPageSettings = createAction(CLNActions.SET_PAGE_SETTINGS_CLN, props<{ payload: PageSettings[] }>()); -export const savePageSettings = createAction(CLNActions.SAVE_PAGE_SETTINGS_CLN, props<{ payload: PageSettingsCLN[] }>()); +export const savePageSettings = createAction(CLNActions.SAVE_PAGE_SETTINGS_CLN, props<{ payload: PageSettings[] }>()); export const fetchInfoCL = createAction(CLNActions.FETCH_INFO_CLN, props<{ payload: { loadPage: string } }>()); diff --git a/src/app/cln/store/cln.effects.ts b/src/app/cln/store/cln.effects.ts index d7c9a0fc..940561d8 100644 --- a/src/app/cln/store/cln.effects.ts +++ b/src/app/cln/store/cln.effects.ts @@ -19,7 +19,7 @@ import { AlertTypeEnum, APICallStatusEnum, UI_MESSAGES, CLNWSEventTypeEnum, CLNA import { closeAllDialogs, closeSpinner, logout, openAlert, openSnackBar, openSpinner, setApiUrl, setNodeData } from '../../store/rtl.actions'; import { RTLState } from '../../store/rtl.state'; -import { addUpdateOfferBookmark, fetchBalance, fetchChannels, fetchFeeRates, fetchFees, fetchInvoices, fetchLocalRemoteBalance, fetchPayments, fetchPeers, fetchUTXOs, setLookup, setPeers, setQueryRoutes, updateCLAPICallStatus, updateInvoice, setOfferInvoice, sendPaymentStatus, setForwardingHistory, fetchPageSettingsCL } from './cln.actions'; +import { addUpdateOfferBookmark, fetchBalance, fetchChannels, fetchFeeRates, fetchFees, fetchInvoices, fetchLocalRemoteBalance, fetchPayments, fetchPeers, fetchUTXOs, setLookup, setPeers, setQueryRoutes, updateCLAPICallStatus, updateInvoice, setOfferInvoice, sendPaymentStatus, setForwardingHistory, fetchPageSettings } from './cln.actions'; import { allAPIsCallStatus } from './cln.selector'; import { ApiCallsListCL } from '../../shared/models/apiCallsPayload'; import { CLNOfferInformationComponent } from '../transactions/offers/offer-information-modal/offer-information.component'; @@ -1004,7 +1004,7 @@ export class CLNEffects implements OnDestroy { newRoute = '/cln/home'; } this.router.navigate([newRoute]); - this.store.dispatch(fetchPageSettingsCL()); + this.store.dispatch(fetchPageSettings()); this.store.dispatch(fetchInvoices({ payload: { num_max_invoices: 1000000, index_offset: 0, reversed: true } })); this.store.dispatch(fetchFees()); this.store.dispatch(fetchChannels()); diff --git a/src/app/cln/store/cln.reducers.ts b/src/app/cln/store/cln.reducers.ts index a551f913..d3b76f59 100644 --- a/src/app/cln/store/cln.reducers.ts +++ b/src/app/cln/store/cln.reducers.ts @@ -8,7 +8,7 @@ import { } from './cln.actions'; import { Channel, OfferBookmark } from '../../shared/models/clnModels'; import { CLNForwardingEventsStatusEnum, CLN_DEFAULT_PAGE_SETTINGS } from '../../shared/services/consts-enums-functions'; -import { PageSettingsCLN } from '../../shared/models/pageSettings'; +import { PageSettings } from '../../shared/models/pageSettings'; export const CLNReducer = createReducer(initCLNState, on(updateCLAPICallStatus, (state, { payload }) => { @@ -219,7 +219,7 @@ export const CLNReducer = createReducer(initCLNState, }; }), on(setPageSettings, (state, { payload }) => { - const newPageSettings: PageSettingsCLN[] = []; + const newPageSettings: PageSettings[] = []; CLN_DEFAULT_PAGE_SETTINGS.forEach((defaultPage) => { const pageSetting = payload.find((p) => p.pageId === defaultPage.pageId) || null; if (pageSetting) { diff --git a/src/app/cln/store/cln.state.ts b/src/app/cln/store/cln.state.ts index f9e5c94d..022ce220 100644 --- a/src/app/cln/store/cln.state.ts +++ b/src/app/cln/store/cln.state.ts @@ -2,12 +2,12 @@ import { SelNodeChild } from '../../shared/models/RTLconfig'; import { APICallStatusEnum, CLN_DEFAULT_PAGE_SETTINGS, UserPersonaEnum } from '../../shared/services/consts-enums-functions'; import { GetInfo, Fees, Balance, LocalRemoteBalance, Peer, Payment, Channel, FeeRates, ListInvoices, UTXO, Offer, OfferBookmark, ListForwards } from '../../shared/models/clnModels'; import { ApiCallsListCL } from '../../shared/models/apiCallsPayload'; -import { PageSettingsCLN } from '../../shared/models/pageSettings'; +import { PageSettings } from '../../shared/models/pageSettings'; export interface CLNState { apisCallStatus: ApiCallsListCL; nodeSettings: SelNodeChild | null; - pageSettings: PageSettingsCLN[]; + pageSettings: PageSettings[]; information: GetInfo; fees: Fees; feeRatesPerKB: FeeRates; diff --git a/src/app/cln/transactions/invoices/invoices-table/lightning-invoices-table.component.ts b/src/app/cln/transactions/invoices/invoices-table/lightning-invoices-table.component.ts index 0fdf016e..7a440d60 100644 --- a/src/app/cln/transactions/invoices/invoices-table/lightning-invoices-table.component.ts +++ b/src/app/cln/transactions/invoices/invoices-table/lightning-invoices-table.component.ts @@ -24,7 +24,7 @@ import { RTLState } from '../../../../store/rtl.state'; import { openAlert, openConfirmation } from '../../../../store/rtl.actions'; import { deleteExpiredInvoice, invoiceLookup, saveNewInvoice } from '../../../store/cln.actions'; import { clnNodeInformation, clnNodeSettings, clnPageSettings, listInvoices } from '../../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-lightning-invoices-table', @@ -78,7 +78,7 @@ export class CLNLightningInvoicesTableComponent implements OnInit, AfterViewInit this.information = nodeInfo; }); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[2])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/transactions/offers/offer-bookmarks-table/offer-bookmarks-table.component.ts b/src/app/cln/transactions/offers/offer-bookmarks-table/offer-bookmarks-table.component.ts index 681793a5..765a45f1 100644 --- a/src/app/cln/transactions/offers/offer-bookmarks-table/offer-bookmarks-table.component.ts +++ b/src/app/cln/transactions/offers/offer-bookmarks-table/offer-bookmarks-table.component.ts @@ -20,7 +20,7 @@ import { clnPageSettings, offerBookmarks } from '../../../store/cln.selector'; import { CLNOfferInformationComponent } from '../offer-information-modal/offer-information.component'; import { CLNLightningSendPaymentsComponent } from '../../send-payment-modal/send-payment.component'; import { deleteOfferBookmark } from '../../../store/cln.actions'; -import { PageSettingsCLN, TableSetting } from '../../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-offer-bookmarks-table', @@ -56,7 +56,7 @@ export class CLNOfferBookmarksTableComponent implements OnInit, AfterViewInit, O ngOnInit() { this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/transactions/offers/offers-table/offers-table.component.ts b/src/app/cln/transactions/offers/offers-table/offers-table.component.ts index beede345..d6c2d5ea 100644 --- a/src/app/cln/transactions/offers/offers-table/offers-table.component.ts +++ b/src/app/cln/transactions/offers/offers-table/offers-table.component.ts @@ -27,7 +27,7 @@ import { RTLState } from '../../../../store/rtl.state'; import { openAlert, openConfirmation } from '../../../../store/rtl.actions'; import { disableOffer } from '../../../store/cln.actions'; import { clnNodeInformation, clnNodeSettings, clnPageSettings, offers } from '../../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-offers-table', @@ -80,7 +80,7 @@ export class CLNOffersTableComponent implements OnInit, AfterViewInit, OnDestroy this.information = nodeInfo; }); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[2])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/cln/transactions/payments/lightning-payments.component.ts b/src/app/cln/transactions/payments/lightning-payments.component.ts index f9f6ef61..2bf5ac0e 100644 --- a/src/app/cln/transactions/payments/lightning-payments.component.ts +++ b/src/app/cln/transactions/payments/lightning-payments.component.ts @@ -24,7 +24,7 @@ import { RTLState } from '../../../store/rtl.state'; import { openAlert, openConfirmation } from '../../../store/rtl.actions'; import { sendPayment } from '../../store/cln.actions'; import { clnNodeInformation, clnNodeSettings, clnPageSettings, payments } from '../../store/cln.selector'; -import { PageSettingsCLN, TableSetting } from '../../../shared/models/pageSettings'; +import { PageSettings, TableSetting } from '../../../shared/models/pageSettings'; @Component({ selector: 'rtl-cln-lightning-payments', @@ -75,7 +75,7 @@ export class CLNLightningPaymentsComponent implements OnInit, AfterViewInit, OnD this.information = nodeInfo; }); this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[2])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = settings.apiCallStatus; if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.html b/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.html index 044e87a1..b4723502 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.html +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.html @@ -26,7 +26,9 @@ {{channel.channel.capacity | number}} - Actions + +
Actions
+
@@ -74,7 +76,9 @@ {{channel.channel.capacity | number}} - Actions + +
Actions
+
@@ -123,7 +127,9 @@ number}}
- Actions + +
Actions
+
@@ -178,7 +184,9 @@ number}}
- Actions + +
Actions
+
diff --git a/src/app/lnd/store/lnd.actions.ts b/src/app/lnd/store/lnd.actions.ts index f2a9e7af..436c3842 100644 --- a/src/app/lnd/store/lnd.actions.ts +++ b/src/app/lnd/store/lnd.actions.ts @@ -7,6 +7,7 @@ import { GetInfo, Peer, NetworkInfo, Fees, Channel, Invoice, ListInvoices, ChannelsTransaction, ClosedChannel, Transaction, SwitchReq, SwitchRes, QueryRoutes, LightningNode, UTXO, ListPayments, SavePeer, SaveInvoice, SaveChannel, CloseChannel, FetchInvoices, FetchPayments, SendPayment, GetNewAddress, GetQueryRoutes, InitWallet, ChannelLookup, SetRestoreChannelsList, NewlyAddedPeer, BlockchainBalance, SetPendingChannels, BackupChannels, SetAllLightningTransactions, Payment } from '../../shared/models/lndModels'; +import { PageSettings } from '../../shared/models/pageSettings'; export const updateLNDAPICallStatus = createAction(LNDActions.UPDATE_API_CALL_STATUS_LND, props<{ payload: ApiCallStatusPayload }>()); @@ -14,6 +15,12 @@ export const resetLNDStore = createAction(LNDActions.RESET_LND_STORE, props<{ pa export const setChildNodeSettingsLND = createAction(LNDActions.SET_CHILD_NODE_SETTINGS_LND, props<{ payload: SelNodeChild }>()); +export const fetchPageSettings = createAction(LNDActions.FETCH_PAGE_SETTINGS_LND); + +export const setPageSettings = createAction(LNDActions.SET_PAGE_SETTINGS_LND, props<{ payload: PageSettings[] }>()); + +export const savePageSettings = createAction(LNDActions.SAVE_PAGE_SETTINGS_LND, props<{ payload: PageSettings[] }>()); + export const fetchInfoLND = createAction(LNDActions.FETCH_INFO_LND, props<{ payload: { loadPage: string } }>()); export const setInfo = createAction(LNDActions.SET_INFO_LND, props<{ payload: GetInfo }>()); diff --git a/src/app/lnd/store/lnd.effects.ts b/src/app/lnd/store/lnd.effects.ts index 21a94559..4b7f874a 100644 --- a/src/app/lnd/store/lnd.effects.ts +++ b/src/app/lnd/store/lnd.effects.ts @@ -19,7 +19,7 @@ import { RTLActions, LNDActions, AlertTypeEnum, APICallStatusEnum, FEE_LIMIT_TYP import { closeAllDialogs, closeSpinner, logout, openAlert, openSnackBar, openSpinner, setApiUrl, setNodeData } from '../../store/rtl.actions'; import { RTLState } from '../../store/rtl.state'; -import { backupChannels, fetchBalanceBlockchain, fetchClosedChannels, fetchFees, fetchInfoLND, fetchInvoices, fetchNetwork, fetchPayments, fetchPeers, fetchPendingChannels, fetchTransactions, setForwardingHistory, setLookup, setPeers, setQueryRoutes, setRestoreChannelsList, updateLNDAPICallStatus, updateInvoice, fetchChannels, paymentLookup, updatePayment } from './lnd.actions'; +import { backupChannels, fetchBalanceBlockchain, fetchClosedChannels, fetchFees, fetchInfoLND, fetchInvoices, fetchNetwork, fetchPayments, fetchPeers, fetchPendingChannels, fetchTransactions, setForwardingHistory, setPeers, setQueryRoutes, setRestoreChannelsList, updateLNDAPICallStatus, updateInvoice, fetchChannels, updatePayment, fetchPageSettings } from './lnd.actions'; import { allAPIsCallStatus, lndNodeInformation } from './lnd.selector'; import { ApiCallsListLND } from '../../shared/models/apiCallsPayload'; import { WebSocketClientService } from '../../shared/services/web-socket.service'; @@ -1188,6 +1188,52 @@ export class LNDEffects implements OnDestroy { })) ); + pageSettingsFetch = createEffect(() => this.actions.pipe( + ofType(LNDActions.FETCH_PAGE_SETTINGS_LND), + mergeMap(() => { + this.store.dispatch(updateLNDAPICallStatus({ payload: { action: 'FetchPageSettings', status: APICallStatusEnum.INITIATED } })); + return this.httpClient.get(environment.PAGE_SETTINGS_API).pipe( + map((pageSettings: any) => { + this.logger.info(pageSettings); + this.store.dispatch(updateLNDAPICallStatus({ payload: { action: 'FetchPageSettings', status: APICallStatusEnum.COMPLETED } })); + return { + type: LNDActions.SET_PAGE_SETTINGS_LND, + payload: pageSettings || [] + }; + }), + catchError((err: any) => { + this.handleErrorWithoutAlert('FetchPageSettings', UI_MESSAGES.NO_SPINNER, 'Fetching Page Settings Failed.', err); + return of({ type: RTLActions.VOID }); + }) + ); + }) + )); + + savePageSettings = createEffect(() => this.actions.pipe( + ofType(LNDActions.SAVE_PAGE_SETTINGS_LND), + mergeMap((action: { type: string, payload: any }) => { + this.store.dispatch(openSpinner({ payload: UI_MESSAGES.UPDATE_PAGE_SETTINGS })); + this.store.dispatch(updateLNDAPICallStatus({ payload: { action: 'SavePageSettings', status: APICallStatusEnum.INITIATED } })); + return this.httpClient.post(environment.PAGE_SETTINGS_API, action.payload). + pipe( + map((postRes: any) => { + this.logger.info(postRes); + this.store.dispatch(updateLNDAPICallStatus({ payload: { action: 'SavePageSettings', status: APICallStatusEnum.COMPLETED } })); + this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.UPDATE_PAGE_SETTINGS })); + this.store.dispatch(openSnackBar({ payload: 'Page Layout Updated Successfully!' })); + return { + type: LNDActions.SET_PAGE_SETTINGS_LND, + payload: postRes || [] + }; + }), + catchError((err: any) => { + this.handleErrorWithoutAlert('SavePageSettings', UI_MESSAGES.UPDATE_PAGE_SETTINGS, 'Page Settings Update Failed.', err); + return of({ type: RTLActions.VOID }); + }) + ); + }) + )); + initializeRemainingData(info: any, landingPage: string) { this.sessionService.setItem('lndUnlocked', 'true'); const node_data = { @@ -1210,6 +1256,7 @@ export class LNDEffects implements OnDestroy { newRoute = '/lnd/home'; } this.router.navigate([newRoute]); + this.store.dispatch(fetchPageSettings()); this.store.dispatch(fetchBalanceBlockchain()); this.store.dispatch(fetchChannels()); this.store.dispatch(fetchPendingChannels()); diff --git a/src/app/lnd/store/lnd.reducers.ts b/src/app/lnd/store/lnd.reducers.ts index 819b2445..f80115a6 100644 --- a/src/app/lnd/store/lnd.reducers.ts +++ b/src/app/lnd/store/lnd.reducers.ts @@ -1,8 +1,10 @@ import { createReducer, on } from '@ngrx/store'; import { initLNDState } from './lnd.state'; -import { addInvoice, removeChannel, removePeer, resetLNDStore, setChannels, setAllLightningTransactions, setBalanceBlockchain, setChildNodeSettingsLND, setClosedChannels, setFees, setForwardingHistory, setInfo, setInvoices, setNetwork, setPayments, setPeers, setPendingChannels, setTransactions, setUTXOs, updateLNDAPICallStatus, updateInvoice, updatePayment } from './lnd.actions'; +import { addInvoice, removeChannel, removePeer, resetLNDStore, setChannels, setAllLightningTransactions, setBalanceBlockchain, setChildNodeSettingsLND, setClosedChannels, setFees, setForwardingHistory, setInfo, setInvoices, setNetwork, setPayments, setPeers, setPendingChannels, setTransactions, setUTXOs, updateLNDAPICallStatus, updateInvoice, updatePayment, setPageSettings } from './lnd.actions'; import { Channel, ClosedChannel, SetAllLightningTransactions } from '../../shared/models/lndModels'; +import { PageSettings } from '../../shared/models/pageSettings'; +import { LND_DEFAULT_PAGE_SETTINGS } from '../../shared/services/consts-enums-functions'; let flgTransactionsSet = false; let flgUTXOsSet = false; @@ -220,6 +222,31 @@ export const LNDReducer = createReducer(initLNDState, ...state, forwardingHistory: updatedPayload }; + }), + on(setPageSettings, (state, { payload }) => { + const newPageSettings: PageSettings[] = []; + LND_DEFAULT_PAGE_SETTINGS.forEach((defaultPage) => { + const pageSetting = payload.find((p) => p.pageId === defaultPage.pageId) || null; + if (pageSetting) { + const tablesSettings = JSON.parse(JSON.stringify(pageSetting.tables)); + pageSetting.tables = []; // To maintain settings order + defaultPage.tables.forEach((defaultTable) => { + const tableSetting = tablesSettings.find((t) => t.tableId === defaultTable.tableId) || null; + if (tableSetting) { + pageSetting.tables.push(tableSetting); + } else { + pageSetting.tables.push(JSON.parse(JSON.stringify(defaultTable))); + } + }); + newPageSettings.push(pageSetting); + } else { + newPageSettings.push(JSON.parse(JSON.stringify(defaultPage))); + } + }); + return { + ...state, + pageSettings: newPageSettings + }; }) ); diff --git a/src/app/lnd/store/lnd.selector.ts b/src/app/lnd/store/lnd.selector.ts index f0dca16a..064036ff 100644 --- a/src/app/lnd/store/lnd.selector.ts +++ b/src/app/lnd/store/lnd.selector.ts @@ -3,6 +3,7 @@ import { LNDState } from './lnd.state'; export const lndState = createFeatureSelector('lnd'); export const lndNodeSettings = createSelector(lndState, (state: LNDState) => state.nodeSettings); +export const lndPageSettings = createSelector(lndState, (state: LNDState) => ({ pageSettings: state.pageSettings, apiCallStatus: state.apisCallStatus.FetchPageSettings })); export const lndNodeInformation = createSelector(lndState, (state: LNDState) => state.information); export const nodeInfoStatus = createSelector(lndState, (state: LNDState) => ({ information: state.information, apiCallStatus: state.apisCallStatus.FetchInfo })); export const allAPIsCallStatus = createSelector(lndState, (state: LNDState) => state.apisCallStatus); diff --git a/src/app/lnd/store/lnd.state.ts b/src/app/lnd/store/lnd.state.ts index ac261fc6..db146c95 100644 --- a/src/app/lnd/store/lnd.state.ts +++ b/src/app/lnd/store/lnd.state.ts @@ -1,11 +1,13 @@ import { SelNodeChild } from '../../shared/models/RTLconfig'; import { ApiCallsListLND } from '../../shared/models/apiCallsPayload'; -import { APICallStatusEnum, UserPersonaEnum } from '../../shared/services/consts-enums-functions'; +import { APICallStatusEnum, LND_DEFAULT_PAGE_SETTINGS, UserPersonaEnum } from '../../shared/services/consts-enums-functions'; import { GetInfo, Peer, Fees, NetworkInfo, BlockchainBalance, Channel, ListInvoices, PendingChannels, ClosedChannel, Transaction, SwitchRes, PendingChannelsSummary, UTXO, ListPayments, LightningBalance, ChannelsSummary } from '../../shared/models/lndModels'; +import { PageSettings } from '../../shared/models/pageSettings'; export interface LNDState { apisCallStatus: ApiCallsListLND; nodeSettings: SelNodeChild | null; + pageSettings: PageSettings[]; information: GetInfo; peers: Peer[]; fees: Fees; @@ -27,6 +29,7 @@ export interface LNDState { export const initLNDState: LNDState = { apisCallStatus: { + FetchPageSettings: { status: APICallStatusEnum.UN_INITIATED }, FetchInfo: { status: APICallStatusEnum.UN_INITIATED }, FetchFees: { status: APICallStatusEnum.UN_INITIATED }, FetchPeers: { status: APICallStatusEnum.UN_INITIATED }, @@ -43,6 +46,7 @@ export const initLNDState: LNDState = { FetchNetwork: { status: APICallStatusEnum.UN_INITIATED } }, nodeSettings: { userPersona: UserPersonaEnum.OPERATOR, fiatConversion: false, channelBackupPath: '', currencyUnits: [], selCurrencyUnit: '', lnImplementation: '', swapServerUrl: '' }, + pageSettings: LND_DEFAULT_PAGE_SETTINGS, information: {}, peers: [], fees: { diff --git a/src/app/shared/components/ln-services/loop/swaps/swaps.component.html b/src/app/shared/components/ln-services/loop/swaps/swaps.component.html index 8c0fc066..3cd619a1 100755 --- a/src/app/shared/components/ln-services/loop/swaps/swaps.component.html +++ b/src/app/shared/components/ln-services/loop/swaps/swaps.component.html @@ -12,49 +12,61 @@
+ + + + - + - - - - - - - - - - - - - - - - - + - + - + + + + + + + + + + + + +
State {{LoopStateEnum[swap?.state]}} Initiation Time {{(swap.initiation_time/1000000) | date:'dd/MMM/y HH:mm'}}{{(swap?.initiation_time/1000000) | date:'dd/MMM/y HH:mm'}} Last Update Time {{(swap.last_update_time/1000000) | date:'dd/MMM/y HH:mm'}} ID {{swap.id}} ID (Bytes) {{swap.id_bytes}} State {{LoopStateEnum[swap.state]}} HTLC Address {{swap.htlc_address}}{{(swap?.last_update_time/1000000) | date:'dd/MMM/y HH:mm'}} Amount (Sats) - {{swap.amt | number}} + {{swap?.amt | number}} Cost Server (Sats) {{swap.cost_server | number}}{{swap?.cost_server | number}} Cost Offchain (Sats) {{swap.cost_offchain | number}}{{swap?.cost_offchain | number}} Cost Onchain (Sats) {{swap?.cost_onchain | number}} HTLC Address + + {{swap?.htlc_address}} + + ID + + {{swap?.id}} + + ID (Bytes) + + {{swap?.id_bytes}} + +
diff --git a/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss b/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss index 4ad066b1..ba63493f 100755 --- a/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss +++ b/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss @@ -1,3 +1,11 @@ +.mat-column-htlc_address, .mat-column-id, .mat-column-id_bytes { + flex: 0 0 15%; + width: 15%; + & .ellipsis-parent { + display: flex; + } +} + .mat-column-actions { min-height: 4.8rem; } diff --git a/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts b/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts index 02d7a73f..5e760ba9 100755 --- a/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts +++ b/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts @@ -1,21 +1,23 @@ -import { Component, OnChanges, OnDestroy, ViewChild, Input, AfterViewInit, SimpleChanges } from '@angular/core'; +import { Component, OnChanges, OnDestroy, ViewChild, Input, AfterViewInit, SimpleChanges, OnInit } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { Actions } from '@ngrx/effects'; import { faHistory } from '@fortawesome/free-solid-svg-icons'; import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { LoopSwapStatus } from '../../../../models/loopModels'; -import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, LoopTypeEnum, LoopStateEnum } from '../../../../services/consts-enums-functions'; +import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, LoopTypeEnum, LoopStateEnum, SortOrderEnum, LND_DEFAULT_PAGE_SETTINGS } from '../../../../services/consts-enums-functions'; import { LoggerService } from '../../../../services/logger.service'; import { CommonService } from '../../../../services/common.service'; import { LoopService } from '../../../../services/loop.service'; import { RTLState } from '../../../../../store/rtl.state'; import { openAlert } from '../../../../../store/rtl.actions'; +import { PageSettings, TableSetting } from '../../../../models/pageSettings'; +import { lndPageSettings } from '../../../../../lnd/store/lnd.selector'; +import { ApiCallStatusPayload } from '../../../../models/apiCallsPayload'; @Component({ selector: 'rtl-swaps', @@ -25,7 +27,7 @@ import { openAlert } from '../../../../../store/rtl.actions'; { provide: MatPaginatorIntl, useValue: getPaginatorLabel('Swaps') } ] }) -export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy { +export class SwapsComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy { @Input() selectedSwapType: LoopTypeEnum = LoopTypeEnum.LOOP_OUT; @Input() swapsData: LoopSwapStatus[] = []; @@ -33,6 +35,8 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy { @Input() emptyTableMessage = 'No swaps available.'; @ViewChild(MatSort, { static: false }) sort: MatSort | undefined; @ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined; + public PAGE_ID = 'loop'; + public tableSetting: TableSetting = { tableId: 'loop', recordsPerPage: PAGE_SIZE, sortBy: 'initiation_time', sortOrder: SortOrderEnum.DESCENDING }; public LoopStateEnum = LoopStateEnum; public faHistory = faHistory; public swapCaption = 'Loop Out'; @@ -47,15 +51,24 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy { constructor(private logger: LoggerService, private commonService: CommonService, private store: Store, private loopService: LoopService) { this.screenSize = this.commonService.getScreenSize(); - if (this.screenSize === ScreenSizeEnum.XS) { - this.displayedColumns = ['state', 'amt', 'actions']; - } else if (this.screenSize === ScreenSizeEnum.SM) { - this.displayedColumns = ['state', 'amt', 'actions']; - } else if (this.screenSize === ScreenSizeEnum.MD) { - this.displayedColumns = ['state', 'initiation_time', 'amt', 'actions']; - } else { - this.displayedColumns = ['state', 'initiation_time', 'amt', 'cost_server', 'cost_offchain', 'cost_onchain', 'actions']; - } + } + + ngOnInit() { + this.store.select(lndPageSettings).pipe(takeUntil(this.unSubs[0])). + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { + this.tableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId) || LND_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId)!; + if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) { + this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelectionSM)); + } else { + this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelection)); + } + this.displayedColumns.push('actions'); + this.pageSize = this.tableSetting.recordsPerPage ? +this.tableSetting.recordsPerPage : PAGE_SIZE; + if (this.swapsData && this.swapsData.length > 0 && this.sort && this.paginator) { + this.loadSwapsTable(this.swapsData); + } + this.logger.info(this.displayedColumns); + }); } ngAfterViewInit() { @@ -74,7 +87,7 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy { } onSwapClick(selSwap: LoopSwapStatus, event: any) { - this.loopService.getSwap(selSwap.id_bytes?.replace(/\//g, '_')?.replace(/\+/g, '-') || '').pipe(takeUntil(this.unSubs[2])). + this.loopService.getSwap(selSwap.id_bytes?.replace(/\//g, '_')?.replace(/\+/g, '-') || '').pipe(takeUntil(this.unSubs[1])). subscribe((fetchedSwap: LoopSwapStatus) => { const reorderedSwap = [ [{ key: 'state', value: LoopStateEnum[fetchedSwap.state || ''], title: 'Status', width: 50, type: DataTypeEnum.STRING }, @@ -104,6 +117,7 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy { this.listSwaps = new MatTableDataSource([...swaps]); this.listSwaps.sort = this.sort; this.listSwaps.sortingDataAccessor = (data: any, sortHeaderId: string) => ((data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null); + this.listSwaps.sort?.sort({ id: this.tableSetting.sortBy, start: this.tableSetting.sortOrder, disableClear: true }); this.listSwaps.filterPredicate = (swap: LoopSwapStatus, fltr: string) => JSON.stringify(swap).toLowerCase().includes(fltr); this.listSwaps.paginator = this.paginator; this.applyFilter(); diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.html b/src/app/shared/components/ln-services/peerswap/peerswap.component.html deleted file mode 100755 index afc58b70..00000000 --- a/src/app/shared/components/ln-services/peerswap/peerswap.component.html +++ /dev/null @@ -1,16 +0,0 @@ -
- - Peerswap -
-
- - - -
- -
-
-
-
diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.scss b/src/app/shared/components/ln-services/peerswap/peerswap.component.scss deleted file mode 100755 index e69de29b..00000000 diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.spec.ts b/src/app/shared/components/ln-services/peerswap/peerswap.component.spec.ts deleted file mode 100755 index af225501..00000000 --- a/src/app/shared/components/ln-services/peerswap/peerswap.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { StoreModule } from '@ngrx/store'; - -import { RootReducer } from '../../../../store/rtl.reducers'; -import { LNDReducer } from '../../../../lnd/store/lnd.reducers'; -import { CLNReducer } from '../../../../cln/store/cln.reducers'; -import { ECLReducer } from '../../../../eclair/store/ecl.reducers'; -import { LoopService } from '../../../services/loop.service'; - -import { PeerswapComponent } from './peerswap.component'; -import { SharedModule } from '../../../shared.module'; -import { mockDataService } from '../../../test-helpers/mock-services'; -import { CommonService } from '../../../services/common.service'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { DataService } from '../../../services/data.service'; - -describe('PeerswapComponent', () => { - let component: PeerswapComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PeerswapComponent], - imports: [ - BrowserAnimationsModule, - SharedModule, - RouterTestingModule, - StoreModule.forRoot({ root: RootReducer, lnd: LNDReducer, cln: CLNReducer, ecl: ECLReducer }) - ], - providers: [ - CommonService, - { provide: DataService, useClass: mockDataService } - ] - }). - compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PeerswapComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - afterEach(() => { - TestBed.resetTestingModule(); - }); -}); diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.ts b/src/app/shared/components/ln-services/peerswap/peerswap.component.ts deleted file mode 100755 index f451bdca..00000000 --- a/src/app/shared/components/ln-services/peerswap/peerswap.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { Router, ResolveEnd, Event } from '@angular/router'; -import { Subject } from 'rxjs'; -import { takeUntil, filter } from 'rxjs/operators'; -import { faHandshake } from '@fortawesome/free-solid-svg-icons'; - - -@Component({ - selector: 'rtl-peerswap', - templateUrl: './peerswap.component.html', - styleUrls: ['./peerswap.component.scss'] -}) -export class PeerswapComponent implements OnInit, OnDestroy { - - public faHandshake = faHandshake; - public links = [{ link: 'peers', name: 'Peers' }, { link: 'psout', name: 'Peerswap Out' }, { link: 'psin', name: 'Peerswap In' }, { link: 'pscancelled', name: 'Cancelled Peerswaps' }]; - public activeTab = this.links[0]; - private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - - constructor(private router: Router) { } - - ngOnInit() { - const linkFound = this.links.find((link) => this.router.url.includes(link.link)); - this.activeTab = linkFound ? linkFound : this.links[0]; - this.router.events.pipe(takeUntil(this.unSubs[0]), filter((e) => e instanceof ResolveEnd)). - subscribe({ - next: (value: ResolveEnd | Event) => { - const linkFound = this.links.find((link) => (value).urlAfterRedirects.includes(link.link)); - this.activeTab = linkFound ? linkFound : this.links[0]; - } - }); - } - - ngOnDestroy() { - this.unSubs.forEach((completeSub) => { - completeSub.next(null); - completeSub.complete(); - }); - } - -} diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.html b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.html deleted file mode 100755 index 26568364..00000000 --- a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.html +++ /dev/null @@ -1 +0,0 @@ -

Swap Peers

\ No newline at end of file diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.scss b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.scss deleted file mode 100755 index e69de29b..00000000 diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.spec.ts deleted file mode 100755 index 6bc0b05f..00000000 --- a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; -import { SharedModule } from '../../../../shared.module'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { SwapPeersComponent } from './swap-peers.component'; - -describe('SwapPeersComponent', () => { - let component: SwapPeersComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [SwapPeersComponent], - imports: [ - BrowserAnimationsModule, - SharedModule - ], - providers: [] - }). - compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SwapPeersComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - afterEach(() => { - TestBed.resetTestingModule(); - }); -}); diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.ts b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.ts deleted file mode 100755 index 2e96c0ef..00000000 --- a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, OnDestroy } from '@angular/core'; -import { Subject } from 'rxjs'; - -@Component({ - selector: 'rtl-peerswap-peers', - templateUrl: './swap-peers.component.html', - styleUrls: ['./swap-peers.component.scss'] -}) -export class SwapPeersComponent implements OnDestroy { - - private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - - constructor() {} - - ngOnDestroy() { - this.unSubs.forEach((completeSub) => { - completeSub.next(null); - completeSub.complete(); - }); - } - -} diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.html b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.html deleted file mode 100755 index 265d51fd..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.html +++ /dev/null @@ -1 +0,0 @@ -

Peerswaps Cancelled

\ No newline at end of file diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.scss b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.scss deleted file mode 100755 index e69de29b..00000000 diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.spec.ts deleted file mode 100755 index 486b81f5..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; -import { SharedModule } from '../../../../shared.module'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { PeerswapsCancelledComponent } from './swaps-cancelled.component'; - -describe('PeerswapsCancelledComponent', () => { - let component: PeerswapsCancelledComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PeerswapsCancelledComponent], - imports: [ - BrowserAnimationsModule, - SharedModule - ], - providers: [] - }). - compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PeerswapsCancelledComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - afterEach(() => { - TestBed.resetTestingModule(); - }); -}); diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.ts b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.ts deleted file mode 100755 index cac2b256..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, OnDestroy } from '@angular/core'; -import { Subject } from 'rxjs'; - -@Component({ - selector: 'rtl-peerswap-cancelled', - templateUrl: './swaps-cancelled.component.html', - styleUrls: ['./swaps-cancelled.component.scss'] -}) -export class PeerswapsCancelledComponent implements OnDestroy { - - private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - - constructor() {} - - ngOnDestroy() { - this.unSubs.forEach((completeSub) => { - completeSub.next(null); - completeSub.complete(); - }); - } - -} diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.html b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.html deleted file mode 100755 index b5db1428..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.html +++ /dev/null @@ -1 +0,0 @@ -

Peerswaps In

\ No newline at end of file diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.scss b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.scss deleted file mode 100755 index e69de29b..00000000 diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.spec.ts deleted file mode 100755 index c4c9b485..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; -import { SharedModule } from '../../../../shared.module'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { PeerswapsInComponent } from './swaps-in.component'; - -describe('PeerswapsInComponent', () => { - let component: PeerswapsInComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PeerswapsInComponent], - imports: [ - BrowserAnimationsModule, - SharedModule - ], - providers: [] - }). - compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PeerswapsInComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - afterEach(() => { - TestBed.resetTestingModule(); - }); -}); diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.ts b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.ts deleted file mode 100755 index 2d1db794..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, OnDestroy } from '@angular/core'; -import { Subject } from 'rxjs'; - -@Component({ - selector: 'rtl-peer-swaps-in', - templateUrl: './swaps-in.component.html', - styleUrls: ['./swaps-in.component.scss'] -}) -export class PeerswapsInComponent implements OnDestroy { - - private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - - constructor() {} - - ngOnDestroy() { - this.unSubs.forEach((completeSub) => { - completeSub.next(null); - completeSub.complete(); - }); - } - -} diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.html b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.html deleted file mode 100755 index c3ce88f3..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.html +++ /dev/null @@ -1 +0,0 @@ -

Peerswaps Out

\ No newline at end of file diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.scss b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.scss deleted file mode 100755 index e69de29b..00000000 diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.spec.ts deleted file mode 100755 index f8c54025..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; -import { SharedModule } from '../../../../shared.module'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { PeerswapsOutComponent } from './swaps-out.component'; - -describe('PeerswapsOutComponent', () => { - let component: PeerswapsOutComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PeerswapsOutComponent], - imports: [ - BrowserAnimationsModule, - SharedModule - ], - providers: [] - }). - compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PeerswapsOutComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - afterEach(() => { - TestBed.resetTestingModule(); - }); -}); diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.ts b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.ts deleted file mode 100755 index 1d71445c..00000000 --- a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, OnDestroy } from '@angular/core'; -import { Subject } from 'rxjs'; - -@Component({ - selector: 'rtl-peer-swaps-out', - templateUrl: './swaps-out.component.html', - styleUrls: ['./swaps-out.component.scss'] -}) -export class PeerswapsOutComponent implements OnDestroy { - - private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; - - constructor() {} - - ngOnDestroy() { - this.unSubs.forEach((completeSub) => { - completeSub.next(null); - completeSub.complete(); - }); - } - -} diff --git a/src/app/shared/components/node-config/page-settings/page-settings.component.ts b/src/app/shared/components/node-config/page-settings/page-settings.component.ts index 746040f7..68547f74 100644 --- a/src/app/shared/components/node-config/page-settings/page-settings.component.ts +++ b/src/app/shared/components/node-config/page-settings/page-settings.component.ts @@ -1,18 +1,21 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; -import { Subject } from 'rxjs'; -import { filter, takeUntil } from 'rxjs/operators'; +import { combineLatest, Subject } from 'rxjs'; +import { filter, takeUntil, withLatestFrom } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { Actions } from '@ngrx/effects'; import { faPenRuler, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; -import { APICallStatusEnum, CLNActions, CLN_DEFAULT_PAGE_SETTINGS, CLN_TABLES_DEF, PAGE_SIZE_OPTIONS, ScreenSizeEnum, SORT_ORDERS } from '../../../services/consts-enums-functions'; +import { APICallStatusEnum, CLNActions, CLN_DEFAULT_PAGE_SETTINGS, CLN_TABLES_DEF, LNDActions, LND_DEFAULT_PAGE_SETTINGS, LND_TABLES_DEF, PAGE_SIZE_OPTIONS, ScreenSizeEnum, SORT_ORDERS } from '../../../services/consts-enums-functions'; import { LoggerService } from '../../../services/logger.service'; import { CommonService } from '../../../services/common.service'; import { RTLState } from '../../../../store/rtl.state'; -import { TableSetting, PageSettingsCLN } from '../../../models/pageSettings'; -import { clnPageSettings } from '../../../../cln/store/cln.selector'; +import { TableSetting, PageSettings } from '../../../models/pageSettings'; +import { clnNodeSettings, clnPageSettings } from '../../../../cln/store/cln.selector'; import { savePageSettings } from '../../../../cln/store/cln.actions'; import { ApiCallStatusPayload } from '../../../models/apiCallsPayload'; +import { rootSelectedNode } from '../../../../store/rtl.selector'; +import { SelNodeChild, ConfigSettingsNode } from '../../../models/RTLconfig'; +import { lndNodeSettings, lndPageSettings } from '../../../../lnd/store/lnd.selector'; @Component({ selector: 'rtl-page-settings', @@ -23,12 +26,13 @@ export class PageSettingsComponent implements OnInit, OnDestroy { public faPenRuler = faPenRuler; public faExclamationTriangle = faExclamationTriangle; + public selNode: ConfigSettingsNode; public screenSize = ''; public screenSizeEnum = ScreenSizeEnum; public pageSizeOptions = PAGE_SIZE_OPTIONS; - public pageSettings: PageSettingsCLN[] = []; - public initialPageSettings: PageSettingsCLN[] = Object.assign([], CLN_DEFAULT_PAGE_SETTINGS); - public tableFieldsDef = CLN_TABLES_DEF; + public pageSettings: PageSettings[] = []; + public initialPageSettings: PageSettings[] = []; + public tableFieldsDef = {}; public sortOrders = SORT_ORDERS; public apiCallStatus: ApiCallStatusPayload | null = null; public apiCallStatusEnum = APICallStatusEnum; @@ -40,23 +44,79 @@ export class PageSettingsComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])). - subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => { - this.errorMessage = null; - this.apiCallStatus = settings.apiCallStatus; - if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { - this.errorMessage = this.apiCallStatus.message || null; - } - this.pageSettings = settings.pageSettings; - this.initialPageSettings = settings.pageSettings; - this.logger.info(settings); - }); - this.actions.pipe(takeUntil(this.unSubs[1]), filter((action) => action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN || action.type === CLNActions.SAVE_PAGE_SETTINGS_CLN)). - subscribe((action: any) => { - if (action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN && action.payload.status === APICallStatusEnum.ERROR && action.payload.action === 'SavePageSettings') { - this.errorMessage = JSON.parse(action.payload.message); - } - }); + this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[0])).subscribe((selNode) => { + this.selNode = selNode; + this.logger.info(this.selNode); + switch (this.selNode.lnImplementation) { + case 'CLN': + this.initialPageSettings = Object.assign([], CLN_DEFAULT_PAGE_SETTINGS); + this.tableFieldsDef = CLN_TABLES_DEF; + this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[1]), + withLatestFrom(this.store.select(clnNodeSettings))). + subscribe(([settings, nodeSettings]: [{ pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }, (SelNodeChild | null)]) => { + const updatedPageSettings = JSON.parse(JSON.stringify(settings.pageSettings)); + this.errorMessage = null; + this.apiCallStatus = settings.apiCallStatus; + if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { + this.errorMessage = this.apiCallStatus.message || null; + this.pageSettings = updatedPageSettings; + this.initialPageSettings = updatedPageSettings; + } else { + if (!nodeSettings?.enableOffers) { + const transactionsPage = updatedPageSettings.find((pg) => pg.pageId === 'transactions'); + transactionsPage?.tables.splice(transactionsPage?.tables.findIndex((tb) => tb.tableId === 'offers'), 1); + transactionsPage?.tables.splice(transactionsPage?.tables.findIndex((tb) => tb.tableId === 'offer_bookmarks'), 1); + } + if (!nodeSettings?.enablePeerswap) { + updatedPageSettings.splice(updatedPageSettings.findIndex((pg) => pg.pageId === 'peerswap'), 1); + } + this.pageSettings = updatedPageSettings; + this.initialPageSettings = updatedPageSettings; + } + this.logger.info(updatedPageSettings); + }); + this.actions.pipe(takeUntil(this.unSubs[2]), filter((action) => action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN || action.type === CLNActions.SAVE_PAGE_SETTINGS_CLN)). + subscribe((action: any) => { + if (action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN && action.payload.status === APICallStatusEnum.ERROR && action.payload.action === 'SavePageSettings') { + this.errorMessage = JSON.parse(action.payload.message); + } + }); + break; + + default: + this.initialPageSettings = Object.assign([], LND_DEFAULT_PAGE_SETTINGS); + this.tableFieldsDef = LND_TABLES_DEF; + this.store.select(lndPageSettings).pipe(takeUntil(this.unSubs[1]), + withLatestFrom(this.store.select(lndNodeSettings))). + subscribe(([settings, nodeSettings]: [{ pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }, (SelNodeChild | null)]) => { + const updatedPageSettings: PageSettings[] = JSON.parse(JSON.stringify(settings.pageSettings)); + this.errorMessage = null; + this.apiCallStatus = settings.apiCallStatus; + if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { + this.errorMessage = this.apiCallStatus.message || null; + this.pageSettings = updatedPageSettings; + this.initialPageSettings = updatedPageSettings; + } else { + if (!nodeSettings?.swapServerUrl || nodeSettings.swapServerUrl.trim() === '') { + updatedPageSettings.splice(updatedPageSettings.findIndex((pg) => pg.pageId === 'loop'), 1); + } + if (!nodeSettings?.boltzServerUrl || nodeSettings.boltzServerUrl.trim() === '') { + updatedPageSettings.splice(updatedPageSettings.findIndex((pg) => pg.pageId === 'boltz'), 1); + } + this.pageSettings = updatedPageSettings; + this.initialPageSettings = updatedPageSettings; + } + this.logger.info(updatedPageSettings); + }); + this.actions.pipe(takeUntil(this.unSubs[2]), filter((action) => action.type === LNDActions.UPDATE_API_CALL_STATUS_LND || action.type === LNDActions.SAVE_PAGE_SETTINGS_LND)). + subscribe((action: any) => { + if (action.type === LNDActions.UPDATE_API_CALL_STATUS_LND && action.payload.status === APICallStatusEnum.ERROR && action.payload.action === 'SavePageSettings') { + this.errorMessage = JSON.parse(action.payload.message); + } + }); + break; + } + }); } oncolumnSelectionChange(table: TableSetting) { diff --git a/src/app/shared/models/apiCallsPayload.ts b/src/app/shared/models/apiCallsPayload.ts index 85a41b3d..6911488f 100644 --- a/src/app/shared/models/apiCallsPayload.ts +++ b/src/app/shared/models/apiCallsPayload.ts @@ -30,6 +30,7 @@ export interface ApiCallsListLND { FetchAllChannels: ApiCallStatusPayload; FetchBalanceBlockchain: ApiCallStatusPayload; // Non-initial calls + FetchPageSettings: ApiCallStatusPayload; FetchPeers: ApiCallStatusPayload; FetchClosedChannels: ApiCallStatusPayload; FetchInvoices: ApiCallStatusPayload; diff --git a/src/app/shared/models/pageSettings.ts b/src/app/shared/models/pageSettings.ts index 09542054..f996c7dd 100644 --- a/src/app/shared/models/pageSettings.ts +++ b/src/app/shared/models/pageSettings.ts @@ -11,7 +11,7 @@ export class TableSetting { } -export class PageSettingsCLN { +export class PageSettings { pageId: string; tables: TableSetting[]; diff --git a/src/app/shared/services/consts-enums-functions.ts b/src/app/shared/services/consts-enums-functions.ts index 59ebbd98..25559ec9 100644 --- a/src/app/shared/services/consts-enums-functions.ts +++ b/src/app/shared/services/consts-enums-functions.ts @@ -1,5 +1,5 @@ import { MatPaginatorIntl } from '@angular/material/paginator'; -import { PageSettingsCLN } from '../models/pageSettings'; +import { PageSettings } from '../models/pageSettings'; export function getPaginatorLabel(field: string) { const appPaginator = new MatPaginatorIntl(); @@ -384,6 +384,9 @@ export enum LNDActions { RESET_LND_STORE = 'RESET_LND_STORE', UPDATE_API_CALL_STATUS_LND = 'UPDATE_API_CALL_STATUS_LND', SET_CHILD_NODE_SETTINGS_LND = 'SET_CHILD_NODE_SETTINGS_LND', + FETCH_PAGE_SETTINGS_LND = 'FETCH_PAGE_SETTINGS_LND', + SET_PAGE_SETTINGS_LND = 'SET_PAGE_SETTINGS_LND', + SAVE_PAGE_SETTINGS_LND = 'SAVE_PAGE_SETTINGS_LND', FETCH_INFO_LND = 'FETCH_INFO_LND', SET_INFO_LND = 'SET_INFO_LND', FETCH_PEERS_LND = 'FETCH_PEERS_LND', @@ -674,7 +677,7 @@ export enum SortOrderEnum { export const SORT_ORDERS = ['asc', 'desc']; -export const CLN_DEFAULT_PAGE_SETTINGS: PageSettingsCLN[] = [ +export const CLN_DEFAULT_PAGE_SETTINGS: PageSettings[] = [ { pageId: 'on_chain', tables: [ { tableId: 'utxos', recordsPerPage: PAGE_SIZE, sortBy: 'blockheight', sortOrder: SortOrderEnum.DESCENDING, columnSelectionSM: ['txid', 'value'], @@ -815,3 +818,38 @@ export const CLN_TABLES_DEF = { } } }; + +export const LND_DEFAULT_PAGE_SETTINGS: PageSettings[] = [ + { pageId: 'loop', tables: [ + { tableId: 'loop', recordsPerPage: PAGE_SIZE, sortBy: 'initiation_time', sortOrder: SortOrderEnum.DESCENDING, + columnSelectionSM: ['state', 'amt'], + columnSelection: ['state', 'initiation_time', 'amt', 'cost_server', 'cost_offchain', 'cost_onchain'] } + ] }, + { pageId: 'boltz', tables: [ + { tableId: 'swap_in', recordsPerPage: PAGE_SIZE, sortBy: 'status', sortOrder: SortOrderEnum.DESCENDING, + columnSelectionSM: ['status', 'id', 'expectedAmount'], + columnSelection: ['status', 'id', 'lockupAddress', 'expectedAmount', 'timeoutBlockHeight'] }, + { tableId: 'swap_out', recordsPerPage: PAGE_SIZE, sortBy: 'status', sortOrder: SortOrderEnum.DESCENDING, + columnSelectionSM: ['status', 'id', 'onchainAmount'], + columnSelection: ['status', 'id', 'claimAddress', 'onchainAmount', 'timeoutBlockHeight'] } + ] } +]; + +export const LND_TABLES_DEF = { + loop: { + loop: { + maxColumns: 8, + allowedColumns: ['state', 'initiation_time', 'last_update_time', 'amt', 'cost_server', 'cost_offchain', 'cost_onchain', 'htlc_address', 'id', 'id_bytes'] + } + }, + boltz: { + swap_in: { + maxColumns: 7, + allowedColumns: ['status', 'id', 'lockupAddress', 'expectedAmount', 'privateKey', 'preimage', 'redeemScript', 'invoice', 'timeoutBlockHeight', 'lockupTransactionId', 'refundTransactionId'] + }, + swap_out: { + maxColumns: 7, + allowedColumns: ['status', 'id', 'claimAddress', 'onchainAmount', 'privateKey', 'preimage', 'redeemScript', 'invoice', 'timeoutBlockHeight', 'lockupTransactionId', 'claimTransactionId'] + } + } +}; diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index d74b87f6..7ff1960d 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -97,11 +97,6 @@ import { SwapServiceInfoComponent } from './components/ln-services/boltz/swap-se import { SwapModalComponent } from './components/ln-services/boltz/swap-modal/swap-modal.component'; import { SwapInInfoGraphicsComponent } from './components/ln-services/boltz/swap-in-info-graphics/info-graphics.component'; import { SwapOutInfoGraphicsComponent } from './components/ln-services/boltz/swap-out-info-graphics/info-graphics.component'; -import { PeerswapComponent } from './components/ln-services/peerswap/peerswap.component'; -import { SwapPeersComponent } from './components/ln-services/peerswap/swap-peers/swap-peers.component'; -import { PeerswapsCancelledComponent } from './components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component'; -import { PeerswapsInComponent } from './components/ln-services/peerswap/swaps-in/swaps-in.component'; -import { PeerswapsOutComponent } from './components/ln-services/peerswap/swaps-out/swaps-out.component'; import { ClipboardDirective } from './directive/clipboard.directive'; import { AutoFocusDirective } from './directive/auto-focus.directive'; @@ -273,12 +268,7 @@ export const DEFAULT_DATE_FORMAT: MatDateFormats = { SwapServiceInfoComponent, SwapModalComponent, SwapInInfoGraphicsComponent, - SwapOutInfoGraphicsComponent, - PeerswapComponent, - SwapPeersComponent, - PeerswapsCancelledComponent, - PeerswapsInComponent, - PeerswapsOutComponent + SwapOutInfoGraphicsComponent ], declarations: [ AppSettingsComponent, @@ -339,12 +329,7 @@ export const DEFAULT_DATE_FORMAT: MatDateFormats = { SwapServiceInfoComponent, SwapModalComponent, SwapInInfoGraphicsComponent, - SwapOutInfoGraphicsComponent, - PeerswapComponent, - SwapPeersComponent, - PeerswapsCancelledComponent, - PeerswapsInComponent, - PeerswapsOutComponent + SwapOutInfoGraphicsComponent ], providers: [ { provide: LoggerService, useClass: ConsoleLoggerService },