mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2024-11-19 01:40:29 +01:00
ECL Filter by selected columns
This commit is contained in:
parent
c0a1472eef
commit
0dc879038a
@ -100,32 +100,22 @@ export class ECLOnChainTransactionHistoryComponent implements OnInit, OnDestroy
|
||||
|
||||
setFilterPredicate() {
|
||||
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();
|
||||
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.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) {
|
||||
|
@ -166,34 +166,23 @@ export class ECLChannelInactiveTableComponent implements OnInit, AfterViewInit,
|
||||
}
|
||||
|
||||
setFilterPredicate() {
|
||||
this.channels.filterPredicate = (rowData: Channel, fltr: string) => JSON.stringify(rowData).toLowerCase().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;
|
||||
this.channels.filterPredicate = (rowData: Channel, fltr: string) => {
|
||||
let rowToFilter = '';
|
||||
switch (this.selFilterBy) {
|
||||
case 'all':
|
||||
rowToFilter = JSON.stringify(rowData).toLowerCase();
|
||||
break;
|
||||
|
||||
// case 'announceChannel':
|
||||
// rowToFilter = rowData?.private ? 'private' : 'public';
|
||||
// break;
|
||||
case 'announceChannel':
|
||||
rowToFilter = rowData?.announceChannel ? 'public' : 'private';
|
||||
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);
|
||||
// };
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
loadChannelsTable() {
|
||||
|
@ -236,34 +236,23 @@ export class ECLChannelOpenTableComponent implements OnInit, AfterViewInit, OnDe
|
||||
}
|
||||
|
||||
setFilterPredicate() {
|
||||
this.channels.filterPredicate = (rowData: Channel, fltr: string) => JSON.stringify(rowData).toLowerCase().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;
|
||||
this.channels.filterPredicate = (rowData: Channel, fltr: string) => {
|
||||
let rowToFilter = '';
|
||||
switch (this.selFilterBy) {
|
||||
case 'all':
|
||||
rowToFilter = JSON.stringify(rowData).toLowerCase();
|
||||
break;
|
||||
|
||||
// case 'announceChannel':
|
||||
// rowToFilter = rowData?.private ? 'private' : 'public';
|
||||
// break;
|
||||
case 'announceChannel':
|
||||
rowToFilter = rowData?.announceChannel ? 'public' : 'private';
|
||||
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);
|
||||
// };
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
loadChannelsTable() {
|
||||
|
@ -136,34 +136,23 @@ export class ECLChannelPendingTableComponent implements OnInit, AfterViewInit, O
|
||||
}
|
||||
|
||||
setFilterPredicate() {
|
||||
this.channels.filterPredicate = (rowData: Channel, fltr: string) => JSON.stringify(rowData).toLowerCase().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;
|
||||
this.channels.filterPredicate = (rowData: Channel, fltr: string) => {
|
||||
let rowToFilter = '';
|
||||
switch (this.selFilterBy) {
|
||||
case 'all':
|
||||
rowToFilter = JSON.stringify(rowData).toLowerCase();
|
||||
break;
|
||||
|
||||
// case 'announceChannel':
|
||||
// rowToFilter = rowData?.private ? 'private' : 'public';
|
||||
// break;
|
||||
case 'announceChannel':
|
||||
rowToFilter = rowData?.announceChannel ? 'public' : 'private';
|
||||
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);
|
||||
// };
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
loadChannelsTable() {
|
||||
|
@ -213,30 +213,23 @@ export class ECLPeersComponent 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;
|
||||
this.peers.filterPredicate = (rowData: Peer, fltr: string) => {
|
||||
let rowToFilter = '';
|
||||
switch (this.selFilterBy) {
|
||||
case 'all':
|
||||
rowToFilter = JSON.stringify(rowData).toLowerCase();
|
||||
break;
|
||||
|
||||
// case '':
|
||||
// rowToFilter = rowData?..toLowerCase() || '';
|
||||
// break;
|
||||
case 'state':
|
||||
rowToFilter = rowData?.state?.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);
|
||||
// };
|
||||
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 === 'state' ? rowToFilter.indexOf(fltr) === 0 : rowToFilter.includes(fltr);
|
||||
};
|
||||
}
|
||||
|
||||
loadPeersTable(peers: Peer[]) {
|
||||
|
@ -152,32 +152,26 @@ export class ECLForwardingHistoryComponent implements OnInit, OnChanges, AfterVi
|
||||
|
||||
setFilterPredicate() {
|
||||
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();
|
||||
return newRowData.includes(fltr);
|
||||
let rowToFilter = '';
|
||||
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[]) {
|
||||
|
@ -188,32 +188,33 @@ export class ECLLightningInvoicesComponent implements OnInit, AfterViewInit, OnD
|
||||
|
||||
setFilterPredicate() {
|
||||
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();
|
||||
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 '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[]) {
|
||||
|
@ -132,32 +132,22 @@ export class ECLLightningPaymentsComponent implements OnInit, AfterViewInit, OnD
|
||||
|
||||
setFilterPredicate() {
|
||||
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();
|
||||
return newRowData.includes(fltr);
|
||||
let rowToFilter = '';
|
||||
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[]) {
|
||||
|
Loading…
Reference in New Issue
Block a user