diff --git a/frontend/src/app/lightning/channel/channel-box/channel-box.component.scss b/frontend/src/app/lightning/channel/channel-box/channel-box.component.scss index 300b98b11..e9fde9ffb 100644 --- a/frontend/src/app/lightning/channel/channel-box/channel-box.component.scss +++ b/frontend/src/app/lightning/channel/channel-box/channel-box.component.scss @@ -16,3 +16,9 @@ color: #ffffff66; font-size: 12px; } + +@media (max-width: 768px) { + .box { + margin-bottom: 20px; + } +} \ No newline at end of file diff --git a/frontend/src/app/lightning/channel/channel.component.html b/frontend/src/app/lightning/channel/channel.component.html index ec49c78a0..7fe82aaea 100644 --- a/frontend/src/app/lightning/channel/channel.component.html +++ b/frontend/src/app/lightning/channel/channel.component.html @@ -14,7 +14,7 @@
- +
@@ -30,32 +30,6 @@ Last update - - Opening transaction - - - {{ channel.transaction_id | shortenString : 10 }} - - - - - - - Closing transaction - - - {{ channel.closing_transaction_id | shortenString : 10 }} - - - - - - Closing type - - - - -
@@ -82,8 +56,23 @@
+
- + +
+ + + +

Opening transaction

+ +
+ +
+

Closing transaction

   +
+ +
+
diff --git a/frontend/src/app/lightning/channel/channel.component.scss b/frontend/src/app/lightning/channel/channel.component.scss index a5aff4428..f19215f87 100644 --- a/frontend/src/app/lightning/channel/channel.component.scss +++ b/frontend/src/app/lightning/channel/channel.component.scss @@ -39,3 +39,16 @@ app-fiat { margin-left: 10px; } } + +.closing-header { + display: flex; + flex-direction: row; + margin-bottom: 1rem; + align-items: center; +} + +@media (max-width: 768px) { + h3 { + font-size: 1.4rem; + } +} diff --git a/frontend/src/app/lightning/channel/channel.component.ts b/frontend/src/app/lightning/channel/channel.component.ts index 9c3cdd57e..bbf9be36d 100644 --- a/frontend/src/app/lightning/channel/channel.component.ts +++ b/frontend/src/app/lightning/channel/channel.component.ts @@ -1,7 +1,9 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { ActivatedRoute, ParamMap } from '@angular/router'; -import { Observable, of } from 'rxjs'; -import { catchError, switchMap, tap } from 'rxjs/operators'; +import { forkJoin, Observable, of, share, zip } from 'rxjs'; +import { catchError, map, shareReplay, switchMap, tap } from 'rxjs/operators'; +import { ApiService } from 'src/app/services/api.service'; +import { ElectrsApiService } from 'src/app/services/electrs-api.service'; import { SeoService } from 'src/app/services/seo.service'; import { LightningApiService } from '../lightning-api.service'; @@ -13,13 +15,15 @@ import { LightningApiService } from '../lightning-api.service'; }) export class ChannelComponent implements OnInit { channel$: Observable; + channelGeo$: Observable; + transactions$: Observable; error: any = null; - channelGeo: number[] = []; constructor( private lightningApiService: LightningApiService, private activatedRoute: ActivatedRoute, private seoService: SeoService, + private electrsApiService: ElectrsApiService, ) { } ngOnInit(): void { @@ -30,28 +34,41 @@ export class ChannelComponent implements OnInit { this.seoService.setTitle(`Channel: ${params.get('short_id')}`); return this.lightningApiService.getChannel$(params.get('short_id')) .pipe( - tap((data) => { - if (!data.node_left.longitude || !data.node_left.latitude || - !data.node_right.longitude || !data.node_right.latitude) { - this.channelGeo = []; - } else { - this.channelGeo = [ - data.node_left.public_key, - data.node_left.alias, - data.node_left.longitude, data.node_left.latitude, - data.node_right.public_key, - data.node_right.alias, - data.node_right.longitude, data.node_right.latitude, - ]; - } - }), catchError((err) => { this.error = err; return of(null); }) ); - }) + }), + shareReplay(), ); + + this.channelGeo$ = this.channel$.pipe( + map((data) => { + if (!data.node_left.longitude || !data.node_left.latitude || + !data.node_right.longitude || !data.node_right.latitude) { + return []; + } else { + return [ + data.node_left.public_key, + data.node_left.alias, + data.node_left.longitude, data.node_left.latitude, + data.node_right.public_key, + data.node_right.alias, + data.node_right.longitude, data.node_right.latitude, + ]; + } + }), + ); + + this.transactions$ = this.channel$.pipe( + switchMap((data) => { + return zip([ + data.transaction_id ? this.electrsApiService.getTransaction$(data.transaction_id) : of(null), + data.closing_transaction_id ? this.electrsApiService.getTransaction$(data.closing_transaction_id) : of(null), + ]); + }), + ); } }