From 9c42a9e3f77ab551bf6414a2ed323e885913a2df Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Sat, 17 Mar 2018 20:05:13 -0600 Subject: [PATCH] web-ui: Complete details on the BlockDetails view --- web-ui/src/app/app.component.ts | 20 ++- .../block-details.component.html | 152 +++++++++++++++++- .../block-details/block-details.component.ts | 44 ++++- 3 files changed, 211 insertions(+), 5 deletions(-) diff --git a/web-ui/src/app/app.component.ts b/web-ui/src/app/app.component.ts index 9472c43..0f12248 100644 --- a/web-ui/src/app/app.component.ts +++ b/web-ui/src/app/app.component.ts @@ -48,6 +48,7 @@ export class AppComponent { 'label.confirmations': 'Confirmations', 'label.blockhash': 'Block Hash', 'label.blocktime': 'Block Time', + 'label.medianTime': 'Median Time', 'label.noInput': 'No input', 'label.coinbase': 'Coinbase', 'label.output': 'Receivers', @@ -60,7 +61,24 @@ export class AppComponent { 'label.balance': 'Balance', 'label.received': 'Received', 'label.spent': 'Spent', - 'label.transactionCount': 'Transactions' + 'label.transactionCount': 'Transactions', + + 'label.blockType': 'Block type', + 'label.next': 'Next', + 'label.previous': 'Previous', + 'label.merkleRoot': 'Merkle root', + 'label.size': 'Size', + 'label.version': 'Version', + 'label.nonce': 'Nonce', + 'label.bits': 'Bits', + 'label.chainwork': 'Chainwork', + 'label.difficulty': 'Difficulty', + 'label.transactions': 'Transactions', + 'label.rewards': 'Rewards', + 'label.coinstake': 'Coinstake', + 'label.masternode': 'Master node', + 'label.amount': 'Amount', + 'label.blockReward': 'Block reward' }; } } diff --git a/web-ui/src/app/components/block-details/block-details.component.html b/web-ui/src/app/components/block-details/block-details.component.html index 8fe0701..7840b0c 100644 --- a/web-ui/src/app/components/block-details/block-details.component.html +++ b/web-ui/src/app/components/block-details/block-details.component.html @@ -1,3 +1,149 @@ -

- block-details works! -

+
+
+ {{'message.blockNotFound' | translate}} +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ +
+ +
+ +
+
+ + +
+
+ + +
+ +
+
+ +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+ +
+
+ +
+
+
+
\ No newline at end of file diff --git a/web-ui/src/app/components/block-details/block-details.component.ts b/web-ui/src/app/components/block-details/block-details.component.ts index 6c81c11..98f5c6a 100644 --- a/web-ui/src/app/components/block-details/block-details.component.ts +++ b/web-ui/src/app/components/block-details/block-details.component.ts @@ -1,4 +1,13 @@ import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { TranslateService } from '@ngx-translate/core'; + +import { BlockDetails } from '../../models/block'; + +import { BlocksService } from '../../services/blocks.service'; +import { ErrorService } from '../../services/error.service'; +import { NavigatorService } from '../../services/navigator.service'; @Component({ selector: 'app-block-details', @@ -7,9 +16,42 @@ import { Component, OnInit } from '@angular/core'; }) export class BlockDetailsComponent implements OnInit { - constructor() { } + blockDetails: BlockDetails; + + constructor( + private route: ActivatedRoute, + private router: Router, + private navigatorService: NavigatorService, + private blocksService: BlocksService, + private errorService: ErrorService) { } ngOnInit() { + const blockhash = this.route.snapshot.paramMap.get('blockhash'); + this.blocksService.get(blockhash).subscribe( + response => this.onBlockRetrieved(response), + response => this.onError(response) + ); + } + + private onBlockRetrieved(response: BlockDetails) { + this.blockDetails = response; } + private onError(response: any) { + this.errorService.renderServerErrors(null, response); + } + + getBlockType(details: BlockDetails): string { + if (details.block.tposContract != null) { + return 'Trustless Proof of Stake'; + } else if (details.block.height > 75) { + return 'Proof of Stake'; + } else { + return 'Proof of Work'; + } + } + + isPoW(details: BlockDetails): boolean { + return details.block.height <= 75; + } }