From c4d5ea971e94ddeb5b48111926a2898587492041 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Mon, 19 Dec 2022 19:02:50 -0600 Subject: [PATCH] display block health as badge --- .../app/components/block/block.component.html | 17 ++++++++++-- .../app/components/block/block.component.ts | 22 +++++++++++----- .../blocks-list/blocks-list.component.html | 26 ++++++++++++------- .../blocks-list/blocks-list.component.ts | 3 +++ 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 2c240c250..e598e9412 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -57,8 +57,21 @@ Block health - {{ blockAudit.matchRate }}% - Unknown + {{ blockAudit?.matchRate }}% + + + Unknown + + + + + diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index e4806f8c6..e92e44937 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -43,6 +43,7 @@ export class BlockComponent implements OnInit, OnDestroy { strippedTransactions: TransactionStripped[]; overviewTransitionDirection: string; isLoadingOverview = true; + isLoadingAudit = true; error: any; blockSubsidy: number; fees: number; @@ -297,13 +298,18 @@ export class BlockComponent implements OnInit, OnDestroy { this.auditSubscription = block$.pipe( startWith(null), pairwise(), - switchMap(([prevBlock, block]) => this.apiService.getBlockAudit$(block.id) - .pipe( - catchError((err) => { - this.overviewError = err; - return of([]); - }) - ) + switchMap(([prevBlock, block]) => { + this.isLoadingAudit = true; + this.blockAudit = null; + return this.apiService.getBlockAudit$(block.id) + .pipe( + catchError((err) => { + this.overviewError = err; + this.isLoadingAudit = false; + return of([]); + }) + ); + } ), filter((response) => response != null), map((response) => { @@ -375,12 +381,14 @@ export class BlockComponent implements OnInit, OnDestroy { console.log(err); this.error = err; this.isLoadingOverview = false; + this.isLoadingAudit = false; return of(null); }), ).subscribe((blockAudit) => { this.blockAudit = blockAudit; this.setupBlockGraphs(); this.isLoadingOverview = false; + this.isLoadingAudit = false; }); } diff --git a/frontend/src/app/components/blocks-list/blocks-list.component.html b/frontend/src/app/components/blocks-list/blocks-list.component.html index 628efb51b..e310d4dc7 100644 --- a/frontend/src/app/components/blocks-list/blocks-list.component.html +++ b/frontend/src/app/components/blocks-list/blocks-list.component.html @@ -46,16 +46,22 @@ - -
-
-
- {{ auditScores[block.id] }}% - ~ -
-
-
+ {{ auditScores[block.id] }}% + + + Unknown + + + + + diff --git a/frontend/src/app/components/blocks-list/blocks-list.component.ts b/frontend/src/app/components/blocks-list/blocks-list.component.ts index 700032225..93f7814cf 100644 --- a/frontend/src/app/components/blocks-list/blocks-list.component.ts +++ b/frontend/src/app/components/blocks-list/blocks-list.component.ts @@ -23,6 +23,7 @@ export class BlocksList implements OnInit, OnDestroy { indexingAvailable = false; isLoading = true; + loadingScores = true; fromBlockHeight = undefined; paginationMaxSize: number; page = 1; @@ -113,6 +114,7 @@ export class BlocksList implements OnInit, OnDestroy { if (this.indexingAvailable) { this.auditScoreSubscription = this.fromHeightSubject.pipe( switchMap((fromBlockHeight) => { + this.loadingScores = true; return this.apiService.getBlockAuditScores$(this.page === 1 ? undefined : fromBlockHeight) .pipe( catchError(() => { @@ -124,6 +126,7 @@ export class BlocksList implements OnInit, OnDestroy { Object.values(scores).forEach(score => { this.auditScores[score.hash] = score?.matchRate != null ? score.matchRate : null; }); + this.loadingScores = false; }); this.latestScoreSubscription = this.stateService.blocks$.pipe(