diff --git a/frontend/src/app/components/pool/pool.component.html b/frontend/src/app/components/pool/pool.component.html index ca350437c..d25e7d810 100644 --- a/frontend/src/app/components/pool/pool.component.html +++ b/frontend/src/app/components/pool/pool.component.html @@ -3,8 +3,8 @@
-

{{ poolStats.pool.name }}

+ onError="this.src = './resources/mining-pools/default.svg'" class="mr-3 mb-3"> +

{{ poolStats.pool.name }}

@@ -59,15 +59,15 @@
- - + diff --git a/frontend/src/app/components/pool/pool.component.ts b/frontend/src/app/components/pool/pool.component.ts index 95df5709b..529298f65 100644 --- a/frontend/src/app/components/pool/pool.component.ts +++ b/frontend/src/app/components/pool/pool.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } import { ActivatedRoute } from '@angular/router'; import { EChartsOption, graphic } from 'echarts'; import { BehaviorSubject, Observable } from 'rxjs'; -import { distinctUntilChanged, map, switchMap, tap, toArray } from 'rxjs/operators'; +import { map, switchMap, tap } from 'rxjs/operators'; import { BlockExtended, PoolStat } from 'src/app/interfaces/node-api.interface'; import { ApiService } from 'src/app/services/api.service'; import { StateService } from 'src/app/services/state.service'; @@ -40,8 +40,7 @@ export class PoolComponent implements OnInit { height: 'auto', }; - fromHeight: number = -1; - fromHeightSubject: BehaviorSubject = new BehaviorSubject(this.fromHeight); + loadMoreSubject: BehaviorSubject = new BehaviorSubject(undefined); blocks: BlockExtended[] = []; poolId: number = undefined; @@ -67,12 +66,9 @@ export class PoolComponent implements OnInit { this.prepareChartOptions(data.hashrates.map(val => [val.timestamp * 1000, val.avgHashrate])); return poolId; }), - ) + ); }), switchMap(() => { - if (this.blocks.length === 0) { - this.fromHeightSubject.next(undefined); - } return this.apiService.getPoolStats$(this.poolId); }), map((poolStats) => { @@ -89,17 +85,16 @@ export class PoolComponent implements OnInit { }) ); - this.blocks$ = this.fromHeightSubject + this.blocks$ = this.loadMoreSubject .pipe( - distinctUntilChanged(), - switchMap((fromHeight) => { - return this.apiService.getPoolBlocks$(this.poolId, fromHeight); + switchMap((flag) => { + return this.apiService.getPoolBlocks$(this.poolId, this.blocks[this.blocks.length - 1]?.height); }), tap((newBlocks) => { this.blocks = this.blocks.concat(newBlocks); }), map(() => this.blocks) - ) + ); } prepareChartOptions(data) { @@ -134,18 +129,18 @@ export class PoolComponent implements OnInit { align: 'left', }, borderColor: '#000', - formatter: function(data) { + formatter: function(ticks: any[]) { let hashratePowerOfTen: any = selectPowerOfTen(1); - let hashrate = data[0].data[1]; + let hashrate = ticks[0].data[1]; if (this.isMobile()) { - hashratePowerOfTen = selectPowerOfTen(data[0].data[1]); - hashrate = Math.round(data[0].data[1] / hashratePowerOfTen.divider); + hashratePowerOfTen = selectPowerOfTen(ticks[0].data[1]); + hashrate = Math.round(ticks[0].data[1] / hashratePowerOfTen.divider); } return ` - ${data[0].axisValueLabel}
- ${data[0].marker} ${data[0].seriesName}: ${formatNumber(hashrate, this.locale, '1.0-0')} ${hashratePowerOfTen.unit}H/s
+ ${ticks[0].axisValueLabel}
+ ${ticks[0].marker} ${ticks[0].seriesName}: ${formatNumber(hashrate, this.locale, '1.0-0')} ${hashratePowerOfTen.unit}H/s
`; }.bind(this) }, @@ -192,7 +187,7 @@ export class PoolComponent implements OnInit { } loadMore() { - this.fromHeightSubject.next(this.blocks[this.blocks.length - 1]?.height); + this.loadMoreSubject.next(undefined); } trackByBlock(index: number, block: BlockExtended) {
Height Timestamp Mined - Coinbase + ScriptSig Reward Fees