2021-02-27 04:19:56 +07:00
|
|
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
|
|
|
import { Observable, combineLatest } from 'rxjs';
|
|
|
|
import { map } from 'rxjs/operators';
|
|
|
|
import { BisqApiService } from '../bisq-api.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-bisq-dashboard',
|
|
|
|
templateUrl: './bisq-dashboard.component.html',
|
|
|
|
styleUrls: ['./bisq-dashboard.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
|
|
|
export class BisqDashboardComponent implements OnInit {
|
|
|
|
tickers$: Observable<any>;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private bisqApiService: BisqApiService,
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.tickers$ = combineLatest([
|
|
|
|
this.bisqApiService.getMarketsTicker$(),
|
2021-02-28 17:18:29 +07:00
|
|
|
this.bisqApiService.getMarkets$(),
|
|
|
|
this.bisqApiService.getMarket24hVolumes$(),
|
2021-02-27 04:19:56 +07:00
|
|
|
])
|
|
|
|
.pipe(
|
2021-02-28 17:18:29 +07:00
|
|
|
map(([tickers, markets, volumes]) => {
|
2021-02-27 04:19:56 +07:00
|
|
|
const newTickers = [];
|
|
|
|
for (const t in tickers) {
|
|
|
|
tickers[t].pair_url = t;
|
|
|
|
tickers[t].pair = t.replace('_', '/').toUpperCase();
|
|
|
|
tickers[t].market = markets[t];
|
2021-02-28 17:18:29 +07:00
|
|
|
tickers[t].volume = volumes[t];
|
2021-02-27 04:19:56 +07:00
|
|
|
newTickers.push(tickers[t]);
|
|
|
|
}
|
2021-02-28 17:18:29 +07:00
|
|
|
|
|
|
|
newTickers.sort((a, b) => (b.volume && b.volume.volume || 0) - (a.volume && a.volume.volume || 0));
|
|
|
|
|
2021-02-27 04:19:56 +07:00
|
|
|
return newTickers;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
trackByFn(index: number) {
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|