added call to explorers api for explorer switcher

This commit is contained in:
Darren Nelsen 2018-02-12 11:17:56 -05:00
parent 4e9c9f5451
commit d5b3705389
3 changed files with 17 additions and 20 deletions

View File

@ -4,9 +4,9 @@
</ion-list-header>
<ion-row *ngIf="switcherOn">
<ion-col *ngFor="let currency of currencies">
<button (click)="changeCurrency(currency)" ion-item detail-none class="text-button" text-center>
<img src="assets/img/currency_logos/{{ currency.ticker.toLowerCase() }}.svg" class="logo"/></button>
<ion-col *ngFor="let explorer of currencyProvider.explorers">
<button (click)="changeExplorer(explorer)" ion-item detail-none class="text-button" text-center>
<img src="assets/img/currency_logos/{{ explorer.ticker.toLowerCase() }}.svg" class="logo"/></button>
</ion-col>
</ion-row>

View File

@ -10,7 +10,6 @@ export class DenominationComponent {
public text: string;
public switcherOn: boolean;
public currencies: any = [];
public units: any = [];
constructor(
@ -19,18 +18,6 @@ export class DenominationComponent {
) {
this.text = 'Hello World';
this.switcherOn = true;
this.currencies = [
{
name: 'Bitcoin',
ticker: 'BTC',
url: 'https://insight.bitpay.com'
},
{
name: 'Bitcoin Cash',
ticker: 'BCH',
url: 'https://bch-insight.bitpay.com'
}
];
this.units = [
'USD',
@ -44,11 +31,9 @@ export class DenominationComponent {
this.viewCtrl.dismiss();
}
public changeCurrency(currency: any): void {
console.log('selected currency is', currency.name, currency.ticker);
public changeExplorer(explorer: any): void {
this.close();
let theUrl: string = currency.url;
console.log('theUrl is', theUrl);
let theUrl: string = explorer.url;
window.location.href = theUrl;
}
}

View File

@ -18,10 +18,22 @@ export class CurrencyProvider {
private bitstamp: number;
private kraken: number;
private loading: boolean;
private explorers: any = [];
constructor(public http: Http, private api: ApiProvider) {
this.defaultCurrency = 'BCH';
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 {