From 5c79a078fa06b165360e266c1ec3c0b8bb8c3686 Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Tue, 25 Oct 2022 16:23:43 -0700 Subject: [PATCH] lnd pending channels page layout --- backend/models/database.model.js | 3 - server/models/database.model.ts | 3 - .../channel-pending-table.component.html | 178 +++++++++++++----- .../channel-pending-table.component.scss | 3 +- .../channel-pending-table.component.ts | 78 +++++--- .../page-settings.component.html | 2 +- .../page-settings/page-settings.component.ts | 8 + .../shared/services/consts-enums-functions.ts | 24 +-- 8 files changed, 210 insertions(+), 89 deletions(-) diff --git a/backend/models/database.model.js b/backend/models/database.model.js index 2ce469aa..5ab624bb 100644 --- a/backend/models/database.model.js +++ b/backend/models/database.model.js @@ -94,9 +94,6 @@ export const validatePageSettings = (documentToValidate) => { if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_ORDER)) { errMsg = errMsg + 'Sort Order is mandatory.'; } - if (!table.hasOwnProperty(CollectionFieldsEnum.RECORDS_PER_PAGE)) { - errMsg = errMsg + 'Records/Page is mandatory.'; - } if (!table.hasOwnProperty(CollectionFieldsEnum.COLUMN_SELECTION_SM)) { errMsg = errMsg + 'Column Selection (Mobile) is mandatory.'; } diff --git a/server/models/database.model.ts b/server/models/database.model.ts index 59eeda29..8bdc06d8 100644 --- a/server/models/database.model.ts +++ b/server/models/database.model.ts @@ -105,9 +105,6 @@ export const validatePageSettings = (documentToValidate): any => { if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_ORDER)) { errMsg = errMsg + 'Sort Order is mandatory.'; } - if (!table.hasOwnProperty(CollectionFieldsEnum.RECORDS_PER_PAGE)) { - errMsg = errMsg + 'Records/Page is mandatory.'; - } if (!table.hasOwnProperty(CollectionFieldsEnum.COLUMN_SELECTION_SM)) { errMsg = errMsg + 'Column Selection (Mobile) is mandatory.'; } 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 1fcea9df..1c2d0c92 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 @@ -11,7 +11,27 @@ Peer - {{channel.channel.remote_alias}} + {{channel.channel.remote_alias}} + + + Pubkey + {{channel.channel.remote_node_pub}} + + + Channel + {{channel.channel.channel_point}} + + + Initiator + {{channel.channel.initiator}} + + + Commitment Type + {{channel.channel.commitment_type}} + + + Confirmation Height + {{channel.confirmation_height | number}} Commit Fee (Sats) @@ -21,10 +41,22 @@ Commit Weight {{channel.commit_weight | number}} + + Fee/KW + {{channel.channel.fee_per_kw | number}} + Capacity (Sats) {{channel.channel.capacity | number}} + + Local Balance (Sats) + {{channel.channel.local_balance | number}} + + + Remote Balance (Sats) + {{channel.channel.remote_balance | number}} +
Actions
@@ -59,22 +91,58 @@
+ + Closing Tx Id + {{channel.closing_txid}} + Peer - {{channel.channel.remote_alias}} + {{channel.channel.remote_alias}} - - Recovered Balance (Sats) - {{channel.recovered_balance | number}} + + Pubkey + {{channel.channel.remote_node_pub}} + + + Channel + {{channel.channel.channel_point}} + + + Initiator + {{channel.channel.initiator}} + + + Commitment Type + {{channel.channel.commitment_type}} Limbo Balance (Sats) {{channel.limbo_balance | number}} + + Maturity Height + {{channel.maturity_height | number}} + + + Blocks till Maturity + {{channel.blocks_til_maturity | number}} + + + Recovered Balance (Sats) + {{channel.recovered_balance | number}} + Capacity (Sats) {{channel.channel.capacity | number}} + + Local Balance (Sats) + {{channel.channel.local_balance | number}} + + + Remote Balance (Sats) + {{channel.channel.remote_balance | number}} +
Actions
@@ -102,29 +170,42 @@ Pending Closing ({{pendingClosingChannelsLength}})
-
+
+ + Closing Tx Id + {{channel.closing_txid}} + - Peer - {{channel.channel.remote_alias}} + Peer + {{channel.channel.remote_alias}} - - - Local Balance (Sats) - {{channel.channel.local_balance | - number}} + + Pubkey + {{channel.channel.remote_node_pub}} - - - Remote Balance (Sats) - {{channel.channel.remote_balance | - number}} + + Channel + {{channel.channel.channel_point}} + + + Initiator + {{channel.channel.initiator}} + + + Commitment Type + {{channel.channel.commitment_type}} - - Capacity (Sats) - {{channel.channel.capacity | - number}} + Capacity (Sats) + {{channel.channel.capacity | number}} + + + Local Balance (Sats) + {{channel.channel.local_balance | number}} + + + Remote Balance (Sats) + {{channel.channel.remote_balance | number}} @@ -153,35 +234,42 @@ Waiting Close ({{pendingWaitClosingChannelsLength}})
-
+
- Peer - {{channel.channel.remote_alias}} + Peer + {{channel.channel.remote_alias}} + + + Pubkey + {{channel.channel.remote_node_pub}} + + + Channel + {{channel.channel.channel_point}} + + + Initiator + {{channel.channel.initiator}} + + + Commitment Type + {{channel.channel.commitment_type}} - - Limbo Balance (Sats) - {{channel.limbo_balance | number}} - + Limbo Balance (Sats) + {{channel.limbo_balance | number}} + + + Capacity (Sats) + {{channel.channel.capacity | number}} - - Local Balance (Sats) - {{channel.channel.local_balance | - number}} + Local Balance (Sats) + {{channel.channel.local_balance | number}} - - Remote Balance (Sats) - {{channel.channel.remote_balance | - number}} - - - - Capacity (Sats) - {{channel.channel.capacity | - number}} + Remote Balance (Sats) + {{channel.channel.remote_balance | number}} diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.scss b/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.scss index 18e37ff8..77dc8364 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.scss +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.scss @@ -1,4 +1,5 @@ -.mat-column-channel_point { +.mat-column-channel_point, .mat-column-remote_alias, .mat-column-remote_node_pub, +.mat-column-commitment_type, .mat-column-closing_txid { flex: 1 1 10%; white-space: nowrap; overflow: hidden; diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts b/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts index bac12b4e..1b2a7abe 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-pending-table/channel-pending-table.component.ts @@ -6,7 +6,7 @@ import { Store } from '@ngrx/store'; import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { Channel, GetInfo, PendingChannels, PendingOpenChannel } from '../../../../../shared/models/lndModels'; -import { AlertTypeEnum, APICallStatusEnum, DataTypeEnum, ScreenSizeEnum } from '../../../../../shared/services/consts-enums-functions'; +import { AlertTypeEnum, APICallStatusEnum, DataTypeEnum, LND_DEFAULT_PAGE_SETTINGS, PAGE_SIZE, ScreenSizeEnum, SortOrderEnum } from '../../../../../shared/services/consts-enums-functions'; import { ApiCallStatusPayload } from '../../../../../shared/models/apiCallsPayload'; import { SelNodeChild } from '../../../../../shared/models/RTLconfig'; import { LoggerService } from '../../../../../shared/services/logger.service'; @@ -15,7 +15,8 @@ import { BumpFeeComponent } from '../../bump-fee-modal/bump-fee.component'; import { openAlert } from '../../../../../store/rtl.actions'; import { RTLState } from '../../../../../store/rtl.state'; -import { lndNodeInformation, lndNodeSettings, pendingChannels } from '../../../../store/lnd.selector'; +import { lndNodeInformation, lndNodeSettings, lndPageSettings, pendingChannels } from '../../../../store/lnd.selector'; +import { PageSettings, TableSetting } from '../../../../../shared/models/pageSettings'; @Component({ selector: 'rtl-channel-pending-table', @@ -25,20 +26,25 @@ import { lndNodeInformation, lndNodeSettings, pendingChannels } from '../../../. export class ChannelPendingTableComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild(MatSort, { static: false }) sort: MatSort | undefined; + public PAGE_ID = 'peers_channels'; + public openTableSetting: TableSetting = { tableId: 'pending_open', recordsPerPage: PAGE_SIZE, sortBy: 'capacity', sortOrder: SortOrderEnum.DESCENDING }; + public forceClosingopenTableSetting: TableSetting = { tableId: 'pending_force_closing', recordsPerPage: PAGE_SIZE, sortBy: 'limbo_balance', sortOrder: SortOrderEnum.DESCENDING }; + public closingOpenTableSetting: TableSetting = { tableId: 'pending_closing', recordsPerPage: PAGE_SIZE, sortBy: 'capacity', sortOrder: SortOrderEnum.DESCENDING }; + public waitingCloseopenTableSetting: TableSetting = { tableId: 'pending_waiting_close', recordsPerPage: PAGE_SIZE, sortBy: 'limbo_balance', sortOrder: SortOrderEnum.DESCENDING }; public selNode: SelNodeChild | null = {}; public selectedFilter = ''; public information: GetInfo = {}; public pendingChannels: PendingChannels = {}; - public displayedOpenColumns = ['remote_alias', 'commit_fee', 'commit_weight', 'capacity', 'actions']; + public displayedOpenColumns: any[] = []; public pendingOpenChannelsLength = 0; public pendingOpenChannels: any; - public displayedForceClosingColumns = ['remote_alias', 'recovered_balance', 'limbo_balance', 'capacity', 'actions']; + public displayedForceClosingColumns: any[] = []; public pendingForceClosingChannelsLength = 0; public pendingForceClosingChannels: any; - public displayedClosingColumns = ['remote_alias', 'local_balance', 'remote_balance', 'capacity', 'actions']; + public displayedClosingColumns: any[] = []; public pendingClosingChannelsLength = 0; public pendingClosingChannels: any; - public displayedWaitClosingColumns = ['remote_alias', 'limbo_balance', 'local_balance', 'remote_balance', 'actions']; + public displayedWaitClosingColumns: any[] = []; public pendingWaitClosingChannelsLength = 0; public pendingWaitClosingChannels: any; public screenSize = ''; @@ -46,32 +52,56 @@ export class ChannelPendingTableComponent implements OnInit, AfterViewInit, OnDe public errorMessage = ''; public apiCallStatus: ApiCallStatusPayload | null = null; public apiCallStatusEnum = APICallStatusEnum; - private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; + private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject(), new Subject()]; constructor(private logger: LoggerService, private store: Store, private commonService: CommonService) { this.screenSize = this.commonService.getScreenSize(); - if (this.screenSize === ScreenSizeEnum.XS) { - this.displayedOpenColumns = ['remote_alias', 'actions']; - this.displayedForceClosingColumns = ['remote_alias', 'actions']; - this.displayedClosingColumns = ['remote_alias', 'actions']; - this.displayedWaitClosingColumns = ['remote_alias', 'actions']; - } else if (this.screenSize === ScreenSizeEnum.SM || this.screenSize === ScreenSizeEnum.MD) { - this.displayedOpenColumns = ['remote_alias', 'commit_fee', 'actions']; - this.displayedForceClosingColumns = ['remote_alias', 'limbo_balance', 'actions']; - this.displayedClosingColumns = ['remote_alias', 'remote_balance', 'actions']; - this.displayedWaitClosingColumns = ['remote_alias', 'limbo_balance', 'actions']; - } else { - this.displayedOpenColumns = ['remote_alias', 'commit_fee', 'commit_weight', 'capacity', 'actions']; - this.displayedForceClosingColumns = ['remote_alias', 'recovered_balance', 'limbo_balance', 'capacity', 'actions']; - this.displayedClosingColumns = ['remote_alias', 'local_balance', 'remote_balance', 'capacity', 'actions']; - this.displayedWaitClosingColumns = ['remote_alias', 'limbo_balance', 'local_balance', 'remote_balance', 'actions']; - } } ngOnInit() { this.store.select(lndNodeSettings).pipe(takeUntil(this.unSubs[0])).subscribe((nodeSettings: SelNodeChild | null) => { this.selNode = nodeSettings; }); this.store.select(lndNodeInformation).pipe(takeUntil(this.unSubs[1])).subscribe((nodeInfo: GetInfo) => { this.information = nodeInfo; }); - this.store.select(pendingChannels).pipe(takeUntil(this.unSubs[0])). + this.store.select(lndPageSettings).pipe(takeUntil(this.unSubs[2])). + subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => { + this.errorMessage = ''; + this.apiCallStatus = settings.apiCallStatus; + if (this.apiCallStatus.status === APICallStatusEnum.ERROR) { + this.errorMessage = this.apiCallStatus.message || ''; + } + this.openTableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.openTableSetting.tableId) || LND_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.openTableSetting.tableId)!; + if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) { + this.displayedOpenColumns = JSON.parse(JSON.stringify(this.openTableSetting.columnSelectionSM)); + } else { + this.displayedOpenColumns = JSON.parse(JSON.stringify(this.openTableSetting.columnSelection)); + } + this.displayedOpenColumns.push('actions'); + this.logger.info(this.displayedOpenColumns); + this.forceClosingopenTableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.forceClosingopenTableSetting.tableId) || LND_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.forceClosingopenTableSetting.tableId)!; + if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) { + this.displayedForceClosingColumns = JSON.parse(JSON.stringify(this.forceClosingopenTableSetting.columnSelectionSM)); + } else { + this.displayedForceClosingColumns = JSON.parse(JSON.stringify(this.forceClosingopenTableSetting.columnSelection)); + } + this.displayedForceClosingColumns.push('actions'); + this.logger.info(this.displayedForceClosingColumns); + this.closingOpenTableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.closingOpenTableSetting.tableId) || LND_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.closingOpenTableSetting.tableId)!; + if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) { + this.displayedClosingColumns = JSON.parse(JSON.stringify(this.closingOpenTableSetting.columnSelectionSM)); + } else { + this.displayedClosingColumns = JSON.parse(JSON.stringify(this.closingOpenTableSetting.columnSelection)); + } + this.displayedClosingColumns.push('actions'); + this.logger.info(this.displayedClosingColumns); + this.waitingCloseopenTableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.waitingCloseopenTableSetting.tableId) || LND_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.waitingCloseopenTableSetting.tableId)!; + if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) { + this.displayedWaitClosingColumns = JSON.parse(JSON.stringify(this.waitingCloseopenTableSetting.columnSelectionSM)); + } else { + this.displayedWaitClosingColumns = JSON.parse(JSON.stringify(this.waitingCloseopenTableSetting.columnSelection)); + } + this.displayedWaitClosingColumns.push('actions'); + this.logger.info(this.displayedWaitClosingColumns); + }); + this.store.select(pendingChannels).pipe(takeUntil(this.unSubs[3])). subscribe((pendingChannelsSelector: { pendingChannels: PendingChannels, apiCallStatus: ApiCallStatusPayload }) => { this.errorMessage = ''; this.apiCallStatus = pendingChannelsSelector.apiCallStatus; diff --git a/src/app/shared/components/node-config/page-settings/page-settings.component.html b/src/app/shared/components/node-config/page-settings/page-settings.component.html index b9544430..8aa2f0ab 100644 --- a/src/app/shared/components/node-config/page-settings/page-settings.component.html +++ b/src/app/shared/components/node-config/page-settings/page-settings.component.html @@ -13,7 +13,7 @@
{{table.tableId | camelcaseWithReplace:'_'}}: - + {{pageSizeOption}} 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 d1807ac6..5c6b0f98 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 @@ -205,6 +205,14 @@ export class PageSettingsComponent implements OnInit, OnDestroy { } } + + disbalePageSize(pageId: string, tableId: string) { + return (this.selNode.lnImplementation === 'LND' && pageId === 'peers_channels' && tableId === 'pending_open') || + (this.selNode.lnImplementation === 'LND' && pageId === 'peers_channels' && tableId === 'pending_force_closing') || + (this.selNode.lnImplementation === 'LND' && pageId === 'peers_channels' && tableId === 'pending_closing') || + (this.selNode.lnImplementation === 'LND' && pageId === 'peers_channels' && tableId === 'pending_waiting_close'); + } + ngOnDestroy() { this.unSubs.forEach((unsub) => { unsub.next(); diff --git a/src/app/shared/services/consts-enums-functions.ts b/src/app/shared/services/consts-enums-functions.ts index 1c4d3721..73f841c4 100644 --- a/src/app/shared/services/consts-enums-functions.ts +++ b/src/app/shared/services/consts-enums-functions.ts @@ -860,16 +860,16 @@ export const LND_DEFAULT_PAGE_SETTINGS: PageSettings[] = [ { tableId: 'open', recordsPerPage: PAGE_SIZE, sortBy: 'balancedness', sortOrder: SortOrderEnum.DESCENDING, columnSelectionSM: ['remote_alias', 'local_balance', 'remote_balance'], columnSelection: ['remote_alias', 'uptime', 'total_satoshis_sent', 'total_satoshis_received', 'local_balance', 'remote_balance', 'balancedness'] }, - { tableId: 'pending_open', recordsPerPage: PAGE_SIZE, sortBy: 'capacity', sortOrder: SortOrderEnum.DESCENDING, + { tableId: 'pending_open', sortBy: 'capacity', sortOrder: SortOrderEnum.DESCENDING, columnSelectionSM: ['remote_alias', 'capacity'], columnSelection: ['remote_alias', 'commit_fee', 'commit_weight', 'capacity'] }, - { tableId: 'pending_force_closing', recordsPerPage: PAGE_SIZE, sortBy: 'limbo_balance', sortOrder: SortOrderEnum.DESCENDING, + { tableId: 'pending_force_closing', sortBy: 'limbo_balance', sortOrder: SortOrderEnum.DESCENDING, columnSelectionSM: ['remote_alias', 'limbo_balance'], columnSelection: ['remote_alias', 'recovered_balance', 'limbo_balance', 'capacity'] }, - { tableId: 'pending_closing', recordsPerPage: PAGE_SIZE, sortBy: 'capacity', sortOrder: SortOrderEnum.DESCENDING, + { tableId: 'pending_closing', sortBy: 'capacity', sortOrder: SortOrderEnum.DESCENDING, columnSelectionSM: ['remote_alias', 'capacity'], columnSelection: ['remote_alias', 'local_balance', 'remote_balance', 'capacity'] }, - { tableId: 'pending_waiting_close', recordsPerPage: PAGE_SIZE, sortBy: 'limbo_balance', sortOrder: SortOrderEnum.DESCENDING, + { tableId: 'pending_waiting_close', sortBy: 'limbo_balance', sortOrder: SortOrderEnum.DESCENDING, columnSelectionSM: ['remote_alias', 'limbo_balance'], columnSelection: ['remote_alias', 'limbo_balance', 'local_balance', 'remote_balance'] }, { tableId: 'closed', recordsPerPage: PAGE_SIZE, sortBy: 'close_type', sortOrder: SortOrderEnum.DESCENDING, @@ -950,20 +950,20 @@ export const LND_TABLES_DEF = { allowedColumns: ['remote_alias', 'uptime', 'total_satoshis_sent', 'total_satoshis_received', 'local_balance', 'remote_balance', 'balancedness'] }, pending_open: { - maxColumns: 4, - allowedColumns: ['remote_alias', 'commit_fee', 'commit_weight', 'capacity'] + maxColumns: 7, + allowedColumns: ['remote_alias', 'remote_node_pub', 'channel_point', 'initiator', 'commitment_type', 'confirmation_height', 'commit_fee', 'commit_weight', 'fee_per_kw', 'capacity', 'local_balance', 'remote_balance'] }, pending_force_closing: { - maxColumns: 4, - allowedColumns: ['remote_alias', 'recovered_balance', 'limbo_balance', 'capacity'] + maxColumns: 7, + allowedColumns: ['closing_txid', 'remote_alias', 'remote_node_pub', 'channel_point', 'initiator', 'commitment_type', 'limbo_balance', 'maturity_height', 'blocks_til_maturity', 'recovered_balance', 'capacity', 'local_balance', 'remote_balance'] }, pending_closing: { - maxColumns: 4, - allowedColumns: ['remote_alias', 'local_balance', 'remote_balance', 'capacity'] + maxColumns: 7, + allowedColumns: ['closing_txid', 'remote_alias', 'remote_node_pub', 'channel_point', 'initiator', 'commitment_type', 'capacity', 'local_balance', 'remote_balance'] }, pending_waiting_close: { - maxColumns: 4, - allowedColumns: ['remote_alias', 'limbo_balance', 'local_balance', 'remote_balance'] + maxColumns: 7, + allowedColumns: ['remote_alias', 'remote_node_pub', 'channel_point', 'initiator', 'commitment_type', 'limbo_balance', 'capacity', 'local_balance', 'remote_balance'] }, closed: { maxColumns: 5,