From 49d3d0b0b9fd5a0c8a058aabe8f6cd34c527cbbe Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Sat, 17 Mar 2018 18:33:33 -0600 Subject: [PATCH] web-ui: Complete details on the AddressDetails view --- web-ui/src/app/app.component.ts | 10 +++++- .../address-details.component.html | 30 ++++++++++++++-- .../address-details.component.ts | 35 ++++++++++++++++++- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/web-ui/src/app/app.component.ts b/web-ui/src/app/app.component.ts index 6646c17..9472c43 100644 --- a/web-ui/src/app/app.component.ts +++ b/web-ui/src/app/app.component.ts @@ -36,6 +36,8 @@ export class AppComponent { // messages 'message.serverUnavailable': 'The server unavailable, please try again in a minute', 'message.unknownError': 'Unknown error, please try again in a minute', + 'message.transactionNotFound': 'Transaction not found', + 'message.addressNotFound': 'Address not found', // actions 'action.find': 'Find', @@ -52,7 +54,13 @@ export class AppComponent { 'label.from': 'From', 'label.to': 'To', 'label.value': 'Amount', - 'label.fee': 'Fee' + 'label.fee': 'Fee', + + 'label.address': 'Address', + 'label.balance': 'Balance', + 'label.received': 'Received', + 'label.spent': 'Spent', + 'label.transactionCount': 'Transactions' }; } } diff --git a/web-ui/src/app/components/address-details/address-details.component.html b/web-ui/src/app/components/address-details/address-details.component.html index b29656f..c679b59 100644 --- a/web-ui/src/app/components/address-details/address-details.component.html +++ b/web-ui/src/app/components/address-details/address-details.component.html @@ -1,3 +1,27 @@ -

- address-details works! -

+
+
+ {{'message.addressNotFound' | translate}} +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
diff --git a/web-ui/src/app/components/address-details/address-details.component.ts b/web-ui/src/app/components/address-details/address-details.component.ts index d6667b1..fbd8eb7 100644 --- a/web-ui/src/app/components/address-details/address-details.component.ts +++ b/web-ui/src/app/components/address-details/address-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 { Address } from '../../models/address'; + +import { AddressesService } from '../../services/addresses.service'; +import { ErrorService } from '../../services/error.service'; +import { NavigatorService } from '../../services/navigator.service'; @Component({ selector: 'app-address-details', @@ -7,9 +16,33 @@ import { Component, OnInit } from '@angular/core'; }) export class AddressDetailsComponent implements OnInit { - constructor() { } + address: Address; + addressString: string; + + constructor( + private route: ActivatedRoute, + private router: Router, + private navigatorService: NavigatorService, + private addressesService: AddressesService, + private errorService: ErrorService) { } ngOnInit() { + this.addressString = this.route.snapshot.paramMap.get('address'); + this.addressesService.get(this.addressString).subscribe( + response => this.onAddressRetrieved(response), + response => this.onError(response) + ); } + private onAddressRetrieved(response: Address) { + this.address = response; + } + + private onError(response: any) { + this.errorService.renderServerErrors(null, response); + } + + getSent(address: Address): number { + return address.received - address.balance; + } }