Address
Address {{ address.addrStr }}
- {{ address.balance }} BTC
+ {{ currency.getConversion(address.balance) }}
Summary
@@ -13,19 +13,19 @@
Total Received
- {{ address.totalReceived }} BTC
+ {{ currency.getConversion(address.totalReceived) }}
Total Sent
- {{ address.totalSent }} BTC
+ {{ currency.getConversion(address.totalSent) }}
Final Balance
- {{ address.balance }} BTC
+ {{ currency.getConversion(address.balance) }}
diff --git a/app/src/pages/address/address.ts b/app/src/pages/address/address.ts
index e392a33..459f4de 100644
--- a/app/src/pages/address/address.ts
+++ b/app/src/pages/address/address.ts
@@ -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');
}
diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts
index fe6f412..b89d2ff 100644
--- a/app/src/providers/currency/currency.ts
+++ b/app/src/providers/currency/currency.ts
@@ -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') {