mirror of
https://github.com/mempool/mempool.git
synced 2025-03-01 01:00:00 +01:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
|
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';
|
||
|
|
||
|
@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,
|
||
|
private route: ActivatedRoute,
|
||
|
) { }
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
this.country = this.route.snapshot.params.country;
|
||
|
this.country = this.country.charAt(0).toUpperCase() + this.country.slice(1);
|
||
|
|
||
|
this.nodes$ = this.apiService.getNodeForCountry$(this.route.snapshot.params.country)
|
||
|
.pipe(
|
||
|
map(nodes => {
|
||
|
console.log(nodes);
|
||
|
return nodes;
|
||
|
})
|
||
|
);
|
||
|
}
|
||
|
|
||
|
trackByPublicKey(index: number, node: any) {
|
||
|
return node.public_key;
|
||
|
}
|
||
|
}
|