Alexis Hernandez
7 years ago
6 changed files with 114 additions and 2 deletions
@ -0,0 +1,37 @@ |
|||||
|
<div> |
||||
|
<div [hidden]="balances != null"> |
||||
|
<alert>{{'message.loadingRichestAddresses' | translate}}</alert> |
||||
|
</div> |
||||
|
|
||||
|
<div *ngIf="balances != null"> |
||||
|
<div class="row"> |
||||
|
<h2 class="col-xs-12 col-sm-12 col-md-offset-1 col-md-10 col-lg-offset-1 col-lg-1'">{{'label.richestAddresses' | translate}}</h2> |
||||
|
</div> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-xs-12 col-sm-12 col-md-offset-1 col-md-10 col-lg-offset-1 col-lg-10"> |
||||
|
<table class="table table-condensed table-bordered table-striped table-hover"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th class="col-xs-2 col-sm-2 col-md-1 col-lg-1">{{'label.address' | translate}}</th> |
||||
|
<th class="col-xs-2 col-sm-2 col-md-1 col-lg-1">{{'label.available' | translate}}</th> |
||||
|
<th class="col-xs-2 col-sm-2 col-md-1 col-lg-1">{{'label.received' | translate}}</th> |
||||
|
<th class="col-xs-2 col-sm-2 col-md-1 col-lg-1">{{'label.spent' | translate}}</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
|
||||
|
<tbody> |
||||
|
<tr *ngFor="let item of balances"> |
||||
|
<td> |
||||
|
<a routerLink="/addresses/{{item.address}}">{{item.address}}</a> |
||||
|
</td> |
||||
|
<td>{{item.available}} {{'label.coinName' | translate}}</td> |
||||
|
<td>{{item.received}} {{'label.coinName' | translate}}</td> |
||||
|
<td>{{item.spent}} {{'label.coinName' | translate}}</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
@ -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<RichestAddressesComponent>; |
||||
|
|
||||
|
beforeEach(async(() => { |
||||
|
TestBed.configureTestingModule({ |
||||
|
declarations: [ RichestAddressesComponent ] |
||||
|
}) |
||||
|
.compileComponents(); |
||||
|
})); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
fixture = TestBed.createComponent(RichestAddressesComponent); |
||||
|
component = fixture.componentInstance; |
||||
|
fixture.detectChanges(); |
||||
|
}); |
||||
|
|
||||
|
it('should create', () => { |
||||
|
expect(component).toBeTruthy(); |
||||
|
}); |
||||
|
}); |
@ -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<Balance>) { |
||||
|
this.balances = response.data; |
||||
|
} |
||||
|
|
||||
|
private onError(response: any) { |
||||
|
this.errorService.renderServerErrors(null, response); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue