diff --git a/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss b/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss
index 4ad066b1..ba63493f 100755
--- a/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss
+++ b/src/app/shared/components/ln-services/loop/swaps/swaps.component.scss
@@ -1,3 +1,11 @@
+.mat-column-htlc_address, .mat-column-id, .mat-column-id_bytes {
+ flex: 0 0 15%;
+ width: 15%;
+ & .ellipsis-parent {
+ display: flex;
+ }
+}
+
.mat-column-actions {
min-height: 4.8rem;
}
diff --git a/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts b/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts
index 02d7a73f..5e760ba9 100755
--- a/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts
+++ b/src/app/shared/components/ln-services/loop/swaps/swaps.component.ts
@@ -1,21 +1,23 @@
-import { Component, OnChanges, OnDestroy, ViewChild, Input, AfterViewInit, SimpleChanges } from '@angular/core';
+import { Component, OnChanges, OnDestroy, ViewChild, Input, AfterViewInit, SimpleChanges, OnInit } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
-import { Actions } from '@ngrx/effects';
import { faHistory } from '@fortawesome/free-solid-svg-icons';
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { LoopSwapStatus } from '../../../../models/loopModels';
-import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, LoopTypeEnum, LoopStateEnum } from '../../../../services/consts-enums-functions';
+import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum, LoopTypeEnum, LoopStateEnum, SortOrderEnum, LND_DEFAULT_PAGE_SETTINGS } from '../../../../services/consts-enums-functions';
import { LoggerService } from '../../../../services/logger.service';
import { CommonService } from '../../../../services/common.service';
import { LoopService } from '../../../../services/loop.service';
import { RTLState } from '../../../../../store/rtl.state';
import { openAlert } from '../../../../../store/rtl.actions';
+import { PageSettings, TableSetting } from '../../../../models/pageSettings';
+import { lndPageSettings } from '../../../../../lnd/store/lnd.selector';
+import { ApiCallStatusPayload } from '../../../../models/apiCallsPayload';
@Component({
selector: 'rtl-swaps',
@@ -25,7 +27,7 @@ import { openAlert } from '../../../../../store/rtl.actions';
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Swaps') }
]
})
-export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy {
+export class SwapsComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy {
@Input() selectedSwapType: LoopTypeEnum = LoopTypeEnum.LOOP_OUT;
@Input() swapsData: LoopSwapStatus[] = [];
@@ -33,6 +35,8 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy {
@Input() emptyTableMessage = 'No swaps available.';
@ViewChild(MatSort, { static: false }) sort: MatSort | undefined;
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
+ public PAGE_ID = 'loop';
+ public tableSetting: TableSetting = { tableId: 'loop', recordsPerPage: PAGE_SIZE, sortBy: 'initiation_time', sortOrder: SortOrderEnum.DESCENDING };
public LoopStateEnum = LoopStateEnum;
public faHistory = faHistory;
public swapCaption = 'Loop Out';
@@ -47,15 +51,24 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy {
constructor(private logger: LoggerService, private commonService: CommonService, private store: Store
, private loopService: LoopService) {
this.screenSize = this.commonService.getScreenSize();
- if (this.screenSize === ScreenSizeEnum.XS) {
- this.displayedColumns = ['state', 'amt', 'actions'];
- } else if (this.screenSize === ScreenSizeEnum.SM) {
- this.displayedColumns = ['state', 'amt', 'actions'];
- } else if (this.screenSize === ScreenSizeEnum.MD) {
- this.displayedColumns = ['state', 'initiation_time', 'amt', 'actions'];
- } else {
- this.displayedColumns = ['state', 'initiation_time', 'amt', 'cost_server', 'cost_offchain', 'cost_onchain', 'actions'];
- }
+ }
+
+ ngOnInit() {
+ this.store.select(lndPageSettings).pipe(takeUntil(this.unSubs[0])).
+ subscribe((settings: { pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }) => {
+ this.tableSetting = settings.pageSettings.find((page) => page.pageId === this.PAGE_ID)?.tables.find((table) => table.tableId === this.tableSetting.tableId) || LND_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.columnSelectionSM));
+ } else {
+ this.displayedColumns = JSON.parse(JSON.stringify(this.tableSetting.columnSelection));
+ }
+ this.displayedColumns.push('actions');
+ this.pageSize = this.tableSetting.recordsPerPage ? +this.tableSetting.recordsPerPage : PAGE_SIZE;
+ if (this.swapsData && this.swapsData.length > 0 && this.sort && this.paginator) {
+ this.loadSwapsTable(this.swapsData);
+ }
+ this.logger.info(this.displayedColumns);
+ });
}
ngAfterViewInit() {
@@ -74,7 +87,7 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy {
}
onSwapClick(selSwap: LoopSwapStatus, event: any) {
- this.loopService.getSwap(selSwap.id_bytes?.replace(/\//g, '_')?.replace(/\+/g, '-') || '').pipe(takeUntil(this.unSubs[2])).
+ this.loopService.getSwap(selSwap.id_bytes?.replace(/\//g, '_')?.replace(/\+/g, '-') || '').pipe(takeUntil(this.unSubs[1])).
subscribe((fetchedSwap: LoopSwapStatus) => {
const reorderedSwap = [
[{ key: 'state', value: LoopStateEnum[fetchedSwap.state || ''], title: 'Status', width: 50, type: DataTypeEnum.STRING },
@@ -104,6 +117,7 @@ export class SwapsComponent implements AfterViewInit, OnChanges, OnDestroy {
this.listSwaps = new MatTableDataSource([...swaps]);
this.listSwaps.sort = this.sort;
this.listSwaps.sortingDataAccessor = (data: any, sortHeaderId: string) => ((data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null);
+ this.listSwaps.sort?.sort({ id: this.tableSetting.sortBy, start: this.tableSetting.sortOrder, disableClear: true });
this.listSwaps.filterPredicate = (swap: LoopSwapStatus, fltr: string) => JSON.stringify(swap).toLowerCase().includes(fltr);
this.listSwaps.paginator = this.paginator;
this.applyFilter();
diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.html b/src/app/shared/components/ln-services/peerswap/peerswap.component.html
deleted file mode 100755
index afc58b70..00000000
--- a/src/app/shared/components/ln-services/peerswap/peerswap.component.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- Peerswap
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.scss b/src/app/shared/components/ln-services/peerswap/peerswap.component.scss
deleted file mode 100755
index e69de29b..00000000
diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.spec.ts b/src/app/shared/components/ln-services/peerswap/peerswap.component.spec.ts
deleted file mode 100755
index af225501..00000000
--- a/src/app/shared/components/ln-services/peerswap/peerswap.component.spec.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
-import { RouterTestingModule } from '@angular/router/testing';
-import { StoreModule } from '@ngrx/store';
-
-import { RootReducer } from '../../../../store/rtl.reducers';
-import { LNDReducer } from '../../../../lnd/store/lnd.reducers';
-import { CLNReducer } from '../../../../cln/store/cln.reducers';
-import { ECLReducer } from '../../../../eclair/store/ecl.reducers';
-import { LoopService } from '../../../services/loop.service';
-
-import { PeerswapComponent } from './peerswap.component';
-import { SharedModule } from '../../../shared.module';
-import { mockDataService } from '../../../test-helpers/mock-services';
-import { CommonService } from '../../../services/common.service';
-import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { DataService } from '../../../services/data.service';
-
-describe('PeerswapComponent', () => {
- let component: PeerswapComponent;
- let fixture: ComponentFixture;
-
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- declarations: [PeerswapComponent],
- imports: [
- BrowserAnimationsModule,
- SharedModule,
- RouterTestingModule,
- StoreModule.forRoot({ root: RootReducer, lnd: LNDReducer, cln: CLNReducer, ecl: ECLReducer })
- ],
- providers: [
- CommonService,
- { provide: DataService, useClass: mockDataService }
- ]
- }).
- compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(PeerswapComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-
- afterEach(() => {
- TestBed.resetTestingModule();
- });
-});
diff --git a/src/app/shared/components/ln-services/peerswap/peerswap.component.ts b/src/app/shared/components/ln-services/peerswap/peerswap.component.ts
deleted file mode 100755
index f451bdca..00000000
--- a/src/app/shared/components/ln-services/peerswap/peerswap.component.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Component, OnInit, OnDestroy } from '@angular/core';
-import { Router, ResolveEnd, Event } from '@angular/router';
-import { Subject } from 'rxjs';
-import { takeUntil, filter } from 'rxjs/operators';
-import { faHandshake } from '@fortawesome/free-solid-svg-icons';
-
-
-@Component({
- selector: 'rtl-peerswap',
- templateUrl: './peerswap.component.html',
- styleUrls: ['./peerswap.component.scss']
-})
-export class PeerswapComponent implements OnInit, OnDestroy {
-
- public faHandshake = faHandshake;
- public links = [{ link: 'peers', name: 'Peers' }, { link: 'psout', name: 'Peerswap Out' }, { link: 'psin', name: 'Peerswap In' }, { link: 'pscancelled', name: 'Cancelled Peerswaps' }];
- public activeTab = this.links[0];
- private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()];
-
- constructor(private router: Router) { }
-
- ngOnInit() {
- const linkFound = this.links.find((link) => this.router.url.includes(link.link));
- this.activeTab = linkFound ? linkFound : this.links[0];
- this.router.events.pipe(takeUntil(this.unSubs[0]), filter((e) => e instanceof ResolveEnd)).
- subscribe({
- next: (value: ResolveEnd | Event) => {
- const linkFound = this.links.find((link) => (value).urlAfterRedirects.includes(link.link));
- this.activeTab = linkFound ? linkFound : this.links[0];
- }
- });
- }
-
- ngOnDestroy() {
- this.unSubs.forEach((completeSub) => {
- completeSub.next(null);
- completeSub.complete();
- });
- }
-
-}
diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.html b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.html
deleted file mode 100755
index 26568364..00000000
--- a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.html
+++ /dev/null
@@ -1 +0,0 @@
-Swap Peers
\ No newline at end of file
diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.scss b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.scss
deleted file mode 100755
index e69de29b..00000000
diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.spec.ts
deleted file mode 100755
index 6bc0b05f..00000000
--- a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.spec.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
-import { SharedModule } from '../../../../shared.module';
-import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { SwapPeersComponent } from './swap-peers.component';
-
-describe('SwapPeersComponent', () => {
- let component: SwapPeersComponent;
- let fixture: ComponentFixture;
-
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- declarations: [SwapPeersComponent],
- imports: [
- BrowserAnimationsModule,
- SharedModule
- ],
- providers: []
- }).
- compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(SwapPeersComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-
- afterEach(() => {
- TestBed.resetTestingModule();
- });
-});
diff --git a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.ts b/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.ts
deleted file mode 100755
index 2e96c0ef..00000000
--- a/src/app/shared/components/ln-services/peerswap/swap-peers/swap-peers.component.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Component, OnDestroy } from '@angular/core';
-import { Subject } from 'rxjs';
-
-@Component({
- selector: 'rtl-peerswap-peers',
- templateUrl: './swap-peers.component.html',
- styleUrls: ['./swap-peers.component.scss']
-})
-export class SwapPeersComponent implements OnDestroy {
-
- private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()];
-
- constructor() {}
-
- ngOnDestroy() {
- this.unSubs.forEach((completeSub) => {
- completeSub.next(null);
- completeSub.complete();
- });
- }
-
-}
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.html b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.html
deleted file mode 100755
index 265d51fd..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.html
+++ /dev/null
@@ -1 +0,0 @@
-Peerswaps Cancelled
\ No newline at end of file
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.scss b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.scss
deleted file mode 100755
index e69de29b..00000000
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.spec.ts
deleted file mode 100755
index 486b81f5..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.spec.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
-import { SharedModule } from '../../../../shared.module';
-import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { PeerswapsCancelledComponent } from './swaps-cancelled.component';
-
-describe('PeerswapsCancelledComponent', () => {
- let component: PeerswapsCancelledComponent;
- let fixture: ComponentFixture;
-
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- declarations: [PeerswapsCancelledComponent],
- imports: [
- BrowserAnimationsModule,
- SharedModule
- ],
- providers: []
- }).
- compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(PeerswapsCancelledComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-
- afterEach(() => {
- TestBed.resetTestingModule();
- });
-});
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.ts b/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.ts
deleted file mode 100755
index cac2b256..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Component, OnDestroy } from '@angular/core';
-import { Subject } from 'rxjs';
-
-@Component({
- selector: 'rtl-peerswap-cancelled',
- templateUrl: './swaps-cancelled.component.html',
- styleUrls: ['./swaps-cancelled.component.scss']
-})
-export class PeerswapsCancelledComponent implements OnDestroy {
-
- private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()];
-
- constructor() {}
-
- ngOnDestroy() {
- this.unSubs.forEach((completeSub) => {
- completeSub.next(null);
- completeSub.complete();
- });
- }
-
-}
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.html b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.html
deleted file mode 100755
index b5db1428..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.html
+++ /dev/null
@@ -1 +0,0 @@
-Peerswaps In
\ No newline at end of file
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.scss b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.scss
deleted file mode 100755
index e69de29b..00000000
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.spec.ts
deleted file mode 100755
index c4c9b485..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.spec.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
-import { SharedModule } from '../../../../shared.module';
-import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { PeerswapsInComponent } from './swaps-in.component';
-
-describe('PeerswapsInComponent', () => {
- let component: PeerswapsInComponent;
- let fixture: ComponentFixture;
-
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- declarations: [PeerswapsInComponent],
- imports: [
- BrowserAnimationsModule,
- SharedModule
- ],
- providers: []
- }).
- compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(PeerswapsInComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-
- afterEach(() => {
- TestBed.resetTestingModule();
- });
-});
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.ts b/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.ts
deleted file mode 100755
index 2d1db794..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-in/swaps-in.component.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Component, OnDestroy } from '@angular/core';
-import { Subject } from 'rxjs';
-
-@Component({
- selector: 'rtl-peer-swaps-in',
- templateUrl: './swaps-in.component.html',
- styleUrls: ['./swaps-in.component.scss']
-})
-export class PeerswapsInComponent implements OnDestroy {
-
- private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()];
-
- constructor() {}
-
- ngOnDestroy() {
- this.unSubs.forEach((completeSub) => {
- completeSub.next(null);
- completeSub.complete();
- });
- }
-
-}
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.html b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.html
deleted file mode 100755
index c3ce88f3..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.html
+++ /dev/null
@@ -1 +0,0 @@
-Peerswaps Out
\ No newline at end of file
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.scss b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.scss
deleted file mode 100755
index e69de29b..00000000
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.spec.ts b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.spec.ts
deleted file mode 100755
index f8c54025..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.spec.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
-import { SharedModule } from '../../../../shared.module';
-import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { PeerswapsOutComponent } from './swaps-out.component';
-
-describe('PeerswapsOutComponent', () => {
- let component: PeerswapsOutComponent;
- let fixture: ComponentFixture;
-
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- declarations: [PeerswapsOutComponent],
- imports: [
- BrowserAnimationsModule,
- SharedModule
- ],
- providers: []
- }).
- compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(PeerswapsOutComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-
- afterEach(() => {
- TestBed.resetTestingModule();
- });
-});
diff --git a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.ts b/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.ts
deleted file mode 100755
index 1d71445c..00000000
--- a/src/app/shared/components/ln-services/peerswap/swaps-out/swaps-out.component.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Component, OnDestroy } from '@angular/core';
-import { Subject } from 'rxjs';
-
-@Component({
- selector: 'rtl-peer-swaps-out',
- templateUrl: './swaps-out.component.html',
- styleUrls: ['./swaps-out.component.scss']
-})
-export class PeerswapsOutComponent implements OnDestroy {
-
- private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()];
-
- constructor() {}
-
- ngOnDestroy() {
- this.unSubs.forEach((completeSub) => {
- completeSub.next(null);
- completeSub.complete();
- });
- }
-
-}
diff --git a/src/app/shared/components/node-config/page-settings/page-settings.component.ts b/src/app/shared/components/node-config/page-settings/page-settings.component.ts
index 746040f7..68547f74 100644
--- a/src/app/shared/components/node-config/page-settings/page-settings.component.ts
+++ b/src/app/shared/components/node-config/page-settings/page-settings.component.ts
@@ -1,18 +1,21 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
-import { Subject } from 'rxjs';
-import { filter, takeUntil } from 'rxjs/operators';
+import { combineLatest, Subject } from 'rxjs';
+import { filter, takeUntil, withLatestFrom } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { Actions } from '@ngrx/effects';
import { faPenRuler, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
-import { APICallStatusEnum, CLNActions, CLN_DEFAULT_PAGE_SETTINGS, CLN_TABLES_DEF, PAGE_SIZE_OPTIONS, ScreenSizeEnum, SORT_ORDERS } from '../../../services/consts-enums-functions';
+import { APICallStatusEnum, CLNActions, CLN_DEFAULT_PAGE_SETTINGS, CLN_TABLES_DEF, LNDActions, LND_DEFAULT_PAGE_SETTINGS, LND_TABLES_DEF, PAGE_SIZE_OPTIONS, ScreenSizeEnum, SORT_ORDERS } from '../../../services/consts-enums-functions';
import { LoggerService } from '../../../services/logger.service';
import { CommonService } from '../../../services/common.service';
import { RTLState } from '../../../../store/rtl.state';
-import { TableSetting, PageSettingsCLN } from '../../../models/pageSettings';
-import { clnPageSettings } from '../../../../cln/store/cln.selector';
+import { TableSetting, PageSettings } from '../../../models/pageSettings';
+import { clnNodeSettings, clnPageSettings } from '../../../../cln/store/cln.selector';
import { savePageSettings } from '../../../../cln/store/cln.actions';
import { ApiCallStatusPayload } from '../../../models/apiCallsPayload';
+import { rootSelectedNode } from '../../../../store/rtl.selector';
+import { SelNodeChild, ConfigSettingsNode } from '../../../models/RTLconfig';
+import { lndNodeSettings, lndPageSettings } from '../../../../lnd/store/lnd.selector';
@Component({
selector: 'rtl-page-settings',
@@ -23,12 +26,13 @@ export class PageSettingsComponent implements OnInit, OnDestroy {
public faPenRuler = faPenRuler;
public faExclamationTriangle = faExclamationTriangle;
+ public selNode: ConfigSettingsNode;
public screenSize = '';
public screenSizeEnum = ScreenSizeEnum;
public pageSizeOptions = PAGE_SIZE_OPTIONS;
- public pageSettings: PageSettingsCLN[] = [];
- public initialPageSettings: PageSettingsCLN[] = Object.assign([], CLN_DEFAULT_PAGE_SETTINGS);
- public tableFieldsDef = CLN_TABLES_DEF;
+ public pageSettings: PageSettings[] = [];
+ public initialPageSettings: PageSettings[] = [];
+ public tableFieldsDef = {};
public sortOrders = SORT_ORDERS;
public apiCallStatus: ApiCallStatusPayload | null = null;
public apiCallStatusEnum = APICallStatusEnum;
@@ -40,23 +44,79 @@ export class PageSettingsComponent implements OnInit, OnDestroy {
}
ngOnInit() {
- this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[0])).
- subscribe((settings: { pageSettings: PageSettingsCLN[], apiCallStatus: ApiCallStatusPayload }) => {
- this.errorMessage = null;
- this.apiCallStatus = settings.apiCallStatus;
- if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
- this.errorMessage = this.apiCallStatus.message || null;
- }
- this.pageSettings = settings.pageSettings;
- this.initialPageSettings = settings.pageSettings;
- this.logger.info(settings);
- });
- this.actions.pipe(takeUntil(this.unSubs[1]), filter((action) => action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN || action.type === CLNActions.SAVE_PAGE_SETTINGS_CLN)).
- subscribe((action: any) => {
- if (action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN && action.payload.status === APICallStatusEnum.ERROR && action.payload.action === 'SavePageSettings') {
- this.errorMessage = JSON.parse(action.payload.message);
- }
- });
+ this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[0])).subscribe((selNode) => {
+ this.selNode = selNode;
+ this.logger.info(this.selNode);
+ switch (this.selNode.lnImplementation) {
+ case 'CLN':
+ this.initialPageSettings = Object.assign([], CLN_DEFAULT_PAGE_SETTINGS);
+ this.tableFieldsDef = CLN_TABLES_DEF;
+ this.store.select(clnPageSettings).pipe(takeUntil(this.unSubs[1]),
+ withLatestFrom(this.store.select(clnNodeSettings))).
+ subscribe(([settings, nodeSettings]: [{ pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }, (SelNodeChild | null)]) => {
+ const updatedPageSettings = JSON.parse(JSON.stringify(settings.pageSettings));
+ this.errorMessage = null;
+ this.apiCallStatus = settings.apiCallStatus;
+ if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
+ this.errorMessage = this.apiCallStatus.message || null;
+ this.pageSettings = updatedPageSettings;
+ this.initialPageSettings = updatedPageSettings;
+ } else {
+ if (!nodeSettings?.enableOffers) {
+ const transactionsPage = updatedPageSettings.find((pg) => pg.pageId === 'transactions');
+ transactionsPage?.tables.splice(transactionsPage?.tables.findIndex((tb) => tb.tableId === 'offers'), 1);
+ transactionsPage?.tables.splice(transactionsPage?.tables.findIndex((tb) => tb.tableId === 'offer_bookmarks'), 1);
+ }
+ if (!nodeSettings?.enablePeerswap) {
+ updatedPageSettings.splice(updatedPageSettings.findIndex((pg) => pg.pageId === 'peerswap'), 1);
+ }
+ this.pageSettings = updatedPageSettings;
+ this.initialPageSettings = updatedPageSettings;
+ }
+ this.logger.info(updatedPageSettings);
+ });
+ this.actions.pipe(takeUntil(this.unSubs[2]), filter((action) => action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN || action.type === CLNActions.SAVE_PAGE_SETTINGS_CLN)).
+ subscribe((action: any) => {
+ if (action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN && action.payload.status === APICallStatusEnum.ERROR && action.payload.action === 'SavePageSettings') {
+ this.errorMessage = JSON.parse(action.payload.message);
+ }
+ });
+ break;
+
+ default:
+ this.initialPageSettings = Object.assign([], LND_DEFAULT_PAGE_SETTINGS);
+ this.tableFieldsDef = LND_TABLES_DEF;
+ this.store.select(lndPageSettings).pipe(takeUntil(this.unSubs[1]),
+ withLatestFrom(this.store.select(lndNodeSettings))).
+ subscribe(([settings, nodeSettings]: [{ pageSettings: PageSettings[], apiCallStatus: ApiCallStatusPayload }, (SelNodeChild | null)]) => {
+ const updatedPageSettings: PageSettings[] = JSON.parse(JSON.stringify(settings.pageSettings));
+ this.errorMessage = null;
+ this.apiCallStatus = settings.apiCallStatus;
+ if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
+ this.errorMessage = this.apiCallStatus.message || null;
+ this.pageSettings = updatedPageSettings;
+ this.initialPageSettings = updatedPageSettings;
+ } else {
+ if (!nodeSettings?.swapServerUrl || nodeSettings.swapServerUrl.trim() === '') {
+ updatedPageSettings.splice(updatedPageSettings.findIndex((pg) => pg.pageId === 'loop'), 1);
+ }
+ if (!nodeSettings?.boltzServerUrl || nodeSettings.boltzServerUrl.trim() === '') {
+ updatedPageSettings.splice(updatedPageSettings.findIndex((pg) => pg.pageId === 'boltz'), 1);
+ }
+ this.pageSettings = updatedPageSettings;
+ this.initialPageSettings = updatedPageSettings;
+ }
+ this.logger.info(updatedPageSettings);
+ });
+ this.actions.pipe(takeUntil(this.unSubs[2]), filter((action) => action.type === LNDActions.UPDATE_API_CALL_STATUS_LND || action.type === LNDActions.SAVE_PAGE_SETTINGS_LND)).
+ subscribe((action: any) => {
+ if (action.type === LNDActions.UPDATE_API_CALL_STATUS_LND && action.payload.status === APICallStatusEnum.ERROR && action.payload.action === 'SavePageSettings') {
+ this.errorMessage = JSON.parse(action.payload.message);
+ }
+ });
+ break;
+ }
+ });
}
oncolumnSelectionChange(table: TableSetting) {
diff --git a/src/app/shared/models/apiCallsPayload.ts b/src/app/shared/models/apiCallsPayload.ts
index 85a41b3d..6911488f 100644
--- a/src/app/shared/models/apiCallsPayload.ts
+++ b/src/app/shared/models/apiCallsPayload.ts
@@ -30,6 +30,7 @@ export interface ApiCallsListLND {
FetchAllChannels: ApiCallStatusPayload;
FetchBalanceBlockchain: ApiCallStatusPayload;
// Non-initial calls
+ FetchPageSettings: ApiCallStatusPayload;
FetchPeers: ApiCallStatusPayload;
FetchClosedChannels: ApiCallStatusPayload;
FetchInvoices: ApiCallStatusPayload;
diff --git a/src/app/shared/models/pageSettings.ts b/src/app/shared/models/pageSettings.ts
index 09542054..f996c7dd 100644
--- a/src/app/shared/models/pageSettings.ts
+++ b/src/app/shared/models/pageSettings.ts
@@ -11,7 +11,7 @@ export class TableSetting {
}
-export class PageSettingsCLN {
+export class PageSettings {
pageId: string;
tables: TableSetting[];
diff --git a/src/app/shared/services/consts-enums-functions.ts b/src/app/shared/services/consts-enums-functions.ts
index 59ebbd98..25559ec9 100644
--- a/src/app/shared/services/consts-enums-functions.ts
+++ b/src/app/shared/services/consts-enums-functions.ts
@@ -1,5 +1,5 @@
import { MatPaginatorIntl } from '@angular/material/paginator';
-import { PageSettingsCLN } from '../models/pageSettings';
+import { PageSettings } from '../models/pageSettings';
export function getPaginatorLabel(field: string) {
const appPaginator = new MatPaginatorIntl();
@@ -384,6 +384,9 @@ export enum LNDActions {
RESET_LND_STORE = 'RESET_LND_STORE',
UPDATE_API_CALL_STATUS_LND = 'UPDATE_API_CALL_STATUS_LND',
SET_CHILD_NODE_SETTINGS_LND = 'SET_CHILD_NODE_SETTINGS_LND',
+ FETCH_PAGE_SETTINGS_LND = 'FETCH_PAGE_SETTINGS_LND',
+ SET_PAGE_SETTINGS_LND = 'SET_PAGE_SETTINGS_LND',
+ SAVE_PAGE_SETTINGS_LND = 'SAVE_PAGE_SETTINGS_LND',
FETCH_INFO_LND = 'FETCH_INFO_LND',
SET_INFO_LND = 'SET_INFO_LND',
FETCH_PEERS_LND = 'FETCH_PEERS_LND',
@@ -674,7 +677,7 @@ export enum SortOrderEnum {
export const SORT_ORDERS = ['asc', 'desc'];
-export const CLN_DEFAULT_PAGE_SETTINGS: PageSettingsCLN[] = [
+export const CLN_DEFAULT_PAGE_SETTINGS: PageSettings[] = [
{ pageId: 'on_chain', tables: [
{ tableId: 'utxos', recordsPerPage: PAGE_SIZE, sortBy: 'blockheight', sortOrder: SortOrderEnum.DESCENDING,
columnSelectionSM: ['txid', 'value'],
@@ -815,3 +818,38 @@ export const CLN_TABLES_DEF = {
}
}
};
+
+export const LND_DEFAULT_PAGE_SETTINGS: PageSettings[] = [
+ { pageId: 'loop', tables: [
+ { tableId: 'loop', recordsPerPage: PAGE_SIZE, sortBy: 'initiation_time', sortOrder: SortOrderEnum.DESCENDING,
+ columnSelectionSM: ['state', 'amt'],
+ columnSelection: ['state', 'initiation_time', 'amt', 'cost_server', 'cost_offchain', 'cost_onchain'] }
+ ] },
+ { pageId: 'boltz', tables: [
+ { tableId: 'swap_in', recordsPerPage: PAGE_SIZE, sortBy: 'status', sortOrder: SortOrderEnum.DESCENDING,
+ columnSelectionSM: ['status', 'id', 'expectedAmount'],
+ columnSelection: ['status', 'id', 'lockupAddress', 'expectedAmount', 'timeoutBlockHeight'] },
+ { tableId: 'swap_out', recordsPerPage: PAGE_SIZE, sortBy: 'status', sortOrder: SortOrderEnum.DESCENDING,
+ columnSelectionSM: ['status', 'id', 'onchainAmount'],
+ columnSelection: ['status', 'id', 'claimAddress', 'onchainAmount', 'timeoutBlockHeight'] }
+ ] }
+];
+
+export const LND_TABLES_DEF = {
+ loop: {
+ loop: {
+ maxColumns: 8,
+ allowedColumns: ['state', 'initiation_time', 'last_update_time', 'amt', 'cost_server', 'cost_offchain', 'cost_onchain', 'htlc_address', 'id', 'id_bytes']
+ }
+ },
+ boltz: {
+ swap_in: {
+ maxColumns: 7,
+ allowedColumns: ['status', 'id', 'lockupAddress', 'expectedAmount', 'privateKey', 'preimage', 'redeemScript', 'invoice', 'timeoutBlockHeight', 'lockupTransactionId', 'refundTransactionId']
+ },
+ swap_out: {
+ maxColumns: 7,
+ allowedColumns: ['status', 'id', 'claimAddress', 'onchainAmount', 'privateKey', 'preimage', 'redeemScript', 'invoice', 'timeoutBlockHeight', 'lockupTransactionId', 'claimTransactionId']
+ }
+ }
+};
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index d74b87f6..7ff1960d 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -97,11 +97,6 @@ import { SwapServiceInfoComponent } from './components/ln-services/boltz/swap-se
import { SwapModalComponent } from './components/ln-services/boltz/swap-modal/swap-modal.component';
import { SwapInInfoGraphicsComponent } from './components/ln-services/boltz/swap-in-info-graphics/info-graphics.component';
import { SwapOutInfoGraphicsComponent } from './components/ln-services/boltz/swap-out-info-graphics/info-graphics.component';
-import { PeerswapComponent } from './components/ln-services/peerswap/peerswap.component';
-import { SwapPeersComponent } from './components/ln-services/peerswap/swap-peers/swap-peers.component';
-import { PeerswapsCancelledComponent } from './components/ln-services/peerswap/swaps-cancelled/swaps-cancelled.component';
-import { PeerswapsInComponent } from './components/ln-services/peerswap/swaps-in/swaps-in.component';
-import { PeerswapsOutComponent } from './components/ln-services/peerswap/swaps-out/swaps-out.component';
import { ClipboardDirective } from './directive/clipboard.directive';
import { AutoFocusDirective } from './directive/auto-focus.directive';
@@ -273,12 +268,7 @@ export const DEFAULT_DATE_FORMAT: MatDateFormats = {
SwapServiceInfoComponent,
SwapModalComponent,
SwapInInfoGraphicsComponent,
- SwapOutInfoGraphicsComponent,
- PeerswapComponent,
- SwapPeersComponent,
- PeerswapsCancelledComponent,
- PeerswapsInComponent,
- PeerswapsOutComponent
+ SwapOutInfoGraphicsComponent
],
declarations: [
AppSettingsComponent,
@@ -339,12 +329,7 @@ export const DEFAULT_DATE_FORMAT: MatDateFormats = {
SwapServiceInfoComponent,
SwapModalComponent,
SwapInInfoGraphicsComponent,
- SwapOutInfoGraphicsComponent,
- PeerswapComponent,
- SwapPeersComponent,
- PeerswapsCancelledComponent,
- PeerswapsInComponent,
- PeerswapsOutComponent
+ SwapOutInfoGraphicsComponent
],
providers: [
{ provide: LoggerService, useClass: ConsoleLoggerService },