mirror of
https://github.com/mempool/mempool.git
synced 2025-02-20 13:34:40 +01:00
Merge pull request #2326 from mempool/nymkappa/feature/hide-map-if-no-geoloc
Hide map if there is not geolocation data available
This commit is contained in:
commit
330ba7cb71
2 changed files with 18 additions and 25 deletions
|
@ -1,14 +1,16 @@
|
|||
<div [class]="'full-container ' + style + (fitContainer ? ' fit-container' : '')">
|
||||
|
||||
<div *ngIf="style === 'graph'" class="card-header">
|
||||
<div class="d-flex d-md-block align-items-baseline" style="margin-bottom: -5px">
|
||||
<span i18n="lightning.nodes-channels-world-map">Lightning nodes channels world map</span>
|
||||
<div *ngIf="channelsObservable | async">
|
||||
<div *ngIf="chartOptions" [class]="'full-container ' + style + (fitContainer ? ' fit-container' : '')">
|
||||
<div *ngIf="style === 'graph'" class="card-header">
|
||||
<div class="d-flex d-md-block align-items-baseline" style="margin-bottom: -5px">
|
||||
<span i18n="lightning.nodes-channels-world-map">Lightning nodes channels world map</span>
|
||||
</div>
|
||||
<small style="color: #ffffff66" i18n="lightning.tor-nodes-excluded">(Tor nodes excluded)</small>
|
||||
</div>
|
||||
|
||||
<div class="chart" echarts [initOpts]="chartInitOptions" [options]="chartOptions" (chartInit)="onChartInit($event)"
|
||||
(chartFinished)="onChartFinished($event)">
|
||||
</div>
|
||||
<small style="color: #ffffff66" i18n="lightning.tor-nodes-excluded">(Tor nodes excluded)</small>
|
||||
</div>
|
||||
|
||||
<div *ngIf="observable$ | async" class="chart" echarts [initOpts]="chartInitOptions" [options]="chartOptions"
|
||||
(chartInit)="onChartInit($event)" (chartFinished)="onChartFinished($event)">
|
||||
</div>
|
||||
|
||||
<div *ngIf="!chartOptions && style === 'nodepage'" style="padding-top: 30px"></div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ChangeDetectionStrategy, Component, HostListener, Input, Output, EventEmitter, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Input, Output, EventEmitter, NgZone, OnInit } from '@angular/core';
|
||||
import { SeoService } from 'src/app/services/seo.service';
|
||||
import { ApiService } from 'src/app/services/api.service';
|
||||
import { Observable, switchMap, tap, zip } from 'rxjs';
|
||||
|
@ -16,14 +16,14 @@ import { isMobile } from 'src/app/shared/common.utils';
|
|||
styleUrls: ['./nodes-channels-map.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class NodesChannelsMap implements OnInit, OnDestroy {
|
||||
export class NodesChannelsMap implements OnInit {
|
||||
@Input() style: 'graph' | 'nodepage' | 'widget' | 'channelpage' = 'graph';
|
||||
@Input() publicKey: string | undefined;
|
||||
@Input() channel: any[] = [];
|
||||
@Input() fitContainer = false;
|
||||
@Output() readyEvent = new EventEmitter();
|
||||
|
||||
observable$: Observable<any>;
|
||||
channelsObservable: Observable<any>;
|
||||
|
||||
center: number[] | undefined;
|
||||
zoom: number | undefined;
|
||||
|
@ -50,8 +50,6 @@ export class NodesChannelsMap implements OnInit, OnDestroy {
|
|||
) {
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.center = this.style === 'widget' ? [0, 40] : [0, 5];
|
||||
this.zoom = 1.3;
|
||||
|
@ -71,7 +69,7 @@ export class NodesChannelsMap implements OnInit, OnDestroy {
|
|||
this.nodeSize = 8;
|
||||
}
|
||||
|
||||
this.observable$ = this.activatedRoute.paramMap
|
||||
this.channelsObservable = this.activatedRoute.paramMap
|
||||
.pipe(
|
||||
switchMap((params: ParamMap) => {
|
||||
return zip(
|
||||
|
@ -175,15 +173,8 @@ export class NodesChannelsMap implements OnInit, OnDestroy {
|
|||
prepareChartOptions(nodes, channels) {
|
||||
let title: object;
|
||||
if (channels.length === 0) {
|
||||
title = {
|
||||
textStyle: {
|
||||
color: 'grey',
|
||||
fontSize: 15
|
||||
},
|
||||
text: $localize`No geolocation data available`,
|
||||
left: 'center',
|
||||
top: 'center'
|
||||
};
|
||||
this.chartOptions = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.chartOptions = {
|
||||
|
|
Loading…
Add table
Reference in a new issue