From 82d5641468884a839556f1ed3f28f8d102876451 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 16 Mar 2018 16:23:33 -0400 Subject: [PATCH] moved call to explorers --- app/package.json | 2 +- .../components/denomination/denomination.ts | 22 +++++++++++++++---- app/src/providers/api/api.ts | 4 +++- app/src/providers/currency/currency.ts | 15 +------------ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/package.json b/app/package.json index b65e0b3..7cbe5da 100644 --- a/app/package.json +++ b/app/package.json @@ -67,4 +67,4 @@ "node": ">=8" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/app/src/components/denomination/denomination.ts b/app/src/components/denomination/denomination.ts index 3d2de77..0cf6093 100644 --- a/app/src/components/denomination/denomination.ts +++ b/app/src/components/denomination/denomination.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; import { CurrencyProvider } from '../../providers/currency/currency'; import { ViewController } from 'ionic-angular'; +import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; @Component({ selector: 'denomination', @@ -8,16 +10,28 @@ import { ViewController } from 'ionic-angular'; }) export class DenominationComponent { - public text: string; public switcherOn: boolean; + private explorers: any = []; public units: any = []; constructor( public currencyProvider: CurrencyProvider, - public viewCtrl: ViewController + public viewCtrl: ViewController, + public http: Http, + public api: ApiProvider ) { - this.text = 'Hello World'; - this.switcherOn = true; + + 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 = [ 'USD', diff --git a/app/src/providers/api/api.ts b/app/src/providers/api/api.ts index 1a2b9a8..54083c0 100644 --- a/app/src/providers/api/api.ts +++ b/app/src/providers/api/api.ts @@ -11,9 +11,11 @@ import 'rxjs/add/operator/map'; @Injectable() export class ApiProvider { - public apiPrefix: string = '/insight-api/'; + public apiPrefix: string; constructor(public http: Http) { + // TODO Make this an API call + this.apiPrefix = '/insight-api/'; } } diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts index 5549d62..4ff2505 100644 --- a/app/src/providers/currency/currency.ts +++ b/app/src/providers/currency/currency.ts @@ -17,23 +17,12 @@ export class CurrencyProvider { public factor: number = 1; private bitstamp: number; private kraken: number; - private loading: boolean; - private explorers: any = []; constructor(public http: Http, private api: ApiProvider) { + // TODO Make this an API call this.defaultCurrency = 'BTC'; this.currencySymbol = this.defaultCurrency; - this.http.get(this.api.apiPrefix + 'explorers').subscribe( - (data) => { - this.explorers = JSON.parse(data['_body']); - this.loading = false; - }, - (err) => { - console.log('err is', err); - this.loading = false; - } - ); } public roundFloat(aFloat: number, decimalPlaces: number): number { @@ -98,11 +87,9 @@ export class CurrencyProvider { } else if (currencyParsed.data.kraken) { this.factor = this.kraken = currencyParsed.data.kraken; } - this.loading = false; }, (err) => { console.log('err is', err); - this.loading = false; } ); } else if (currency === 'm' + this.defaultCurrency) {