diff --git a/web-ui/src/app/app.component.ts b/web-ui/src/app/app.component.ts index f819e4c..15f477b 100644 --- a/web-ui/src/app/app.component.ts +++ b/web-ui/src/app/app.component.ts @@ -46,6 +46,7 @@ export class AppComponent { 'message.addressNotFound': 'Address not found', 'message.blockNotFound': 'Block not found', 'message.loadingLatestBlocks': 'Loading latest blocks...', + 'message.loadingRichestAddresses': 'Loading richest addresses...', // error messages 'error.nothingFound': 'That doesn\'t seem to be a valid address, nor valid block, neither a valid transaction', @@ -71,6 +72,7 @@ export class AppComponent { 'label.address': 'Address', 'label.balance': 'Balance', + 'label.available': 'Available', 'label.received': 'Received', 'label.spent': 'Spent', 'label.transactionCount': 'Transactions', @@ -102,7 +104,8 @@ export class AppComponent { 'label.height': 'Block height', 'label.extractedBy': 'Extracted by', 'label.latestBlocks': 'Latest 10 blocks', - 'label.totalSupply': 'Total supply' + 'label.totalSupply': 'Total supply', + 'label.richestAddresses': 'Richest addresses' }; } } diff --git a/web-ui/src/app/app.module.ts b/web-ui/src/app/app.module.ts index 035c5b6..5ee9e7b 100644 --- a/web-ui/src/app/app.module.ts +++ b/web-ui/src/app/app.module.ts @@ -13,6 +13,7 @@ import { ToastrModule } from 'ngx-toastr'; import { NgHttpLoaderModule } from 'ng-http-loader/ng-http-loader.module' import { AddressesService } from './services/addresses.service'; +import { BalancesService } from './services/balances.service'; import { BlocksService } from './services/blocks.service'; import { ErrorService } from './services/error.service'; import { LanguageService } from './services/language.service'; @@ -31,6 +32,7 @@ import { AddressDetailsComponent } from './components/address-details/address-de import { BlockDetailsComponent } from './components/block-details/block-details.component'; import { LatestBlocksComponent } from './components/latest-blocks/latest-blocks.component'; import { TickerComponent } from './components/ticker/ticker.component'; +import { RichestAddressesComponent } from './components/richest-addresses/richest-addresses.component'; @NgModule({ declarations: [ @@ -43,7 +45,8 @@ import { TickerComponent } from './components/ticker/ticker.component'; AddressDetailsComponent, BlockDetailsComponent, LatestBlocksComponent, - TickerComponent + TickerComponent, + RichestAddressesComponent ], imports: [ AppRoutingModule, @@ -64,6 +67,7 @@ import { TickerComponent } from './components/ticker/ticker.component'; ], providers: [ AddressesService, + BalancesService, BlocksService, ErrorService, LanguageService, diff --git a/web-ui/src/app/components/richest-addresses/richest-addresses.component.css b/web-ui/src/app/components/richest-addresses/richest-addresses.component.css new file mode 100644 index 0000000..e69de29 diff --git a/web-ui/src/app/components/richest-addresses/richest-addresses.component.html b/web-ui/src/app/components/richest-addresses/richest-addresses.component.html new file mode 100644 index 0000000..54df896 --- /dev/null +++ b/web-ui/src/app/components/richest-addresses/richest-addresses.component.html @@ -0,0 +1,37 @@ +
+
+ {{'message.loadingRichestAddresses' | translate}} +
+ +
+
+

{{'label.richestAddresses' | translate}}

+
+ +
+
+ + + + + + + + + + + + + + + + + + +
{{'label.address' | translate}}{{'label.available' | translate}}{{'label.received' | translate}}{{'label.spent' | translate}}
+ {{item.address}} + {{item.available}} {{'label.coinName' | translate}}{{item.received}} {{'label.coinName' | translate}}{{item.spent}} {{'label.coinName' | translate}}
+
+
+
+
diff --git a/web-ui/src/app/components/richest-addresses/richest-addresses.component.spec.ts b/web-ui/src/app/components/richest-addresses/richest-addresses.component.spec.ts new file mode 100644 index 0000000..e58bd15 --- /dev/null +++ b/web-ui/src/app/components/richest-addresses/richest-addresses.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RichestAddressesComponent } from './richest-addresses.component'; + +describe('RichestAddressesComponent', () => { + let component: RichestAddressesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ RichestAddressesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RichestAddressesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/web-ui/src/app/components/richest-addresses/richest-addresses.component.ts b/web-ui/src/app/components/richest-addresses/richest-addresses.component.ts new file mode 100644 index 0000000..6003055 --- /dev/null +++ b/web-ui/src/app/components/richest-addresses/richest-addresses.component.ts @@ -0,0 +1,43 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; + +import { Balance } from '../../models/balance'; + +import { BalancesService } from '../../services/balances.service'; +import { ErrorService } from '../../services/error.service'; +import { PaginatedResult } from '../../models/paginated-result'; + +@Component({ + selector: 'app-richest-addresses', + templateUrl: './richest-addresses.component.html', + styleUrls: ['./richest-addresses.component.css'] +}) +export class RichestAddressesComponent implements OnInit { + + balances: Balance[]; + + constructor( + private balancesService: BalancesService, + private errorService: ErrorService) { } + + ngOnInit() { + this.balances = []; + this.updateBalances(); + } + + private updateBalances() { + this.balancesService + .getRichest() + .subscribe( + response => this.onBalancesRetrieved(response), + response => this.onError(response) + ); + } + + private onBalancesRetrieved(response: PaginatedResult) { + this.balances = response.data; + } + + private onError(response: any) { + this.errorService.renderServerErrors(null, response); + } +}