Peerswap page settings

cln-peer-swap
ShahanaFarooqui 10 months ago
parent 4f348c7f24
commit a884065a40

@ -22,7 +22,7 @@
</div>
<div fxLayout="column" fxLayoutAlign="start center" fxFlex="100" class="table-container" [perfectScrollbar]>
<mat-progress-bar *ngIf="apiCallStatus?.status === apiCallStatusEnum.INITIATED" mode="indeterminate"></mat-progress-bar>
<table #table mat-table class="overflow-auto" fxFlex="100" matSort [dataSource]="swapPeers" [ngClass]="{'error-border': errorMessage !== ''}">
<table #table mat-table class="overflow-auto" fxFlex="100" matSort [matSortActive]="tableSetting.sortBy" [matSortDirection]="tableSetting.sortOrder" [dataSource]="swapPeers" [ngClass]="{'error-border': errorMessage !== ''}">
<ng-container matColumnDef="short_channel_id">
<th *matHeaderCellDef mat-header-cell mat-sort-header>Short Channel ID</th>
<td *matCellDef="let sPeer" mat-cell>{{sPeer?.short_channel_id}}</td>

@ -41,7 +41,7 @@ export class PSPeersComponent implements OnInit, OnDestroy {
public selFilterBy = 'all';
public colWidth = '20rem';
public PAGE_ID = 'peerswap';
public tableSetting: TableSetting = { tableId: 'pspeers', recordsPerPage: PAGE_SIZE, sortBy: 'swaps_allowed', sortOrder: SortOrderEnum.DESCENDING };
public tableSetting: TableSetting = { tableId: 'peers', recordsPerPage: PAGE_SIZE, sortBy: 'swaps_allowed', sortOrder: SortOrderEnum.DESCENDING };
public displayedColumns: any[] = [];
public totalSwapPeers = 0;
public peersData: SwapPeerChannelsFlattened[] = [];

@ -103,7 +103,7 @@
<tr *matFooterRowDef="['no_swap']" mat-footer-row
[ngClass]="{'display-none': swaps?.data && swaps?.data?.length && swaps?.data?.length>0}">
</tr>
<tr *matHeaderRowDef="displayedColumns; sticky: flgSticky;" mat-header-row></tr>
<tr *matHeaderRowDef="displayedColumns;" mat-header-row></tr>
<tr *matRowDef="let row; columns: displayedColumns;" mat-row></tr>
</table>
</div>

@ -45,12 +45,11 @@ export class PSSwapsListComponent implements OnInit, AfterViewInit, OnDestroy {
public selFilterBy = 'all';
public colWidth = '20rem';
public PAGE_ID = 'peerswap';
public tableSetting: TableSetting = { tableId: 'psout', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING };
public psPageSettings: PageSettings[] = CLN_DEFAULT_PAGE_SETTINGS;
public tableSetting: TableSetting = { tableId: 'swap_out', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING };
public psPageSettings: PageSettings = { pageId: this.PAGE_ID, tables: [] };
public displayedColumns: any[] = [];
public allSwapsData: any = null;
public swaps: any;
public flgSticky = false;
public pageSize = PAGE_SIZE;
public pageSizeOptions = PAGE_SIZE_OPTIONS;
public screenSize = '';
@ -71,13 +70,10 @@ export class PSSwapsListComponent implements OnInit, AfterViewInit, OnDestroy {
ngOnInit() {
this.selSwapList = this.router.url.substring(this.router.url.lastIndexOf('/') + 1);
this.tableSetting.tableId = this.selSwapList;
this.updateTableDef();
this.router.events.pipe(takeUntil(this.unSubs[0]), filter((e) => e instanceof ResolveEnd)).
subscribe({
next: (value: ResolveEnd) => {
this.selSwapList = value.url.substring(value.url.lastIndexOf('/') + 1);
this.tableSetting.tableId = this.selSwapList;
this.updateTableDef();
if (this.allSwapsData && this.sort && this.paginator) {
this.loadSwapsTable();
@ -91,7 +87,9 @@ export class PSSwapsListComponent implements OnInit, AfterViewInit, OnDestroy {
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
this.errorMessage = this.apiCallStatus.message || '';
}
this.psPageSettings = settings.pageSettings || CLN_DEFAULT_PAGE_SETTINGS;
this.psPageSettings = (settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)) || (CLN_DEFAULT_PAGE_SETTINGS.find((page) => page.pageId === this.PAGE_ID));
this.updateTableDef();
this.logger.info(this.psPageSettings);
});
this.store.select(swaps).pipe(takeUntil(this.unSubs[2])).
subscribe((swapsSeletor: { swapOuts: Swap[], swapIns: Swap[], swapsCanceled: Swap[], apiCallStatus: ApiCallStatusPayload }) => {
@ -213,17 +211,21 @@ export class PSSwapsListComponent implements OnInit, AfterViewInit, OnDestroy {
}
updateTableDef() {
this.tableSetting = JSON.parse(JSON.stringify(this.psPageSettings.find((page) => page.pageId === this.PAGE_ID).tables.find((table) => table.tableId === this.selSwapList)));
if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) {
this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelectionSM));
} else {
this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelection));
const sel_table = this.selSwapList.includes('psin') ? 'swap_in' : this.selSwapList.includes('pscanceled') ? 'swap_canceled' : 'swap_out';
const found_table = this.psPageSettings.tables.find((table) => table.tableId === sel_table);
if (found_table) {
this.tableSetting = JSON.parse(JSON.stringify(found_table));
if (this.screenSize === ScreenSizeEnum.XS || this.screenSize === ScreenSizeEnum.SM) {
this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelectionSM));
} else {
this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelection));
}
this.displayedColumns.unshift('role');
this.displayedColumns.push('actions');
this.pageSize = this.tableSetting.recordsPerPage ? +this.tableSetting.recordsPerPage : PAGE_SIZE;
this.colWidth = this.displayedColumns.length ? ((this.commonService.getContainerSize().width / this.displayedColumns.length) / 14) + 'rem' : '20rem';
this.filterColumns = ['all', ...this.displayedColumns.slice(0, -1)];
}
this.displayedColumns.unshift('role');
this.displayedColumns.push('actions');
this.pageSize = this.tableSetting.recordsPerPage ? +this.tableSetting.recordsPerPage : PAGE_SIZE;
this.colWidth = this.displayedColumns.length ? ((this.commonService.getContainerSize().width / this.displayedColumns.length) / 14) + 'rem' : '20rem';
this.filterColumns = ['all', ...this.displayedColumns.slice(0, -1)];
this.logger.info(this.displayedColumns);
}

@ -138,10 +138,10 @@ export class CLNPageDefinitions {
query_routes: TableDefinition;
};
peerswap: {
pspeers: TableDefinition;
psout: TableDefinition;
psin: TableDefinition;
pscanceled: TableDefinition;
peers: TableDefinition;
swap_out: TableDefinition;
swap_in: TableDefinition;
swap_canceled: TableDefinition;
};
};

@ -812,16 +812,16 @@ export const CLN_DEFAULT_PAGE_SETTINGS: PageSettings[] = [
columnSelection: ['alias', 'channel', 'direction', 'delay', 'msatoshi'] }
] },
{ pageId: 'peerswap', tables: [
{ tableId: 'pspeers', recordsPerPage: PAGE_SIZE, sortBy: 'swaps_allowed', sortOrder: SortOrderEnum.DESCENDING,
{ tableId: 'peers', recordsPerPage: PAGE_SIZE, sortBy: 'swaps_allowed', sortOrder: SortOrderEnum.DESCENDING,
columnSelectionSM: ['alias', 'short_channel_id'],
columnSelection: ['short_channel_id', 'alias', 'swaps_allowed', 'local_balance', 'remote_balance'] },
{ tableId: 'psout', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
{ tableId: 'swap_out', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
columnSelectionSM: ['state', 'created_at', 'amount'],
columnSelection: ['state', 'created_at', 'swap_id', 'alias', 'short_channel_id', 'amount'] },
{ tableId: 'psin', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
{ tableId: 'swap_in', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
columnSelectionSM: ['state', 'created_at', 'amount'],
columnSelection: ['state', 'created_at', 'swap_id', 'alias', 'short_channel_id', 'amount'] },
{ tableId: 'pscanceled', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
{ tableId: 'swap_canceled', recordsPerPage: PAGE_SIZE, sortBy: 'created_at', sortOrder: SortOrderEnum.DESCENDING,
columnSelectionSM: ['created_at', 'amount', 'cancel_message'],
columnSelection: ['created_at', 'swap_id', 'alias', 'short_channel_id', 'amount', 'cancel_message'] }
] }
@ -932,19 +932,19 @@ export const CLN_PAGE_DEFS: CLNPageDefinitions = {
}
},
peerswap: {
pspeers: {
peers: {
maxColumns: 5,
allowedColumns: [{ column:'short_channel_id' }, { column:'alias' }, { column:'swaps_allowed' }, { column:'local_balance' }, { column:'remote_balance' }]
},
psout: {
swap_out: {
maxColumns: 6,
allowedColumns: [{ column:'state' }, { column:'created_at' }, { column:'swap_id' }, { column:'alias' }, { column:'short_channel_id' }, { column:'amount' }]
},
psin: {
swap_in: {
maxColumns: 6,
allowedColumns: [{ column:'state' }, { column:'created_at' }, { column:'swap_id' }, { column:'alias' }, { column:'short_channel_id' }, { column:'amount' }]
},
pscanceled: {
swap_canceled: {
maxColumns: 6,
allowedColumns: [{ column:'created_at' }, { column:'swap_id' }, { column:'alias' }, { column:'short_channel_id' }, { column:'amount' }, { column:'cancel_message' }]
}

Loading…
Cancel
Save