moved explorers call back into currency provider so that explorers data is available when denomination component is instantiated

This commit is contained in:
Darren Nelsen 2018-03-20 11:51:34 -04:00
parent a345269a8d
commit 87b8319bf3
6 changed files with 20 additions and 18 deletions

View File

@ -67,4 +67,4 @@
"node": ">=8" "node": ">=8"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -11,7 +11,6 @@ import { ApiProvider } from '../../providers/api/api';
export class DenominationComponent { export class DenominationComponent {
public switcherOn: boolean; public switcherOn: boolean;
private explorers: any = [];
public units: any = []; public units: any = [];
constructor( constructor(
@ -20,25 +19,14 @@ export class DenominationComponent {
public http: Http, public http: Http,
public api: ApiProvider public api: ApiProvider
) { ) {
let url: string = this.api.apiPrefix + 'explorers';
this.http.get(url).subscribe(
(data) => {
this.explorers = JSON.parse(data['_body']);
this.switcherOn = true;
},
(err) => {
this.switcherOn = false;
console.error('err', err);
}
);
this.units = [ this.units = [
'USD', 'USD',
this.currencyProvider.defaultCurrency, this.currencyProvider.defaultCurrency,
'm' + this.currencyProvider.defaultCurrency, 'm' + this.currencyProvider.defaultCurrency,
'bits' 'bits'
]; ];
this.switcherOn = currencyProvider.explorers.length > 1;
} }
public close(): void { public close(): void {

View File

@ -15,7 +15,7 @@ export class ApiProvider {
constructor(public http: Http) { constructor(public http: Http) {
// TODO Make this an API call // TODO Make this an API call
this.apiPrefix = '/insight-api/'; this.apiPrefix = '/api/';
} }
} }

View File

@ -18,11 +18,24 @@ export class CurrencyProvider {
private bitstamp: number; private bitstamp: number;
private kraken: number; private kraken: number;
private loading: boolean; private loading: boolean;
public explorers: any = [];
constructor(public http: Http, private api: ApiProvider) { constructor(public http: Http, private api: ApiProvider) {
// TODO Make this an API call // TODO Make this an API call
this.defaultCurrency = 'BTC'; this.defaultCurrency = 'BTC';
this.currencySymbol = this.defaultCurrency; this.currencySymbol = this.defaultCurrency;
let url: string = this.api.apiPrefix + 'explorers';
console.log('exploers url is', url);
this.http.get(url).subscribe(
(data) => {
console.log('', data);
this.explorers = JSON.parse(data['_body']);
},
(err) => {
console.error('err', err);
}
);
} }
public roundFloat(aFloat: number, decimalPlaces: number): number { public roundFloat(aFloat: number, decimalPlaces: number): number {

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{ {
"name": "insight", "name": "insight-ui",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,

View File

@ -1,5 +1,5 @@
{ {
"name": "insight", "name": "insight-ui",
"description": "A bitcoin block explorer and API.", "description": "A bitcoin block explorer and API.",
"version": "1.0.0", "version": "1.0.0",
"repository": "git://github.com/bitpay/insight.git", "repository": "git://github.com/bitpay/insight.git",
@ -10,6 +10,7 @@
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
"insight", "insight",
"insight-ui",
"blockchain", "blockchain",
"block explorer", "block explorer",
"bitcoin", "bitcoin",