Socket selector and copy
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, ParamMap } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { LightningApiService } from '../lightning-api.service';
|
||||
|
||||
@Component({
|
||||
@@ -14,6 +14,7 @@ export class NodeComponent implements OnInit {
|
||||
node$: Observable<any>;
|
||||
statistics$: Observable<any>;
|
||||
publicKey$: Observable<string>;
|
||||
selectedSocketIndex = 0;
|
||||
|
||||
constructor(
|
||||
private lightningApiService: LightningApiService,
|
||||
@@ -25,7 +26,27 @@ export class NodeComponent implements OnInit {
|
||||
.pipe(
|
||||
switchMap((params: ParamMap) => {
|
||||
return this.lightningApiService.getNode$(params.get('public_key'));
|
||||
})
|
||||
}),
|
||||
map((node) => {
|
||||
const socketsObject = [];
|
||||
for (const socket of node.sockets.split(',')) {
|
||||
let label = '';
|
||||
if (socket.match(/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/)) {
|
||||
label = 'IPv4';
|
||||
} else if (socket.indexOf('[') > -1) {
|
||||
label = 'IPv6';
|
||||
} else if (socket.indexOf('onion') > -1) {
|
||||
label = 'Tor';
|
||||
}
|
||||
socketsObject.push({
|
||||
label: label,
|
||||
socket: node.public_key + '@' + socket,
|
||||
});
|
||||
}
|
||||
console.log(socketsObject);
|
||||
node.socketsObject = socketsObject;
|
||||
return node;
|
||||
}),
|
||||
);
|
||||
|
||||
this.statistics$ = this.activatedRoute.paramMap
|
||||
@@ -36,4 +57,8 @@ export class NodeComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
changeSocket(index: number) {
|
||||
this.selectedSocketIndex = index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user