Merge branch 'master' into nymkappa/bugfix/hashrate-native-js-timestamp

This commit is contained in:
wiz 2022-03-23 00:09:55 +00:00 committed by GitHub
commit 7ace0cfbc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 25 deletions

View File

@ -30,7 +30,7 @@
onError="this.src = './resources/mining-pools/default.svg'"> onError="this.src = './resources/mining-pools/default.svg'">
<span class="pool-name">{{ block.extras.pool.name }}</span> <span class="pool-name">{{ block.extras.pool.name }}</span>
</a> </a>
<span class="tooltiptext badge badge-secondary scriptmessage">{{ block.extras.coinbaseRaw | hex2ascii }}</span> <span *ngIf="!widget" class="tooltiptext badge badge-secondary scriptmessage">{{ block.extras.coinbaseRaw | hex2ascii }}</span>
</div> </div>
</td> </td>
<td class="timestamp" *ngIf="!widget"> <td class="timestamp" *ngIf="!widget">

View File

@ -3,6 +3,7 @@ import { EChartsOption } from 'echarts';
import { OnChanges } from '@angular/core'; import { OnChanges } from '@angular/core';
import { StorageService } from 'src/app/services/storage.service'; import { StorageService } from 'src/app/services/storage.service';
import { formatterXAxis, formatterXAxisLabel } from 'src/app/shared/graphs.utils'; import { formatterXAxis, formatterXAxisLabel } from 'src/app/shared/graphs.utils';
import { formatNumber } from '@angular/common';
@Component({ @Component({
selector: 'app-incoming-transactions-graph', selector: 'app-incoming-transactions-graph',
@ -116,7 +117,7 @@ export class IncomingTransactionsGraphComponent implements OnInit, OnChanges {
itemFormatted += `<div class="item"> itemFormatted += `<div class="item">
<div class="indicator-container">${colorSpan(item.color)}</div> <div class="indicator-container">${colorSpan(item.color)}</div>
<div class="grow"></div> <div class="grow"></div>
<div class="value">${item.value[1]} <span class="symbol">vB/s</span></div> <div class="value">${formatNumber(item.value[1], this.locale, '1.0-0')}<span class="symbol">vB/s</span></div>
</div>`; </div>`;
} }
}); });

View File

@ -1,9 +1,9 @@
<div class="container-xl"> <div class="container-xl">
<div *ngIf="poolStats$ | async as poolStats; else loadingMain"> <div *ngIf="poolStats$ | async as poolStats; else loadingMain">
<div style="display:flex"> <div style="display:flex" class="mb-3">
<img width="50" height="50" src="{{ poolStats['logo'] }}" <img width="50" height="50" src="{{ poolStats['logo'] }}"
onError="this.src = './resources/mining-pools/default.svg'" class="mr-3 mb-3"> onError="this.src = './resources/mining-pools/default.svg'" class="mr-3">
<h1 class="m-0 pt-1 pt-md-0">{{ poolStats.pool.name }}</h1> <h1 class="m-0 pt-1 pt-md-0">{{ poolStats.pool.name }}</h1>
</div> </div>
@ -111,7 +111,7 @@
</tbody> </tbody>
<ng-template #skeleton> <ng-template #skeleton>
<tbody> <tbody>
<tr *ngFor="let item of skeletonLines"> <tr *ngFor="let item of [1,2,3,4,5]">
<td class="height"> <td class="height">
<span class="skeleton-loader"></span> <span class="skeleton-loader"></span>
</td> </td>
@ -145,15 +145,15 @@
<ng-template #loadingMain> <ng-template #loadingMain>
<div> <div>
<div style="display:flex"> <div class="mb-3" style="display:flex; position: relative">
<img width="50" height="50" src="./resources/mining-pools/default.svg" class="mr-3 mb-3"> <div class="skeleton-loader mr-3" style="width: 50px; height: 50px"></div>
<h1 class="m-0 pt-1 pt-md-0"><div class="skeleton-loader"></div></h1> <h1 class="m-0 pt-1 pt-md-0"><div class="skeleton-loader" style="position: absolute; top: 32%; width: 150px; height: 20px"></div></h1>
</div> </div>
<div class="box"> <div class="box">
<div class="row"> <div class="row">
<div class="col-lg-9"> <div class="col-lg-9">
<table class="table table-borderless table-striped" style="table-layout: fixed;"> <table class="table table-borderless table-striped">
<tbody> <tbody>
<tr> <tr>
<td class="label">Tags</td> <td class="label">Tags</td>
@ -176,7 +176,7 @@
</table> </table>
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
<table class="table table-borderless table-striped"> <table class="table table-borderless table-striped" >
<tbody> <tbody>
<tr> <tr>
<td class="label">Mined Blocks</td> <td class="label">Mined Blocks</td>

View File

@ -45,7 +45,7 @@ div.scrollable {
} }
.label { .label {
width: 30%; width: 35%;
} }
.data { .data {
@ -136,4 +136,18 @@ div.scrollable {
@media (max-width: 450px) { @media (max-width: 450px) {
text-align: right; text-align: right;
} }
} }
.skeleton-loader {
max-width: 200px;
}
.loadingGraphs {
position: absolute;
left: calc(50% - 15px);
z-index: 100;
top: 475px;
@media (max-width: 992px) {
top: 600px;
}
}

View File

@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { EChartsOption, graphic } from 'echarts'; import { EChartsOption, graphic } from 'echarts';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable, timer } from 'rxjs';
import { map, switchMap, tap } from 'rxjs/operators'; import { map, switchMap, tap } from 'rxjs/operators';
import { BlockExtended, PoolStat } from 'src/app/interfaces/node-api.interface'; import { BlockExtended, PoolStat } from 'src/app/interfaces/node-api.interface';
import { ApiService } from 'src/app/services/api.service'; import { ApiService } from 'src/app/services/api.service';
@ -13,14 +13,6 @@ import { formatNumber } from '@angular/common';
selector: 'app-pool', selector: 'app-pool',
templateUrl: './pool.component.html', templateUrl: './pool.component.html',
styleUrls: ['./pool.component.scss'], styleUrls: ['./pool.component.scss'],
styles: [`
.loadingGraphs {
position: absolute;
top: 50%;
left: calc(50% - 15px);
z-index: 100;
}
`],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class PoolComponent implements OnInit { export class PoolComponent implements OnInit {
@ -31,7 +23,6 @@ export class PoolComponent implements OnInit {
poolStats$: Observable<PoolStat>; poolStats$: Observable<PoolStat>;
blocks$: Observable<BlockExtended[]>; blocks$: Observable<BlockExtended[]>;
isLoading = true; isLoading = true;
skeletonLines: number[] = [...Array(5).keys()];
chartOptions: EChartsOption = {}; chartOptions: EChartsOption = {};
chartInitOptions = { chartInitOptions = {
@ -40,11 +31,11 @@ export class PoolComponent implements OnInit {
height: 'auto', height: 'auto',
}; };
loadMoreSubject: BehaviorSubject<undefined> = new BehaviorSubject(undefined);
blocks: BlockExtended[] = []; blocks: BlockExtended[] = [];
poolId: number = undefined; poolId: number = undefined;
loadMoreSubject: BehaviorSubject<number> = new BehaviorSubject(this.poolId);
constructor( constructor(
@Inject(LOCALE_ID) public locale: string, @Inject(LOCALE_ID) public locale: string,
private apiService: ApiService, private apiService: ApiService,
@ -59,6 +50,7 @@ export class PoolComponent implements OnInit {
switchMap((poolId: any) => { switchMap((poolId: any) => {
this.isLoading = true; this.isLoading = true;
this.poolId = poolId; this.poolId = poolId;
this.loadMoreSubject.next(this.poolId);
return this.apiService.getPoolHashrate$(this.poolId) return this.apiService.getPoolHashrate$(this.poolId)
.pipe( .pipe(
switchMap((data) => { switchMap((data) => {
@ -88,6 +80,9 @@ export class PoolComponent implements OnInit {
this.blocks$ = this.loadMoreSubject this.blocks$ = this.loadMoreSubject
.pipe( .pipe(
switchMap((flag) => { switchMap((flag) => {
if (this.poolId === undefined) {
return [];
}
return this.apiService.getPoolBlocks$(this.poolId, this.blocks[this.blocks.length - 1]?.height); return this.apiService.getPoolBlocks$(this.poolId, this.blocks[this.blocks.length - 1]?.height);
}), }),
tap((newBlocks) => { tap((newBlocks) => {
@ -187,7 +182,7 @@ export class PoolComponent implements OnInit {
} }
loadMore() { loadMore() {
this.loadMoreSubject.next(undefined); this.loadMoreSubject.next(this.poolId);
} }
trackByBlock(index: number, block: BlockExtended) { trackByBlock(index: number, block: BlockExtended) {