2022-07-16 15:56:36 +02:00
|
|
|
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
|
import { map, Observable } from 'rxjs';
|
|
|
|
import { ApiService } from 'src/app/services/api.service';
|
2022-07-16 23:25:44 +02:00
|
|
|
import { SeoService } from 'src/app/services/seo.service';
|
2022-07-16 15:56:36 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-nodes-per-country',
|
|
|
|
templateUrl: './nodes-per-country.component.html',
|
|
|
|
styleUrls: ['./nodes-per-country.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
|
})
|
|
|
|
export class NodesPerCountry implements OnInit {
|
|
|
|
nodes$: Observable<any>;
|
|
|
|
country: string;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private apiService: ApiService,
|
2022-07-16 23:25:44 +02:00
|
|
|
private seoService: SeoService,
|
2022-07-16 15:56:36 +02:00
|
|
|
private route: ActivatedRoute,
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.nodes$ = this.apiService.getNodeForCountry$(this.route.snapshot.params.country)
|
|
|
|
.pipe(
|
2022-07-16 23:25:44 +02:00
|
|
|
map(response => {
|
|
|
|
this.country = response.country.en
|
|
|
|
this.seoService.setTitle($localize`Lightning nodes in ${this.country}`);
|
|
|
|
return response.nodes;
|
2022-07-16 15:56:36 +02:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
trackByPublicKey(index: number, node: any) {
|
|
|
|
return node.public_key;
|
|
|
|
}
|
|
|
|
}
|