ECL Filter by selected columns

This commit is contained in:
ShahanaFarooqui 2022-11-03 09:49:10 -07:00
parent c0a1472eef
commit 0dc879038a
8 changed files with 135 additions and 200 deletions

View File

@ -100,32 +100,22 @@ export class ECLOnChainTransactionHistoryComponent implements OnInit, OnDestroy
setFilterPredicate() { setFilterPredicate() {
this.listTransactions.filterPredicate = (rowData: Transaction, fltr: string) => { this.listTransactions.filterPredicate = (rowData: Transaction, fltr: string) => {
const newRowData = ((rowData.timestamp) ? this.datePipe.transform(new Date(rowData.timestamp * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); let rowToFilter = '';
return newRowData.includes(fltr); 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.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 '':
// 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);
// };
} }
onTransactionClick(selTransaction: Transaction, event: any) { onTransactionClick(selTransaction: Transaction, event: any) {

View File

@ -166,34 +166,23 @@ export class ECLChannelInactiveTableComponent implements OnInit, AfterViewInit,
} }
setFilterPredicate() { setFilterPredicate() {
this.channels.filterPredicate = (rowData: Channel, fltr: string) => JSON.stringify(rowData).toLowerCase().includes(fltr); this.channels.filterPredicate = (rowData: Channel, fltr: string) => {
// this.invoices.filterPredicate = (rowData: Invoice, fltr: string) => { let rowToFilter = '';
// let rowToFilter = ''; switch (this.selFilterBy) {
// switch (this.selFilterBy) { case 'all':
// case 'all': rowToFilter = JSON.stringify(rowData).toLowerCase();
// for (let i = 0; i < this.displayedColumns.length - 1; i++) { break;
// rowToFilter = rowToFilter + (
// (this.displayedColumns[i] === '') ?
// (rowData ? rowData..toLowerCase() : '') :
// (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '')
// ) + ', ';
// }
// break;
// case 'announceChannel': case 'announceChannel':
// rowToFilter = rowData?.private ? 'private' : 'public'; rowToFilter = rowData?.announceChannel ? 'public' : 'private';
// break; break;
// case '': default:
// rowToFilter = rowData?..toLowerCase() || ''; 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; break;
}
// default: return rowToFilter.includes(fltr);
// 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);
// };
} }
loadChannelsTable() { loadChannelsTable() {

View File

@ -236,34 +236,23 @@ export class ECLChannelOpenTableComponent implements OnInit, AfterViewInit, OnDe
} }
setFilterPredicate() { setFilterPredicate() {
this.channels.filterPredicate = (rowData: Channel, fltr: string) => JSON.stringify(rowData).toLowerCase().includes(fltr); this.channels.filterPredicate = (rowData: Channel, fltr: string) => {
// this.invoices.filterPredicate = (rowData: Invoice, fltr: string) => { let rowToFilter = '';
// let rowToFilter = ''; switch (this.selFilterBy) {
// switch (this.selFilterBy) { case 'all':
// case 'all': rowToFilter = JSON.stringify(rowData).toLowerCase();
// for (let i = 0; i < this.displayedColumns.length - 1; i++) { break;
// rowToFilter = rowToFilter + (
// (this.displayedColumns[i] === '') ?
// (rowData ? rowData..toLowerCase() : '') :
// (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '')
// ) + ', ';
// }
// break;
// case 'announceChannel': case 'announceChannel':
// rowToFilter = rowData?.private ? 'private' : 'public'; rowToFilter = rowData?.announceChannel ? 'public' : 'private';
// break; break;
// case '': default:
// rowToFilter = rowData?..toLowerCase() || ''; 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; break;
}
// default: return rowToFilter.includes(fltr);
// 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);
// };
} }
loadChannelsTable() { loadChannelsTable() {

View File

@ -136,34 +136,23 @@ export class ECLChannelPendingTableComponent implements OnInit, AfterViewInit, O
} }
setFilterPredicate() { setFilterPredicate() {
this.channels.filterPredicate = (rowData: Channel, fltr: string) => JSON.stringify(rowData).toLowerCase().includes(fltr); this.channels.filterPredicate = (rowData: Channel, fltr: string) => {
// this.channels.filterPredicate = (rowData: Channel, fltr: string) => { let rowToFilter = '';
// let rowToFilter = ''; switch (this.selFilterBy) {
// switch (this.selFilterBy) { case 'all':
// case 'all': rowToFilter = JSON.stringify(rowData).toLowerCase();
// for (let i = 0; i < this.displayedColumns.length - 1; i++) { break;
// rowToFilter = rowToFilter + (
// (this.displayedColumns[i] === '') ?
// (rowData ? rowData..toLowerCase() : '') :
// (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '')
// ) + ', ';
// }
// break;
// case 'announceChannel': case 'announceChannel':
// rowToFilter = rowData?.private ? 'private' : 'public'; rowToFilter = rowData?.announceChannel ? 'public' : 'private';
// break; break;
// case '': default:
// rowToFilter = rowData?..toLowerCase() || ''; 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; break;
}
// default: return rowToFilter.includes(fltr);
// 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);
// };
} }
loadChannelsTable() { loadChannelsTable() {

View File

@ -213,30 +213,23 @@ export class ECLPeersComponent implements OnInit, AfterViewInit, OnDestroy {
} }
setFilterPredicate() { setFilterPredicate() {
this.peers.filterPredicate = (rowData: Peer, fltr: string) => JSON.stringify(rowData).toLowerCase().includes(fltr); this.peers.filterPredicate = (rowData: Peer, fltr: string) => {
// this.peers.filterPredicate = (rowData: Peer, fltr: string) => { let rowToFilter = '';
// let rowToFilter = ''; switch (this.selFilterBy) {
// switch (this.selFilterBy) { case 'all':
// case 'all': rowToFilter = JSON.stringify(rowData).toLowerCase();
// for (let i = 0; i < this.displayedColumns.length - 1; i++) { break;
// rowToFilter = rowToFilter + (
// (this.displayedColumns[i] === '') ?
// (rowData ? rowData..toLowerCase() : '') :
// (rowData[this.displayedColumns[i]] ? rowData[this.displayedColumns[i]].toLowerCase() : '')
// ) + ', ';
// }
// break;
// case '': case 'state':
// rowToFilter = rowData?..toLowerCase() || ''; rowToFilter = rowData?.state?.toLowerCase() || '';
// break; break;
// default: 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(); 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; break;
// } }
// return rowToFilter.includes(fltr); return this.selFilterBy === 'state' ? rowToFilter.indexOf(fltr) === 0 : rowToFilter.includes(fltr);
// }; };
} }
loadPeersTable(peers: Peer[]) { loadPeersTable(peers: Peer[]) {

View File

@ -152,32 +152,26 @@ export class ECLForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
setFilterPredicate() { setFilterPredicate() {
this.forwardingHistoryEvents.filterPredicate = (rowData: PaymentRelayed, fltr: string) => { this.forwardingHistoryEvents.filterPredicate = (rowData: PaymentRelayed, fltr: string) => {
const newRowData = ((rowData.timestamp) ? this.datePipe.transform(new Date(rowData.timestamp), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); let rowToFilter = '';
return newRowData.includes(fltr); switch (this.selFilterBy) {
case 'all':
rowToFilter = ((rowData.timestamp) ? this.datePipe.transform(new Date(rowData.timestamp), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase();
break;
case 'timestamp':
rowToFilter = this.datePipe.transform(new Date((rowData.timestamp || 0)), 'dd/MMM/YYYY HH:mm')?.toLowerCase() || '';
break;
case 'fee':
rowToFilter = (rowData.amountIn - rowData.amountOut).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.forwardingHistoryEvents.filterPredicate = (rowData: PaymentRelayed, 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: PaymentRelayed[]) { loadForwardingEventsTable(forwardingEvents: PaymentRelayed[]) {

View File

@ -188,32 +188,33 @@ export class ECLLightningInvoicesComponent implements OnInit, AfterViewInit, OnD
setFilterPredicate() { setFilterPredicate() {
this.invoices.filterPredicate = (rowData: Invoice, fltr: string) => { this.invoices.filterPredicate = (rowData: Invoice, fltr: string) => {
const newRowData = ((rowData.timestamp) ? this.datePipe.transform(new Date(rowData.timestamp * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); let rowToFilter = '';
return newRowData.includes(fltr); 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 'status':
rowToFilter = !rowData?.status || rowData?.status === 'expired' || rowData?.status === 'unknown' ? 'expired/unknown' : rowData.status?.toLowerCase();
break;
case 'timestamp':
case 'expiresAt':
case 'receivedAt':
rowToFilter = this.datePipe.transform(new Date((rowData[this.selFilterBy] || 0) * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() || '';
break;
case 'amount':
case 'amountSettled':
rowToFilter = rowData[this.selFilterBy]?.toString() || '-';
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 === 'status' ? rowToFilter.indexOf(fltr) === 0 : 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;
// 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);
// };
} }
loadInvoicesTable(invs: Invoice[]) { loadInvoicesTable(invs: Invoice[]) {

View File

@ -132,32 +132,22 @@ export class ECLLightningPaymentsComponent implements OnInit, AfterViewInit, OnD
setFilterPredicate() { setFilterPredicate() {
this.payments.filterPredicate = (rowData: PaymentSent, fltr: string) => { this.payments.filterPredicate = (rowData: PaymentSent, fltr: string) => {
const newRowData = ((rowData.firstPartTimestamp) ? this.datePipe.transform(new Date(rowData.firstPartTimestamp), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase(); let rowToFilter = '';
return newRowData.includes(fltr); switch (this.selFilterBy) {
case 'all':
rowToFilter = ((rowData.firstPartTimestamp) ? this.datePipe.transform(new Date(rowData.firstPartTimestamp), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + JSON.stringify(rowData).toLowerCase();
break;
case 'firstPartTimestamp':
rowToFilter = this.datePipe.transform(new Date(rowData.firstPartTimestamp || 0), '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.payments.filterPredicate = (rowData: PaymentSent, 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);
// };
} }
loadPaymentsTable(payms: PaymentSent[]) { loadPaymentsTable(payms: PaymentSent[]) {