2022-05-01 03:01:27 +04:00
|
|
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
2022-04-29 03:57:27 +04:00
|
|
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
|
|
|
import { Observable } from 'rxjs';
|
2022-05-06 00:20:14 +04:00
|
|
|
import { map, switchMap } from 'rxjs/operators';
|
2022-05-15 19:22:14 +04:00
|
|
|
import { SeoService } from 'src/app/services/seo.service';
|
2022-04-29 03:57:27 +04:00
|
|
|
import { LightningApiService } from '../lightning-api.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-node',
|
|
|
|
templateUrl: './node.component.html',
|
2022-05-01 03:01:27 +04:00
|
|
|
styleUrls: ['./node.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
2022-04-29 03:57:27 +04:00
|
|
|
})
|
|
|
|
export class NodeComponent implements OnInit {
|
|
|
|
node$: Observable<any>;
|
2022-05-05 23:19:24 +04:00
|
|
|
statistics$: Observable<any>;
|
2022-05-01 03:01:27 +04:00
|
|
|
publicKey$: Observable<string>;
|
2022-05-06 00:20:14 +04:00
|
|
|
selectedSocketIndex = 0;
|
2022-05-06 00:52:25 +04:00
|
|
|
qrCodeVisible = false;
|
2022-07-23 15:43:38 +02:00
|
|
|
channelsListMode = 'list';
|
2022-07-24 11:51:05 +02:00
|
|
|
channelsListStatus: string;
|
2022-04-29 03:57:27 +04:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private lightningApiService: LightningApiService,
|
|
|
|
private activatedRoute: ActivatedRoute,
|
2022-05-15 19:22:14 +04:00
|
|
|
private seoService: SeoService,
|
2022-04-29 03:57:27 +04:00
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.node$ = this.activatedRoute.paramMap
|
|
|
|
.pipe(
|
|
|
|
switchMap((params: ParamMap) => {
|
2022-05-01 03:01:27 +04:00
|
|
|
return this.lightningApiService.getNode$(params.get('public_key'));
|
2022-05-06 00:20:14 +04:00
|
|
|
}),
|
|
|
|
map((node) => {
|
2022-05-15 19:22:14 +04:00
|
|
|
this.seoService.setTitle(`Node: ${node.alias}`);
|
|
|
|
|
2022-05-06 00:20:14 +04:00
|
|
|
const socketsObject = [];
|
|
|
|
for (const socket of node.sockets.split(',')) {
|
2022-05-06 00:52:25 +04:00
|
|
|
if (socket === '') {
|
|
|
|
continue;
|
|
|
|
}
|
2022-05-06 00:20:14 +04:00
|
|
|
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,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
node.socketsObject = socketsObject;
|
|
|
|
return node;
|
|
|
|
}),
|
2022-04-29 03:57:27 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-05-06 00:20:14 +04:00
|
|
|
changeSocket(index: number) {
|
|
|
|
this.selectedSocketIndex = index;
|
|
|
|
}
|
|
|
|
|
2022-07-23 15:43:38 +02:00
|
|
|
channelsListModeChange(e) {
|
|
|
|
if (e.target.checked === true) {
|
|
|
|
this.channelsListMode = 'map';
|
|
|
|
} else {
|
|
|
|
this.channelsListMode = 'list';
|
|
|
|
}
|
|
|
|
}
|
2022-07-24 11:51:05 +02:00
|
|
|
|
|
|
|
onChannelsListStatusChanged(e) {
|
|
|
|
this.channelsListStatus = e;
|
|
|
|
}
|
2022-04-29 03:57:27 +04:00
|
|
|
}
|