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 f49d5fdd..04e7a6d4 100644 --- a/src/app/cln/routing/routing-peers/routing-peers.component.ts +++ b/src/app/cln/routing/routing-peers/routing-peers.component.ts @@ -131,41 +131,41 @@ export class CLNRoutingPeersComponent implements OnInit, OnChanges, AfterViewIni setFilterPredicate() { this.routingPeersIncoming.filterPredicate = (rowDataIn: RoutingPeer, fltr: string) => { - let rowToFilter = ''; + let rowToFilterIn = ''; switch (this.selFilterByIn) { case 'all': - rowToFilter = JSON.stringify(rowDataIn).toLowerCase(); + rowToFilterIn = JSON.stringify(rowDataIn).toLowerCase(); break; case 'total_amount': case 'total_fee': - rowToFilter = ((+(rowDataIn[this.selFilterByIn] || 0)) / 1000)?.toString() || ''; + rowToFilterIn = ((+(rowDataIn[this.selFilterByIn] || 0)) / 1000)?.toString() || ''; break; default: - rowToFilter = typeof rowDataIn[this.selFilterByIn] === 'string' ? rowDataIn[this.selFilterByIn].toLowerCase() : typeof rowDataIn[this.selFilterByIn] === 'boolean' ? (rowDataIn[this.selFilterByIn] ? 'yes' : 'no') : rowDataIn[this.selFilterByIn].toString(); + rowToFilterIn = typeof rowDataIn[this.selFilterByIn] === 'string' ? rowDataIn[this.selFilterByIn].toLowerCase() : typeof rowDataIn[this.selFilterByIn] === 'boolean' ? (rowDataIn[this.selFilterByIn] ? 'yes' : 'no') : rowDataIn[this.selFilterByIn].toString(); break; } - return rowToFilter.includes(fltr); + return rowToFilterIn.includes(fltr); }; - this.routingPeersIncoming.filterPredicate = (rowDataOut: RoutingPeer, fltr: string) => { - let rowToFilter = ''; + this.routingPeersOutgoing.filterPredicate = (rowDataOut: RoutingPeer, fltr: string) => { + let rowToFilterOut = ''; switch (this.selFilterByOut) { case 'all': - rowToFilter = JSON.stringify(rowDataOut).toLowerCase(); + rowToFilterOut = JSON.stringify(rowDataOut).toLowerCase(); break; case 'total_amount': case 'total_fee': - rowToFilter = ((+(rowDataOut[this.selFilterByOut] || 0)) / 1000)?.toString() || ''; + rowToFilterOut = ((+(rowDataOut[this.selFilterByOut] || 0)) / 1000)?.toString() || ''; break; default: - rowToFilter = typeof rowDataOut[this.selFilterByOut] === 'string' ? rowDataOut[this.selFilterByOut].toLowerCase() : typeof rowDataOut[this.selFilterByOut] === 'boolean' ? (rowDataOut[this.selFilterByOut] ? 'yes' : 'no') : rowDataOut[this.selFilterByOut].toString(); + rowToFilterOut = typeof rowDataOut[this.selFilterByOut] === 'string' ? rowDataOut[this.selFilterByOut].toLowerCase() : typeof rowDataOut[this.selFilterByOut] === 'boolean' ? (rowDataOut[this.selFilterByOut] ? 'yes' : 'no') : rowDataOut[this.selFilterByOut].toString(); break; } - return rowToFilter.includes(fltr); + return rowToFilterOut.includes(fltr); }; } diff --git a/src/app/eclair/routing/routing-peers/routing-peers.component.ts b/src/app/eclair/routing/routing-peers/routing-peers.component.ts index 15f8548a..2dfa92aa 100644 --- a/src/app/eclair/routing/routing-peers/routing-peers.component.ts +++ b/src/app/eclair/routing/routing-peers/routing-peers.component.ts @@ -109,31 +109,38 @@ export class ECLRoutingPeersComponent implements OnInit, AfterViewInit, OnDestro } setFilterPredicate() { - this.routingPeersIncoming.filterPredicate = (rowDataIn: RoutingPeers, fltr: string) => JSON.stringify(rowDataIn).toLowerCase().includes(fltr); - this.routingPeersOutgoing.filterPredicate = (rowDataOut: RoutingPeers, fltr: string) => JSON.stringify(rowDataOut).toLowerCase().includes(fltr); - // this.routingPeersIncoming.filterPredicate = (rowData: RoutingPeer, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; + this.routingPeersIncoming.filterPredicate = (rowDataIn: RoutingPeers, fltr: string) => { + let rowToFilterIn = ''; + switch (this.selFilterByIn) { + case 'all': + rowToFilterIn = JSON.stringify(rowDataIn).toLowerCase(); + break; + + default: + rowToFilterIn = typeof rowDataIn[this.selFilterByIn] === 'string' ? rowDataIn[this.selFilterByIn].toLowerCase() : typeof rowDataIn[this.selFilterByIn] === 'boolean' ? (rowDataIn[this.selFilterByIn] ? 'yes' : 'no') : rowDataIn[this.selFilterByIn].toString(); + break; + } + return rowToFilterIn.includes(fltr); + }; + + this.routingPeersOutgoing.filterPredicate = (rowDataOut: RoutingPeers, fltr: string) => { + let rowToFilterOut = ''; + switch (this.selFilterByOut) { + case 'all': + rowToFilterOut = JSON.stringify(rowDataOut).toLowerCase(); + break; + + case 'total_amount': + case 'total_fee': + rowToFilterOut = ((+(rowDataOut[this.selFilterByOut] || 0)) / 1000)?.toString() || ''; + break; + + default: + rowToFilterOut = typeof rowDataOut[this.selFilterByOut] === 'string' ? rowDataOut[this.selFilterByOut].toLowerCase() : typeof rowDataOut[this.selFilterByOut] === 'boolean' ? (rowDataOut[this.selFilterByOut] ? 'yes' : 'no') : rowDataOut[this.selFilterByOut].toString(); + break; + } + return rowToFilterOut.includes(fltr); + }; } loadRoutingPeersTable(forwardingEvents: PaymentRelayed[]) { diff --git a/src/app/lnd/on-chain/utxo-tables/on-chain-transaction-history/on-chain-transaction-history.component.ts b/src/app/lnd/on-chain/utxo-tables/on-chain-transaction-history/on-chain-transaction-history.component.ts index e364abd7..df591d81 100644 --- a/src/app/lnd/on-chain/utxo-tables/on-chain-transaction-history/on-chain-transaction-history.component.ts +++ b/src/app/lnd/on-chain/utxo-tables/on-chain-transaction-history/on-chain-transaction-history.component.ts @@ -130,32 +130,22 @@ export class OnChainTransactionHistoryComponent implements OnInit, OnChanges, On setFilterPredicate() { this.listTransactions.filterPredicate = (rowData: Transaction, fltr: string) => { - const newRowData = ((rowData.time_stamp) ? this.datePipe.transform(new Date(rowData.time_stamp * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); - return newRowData.includes(fltr); + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = ((rowData.time_stamp) ? this.datePipe.transform(new Date(rowData.time_stamp * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); + break; + + case 'time_stamp': + rowToFilter = this.datePipe.transform(new Date((rowData?.time_stamp || 0) * 1000), 'dd/MMM/YYYY HH:mm') || ''; + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } + return rowToFilter.includes(fltr); }; - // this.listTransactions.filterPredicate = (rowData: Transaction, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case 'time_stamp': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; } loadTransactionsTable(transactions) { diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-active-htlcs-table/channel-active-htlcs-table.component.ts b/src/app/lnd/peers-channels/channels/channels-tables/channel-active-htlcs-table/channel-active-htlcs-table.component.ts index d468e516..8f2348cf 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-active-htlcs-table/channel-active-htlcs-table.component.ts +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-active-htlcs-table/channel-active-htlcs-table.component.ts @@ -132,33 +132,19 @@ export class ChannelActiveHTLCsTableComponent implements OnInit, AfterViewInit, setFilterPredicate() { this.channels.filterPredicate = (rowData: Channel, fltr: string) => { - const rowToFilter = (rowData.remote_alias ? rowData.remote_alias.toLowerCase() : '') + - rowData.pending_htlcs?.map((htlc) => JSON.stringify(htlc) + (htlc.incoming ? 'yes' : 'no')); + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = (rowData.remote_alias ? rowData.remote_alias.toLowerCase() : '') + + rowData.pending_htlcs?.map((htlc) => JSON.stringify(htlc) + (htlc.incoming ? 'yes' : 'no')); + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } return rowToFilter.includes(fltr); }; - // this.channels.filterPredicate = (rowData: Channel, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; } loadHTLCsTable(channels: Channel[]) { diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.html b/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.html index f4568de1..e2d0397f 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.html +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.html @@ -20,7 +20,7 @@
info_outline - {{channelClosureType[channel.close_type].name}} + {{channelClosureType[channel.close_type].name}}
diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.ts b/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.ts index a25d8410..212fa4aa 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.ts +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-closed-table/channel-closed-table.component.ts @@ -105,30 +105,28 @@ export class ChannelClosedTableComponent implements OnInit, AfterViewInit, OnDes } setFilterPredicate() { - this.closedChannels.filterPredicate = (rowData: ClosedChannel, fltr: string) => JSON.stringify(rowData).toLowerCase().includes(fltr); - // this.closedChannels.filterPredicate = (rowData: ClosedChannel, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; + this.closedChannels.filterPredicate = (rowData: ClosedChannel, fltr: string) => { + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = JSON.stringify(rowData).toLowerCase(); + break; + + case 'close_type': + rowToFilter = (rowData.close_type && this.channelClosureType[rowData.close_type] && this.channelClosureType[rowData.close_type].name ? this.channelClosureType[rowData.close_type].name.toLowerCase() : ''); + break; + + case 'open_initiator': + case 'close_initiator': + rowToFilter = this.camelCaseWithReplace.transform((rowData[this.selFilterBy] || ''), 'initiator_'); + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } + return rowToFilter.includes(fltr); + }; } onClosedChannelClick(selChannel: ClosedChannel, event: any) { diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.html b/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.html index bd8364e0..184f2ceb 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.html +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.html @@ -33,7 +33,7 @@ Peer
- {{channel.remote_alias || channel.remote_pubkey}} + {{channel.remote_alias}}
@@ -69,11 +69,11 @@ Static Remote Key {{channel.static_remote_key ? 'Yes' : 'No'}} - + Uptime ({{timeUnit}}) {{channel.uptime_str}} - + Lifetime ({{timeUnit}}) {{channel.lifetime_str}} diff --git a/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts b/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts index ab751614..c456216b 100644 --- a/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts +++ b/src/app/lnd/peers-channels/channels/channels-tables/channel-open-table/channel-open-table.component.ts @@ -318,45 +318,31 @@ export class ChannelOpenTableComponent implements OnInit, AfterViewInit, OnDestr setFilterPredicate() { this.channels.filterPredicate = (rowData: Channel, fltr: string) => { - const rowToFilter = ((rowData.active) ? 'active' : 'inactive') + (rowData.chan_id ? rowData.chan_id.toLowerCase() : '') + - (rowData.remote_pubkey ? rowData.remote_pubkey.toLowerCase() : '') + (rowData.remote_alias ? rowData.remote_alias.toLowerCase() : '') + - (rowData.capacity ? rowData.capacity : '') + (rowData.local_balance ? rowData.local_balance : '') + - (rowData.remote_balance ? rowData.remote_balance : '') + (rowData.total_satoshis_sent ? rowData.total_satoshis_sent : '') + - (rowData.total_satoshis_received ? rowData.total_satoshis_received : '') + (rowData.commit_fee ? rowData.commit_fee : '') + - (rowData.private ? 'private' : 'public'); - return rowToFilter.includes(fltr); - }; - // this.channels.filterPredicate = (rowData: Channel, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case 'active': - // rowToFilter = rowData?.active ? 'active' : 'inactive'; - // break; + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = ((rowData.active) ? 'active' : 'inactive') + (rowData.chan_id ? rowData.chan_id.toLowerCase() : '') + + (rowData.remote_pubkey ? rowData.remote_pubkey.toLowerCase() : '') + (rowData.remote_alias ? rowData.remote_alias.toLowerCase() : '') + + (rowData.capacity ? rowData.capacity : '') + (rowData.local_balance ? rowData.local_balance : '') + + (rowData.remote_balance ? rowData.remote_balance : '') + (rowData.total_satoshis_sent ? rowData.total_satoshis_sent : '') + + (rowData.total_satoshis_received ? rowData.total_satoshis_received : '') + (rowData.commit_fee ? rowData.commit_fee : '') + + (rowData.private ? 'private' : 'public'); + break; - // case 'private': - // rowToFilter = rowData?.private ? 'private' : 'public'; - // break; + case 'active': + rowToFilter = rowData?.active ? 'active' : 'inactive'; + break; - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; + case 'private': + rowToFilter = rowData?.private ? 'private' : 'public'; + break; - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return this.selFilterBy === 'active' ? rowToFilter.indexOf(fltr) === 0 : rowToFilter.includes(fltr); - // }; + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } + return this.selFilterBy === 'active' ? rowToFilter.indexOf(fltr) === 0 : rowToFilter.includes(fltr); + }; } loadChannelsTable(mychannels: Channel[]) { diff --git a/src/app/lnd/peers-channels/peers/peers.component.ts b/src/app/lnd/peers-channels/peers/peers.component.ts index b11b9edf..8c6f3620 100644 --- a/src/app/lnd/peers-channels/peers/peers.component.ts +++ b/src/app/lnd/peers-channels/peers/peers.component.ts @@ -186,30 +186,23 @@ export class PeersComponent implements OnInit, AfterViewInit, OnDestroy { } setFilterPredicate() { - this.peers.filterPredicate = (rowData: Peer, fltr: string) => JSON.stringify(rowData).toLowerCase().includes(fltr); - // this.peers.filterPredicate = (rowData: Peer, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; + this.peers.filterPredicate = (rowData: Peer, fltr: string) => { + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = JSON.stringify(rowData).toLowerCase(); + break; + + case 'sync_type': + rowToFilter = this.camelCaseWithReplace.transform((rowData.sync_type || ''), 'sync', '_'); + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } + return rowToFilter.includes(fltr); + }; } loadPeersTable(peers: Peer[]) { diff --git a/src/app/lnd/routing/forwarding-history/forwarding-history.component.ts b/src/app/lnd/routing/forwarding-history/forwarding-history.component.ts index 639e5be0..8dca74c5 100644 --- a/src/app/lnd/routing/forwarding-history/forwarding-history.component.ts +++ b/src/app/lnd/routing/forwarding-history/forwarding-history.component.ts @@ -147,32 +147,22 @@ export class ForwardingHistoryComponent implements OnInit, AfterViewInit, OnChan setFilterPredicate() { this.forwardingHistoryEvents.filterPredicate = (rowData: ForwardingEvent, fltr: string) => { - const newRowData = ((rowData.timestamp) ? this.datePipe.transform(new Date(rowData.timestamp * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); - return newRowData.includes(fltr); + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = ((rowData.timestamp) ? this.datePipe.transform(new Date(rowData.timestamp * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); + break; + + case 'timestamp': + rowToFilter = this.datePipe.transform(new Date((rowData[this.selFilterBy] || 0) * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() || ''; + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } + return rowToFilter.includes(fltr); }; - // this.forwardingHistoryEvents.filterPredicate = (rowData: ForwardingEvent, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; } loadForwardingEventsTable(forwardingEvents: ForwardingEvent[]) { diff --git a/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.html b/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.html index cb40b43c..c9bde73a 100644 --- a/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.html +++ b/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.html @@ -49,11 +49,11 @@ - + Uptime ({{timeUnit}}) {{nonRPeer.uptime_str}} - + Lifetime ({{timeUnit}}) {{nonRPeer.lifetime_str}} diff --git a/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.ts b/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.ts index a425b6d4..8eddbf9b 100644 --- a/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.ts +++ b/src/app/lnd/routing/non-routing-peers/non-routing-peers.component.ts @@ -199,30 +199,19 @@ export class NonRoutingPeersComponent implements OnInit, AfterViewInit, OnDestro } setFilterPredicate() { - this.nonRoutingPeers.filterPredicate = (rowData: Channel, fltr: string) => JSON.stringify(rowData).toLowerCase().includes(fltr); - // this.peers.filterPredicate = (rowData: Peer, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; + this.nonRoutingPeers.filterPredicate = (rowData: Channel, fltr: string) => { + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = JSON.stringify(rowData).toLowerCase(); + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } + return rowToFilter.includes(fltr); + }; } loadNonRoutingPeersTable(forwardingEvents: ForwardingEvent[]) { diff --git a/src/app/lnd/routing/routing-peers/routing-peers.component.ts b/src/app/lnd/routing/routing-peers/routing-peers.component.ts index 3be22246..5a12c869 100644 --- a/src/app/lnd/routing/routing-peers/routing-peers.component.ts +++ b/src/app/lnd/routing/routing-peers/routing-peers.component.ts @@ -138,31 +138,38 @@ export class RoutingPeersComponent implements OnInit, AfterViewInit, OnDestroy { } setFilterPredicate() { - this.routingPeersIncoming.filterPredicate = (rowDataIn: RoutingPeers, fltr: string) => JSON.stringify(rowDataIn).toLowerCase().includes(fltr); - this.routingPeersOutgoing.filterPredicate = (rowDataOut: RoutingPeers, fltr: string) => JSON.stringify(rowDataOut).toLowerCase().includes(fltr); - // this.routingPeersIncoming.filterPredicate = (rowData: RoutingPeer, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; + this.routingPeersIncoming.filterPredicate = (rowDataIn: RoutingPeers, fltr: string) => { + let rowToFilterIn = ''; + switch (this.selFilterByIn) { + case 'all': + rowToFilterIn = JSON.stringify(rowDataIn).toLowerCase(); + break; + + default: + rowToFilterIn = typeof rowDataIn[this.selFilterByIn] === 'string' ? rowDataIn[this.selFilterByIn].toLowerCase() : typeof rowDataIn[this.selFilterByIn] === 'boolean' ? (rowDataIn[this.selFilterByIn] ? 'yes' : 'no') : rowDataIn[this.selFilterByIn].toString(); + break; + } + return rowToFilterIn.includes(fltr); + }; + + this.routingPeersOutgoing.filterPredicate = (rowDataOut: RoutingPeers, fltr: string) => { + let rowToFilterOut = ''; + switch (this.selFilterByOut) { + case 'all': + rowToFilterOut = JSON.stringify(rowDataOut).toLowerCase(); + break; + + case 'total_amount': + case 'total_fee': + rowToFilterOut = ((+(rowDataOut[this.selFilterByOut] || 0)) / 1000)?.toString() || ''; + break; + + default: + rowToFilterOut = typeof rowDataOut[this.selFilterByOut] === 'string' ? rowDataOut[this.selFilterByOut].toLowerCase() : typeof rowDataOut[this.selFilterByOut] === 'boolean' ? (rowDataOut[this.selFilterByOut] ? 'yes' : 'no') : rowDataOut[this.selFilterByOut].toString(); + break; + } + return rowToFilterOut.includes(fltr); + }; } loadRoutingPeersTable(forwardingEvents: ForwardingEvent[]) { diff --git a/src/app/lnd/transactions/invoices/lightning-invoices.component.html b/src/app/lnd/transactions/invoices/lightning-invoices.component.html index 5ba9a00b..22f30c70 100644 --- a/src/app/lnd/transactions/invoices/lightning-invoices.component.html +++ b/src/app/lnd/transactions/invoices/lightning-invoices.component.html @@ -42,7 +42,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/src/app/lnd/transactions/invoices/lightning-invoices.component.ts b/src/app/lnd/transactions/invoices/lightning-invoices.component.ts index d0cad424..42d418d0 100644 --- a/src/app/lnd/transactions/invoices/lightning-invoices.component.ts +++ b/src/app/lnd/transactions/invoices/lightning-invoices.component.ts @@ -184,33 +184,36 @@ export class LightningInvoicesComponent implements OnInit, AfterViewInit, OnDest setFilterPredicate() { this.invoices.filterPredicate = (rowData: Invoice, fltr: string) => { - const rowToFilter = (rowData.creation_date ? this.datePipe.transform(new Date(rowData.creation_date * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '')! + - (rowData.settle_date ? this.datePipe.transform(new Date(rowData.settle_date * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); - return rowToFilter.includes(fltr); - }; - // this.invoices.filterPredicate = (rowData: Invoice, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = (rowData.creation_date ? this.datePipe.transform(new Date(rowData.creation_date * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '')! + + (rowData.settle_date ? this.datePipe.transform(new Date(rowData.settle_date * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); + break; + + case 'creation_date': + case 'settle_date': + rowToFilter = this.datePipe.transform(new Date((rowData[this.selFilterBy] || 0) * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() || ''; + break; + + case 'private': + rowToFilter = rowData?.private ? 'private' : 'public'; + break; - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; + case 'is_keysend': + rowToFilter = rowData?.is_keysend ? 'keysend invoices' : 'non keysend invoices'; + break; - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; + case 'is_amp': + rowToFilter = rowData?.is_amp ? 'atomic multi path payment' : 'non atomic payment'; + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } + return (this.selFilterBy === 'is_keysend' || this.selFilterBy === 'is_amp') ? rowToFilter.indexOf(fltr) === 0 : rowToFilter.includes(fltr); + }; } loadInvoicesTable(invoices) { diff --git a/src/app/lnd/transactions/payments/lightning-payments.component.ts b/src/app/lnd/transactions/payments/lightning-payments.component.ts index 3db5531b..9587704a 100644 --- a/src/app/lnd/transactions/payments/lightning-payments.component.ts +++ b/src/app/lnd/transactions/payments/lightning-payments.component.ts @@ -441,36 +441,34 @@ export class LightningPaymentsComponent implements OnInit, AfterViewInit, OnDest setFilterPredicate() { this.payments.filterPredicate = (rowData: Payment, fltr: string) => { - const rowToFilter = ((rowData.creation_date) ? this.datePipe.transform(new Date(rowData.creation_date * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); + let rowToFilter = ''; + switch (this.selFilterBy) { + case 'all': + rowToFilter = ((rowData.creation_date) ? this.datePipe.transform(new Date(rowData.creation_date * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); + break; + + case 'status': + rowToFilter = rowData?.status === 'SUCCEEDED' ? 'succeeded' : 'failed'; + break; + + case 'creation_date': + rowToFilter = this.datePipe.transform(new Date((rowData[this.selFilterBy] || 0) * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() || ''; + break; + + case 'failure_reason': + rowToFilter = this.camelCaseWithReplace.transform((rowData.failure_reason || ''), 'failure_reason', '_'); + break; + + case 'hops': + rowToFilter = rowData.htlcs && rowData.htlcs[0] && rowData.htlcs[0].route && rowData.htlcs[0].route.hops && rowData.htlcs[0].route.hops.length ? rowData.htlcs[0].route.hops.length.toString() : '0'; + break; + + default: + rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); + break; + } return rowToFilter.includes(fltr); }; - // this.channels.filterPredicate = (rowData: Channel, fltr: string) => { - // let rowToFilter = ''; - // switch (this.selFilterBy) { - // case 'all': - // for (let i = 0; i < this.displayedColumns.length - 1; i++) { - // rowToFilter = rowToFilter + ( - // (this.displayedColumns[i] === '') ? - // (rowData ? rowData..toLowerCase() : '') : - // (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '') - // ) + ', '; - // } - // break; - - // case 'status': - // rowToFilter = rowData?.status === 'SUCCEEDED' ? 'succeeded' : 'failed'; - // break; - - // case '': - // rowToFilter = rowData?..toLowerCase() || ''; - // break; - - // default: - // rowToFilter = typeof rowData[this.selFilterBy] === 'string' ? rowData[this.selFilterBy].toLowerCase() : typeof rowData[this.selFilterBy] === 'boolean' ? (rowData[this.selFilterBy] ? 'yes' : 'no') : rowData[this.selFilterBy].toString(); - // break; - // } - // return rowToFilter.includes(fltr); - // }; } loadPaymentsTable(payms) { diff --git a/src/app/shared/services/consts-enums-functions.ts b/src/app/shared/services/consts-enums-functions.ts index dc3c781e..dc000c85 100644 --- a/src/app/shared/services/consts-enums-functions.ts +++ b/src/app/shared/services/consts-enums-functions.ts @@ -968,7 +968,7 @@ export const LND_PAGE_DEFS: LNDPageDefinitions = { open: { maxColumns: 8, allowedColumns: [{ column:'remote_alias', label: 'Peer' }, { column:'remote_pubkey', label: 'Pubkey' }, { column:'channel_point' }, { column:'chan_id', label: 'Channel ID' }, { column:'initiator' }, - { column:'static_remote_key' }, { column:'uptime' }, { column:'lifetime' }, { column:'commit_fee' }, { column:'commit_weight' }, { column:'fee_per_kw', label: 'Fee/KW' }, + { column:'static_remote_key' }, { column:'uptime_str', label: 'Uptime' }, { column:'lifetime_str', label: 'Lifetime' }, { column:'commit_fee' }, { column:'commit_weight' }, { column:'fee_per_kw', label: 'Fee/KW' }, { column:'num_updates', label: 'Updates' }, { column:'unsettled_balance' }, { column:'capacity' }, { column:'local_chan_reserve_sat', label: 'Local Reserve' }, { column:'remote_chan_reserve_sat', label: 'Remote Reserve' }, { column:'total_satoshis_sent', label: 'Sats Sent' }, { column:'total_satoshis_received', label: 'Sats Received' }, { column:'local_balance' }, { column:'remote_balance' }, { column:'balancedness', label: 'Balance Score' }] @@ -1025,7 +1025,7 @@ export const LND_PAGE_DEFS: LNDPageDefinitions = { }, invoices: { maxColumns: 9, - allowedColumns: [{ column:'private' }, { column:'is_keysend' }, { column:'is_amp' }, { column:'creation_date', label: 'Date Created' }, { column:'settle_date', label: 'Date Settled' }, + allowedColumns: [{ column:'private' }, { column:'is_keysend', label: 'Keysend' }, { column:'is_amp', label: 'AMP' }, { column:'creation_date', label: 'Date Created' }, { column:'settle_date', label: 'Date Settled' }, { column:'memo' }, { column:'r_preimage', label: 'Preimage' }, { column:'r_hash', label: 'Preimage Hash' }, { column:'payment_addr', label: 'Payment Address' }, { column:'payment_request' }, { column:'description_hash' }, { column:'expiry' }, { column:'cltv_expiry' }, { column:'add_index' }, { column:'settle_index' }, { column:'value', label: 'Amount' }, { column:'amt_paid_sat', label: 'Amount Settled' }] } @@ -1042,8 +1042,8 @@ export const LND_PAGE_DEFS: LNDPageDefinitions = { }, non_routing_peers: { maxColumns: 8, - allowedColumns: [{ column:'chan_id', label: 'Channel ID' }, { column:'remote_alias', label: 'Peer Alias' }, { column:'remote_pubkey', label: 'Peer Pubkey' }, { column:'channel_point' }, { column:'uptime' }, - { column:'lifetime' }, { column:'commit_fee' }, { column:'commit_weight' }, { column:'fee_per_kw', label: 'Fee/KW' }, { column:'num_updates', label: 'Updates' }, + allowedColumns: [{ column:'chan_id', label: 'Channel ID' }, { column:'remote_alias', label: 'Peer Alias' }, { column:'remote_pubkey', label: 'Peer Pubkey' }, { column:'channel_point' }, { column:'uptime_str', label: 'Uptime' }, + { column:'lifetime_str', label: 'Lifetime' }, { column:'commit_fee' }, { column:'commit_weight' }, { column:'fee_per_kw', label: 'Fee/KW' }, { column:'num_updates', label: 'Updates' }, { column:'unsettled_balance' }, { column:'capacity' }, { column:'local_chan_reserve_sat', label: 'Local Reserve' }, { column:'remote_chan_reserve_sat', label: 'Remote Reserve' }, { column:'total_satoshis_sent', label: 'Sats Sent' }, { column:'total_satoshis_received', label: 'Sats Received' }, { column:'local_balance' }, { column:'remote_balance' }] }