Merge pull request #808 from SonicWizard/next

BEM-ified some of the styles
This commit is contained in:
Jason Dreyzehner 2018-02-01 15:32:37 -05:00 committed by GitHub
commit 51199e4d87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 262 additions and 137 deletions

View File

@ -7,6 +7,6 @@
}, },
"proxies": [{ "proxies": [{
"path": "/api", "path": "/api",
"proxyUrl": "http://localhost:3000/api" "proxyUrl": "https://bch-insight.bitpay.com/api"
}] }]
} }

View File

@ -41,7 +41,7 @@
"@types/jasmine": "2.5.41", "@types/jasmine": "2.5.41",
"@types/node": "7.0.4", "@types/node": "7.0.4",
"codecov": "2.2.0", "codecov": "2.2.0",
"ionic": "3.9.2", "ionic": "3.19.1",
"jasmine-core": "2.5.2", "jasmine-core": "2.5.2",
"jasmine-spec-reporter": "3.2.0", "jasmine-spec-reporter": "3.2.0",
"karma": "1.4.1", "karma": "1.4.1",

View File

@ -8,6 +8,10 @@
// Additionally, this file can be also used as an entry point // Additionally, this file can be also used as an entry point
// to import other Sass files to be included in the output CSS. // to import other Sass files to be included in the output CSS.
body {
user-select: text;
}
.ellipsis { .ellipsis {
display: block; display: block;
overflow: hidden; overflow: hidden;
@ -15,19 +19,47 @@
white-space: nowrap; white-space: nowrap;
} }
.summary ion-label { .list--summary {
color: #333; ion-label {
font-weight: bold; color: #333;
font-weight: bold;
}
ion-item {
color: #999;
font-size: 1.125rem;
}
ion-note {
color: #999;
max-width: 50%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
} }
.summary ion-item { .grid--table {
color: #999; margin: 10px 0 20px;
font-size: 1.4rem;
ion-row {
border-top: 1px solid #ccc;
&:first-child {
background-color: white;
border-top: none;
}
&:nth-child(even) {
background-color: #f4f4f4;
}
&:last-child {
background-color: white;
}
}
} }
body {
user-select: text;
}
// Shared Sass variables, which can be used to adjust Ionic's // Shared Sass variables, which can be used to adjust Ionic's
// default Sass variables, belong in "theme/variables.scss". // default Sass variables, belong in "theme/variables.scss".

View File

@ -0,0 +1,10 @@
<ion-list radio-group [(ngModel)]="currency.currencySymbol" (ionChange)="currency.setCurrency(currency.currencySymbol)">
<ion-list-header>
Units
</ion-list-header>
<ion-item *ngFor="let unit of units">
<ion-label color="dark">{{ unit }}</ion-label>
<ion-radio value="{{ unit }}" (click)="close()"></ion-radio>
</ion-item>
</ion-list>

View File

@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { DenominationComponent } from './denomination';
@NgModule({
declarations: [
DenominationComponent
],
imports: [
IonicModule
],
exports: [
DenominationComponent
],
entryComponents: [
DenominationComponent
]
})
export class DenominationComponentModule {}

View File

@ -0,0 +1,3 @@
denomination {
}

View File

@ -0,0 +1,31 @@
import { Component } from '@angular/core';
import { CurrencyProvider } from '../../providers/currency/currency';
import { ViewController } from 'ionic-angular';
@Component({
selector: 'denomination',
templateUrl: 'denomination.html'
})
export class DenominationComponent {
public text: string;
public units: any = [];
constructor(
public currency: CurrencyProvider,
public viewCtrl: ViewController
) {
this.text = 'Hello World';
this.units = [
'USD',
this.currency.defaultCurrency,
'm' + this.currency.defaultCurrency,
'bits'
];
}
public close(): void {
this.viewCtrl.dismiss();
}
}

View File

@ -4,7 +4,7 @@
</button> </button>
<ion-title>{{title}}</ion-title> <ion-title>{{title}}</ion-title>
<ion-buttons end> <ion-buttons end>
<button ion-button (click)="changeCurrency()"> <button ion-button (click)="changeCurrency($event)">
<ion-icon name="logo-bitcoin" *ngIf="currency.currencySymbol !== 'USD'"></ion-icon><ion-icon name="logo-usd" *ngIf="currency.currencySymbol === 'USD'"></ion-icon>&nbsp;{{ currency.currencySymbol }} <ion-icon name="logo-bitcoin" *ngIf="currency.currencySymbol !== 'USD'"></ion-icon><ion-icon name="logo-usd" *ngIf="currency.currencySymbol === 'USD'"></ion-icon>&nbsp;{{ currency.currencySymbol }}
</button> </button>
<button ion-button icon-only (click)="toggleSearch()"> <button ion-button icon-only (click)="toggleSearch()">
@ -12,4 +12,7 @@
</button> </button>
</ion-buttons> </ion-buttons>
</ion-navbar> </ion-navbar>
<ion-searchbar [hidden]="!showSearch" (ionInput)="search($event)" placeholder="{{ 'Search for block, transaction or address' }}" [(ngModel)]="q" [debounce]="1500"></ion-searchbar>
<form (ngSubmit)="search($event)">
<ion-searchbar [hidden]="!showSearch" placeholder="{{ 'Search for block, transaction or address' }}" [(ngModel)]="q" name="search"></ion-searchbar>
</form>

View File

@ -1,13 +1,15 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular'; import { IonicModule } from 'ionic-angular';
import { HeadNavComponent } from './head-nav'; import { HeadNavComponent } from './head-nav';
import { DenominationComponentModule } from '../denomination/denomination.module';
@NgModule({ @NgModule({
declarations: [ declarations: [
HeadNavComponent HeadNavComponent
], ],
imports: [ imports: [
IonicModule IonicModule,
DenominationComponentModule
], ],
exports: [ exports: [
HeadNavComponent HeadNavComponent

View File

@ -5,6 +5,8 @@ import { Http } from '@angular/http';
import { ApiProvider } from '../../providers/api/api'; import { ApiProvider } from '../../providers/api/api';
import { CurrencyProvider } from '../../providers/currency/currency'; import { CurrencyProvider } from '../../providers/currency/currency';
import { ActionSheetController } from 'ionic-angular'; import { ActionSheetController } from 'ionic-angular';
import { PopoverController } from 'ionic-angular';
import { DenominationComponent } from '../denomination/denomination';
/** /**
* Generated class for the HeadNavComponent component. * Generated class for the HeadNavComponent component.
@ -24,7 +26,14 @@ export class HeadNavComponent {
public q: string; public q: string;
public badQuery: boolean = false; public badQuery: boolean = false;
constructor(private navCtrl: NavController, private http: Http, private api: ApiProvider, public currency: CurrencyProvider, public actionSheetCtrl: ActionSheetController) { constructor(
private navCtrl: NavController,
private http: Http,
private api: ApiProvider,
public currency: CurrencyProvider,
public actionSheetCtrl: ActionSheetController,
public popoverCtrl: PopoverController
) {
} }
public search(): void { public search(): void {
@ -102,7 +111,8 @@ export class HeadNavComponent {
} }
/* tslint:enable:no-unused-variable */ /* tslint:enable:no-unused-variable */
public changeCurrency(): void { public changeCurrency(myEvent: any): void {
/*
let actionSheet: any = this.actionSheetCtrl.create({ let actionSheet: any = this.actionSheetCtrl.create({
title: 'Change Denomination', title: 'Change Denomination',
buttons: [ buttons: [
@ -113,15 +123,15 @@ export class HeadNavComponent {
} }
}, },
{ {
text: 'BTC', text: this.currency.defaultCurrency,
handler: () => { handler: () => {
this.currency.setCurrency('BTC'); this.currency.setCurrency(this.currency.defaultCurrency);
} }
}, },
{ {
text: 'mBTC', text: 'm' + this.currency.defaultCurrency,
handler: () => { handler: () => {
this.currency.setCurrency('mBTC'); this.currency.setCurrency('m' + this.currency.defaultCurrency);
} }
}, },
{ {
@ -137,6 +147,12 @@ export class HeadNavComponent {
] ]
}); });
actionSheet.present(); actionSheet.present();
*/
let popover: any = this.popoverCtrl.create(DenominationComponent);
popover.present({
ev: myEvent
});
} }
public toggleSearch(): void { public toggleSearch(): void {

View File

@ -5,7 +5,7 @@
</div> </div>
<div *ngIf="!loading"> <div *ngIf="!loading">
<ion-grid> <ion-grid class="grid--table">
<ion-row> <ion-row>
<ion-col><b>Height</b></ion-col> <ion-col><b>Height</b></ion-col>
@ -15,6 +15,7 @@
<ion-col hideWhen="portrait"><b>Mined By</b></ion-col> <ion-col hideWhen="portrait"><b>Mined By</b></ion-col>
<ion-col text-right><b>Size</b></ion-col> <ion-col text-right><b>Size</b></ion-col>
</ion-row> </ion-row>
<ion-row *ngFor="let block of getBlocks()"> <ion-row *ngFor="let block of getBlocks()">
<ion-col> <ion-col>
<a (click)="goToBlock(block.hash)">{{block.height}}</a> <a (click)="goToBlock(block.hash)">{{block.height}}</a>
@ -35,6 +36,7 @@
{{ block.size }} {{ block.size }}
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row *ngIf="showAllBlocksButton"> <ion-row *ngIf="showAllBlocksButton">
<ion-col text-center> <ion-col text-center>
<button ion-button (click)="goToBlocks()">See all blocks</button> <button ion-button (click)="goToBlocks()">See all blocks</button>

View File

@ -1,23 +1,2 @@
latest-blocks { latest-blocks {
ion-grid {
// border: 2px solid green;
margin: 10px 0 20px;
ion-row {
border-top: 1px solid #ccc;
}
ion-row:nth-child(even) {
background-color: #f4f4f4;
}
ion-row:first-child {
background-color: white;
border-top: none;
}
ion-row:last-child {
background-color: white;
}
}
} }

View File

@ -4,7 +4,7 @@
</div> </div>
<div *ngIf="!loading"> <div *ngIf="!loading">
<ion-grid> <ion-grid class="grid--table">
<ion-row> <ion-row>
<ion-col><b>Hash</b></ion-col> <ion-col><b>Hash</b></ion-col>

View File

@ -1,23 +1,2 @@
latest-transactions { latest-transactions {
ion-grid {
// border: 2px solid green;
margin: 10px 0 20px;
ion-row {
border-top: 1px solid #ccc;
}
ion-row:nth-child(even) {
background-color: #f4f4f4;
}
ion-row:first-child {
background-color: white;
border-top: none;
}
ion-row:last-child {
background-color: white;
}
}
} }

View File

@ -1,19 +1,19 @@
<ion-grid> <ion-grid>
<ion-row> <ion-row>
<ion-col col-8> <ion-col col-7>
<div class="ellipsis"> <div class="ellipsis">
<ion-icon name="add-circle" [hidden]="expanded" (click)="toggleExpanded()"></ion-icon><ion-icon name="remove-circle" [hidden]="!expanded" (click)="toggleExpanded()"></ion-icon> <span><a (click)="goToTx(tx.txid)">{{ tx.txid }}</a></span> <ion-icon name="add-circle" [hidden]="expanded" (click)="toggleExpanded()"></ion-icon><ion-icon name="remove-circle" [hidden]="!expanded" (click)="toggleExpanded()"></ion-icon> <span><a (click)="goToTx(tx.txid)">{{ tx.txid }}</a></span>
</div> </div>
</ion-col> </ion-col>
<ion-col col-4 text-right> <ion-col col-5 text-right>
<div [hidden]="!tx.firstSeenTs"> <ion-note [hidden]="!tx.firstSeenTs">
<span translate>first seen at</span> <span translate>first seen at</span>
<time>{{tx.firstSeenTs * 1000 | date:'medium'}}</time> <time>{{tx.firstSeenTs * 1000 | date:'medium'}}</time>
</div> </ion-note>
<div [hidden]="!tx.blocktime && tx.firstSeenTs"> <ion-note [hidden]="!tx.blocktime && tx.firstSeenTs">
<span translate>mined</span> <span translate>mined</span>
<time>{{tx.time * 1000 | date:'medium'}}</time> <time>{{tx.time * 1000 | date:'MMM d, y'}}</time> <time>{{tx.time * 1000 | date:'hh:mm:ss a'}}</time>
</div> </ion-note>
</ion-col> </ion-col>
</ion-row> </ion-row>
@ -48,7 +48,7 @@
</div> </div>
<div item-end> <div item-end>
{{ currency.getConversion(vin.value) }} {{ currency.getConvertedNumber(vin.value) | number:'1.0-8' }} {{ currency.currencySymbol }}
</div> </div>
</ion-item> </ion-item>
</ion-list> </ion-list>
@ -76,7 +76,7 @@
</div> </div>
<div item-end> <div item-end>
{{ currency.getConversion(vout.value) }} {{ currency.getConvertedNumber(vout.value) | number:'1.0-8' }} {{ currency.currencySymbol }}
<span [hidden]="!vout.spentTxId">(S)</span> <span [hidden]="!vout.spentTxId">(S)</span>
<span [hidden]="vout.spentTxId">(U)</span> <span [hidden]="vout.spentTxId">(U)</span>
</div> </div>
@ -85,15 +85,15 @@
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row align-items-center text-uppercase class="small">
<ion-col col-3> <ion-col col-6>
<span [hidden]="tx.isCoinBase">Fee {{ currency.getConversion(tx.fees) }}</span> <div [hidden]="tx.isCoinBase">
Fee <span text-nowrap>{{ currency.getConvertedNumber(tx.fees) | number:'1.0-8' }} {{ currency.currencySymbol }}</span>
</div>
</ion-col> </ion-col>
<ion-col col-6 text-center> <ion-col col-6 text-right>
{{ tx.confirmations }} Confirmations <span text-nowrap>{{ tx.confirmations }} Confirmation<span *ngIf="tx.confirmations !== 1">s</span></span>
</ion-col> <span text-nowrap>{{ currency.getConvertedNumber(tx.valueOut) | number:'1.0-8' }} {{ currency.currencySymbol }}</span>
<ion-col col-3 text-right>
<span class="">{{ currency.getConversion(tx.valueOut) }}</span>
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-grid> </ion-grid>

View File

@ -9,6 +9,24 @@ transaction {
ion-row { ion-row {
border: 1px solid #eee; border: 1px solid #eee;
&.small {
font-size: 1.1rem;
}
ion-col {
ion-note {
font-size: 1.2rem;
}
}
} }
} }
.item, .item p {
font-size: 1.4rem;
}
.list {
margin-bottom: 5px
}
} }

View File

@ -10,34 +10,34 @@
<div *ngIf="!loading"> <div *ngIf="!loading">
<h1>Address</h1> <h1>Address</h1>
<p class="ellipsis"><b>Address</b> {{ address.addrStr }}</p> <p class="ellipsis"><b>Address</b> {{ address.addrStr }}</p>
<p>{{ currency.getConversion(address.balance) }}</p> <p>{{ currency.getConvertedNumber(address.balance) | number:'1.0-8' }} {{ currency.currencySymbol }}</p>
<h2>Summary</h2> <h2>Summary</h2>
<ion-list class="summary"> <ion-list class="list--summary">
<ion-item> <ion-item>
Total Received Total Received
<span item-end> <ion-note item-end>
{{ currency.getConversion(address.totalReceived) }} {{ currency.getConvertedNumber(address.totalReceived) | number:'1.0-8' }} {{ currency.currencySymbol }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Total Sent Total Sent
<span item-end> <ion-note item-end>
{{ currency.getConversion(address.totalSent) }} {{ currency.getConvertedNumber(address.totalSent) | number:'1.0-8' }} {{ currency.currencySymbol }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Final Balance Final Balance
<span item-end> <ion-note item-end>
{{ currency.getConversion(address.balance) }} {{ currency.getConvertedNumber(address.balance) | number:'1.0-8' }} {{ currency.currencySymbol }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
No. Transactions No. Transactions
<span item-end> <ion-note item-end>
{{ address.txApperances }} {{ address.txApperances }}
</span> </ion-note>
</ion-item> </ion-item>
</ion-list> </ion-list>

View File

@ -13,84 +13,84 @@
<h2>Summary</h2> <h2>Summary</h2>
<ion-list *ngIf="!loading" class="summary"> <ion-list *ngIf="!loading" class="list--summary">
<ion-item> <ion-item>
Number of Transactions Number of Transactions
<span item-end> <ion-note item-end>
{{ block.tx.length }} {{ block.tx.length }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Height Height
<span item-end> <ion-note item-end>
{{ block.height }} <span [hidden]="!block.isMainChain">(Mainchain)</span> {{ block.height }} <span [hidden]="!block.isMainChain">(Mainchain)</span>
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Block Reward Block Reward
<span item-end> <ion-note item-end>
{{ currency.getConversion(block.reward) }} {{ currency.getConvertedNumber(block.reward) | number:'1.0-8' }} {{ currency.currencySymbol }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Timestamp Timestamp
<span item-end> <ion-note item-end>
{{ block.time * 1000 | date:'medium' }} {{ block.time * 1000 | date:'medium' }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Mined by Mined by
<span item-end *ngIf="block.poolInfo"> <ion-note item-end *ngIf="block.poolInfo">
<a href="{{ block.poolInfo.url }}">{{ block.poolInfo.poolName }}</a> <a href="{{ block.poolInfo.url }}">{{ block.poolInfo.poolName }}</a>
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Merkle Root Merkle Root
<span item-end class="ellipsis"> <ion-note item-end>
{{ block.merkleroot }} {{ block.merkleroot }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Previous Block Previous Block
<span item-end> <ion-note item-end>
<a (click)="goToPreviousBlock()">{{ block.height - 1 }}</a> <a (click)="goToPreviousBlock()">{{ block.height - 1 }}</a>
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Difficulty Difficulty
<span item-end> <ion-note item-end>
{{ block.difficulty }} {{ block.difficulty }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Bits Bits
<span item-end> <ion-note item-end>
{{ block.bits }} {{ block.bits }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Size (bytes) Size (bytes)
<span item-end> <ion-note item-end>
{{ block.size }} {{ block.size }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Version Version
<span item-end> <ion-note item-end>
{{ block.version }} {{ block.version }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Nonce Nonce
<span item-end> <ion-note item-end>
{{ block.nonce }} {{ block.nonce }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Next Block Next Block
<span item-end> <ion-note item-end>
<a (click)="goToNextBlock()">{{ block.height + 1 }}</a> <a (click)="goToNextBlock()">{{ block.height + 1 }}</a>
</span> </ion-note>
</ion-item> </ion-item>
</ion-list> </ion-list>

View File

@ -16,16 +16,18 @@
<latest-blocks [numBlocks]="6" [showTimeAs]="'age'" [showAllBlocksButton]="true"></latest-blocks> <latest-blocks [numBlocks]="6" [showTimeAs]="'age'" [showAllBlocksButton]="true"></latest-blocks>
</div> </div>
<!--
<div> <div>
<h1>Latest Transactions</h1> <h1>Latest Transactions</h1>
<latest-transactions [refreshSeconds]="8"></latest-transactions> <latest-transactions [refreshSeconds]="8"></latest-transactions>
</div> </div>
-->
<div class="about"> <div class="about">
<h2>About</h2> <h2>About</h2>
<p><strong>insight</strong> is an <a href="https://insight.is/" <p><strong>insight</strong> is an <a href="https://insight.is/"
target="_blank">open-source Bitcoin blockchain explorer</a> with complete REST and websocket APIs that can be used for writing web wallets and other apps that need more advanced blockchain queries than provided by bitcoind RPC. Check out the <a href="https://github.com/bitpay/insight-ui" target="_blank">source code</a>.</p> target="_blank">open-source Bitcoin blockchain explorer</a> with complete REST and websocket APIs that can be used for writing web wallets and other apps that need more advanced blockchain queries than provided by bitcoind RPC. Check out the <a href="https://github.com/bitpay/insight-ui" target="_blank">source code</a>.</p>
<p><strong>insight</strong> is still in development, so be sure to report any bugs and provide feedback for improvement at our <a href="https://github.com/bitpay/insight-ui/issues" target="_blank">github issue tracker</a>.</p> <p><strong>insight</strong> is still in development, so be sure to report any bugs and provide feedback for improvement at our <a href="https://github.com/bitpay/insight/issues" target="_blank">github issue tracker</a>.</p>
<div id="powered" class="row"> <div id="powered" class="row">
<div class="powered-text"> <div class="powered-text">
<small class="text-muted">Powered by</small> <small class="text-muted">Powered by</small>

View File

@ -13,30 +13,30 @@
<h2>Summary</h2> <h2>Summary</h2>
<ion-list class="summary"> <ion-list class="list--summary">
<ion-item> <ion-item>
Size Size
<span item-end> <ion-note item-end>
{{ tx.size }} (bytes) {{ tx.size }} (bytes)
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Received Time Received Time
<span item-end> <ion-note item-end>
{{ tx.time * 1000 | date:'medium' }} {{ tx.time * 1000 | date:'medium' }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Mined Time Mined Time
<span item-end> <ion-note item-end>
{{ tx.blocktime * 1000 | date:'medium' }} {{ tx.blocktime * 1000 | date:'medium' }}
</span> </ion-note>
</ion-item> </ion-item>
<ion-item> <ion-item>
Included in Block Included in Block
<span item-end> <ion-note item-end>
<a (click)="goToBlock(tx.blockhash)">{{ tx.blockhash }}</a> <a (click)="goToBlock(tx.blockhash)">{{ tx.blockhash }}</a>
</span> </ion-note>
</ion-item> </ion-item>
</ion-list> </ion-list>

View File

@ -16,10 +16,11 @@ export class CurrencyProvider {
public currencySymbol: string; public currencySymbol: string;
public factor: number = 1; public factor: number = 1;
private bitstamp: number; private bitstamp: number;
private kraken: number;
private loading: boolean; private loading: boolean;
constructor(public http: Http, private api: ApiProvider) { constructor(public http: Http, private api: ApiProvider) {
this.defaultCurrency = 'BTC'; this.defaultCurrency = 'BCH';
this.currencySymbol = this.defaultCurrency; this.currencySymbol = this.defaultCurrency;
} }
@ -27,6 +28,30 @@ export class CurrencyProvider {
return Math.round(aFloat * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces); return Math.round(aFloat * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces);
} }
public getConvertedNumber(value: number): number {
if (value === 0.00000000) return 0;
let response: number;
if (this.currencySymbol === 'USD') {
response = this.roundFloat((value * this.factor), 2);
} else if (this.currencySymbol === 'm' + this.defaultCurrency) {
this.factor = 1000;
response = this.roundFloat((value * this.factor), 5);
} else if (this.currencySymbol === 'bits') {
this.factor = 1000000;
response = this.roundFloat((value * this.factor), 2);
} else {
this.factor = 1;
response = this.roundFloat((value * this.factor), 8);
}
return response;
}
/**
* @deprecated use getConvertedNumber
*/
public getConversion(value: number): string { public getConversion(value: number): string {
if (value === 0.00000000) return '0 ' + this.currencySymbol; // fix value to show if (value === 0.00000000) return '0 ' + this.currencySymbol; // fix value to show
@ -34,13 +59,13 @@ export class CurrencyProvider {
if (this.currencySymbol === 'USD') { if (this.currencySymbol === 'USD') {
response = this.roundFloat((value * this.factor), 2); response = this.roundFloat((value * this.factor), 2);
} else if (this.currencySymbol === 'mBTC') { } else if (this.currencySymbol === 'm' + this.defaultCurrency) {
this.factor = 1000; this.factor = 1000;
response = this.roundFloat((value * this.factor), 5); response = this.roundFloat((value * this.factor), 5);
} else if (this.currencySymbol === 'bits') { } else if (this.currencySymbol === 'bits') {
this.factor = 1000000; this.factor = 1000000;
response = this.roundFloat((value * this.factor), 2); response = this.roundFloat((value * this.factor), 2);
} else { // assumes currencySymbol is BTC } else {
this.factor = 1; this.factor = 1;
response = this.roundFloat((value * this.factor), 8); response = this.roundFloat((value * this.factor), 8);
} }
@ -56,7 +81,11 @@ export class CurrencyProvider {
this.http.get(this.api.apiPrefix + 'currency').subscribe( this.http.get(this.api.apiPrefix + 'currency').subscribe(
(data) => { (data) => {
let currencyParsed: any = JSON.parse(data['_body']); let currencyParsed: any = JSON.parse(data['_body']);
this.factor = this.bitstamp = currencyParsed.data.bitstamp; if (currencyParsed.data.bitstamp) {
this.factor = this.bitstamp = currencyParsed.data.bitstamp;
} else if (currencyParsed.data.kraken) {
this.factor = this.kraken = currencyParsed.data.kraken;
}
this.loading = false; this.loading = false;
}, },
(err) => { (err) => {
@ -64,7 +93,7 @@ export class CurrencyProvider {
this.loading = false; this.loading = false;
} }
); );
} else if (currency === 'mBTC') { } else if (currency === 'm' + this.defaultCurrency) {
this.factor = 1000; this.factor = 1000;
} else if (currency === 'bits') { } else if (currency === 'bits') {
this.factor = 1000000; this.factor = 1000000;