diff --git a/backend/src/api/explorer/nodes.api.ts b/backend/src/api/explorer/nodes.api.ts index 3791b4c9d..ec8ee35fb 100644 --- a/backend/src/api/explorer/nodes.api.ts +++ b/backend/src/api/explorer/nodes.api.ts @@ -9,7 +9,10 @@ class NodesApi { geo_names_country.names as country, geo_names_subdivision.names as subdivision, (SELECT Count(*) FROM channels - WHERE channels.status < 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS channel_count, + WHERE channels.status = 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS channel_closed_count, + (SELECT Count(*) + FROM channels + WHERE channels.status < 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS channel_active_count, (SELECT Sum(capacity) FROM channels WHERE channels.status < 2 AND ( channels.node1_public_key = ? OR channels.node2_public_key = ? )) AS capacity, @@ -23,7 +26,7 @@ class NodesApi { LEFT JOIN geo_names geo_names_country on geo_names_country.id = country_id WHERE public_key = ? `; - const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key, public_key, public_key]); + const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key, public_key, public_key, public_key, public_key]); if (rows.length > 0) { rows[0].as_organization = JSON.parse(rows[0].as_organization); rows[0].subdivision = JSON.parse(rows[0].subdivision); diff --git a/frontend/src/app/lightning/channels-list/channels-list.component.html b/frontend/src/app/lightning/channels-list/channels-list.component.html index ff67788e1..82283f689 100644 --- a/frontend/src/app/lightning/channels-list/channels-list.component.html +++ b/frontend/src/app/lightning/channels-list/channels-list.component.html @@ -10,7 +10,7 @@ - +
@@ -19,7 +19,11 @@
- + + + +
No channels to display
+
diff --git a/frontend/src/app/lightning/channels-list/channels-list.component.ts b/frontend/src/app/lightning/channels-list/channels-list.component.ts index 0ac7da578..4060d36da 100644 --- a/frontend/src/app/lightning/channels-list/channels-list.component.ts +++ b/frontend/src/app/lightning/channels-list/channels-list.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { BehaviorSubject, combineLatest, merge, Observable, of } from 'rxjs'; import { map, startWith, switchMap } from 'rxjs/operators'; @@ -12,6 +12,7 @@ import { LightningApiService } from '../lightning-api.service'; }) export class ChannelsListComponent implements OnInit, OnChanges { @Input() publicKey: string; + @Output() channelsStatusChangedEvent = new EventEmitter(); channels$: Observable; // @ts-ignore @@ -41,13 +42,17 @@ export class ChannelsListComponent implements OnInit, OnChanges { ngOnChanges(): void { this.channelStatusForm.get('status').setValue(this.defaultStatus, { emitEvent: false }) + this.channelsStatusChangedEvent.emit(this.defaultStatus); this.channels$ = combineLatest([ this.channelsPage$, this.channelStatusForm.get('status').valueChanges.pipe(startWith(this.defaultStatus)) ]) .pipe( - switchMap(([page, status]) =>this.lightningApiService.getChannelsByNodeId$(this.publicKey, (page -1) * this.itemsPerPage, status)), + switchMap(([page, status]) => { + this.channelsStatusChangedEvent.emit(status); + return this.lightningApiService.getChannelsByNodeId$(this.publicKey, (page -1) * this.itemsPerPage, status); + }), map((response) => { return { channels: response.body, diff --git a/frontend/src/app/lightning/node/node.component.html b/frontend/src/app/lightning/node/node.component.html index 68f5b31e0..e2132bca5 100644 --- a/frontend/src/app/lightning/node/node.component.html +++ b/frontend/src/app/lightning/node/node.component.html @@ -1,127 +1,146 @@
-
+
-
+
+ No node found for public key "{{ node.public_key | shortenString : 12}}" + Back to the lightning dashboard +
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
Total capacity - -
Total channels - {{ node.channel_count }} -
Average channel size - -
Location{{ node.city.en }}, {{ node.subdivision.en }}
{{ node.country.en }}
Location{{ node.country.en }}
-
-
-
- - - - - - - - - - - - - - - - - - - -
First seen - -
Last update - -
Color
{{ node.color }}
ISP - {{ node.as_organization }} [ASN {{node.as_number}}] -
-
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Total capacity + + +
Total channels + {{ node.channel_active_count }} +
Average channel size + + +
Location{{ node.city.en }}, {{ node.subdivision.en }}
{{ node.country.en }}
Location{{ node.country.en }}
+
+
+
+ + + + + + + + + + + + + + + + + + + +
First seen + +
Last update + +
Color +
{{ node.color }}
+
ISP + {{ node.as_organization }} [ASN {{node.as_number}}] +
-
-
+
-
-
- -
- -
+
+ +
+
+ +
+
- - {{ node.socketsObject[selectedSocketIndex].label }} - - - -
+ + {{ node.socketsObject[selectedSocketIndex].label }} + + + + +
-
+
- + + +
+ +
+

Channels ({{ channelsListStatus === 'open' ? node.channel_active_count : node.channel_closed_count }})

+
+ List  + +  Map +
+
+ + + + -
- -
-

Channels ({{ node.channel_count }})

-
- List  - -  Map -
-
- - - -
-
+
\ No newline at end of file diff --git a/frontend/src/app/lightning/node/node.component.ts b/frontend/src/app/lightning/node/node.component.ts index a286aa987..c70983b54 100644 --- a/frontend/src/app/lightning/node/node.component.ts +++ b/frontend/src/app/lightning/node/node.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { ActivatedRoute, ParamMap } from '@angular/router'; import { Observable } from 'rxjs'; -import { map, switchMap } from 'rxjs/operators'; +import { catchError, map, switchMap } from 'rxjs/operators'; import { SeoService } from 'src/app/services/seo.service'; import { LightningApiService } from '../lightning-api.service'; @@ -18,6 +18,9 @@ export class NodeComponent implements OnInit { selectedSocketIndex = 0; qrCodeVisible = false; channelsListMode = 'list'; + channelsListStatus: string; + error: Error; + publicKey: string; constructor( private lightningApiService: LightningApiService, @@ -29,6 +32,7 @@ export class NodeComponent implements OnInit { this.node$ = this.activatedRoute.paramMap .pipe( switchMap((params: ParamMap) => { + this.publicKey = params.get('public_key'); return this.lightningApiService.getNode$(params.get('public_key')); }), map((node) => { @@ -55,6 +59,13 @@ export class NodeComponent implements OnInit { node.socketsObject = socketsObject; return node; }), + catchError(err => { + this.error = err; + return [{ + alias: this.publicKey, + public_key: this.publicKey, + }]; + }) ); } @@ -69,4 +80,8 @@ export class NodeComponent implements OnInit { this.channelsListMode = 'list'; } } + + onChannelsListStatusChanged(e) { + this.channelsListStatus = e; + } }