CLN Payments tiny adjustments

CLN Payments tiny adjustments
This commit is contained in:
ShahanaFarooqui 2022-10-17 09:33:45 -07:00
parent e74c5bc635
commit d350f1c0f9
4 changed files with 12 additions and 14 deletions

View File

@ -12,15 +12,15 @@
@include for_screensize(tab-port) {
width:0.6rem;
height: 0.6rem;
left: 0;
margin-top: 0;
left: 4rem;
margin-top: -0.4rem;
position: absolute;
}
@include for_screensize(phone) {
width:0.6rem;
height: 0.6rem;
left: 0;
margin-top: 0;
margin-top: -0.2rem;
position: absolute;
}
}

View File

@ -41,7 +41,7 @@ export class CLNLightningPaymentsComponent implements OnInit, AfterViewInit, OnD
@ViewChild(MatSort, { static: false }) sort: MatSort | undefined;
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
public PAGE_ID = 'payments';
public tableSetting: TableSetting = { tableId: 'payments' };
public tableSetting: TableSetting = { tableId: 'payments', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING };
public faHistory = faHistory;
public newlyAddedPayment = '';
public selNode: SelNodeChild | null = {};
@ -58,7 +58,6 @@ export class CLNLightningPaymentsComponent implements OnInit, AfterViewInit, OnD
public screenSize = '';
public screenSizeEnum = ScreenSizeEnum;
public errorMessage = '';
public pageSettings: PageSettingsCLN[] = [];
public selFilter = '';
public apiCallStatus: ApiCallStatusPayload | null = null;
public apiCallStatusEnum = APICallStatusEnum;
@ -82,8 +81,7 @@ export class CLNLightningPaymentsComponent implements OnInit, AfterViewInit, OnD
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
this.errorMessage = this.apiCallStatus.message || '';
}
this.pageSettings = settings.pageSettings;
this.tableSetting = this.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId) || CLN_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId)!;
this.tableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId) || CLN_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId)!;
if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) {
this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.showColumnsSM));
} else {
@ -299,9 +297,9 @@ export class CLNLightningPaymentsComponent implements OnInit, AfterViewInit, OnD
loadPaymentsTable(payments: Payment[]) {
this.payments = (payments) ? new MatTableDataSource<Payment>([...payments]) : new MatTableDataSource([]);
this.payments.sort = this.sort;
this.payments.sortingDataAccessor = (data: any, sortHeaderId: string) => ((data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null);
this.payments.sort.sort({ id: this.tableSetting.sortBy, start: this.tableSetting.sortOrder, disableClear: false });
this.payments.sort = this.sort;
this.payments.sort.sort({ id: this.tableSetting.sortBy, start: this.tableSetting.sortOrder, disableClear: true });
this.payments.filterPredicate = (rowData: Payment, fltr: string) => {
const newRowData = ((rowData.created_at) ? this.datePipe.transform(new Date(rowData.created_at * 1000), 'dd/MMM/YYYY HH:mm')?.toLowerCase() : '') + ((rowData.bolt12) ? 'bolt12' : (rowData.bolt11) ? 'bolt11' : 'keysend') + JSON.stringify(rowData).toLowerCase();
return newRowData.includes(fltr);

View File

@ -28,7 +28,7 @@
<mat-form-field fxFlex="10">
<mat-select [(ngModel)]="table.sortOrder" placeholder="Sort Order" name="{{table.tableId}}-sort-order" tabindex="3" required>
<mat-option *ngFor="let so of sortOrders" [value]="so">
{{so}}
{{so === 'desc' ? 'Descending' : 'Ascending'}}
</mat-option>
</mat-select>
</mat-form-field>

View File

@ -675,10 +675,10 @@ export enum SortOrderEnum {
export const SORT_ORDERS = ['asc', 'desc'];
export const CLN_DEFAULT_PAGE_SETTINGS: PageSettingsCLN[] = [
{ pageId: 'payments', tables: [{ tableId: 'payments', recordsPerPage: 10, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
{ pageId: 'payments', tables: [{ tableId: 'payments', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
showColumnsSM: ['created_at', 'msatoshi'],
showColumns: ['created_at', 'type', 'payment_hash', 'msatoshi_sent', 'msatoshi'] }] },
{ pageId: 'invoices', tables: [{ tableId: 'invoices', recordsPerPage: 10, sortBy: 'expires_at', sortOrder: SortOrderEnum.DESCENDING,
{ pageId: 'invoices', tables: [{ tableId: 'invoices', recordsPerPage: PAGE_SIZE, sortBy: 'expires_at', sortOrder: SortOrderEnum.DESCENDING,
showColumnsSM: ['expires_at', 'msatoshi'],
showColumns: ['expires_at', 'paid_at', 'type', 'description', 'msatoshi', 'msatoshi_received'] }] }
];
@ -686,10 +686,10 @@ export const CLN_DEFAULT_PAGE_SETTINGS: PageSettingsCLN[] = [
export const CLN_TABLES_DEF = {
payments: {
maxColumns: 5,
allowedColumns: ['created_at', 'type', 'payment_hash', 'msatoshi_sent', 'msatoshi', 'bolt11', 'destination', 'memo', 'label']
allowedColumns: ['created_at', 'type', 'payment_hash', 'bolt11', 'destination', 'memo', 'label', 'msatoshi_sent', 'msatoshi']
},
invoices: {
maxColumns: 6,
allowedColumns: ['expires_at', 'paid_at', 'type', 'description', 'msatoshi', 'msatoshi_received', 'label', 'payment_hash', 'status']
allowedColumns: ['expires_at', 'paid_at', 'type', 'description', 'label', 'payment_hash', 'bolt11', 'msatoshi', 'msatoshi_received']
}
};