Browse Source

web-ui: Update the richest addresses view to show the percent of coins

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
85e4f7e59d
  1. 3
      web-ui/src/app/app.component.ts
  2. 9
      web-ui/src/app/components/richest-addresses/richest-addresses.component.html
  3. 11
      web-ui/src/app/components/richest-addresses/richest-addresses.component.ts

3
web-ui/src/app/app.component.ts

@ -108,7 +108,8 @@ export class AppComponent {
'label.circulatingSupply': 'Circulating supply', 'label.circulatingSupply': 'Circulating supply',
'label.blocks': 'Blocks', 'label.blocks': 'Blocks',
'label.richestAddresses': 'Richest addresses', 'label.richestAddresses': 'Richest addresses',
'label.masternodes': 'Masternodes' 'label.masternodes': 'Masternodes',
'label.percentOfCoins': 'Percent of coins'
}; };
} }
} }

9
web-ui/src/app/components/richest-addresses/richest-addresses.component.html

@ -9,9 +9,8 @@
<thead> <thead>
<tr> <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.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.amount' | 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.percentOfCoins' | translate}}</th>
<th class="col-xs-2 col-sm-2 col-md-1 col-lg-1">{{'label.spent' | translate}}</th>
</tr> </tr>
</thead> </thead>
@ -21,8 +20,8 @@
<a routerLink="/addresses/{{item.address}}">{{item.address}}</a> <a routerLink="/addresses/{{item.address}}">{{item.address}}</a>
</td> </td>
<td>{{item.available}} {{'label.coinName' | translate}}</td> <td>{{item.available}} {{'label.coinName' | translate}}</td>
<td>{{item.received}} {{'label.coinName' | translate}}</td> <td *ngIf="ticker == null || ticker.circulatingSupply == null">{{'label.unavailable' | translate}}</td>
<td>{{item.spent}} {{'label.coinName' | translate}}</td> <td *ngIf="ticker != null && ticker.circulatingSupply != null">{{getPercent(item)}} %</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

11
web-ui/src/app/components/richest-addresses/richest-addresses.component.ts

@ -9,6 +9,8 @@ import { Balance } from '../../models/balance';
import { BalancesService } from '../../services/balances.service'; import { BalancesService } from '../../services/balances.service';
import { ErrorService } from '../../services/error.service'; import { ErrorService } from '../../services/error.service';
import { TickerService } from '../../services/ticker.service';
import { ServerStats } from '../../models/ticker';
@Component({ @Component({
selector: 'app-richest-addresses', selector: 'app-richest-addresses',
@ -17,6 +19,9 @@ import { ErrorService } from '../../services/error.service';
}) })
export class RichestAddressesComponent implements OnInit { export class RichestAddressesComponent implements OnInit {
// ticker
ticker: ServerStats;
// pagination // pagination
total = 0; total = 0;
currentPage = 1; currentPage = 1;
@ -25,10 +30,12 @@ export class RichestAddressesComponent implements OnInit {
constructor( constructor(
private balancesService: BalancesService, private balancesService: BalancesService,
private tickerService: TickerService,
private errorService: ErrorService) { } private errorService: ErrorService) { }
ngOnInit() { ngOnInit() {
this.getPage(this.currentPage); this.getPage(this.currentPage);
this.tickerService.get().subscribe(response => this.ticker = response);
} }
getPage(page: number) { getPage(page: number) {
@ -41,4 +48,8 @@ export class RichestAddressesComponent implements OnInit {
.do(response => this.currentPage = 1 + (response.offset / this.pageSize)) .do(response => this.currentPage = 1 + (response.offset / this.pageSize))
.map(response => response.data); .map(response => response.data);
} }
getPercent(balance: Balance): number {
return balance.available * 100 / this.ticker.circulatingSupply;
}
} }

Loading…
Cancel
Save