2022-04-27 02:52:23 +04:00
|
|
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { map, share } from 'rxjs/operators';
|
2022-07-10 14:07:53 +02:00
|
|
|
import { SeoService } from 'src/app/services/seo.service';
|
2022-04-27 02:52:23 +04:00
|
|
|
import { LightningApiService } from '../lightning-api.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-lightning-dashboard',
|
|
|
|
templateUrl: './lightning-dashboard.component.html',
|
|
|
|
styleUrls: ['./lightning-dashboard.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
|
})
|
|
|
|
export class LightningDashboardComponent implements OnInit {
|
|
|
|
nodesByCapacity$: Observable<any>;
|
|
|
|
nodesByChannels$: Observable<any>;
|
|
|
|
statistics$: Observable<any>;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private lightningApiService: LightningApiService,
|
2022-07-10 14:07:53 +02:00
|
|
|
private seoService: SeoService,
|
2022-04-27 02:52:23 +04:00
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
2022-07-10 14:07:53 +02:00
|
|
|
this.seoService.setTitle($localize`Lightning Dashboard`);
|
|
|
|
|
2022-04-27 02:52:23 +04:00
|
|
|
const sharedObservable = this.lightningApiService.listTopNodes$().pipe(share());
|
|
|
|
|
|
|
|
this.nodesByCapacity$ = sharedObservable
|
|
|
|
.pipe(
|
|
|
|
map((object) => object.topByCapacity),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.nodesByChannels$ = sharedObservable
|
|
|
|
.pipe(
|
|
|
|
map((object) => object.topByChannels),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.statistics$ = this.lightningApiService.getLatestStatistics$();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|