added USD conversion; added conversion to address page
This commit is contained in:
parent
8ba0a07772
commit
1dfe384271
@ -5,7 +5,7 @@
|
||||
<ion-content padding>
|
||||
<h1>Address</h1>
|
||||
<p class="ellipsis"><b>Address</b> {{ address.addrStr }}</p>
|
||||
<p>{{ address.balance }} BTC</p>
|
||||
<p>{{ currency.getConversion(address.balance) }}</p>
|
||||
|
||||
<h2>Summary</h2>
|
||||
|
||||
@ -13,19 +13,19 @@
|
||||
<ion-item>
|
||||
Total Received
|
||||
<span item-end>
|
||||
{{ address.totalReceived }} BTC
|
||||
{{ currency.getConversion(address.totalReceived) }}
|
||||
</span>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
Total Sent
|
||||
<span item-end>
|
||||
{{ address.totalSent }} BTC
|
||||
{{ currency.getConversion(address.totalSent) }}
|
||||
</span>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
Final Balance
|
||||
<span item-end>
|
||||
{{ address.balance }} BTC
|
||||
{{ currency.getConversion(address.balance) }}
|
||||
</span>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
|
||||
@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import { Http } from '@angular/http';
|
||||
import { ApiProvider } from '../../providers/api/api';
|
||||
import { CurrencyProvider } from '../../providers/currency/currency';
|
||||
|
||||
/**
|
||||
* Generated class for the AddressPage page.
|
||||
@ -23,7 +24,7 @@ export class AddressPage {
|
||||
private addrStr: string;
|
||||
public address: any = {};
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http, private api: ApiProvider) {
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http, private api: ApiProvider, public currency: CurrencyProvider) {
|
||||
this.addrStr = navParams.get('addrStr');
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { ApiProvider } from '../../providers/api/api';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
/*
|
||||
@ -14,8 +15,10 @@ export class CurrencyProvider {
|
||||
private defaultCurrency: string;
|
||||
private currencySymbol: string;
|
||||
private factor: number = 1;
|
||||
private bitstamp: number;
|
||||
private loading: boolean;
|
||||
|
||||
constructor(public http: Http) {
|
||||
constructor(public http: Http, private api: ApiProvider) {
|
||||
this.defaultCurrency = 'BTC';
|
||||
this.currencySymbol = this.defaultCurrency;
|
||||
}
|
||||
@ -50,12 +53,17 @@ export class CurrencyProvider {
|
||||
localStorage.setItem('insight-currency', currency);
|
||||
|
||||
if (currency === 'USD') {
|
||||
// TODO Replace this with call
|
||||
/*
|
||||
Currency.get({}, function(res) {
|
||||
$rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp;
|
||||
});
|
||||
*/
|
||||
this.http.get(this.api.apiPrefix + 'currency').subscribe(
|
||||
(data) => {
|
||||
let currencyParsed = JSON.parse(data['_body']);
|
||||
this.factor = this.bitstamp = currencyParsed.data.bitstamp;
|
||||
this.loading = false;
|
||||
},
|
||||
(err) => {
|
||||
console.log('err is', err);
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
} else if (currency === 'mBTC') {
|
||||
this.factor = 1000;
|
||||
} else if (currency === 'bits') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user