From 1fc35956cb3e7ec22356f05410d8286879313175 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 10 Aug 2017 16:12:06 -0400 Subject: [PATCH 1/9] style the summary items and labels --- app/src/app/app.scss | 10 ++++++++++ app/src/components/transaction/transaction.html | 6 +++--- app/src/pages/address/address.html | 2 +- app/src/pages/block-detail/block-detail.html | 4 ++-- app/src/pages/transaction/transaction.html | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/app/app.scss b/app/src/app/app.scss index 553250e..6e2f3a9 100644 --- a/app/src/app/app.scss +++ b/app/src/app/app.scss @@ -15,6 +15,16 @@ white-space: nowrap; } +.summary ion-label { + color: #333; + font-weight: bold; +} + +.summary ion-item { + color: #999; + font-size: 1.4rem; +} + // Shared Sass variables, which can be used to adjust Ionic's // default Sass variables, belong in "theme/variables.scss". // diff --git a/app/src/components/transaction/transaction.html b/app/src/components/transaction/transaction.html index ca9b1e8..39020c5 100644 --- a/app/src/components/transaction/transaction.html +++ b/app/src/components/transaction/transaction.html @@ -31,7 +31,7 @@

{{ vin.addr }} {{ vin.value + ' BTC' }}

-

Confirmations {{vin.confirmations}}

+

Confirmations {{vin.confirmations}}

scriptSig

@@ -44,10 +44,10 @@ - + - +
diff --git a/app/src/pages/address/address.html b/app/src/pages/address/address.html index 9e441f5..d70fc96 100644 --- a/app/src/pages/address/address.html +++ b/app/src/pages/address/address.html @@ -9,7 +9,7 @@

Summary

- + Total Received diff --git a/app/src/pages/block-detail/block-detail.html b/app/src/pages/block-detail/block-detail.html index 354ef77..fcd94f6 100644 --- a/app/src/pages/block-detail/block-detail.html +++ b/app/src/pages/block-detail/block-detail.html @@ -8,9 +8,9 @@

Summary

- + - Number of Transactions + Number of Transactions {{ block.tx.length }} diff --git a/app/src/pages/transaction/transaction.html b/app/src/pages/transaction/transaction.html index 26a1663..bed9bd1 100644 --- a/app/src/pages/transaction/transaction.html +++ b/app/src/pages/transaction/transaction.html @@ -8,7 +8,7 @@

Summary

- + Size From 5a551a5e3ba5dbdad74f7403e12baaf3a1c4603e Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 10 Aug 2017 17:19:31 -0400 Subject: [PATCH 2/9] add currency conversion button and action sheet --- app/src/app/app.module.ts | 4 +- app/src/components/head-nav/head-nav.html | 3 ++ app/src/components/head-nav/head-nav.ts | 48 +++++++++++++++++++- app/src/pages/block-detail/block-detail.html | 2 +- app/src/pages/block-detail/block-detail.ts | 3 +- 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/app/src/app/app.module.ts b/app/src/app/app.module.ts index ca547f3..c0b673b 100644 --- a/app/src/app/app.module.ts +++ b/app/src/app/app.module.ts @@ -8,6 +8,7 @@ import { InsightApp } from './app.component'; import { PagesModule, BlocksPage, BroadcastTxPage, NodeStatusPage, VerifyMessagePage } from '../pages'; import { BlocksService, StorageService } from '../services'; import { ApiProvider } from '../providers/api/api'; +import { CurrencyProvider } from '../providers/currency/currency'; @NgModule({ declarations: [ @@ -33,7 +34,8 @@ import { ApiProvider } from '../providers/api/api'; StorageService, BlocksService, {provide: ErrorHandler, useClass: IonicErrorHandler}, - ApiProvider + ApiProvider, + CurrencyProvider ] }) diff --git a/app/src/components/head-nav/head-nav.html b/app/src/components/head-nav/head-nav.html index b441164..e7f73fd 100644 --- a/app/src/components/head-nav/head-nav.html +++ b/app/src/components/head-nav/head-nav.html @@ -4,6 +4,9 @@ {{title}} + diff --git a/app/src/components/head-nav/head-nav.ts b/app/src/components/head-nav/head-nav.ts index 54fee4c..b38b01c 100644 --- a/app/src/components/head-nav/head-nav.ts +++ b/app/src/components/head-nav/head-nav.ts @@ -3,6 +3,8 @@ import { Input } from '@angular/core'; import { NavController } from 'ionic-angular'; import { Http } from '@angular/http'; import { ApiProvider } from '../../providers/api/api'; +import { CurrencyProvider } from '../../providers/currency/currency'; +import { ActionSheetController } from 'ionic-angular'; /** * Generated class for the HeadNavComponent component. @@ -21,7 +23,7 @@ export class HeadNavComponent { public q: string; public badQuery: boolean = false; - constructor(private navCtrl: NavController, private http: Http, private api: ApiProvider) { + constructor(private navCtrl: NavController, private http: Http, private api: ApiProvider, public currency: CurrencyProvider, public actionSheetCtrl: ActionSheetController) { } private resetSearch(): void { @@ -98,4 +100,48 @@ export class HeadNavComponent { }; /* tslint:enable:no-unused-variable */ + public changeCurrency() { + console.log('changeCurrency'); + this.presentActionSheet(); + } + + presentActionSheet() { + let actionSheet = this.actionSheetCtrl.create({ + title: 'Change Currency', + buttons: [ + { + text: 'USD', + handler: () => { + this.currency.setCurrency('USD'); + } + }, + { + text: 'BTC', + handler: () => { + this.currency.setCurrency('BTC'); + } + }, + { + text: 'mBTC', + handler: () => { + this.currency.setCurrency('mBTC'); + } + }, + { + text: 'bits', + handler: () => { + this.currency.setCurrency('bits'); + } + }, + { + text: 'Cancel', + role: 'cancel', + handler: () => { + console.log('Cancel clicked'); + } + } + ] + }); + actionSheet.present(); + } } diff --git a/app/src/pages/block-detail/block-detail.html b/app/src/pages/block-detail/block-detail.html index fcd94f6..daa0444 100644 --- a/app/src/pages/block-detail/block-detail.html +++ b/app/src/pages/block-detail/block-detail.html @@ -24,7 +24,7 @@ Block Reward - {{ block.reward + ' BTC' }} + {{ currency.getConversion(block.reward) }} diff --git a/app/src/pages/block-detail/block-detail.ts b/app/src/pages/block-detail/block-detail.ts index 66053d5..fb3b333 100644 --- a/app/src/pages/block-detail/block-detail.ts +++ b/app/src/pages/block-detail/block-detail.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 BlockDetailPage page. @@ -25,7 +26,7 @@ export class BlockDetailPage { tx: [] }; - constructor(public navCtrl: NavController, private http: Http, public navParams: NavParams, private api: ApiProvider) { + constructor(public navCtrl: NavController, private http: Http, public navParams: NavParams, private api: ApiProvider, public currency: CurrencyProvider) { this.blockHash = navParams.get('blockHash'); this.http.get(this.api.apiPrefix + 'block/' + this.blockHash).subscribe( From ac656802c96a363a7b29951c4d3760184aac77ad Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 10 Aug 2017 17:30:46 -0400 Subject: [PATCH 3/9] fixed lint warnings; renamed action sheet title --- app/src/components/head-nav/head-nav.ts | 32 ++++++++++--------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/app/src/components/head-nav/head-nav.ts b/app/src/components/head-nav/head-nav.ts index b38b01c..5333728 100644 --- a/app/src/components/head-nav/head-nav.ts +++ b/app/src/components/head-nav/head-nav.ts @@ -26,16 +26,11 @@ export class HeadNavComponent { constructor(private navCtrl: NavController, private http: Http, private api: ApiProvider, public currency: CurrencyProvider, public actionSheetCtrl: ActionSheetController) { } - private resetSearch(): void { - this.q = ''; - this.loading = false; - } - public search(): void { let apiPrefix: string = this.api.apiPrefix; this.http.get(apiPrefix + 'block/' + this.q).subscribe( - function (data: any) { + function (data: any): void { this.resetSearch(); console.log('block', data); let parsedData: any = JSON.parse(data._body); @@ -45,7 +40,7 @@ export class HeadNavComponent { }.bind(this), () => { this.http.get(apiPrefix + 'tx/' + this.q).subscribe( - function (data: any) { + function (data: any): void { this.resetSearch(); console.log('tx', data); let parsedData: any = JSON.parse(data._body); @@ -55,7 +50,7 @@ export class HeadNavComponent { }.bind(this), () => { this.http.get(apiPrefix + 'addr/' + this.q).subscribe( - function (data: any) { + function (data: any): void { this.resetSearch(); console.log('addr', data); let parsedData: any = JSON.parse(data._body); @@ -98,16 +93,16 @@ export class HeadNavComponent { 2000 ); }; + + private resetSearch(): void { + this.q = ''; + this.loading = false; + } /* tslint:enable:no-unused-variable */ - public changeCurrency() { - console.log('changeCurrency'); - this.presentActionSheet(); - } - - presentActionSheet() { - let actionSheet = this.actionSheetCtrl.create({ - title: 'Change Currency', + public changeCurrency(): void { + let actionSheet: any = this.actionSheetCtrl.create({ + title: 'Change Denomination', buttons: [ { text: 'USD', @@ -135,10 +130,7 @@ export class HeadNavComponent { }, { text: 'Cancel', - role: 'cancel', - handler: () => { - console.log('Cancel clicked'); - } + role: 'cancel' } ] }); From db5bf4420a5049ba310d271054e397f64f3e4be5 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 10 Aug 2017 17:35:17 -0400 Subject: [PATCH 4/9] fixed e2e tests by adding provider dependencies --- app/src/test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/test.ts b/app/src/test.ts index 5a0cc78..c317506 100644 --- a/app/src/test.ts +++ b/app/src/test.ts @@ -17,7 +17,9 @@ import { ConfigMock, PlatformMock } from './mocks'; import { BlocksServiceMock } from './services/mocks'; import { BlocksService } from './services'; import { ApiProvider } from './providers/api/api'; +import { CurrencyProvider } from './providers/currency/currency'; import { HeadNavComponentModule } from './components/head-nav/head-nav.module'; +import { ActionSheetController } from 'ionic-angular'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; @@ -63,7 +65,9 @@ export class TestUtils { {provide: Platform, useClass: PlatformMock}, {provide: Config, useClass: ConfigMock}, {provide: BlocksService, useClass: BlocksServiceMock}, - ApiProvider + ApiProvider, + CurrencyProvider, + ActionSheetController ], imports: [ FormsModule, From 3bc5959075516234d897a849d4047816f64f9c3f Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 10 Aug 2017 17:44:51 -0400 Subject: [PATCH 5/9] Added currency conversion to transaction component --- app/src/components/transaction/transaction.html | 8 ++++---- app/src/components/transaction/transaction.ts | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/components/transaction/transaction.html b/app/src/components/transaction/transaction.html index 39020c5..75cc9b4 100644 --- a/app/src/components/transaction/transaction.html +++ b/app/src/components/transaction/transaction.html @@ -29,7 +29,7 @@
-

{{ vin.addr }} {{ vin.value + ' BTC' }}

+

{{ vin.addr }} {{ currency.getConversion(vin.value) }}

Confirmations {{vin.confirmations}}

scriptSig

@@ -62,7 +62,7 @@
- {{ vout.value + ' BTC' }} + {{ currency.getConversion(vout.value) }} (S) (U)
@@ -73,11 +73,11 @@ - Fee {{ tx.fees + ' BTC' }} + Fee {{ currency.getConversion(tx.fees) }} {{ tx.confirmations }} Confirmations - {{ tx.valueOut + ' BTC' }} + {{ currency.getConversion(tx.valueOut) }} diff --git a/app/src/components/transaction/transaction.ts b/app/src/components/transaction/transaction.ts index 074ee97..b01a7bb 100644 --- a/app/src/components/transaction/transaction.ts +++ b/app/src/components/transaction/transaction.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { Input } from '@angular/core'; import { NavController } from 'ionic-angular'; +import { CurrencyProvider } from '../../providers/currency/currency'; /** * Generated class for the TransactionComponent component. @@ -17,7 +18,7 @@ export class TransactionComponent { public expanded: boolean = false; @Input() public tx: any = {}; - constructor(private navCtrl: NavController) { + constructor(private navCtrl: NavController, public currency: CurrencyProvider) { } public getAddress(vout: any): string { From 8ba0a0777262c21cb59d03fe18b6f3fa39e4c871 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 10 Aug 2017 17:48:48 -0400 Subject: [PATCH 6/9] fixed tslint issues --- app/src/components/head-nav/head-nav.module.ts | 4 ++-- app/src/providers/currency/currency.spec.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/components/head-nav/head-nav.module.ts b/app/src/components/head-nav/head-nav.module.ts index 7fb2c00..96140da 100644 --- a/app/src/components/head-nav/head-nav.module.ts +++ b/app/src/components/head-nav/head-nav.module.ts @@ -4,10 +4,10 @@ import { HeadNavComponent } from './head-nav'; @NgModule({ declarations: [ - HeadNavComponent, + HeadNavComponent ], imports: [ - IonicModule, + IonicModule ], exports: [ HeadNavComponent diff --git a/app/src/providers/currency/currency.spec.ts b/app/src/providers/currency/currency.spec.ts index d1ef863..2170c01 100644 --- a/app/src/providers/currency/currency.spec.ts +++ b/app/src/providers/currency/currency.spec.ts @@ -4,7 +4,7 @@ import { HttpModule } from '@angular/http'; import { CurrencyProvider } from './currency'; describe('CurrencyProvider', () => { - let currency; + let currency: CurrencyProvider; beforeEach(() => { TestBed.configureTestingModule({ @@ -47,7 +47,7 @@ describe('CurrencyProvider', () => { }); it('rounds float using specified number of decimal places', () => { - let aFloat = 4.32943; + let aFloat: number = 4.32943; expect(currency.roundFloat(aFloat, 2)).toBe(4.33); expect(currency.roundFloat(aFloat, 3)).toBe(4.329); @@ -66,7 +66,7 @@ describe('CurrencyProvider', () => { }); it('gets proper conversion after changing currency', () => { - let aFloat = 12345.09876543; + let aFloat: number = 12345.09876543; expect(currency.getConversion(aFloat)).toBe('12345.09876543 BTC'); currency.setCurrency('mBTC'); From 1dfe384271dcd25e4280662faf4e43f01291f409 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 11 Aug 2017 10:33:44 -0400 Subject: [PATCH 7/9] added USD conversion; added conversion to address page --- app/src/pages/address/address.html | 8 ++++---- app/src/pages/address/address.ts | 3 ++- app/src/providers/currency/currency.ts | 22 +++++++++++++++------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/src/pages/address/address.html b/app/src/pages/address/address.html index d70fc96..752120a 100644 --- a/app/src/pages/address/address.html +++ b/app/src/pages/address/address.html @@ -5,7 +5,7 @@

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') { From 2226a2cc18335a72a30d0821657d1b8a0c3e9ea6 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 11 Aug 2017 10:42:34 -0400 Subject: [PATCH 8/9] fixed lint warnings and tests --- app/src/providers/currency/currency.spec.ts | 2 ++ app/src/providers/currency/currency.ts | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/providers/currency/currency.spec.ts b/app/src/providers/currency/currency.spec.ts index 2170c01..02fa17a 100644 --- a/app/src/providers/currency/currency.spec.ts +++ b/app/src/providers/currency/currency.spec.ts @@ -2,6 +2,7 @@ import { TestBed, ComponentFixture, inject } from '@angular/core/testing'; import { HttpModule } from '@angular/http'; import { CurrencyProvider } from './currency'; +import { ApiProvider } from '../api/api'; describe('CurrencyProvider', () => { let currency: CurrencyProvider; @@ -12,6 +13,7 @@ describe('CurrencyProvider', () => { HttpModule ], providers: [ + ApiProvider, CurrencyProvider ] }); diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts index b89d2ff..b3f571b 100644 --- a/app/src/providers/currency/currency.ts +++ b/app/src/providers/currency/currency.ts @@ -12,9 +12,9 @@ import 'rxjs/add/operator/map'; @Injectable() export class CurrencyProvider { - private defaultCurrency: string; - private currencySymbol: string; - private factor: number = 1; + public defaultCurrency: string; + public currencySymbol: string; + public factor: number = 1; private bitstamp: number; private loading: boolean; @@ -23,7 +23,7 @@ export class CurrencyProvider { this.currencySymbol = this.defaultCurrency; } - private roundFloat(aFloat: number, decimalPlaces: number): number { + public roundFloat(aFloat: number, decimalPlaces: number): number { return Math.round(aFloat * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces); } @@ -55,7 +55,7 @@ export class CurrencyProvider { if (currency === 'USD') { this.http.get(this.api.apiPrefix + 'currency').subscribe( (data) => { - let currencyParsed = JSON.parse(data['_body']); + let currencyParsed: any = JSON.parse(data['_body']); this.factor = this.bitstamp = currencyParsed.data.bitstamp; this.loading = false; }, From 34792d5d658eb81b3eb60203c3892a0dd68eff22 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 11 Aug 2017 17:29:29 -0400 Subject: [PATCH 9/9] fixed bug where block detail did not retain data after leaving view and coming back --- app/src/pages/block-detail/block-detail.ts | 6 ++---- app/src/pipes/split/split.ts | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/pages/block-detail/block-detail.ts b/app/src/pages/block-detail/block-detail.ts index fb3b333..95bdaf8 100644 --- a/app/src/pages/block-detail/block-detail.ts +++ b/app/src/pages/block-detail/block-detail.ts @@ -28,7 +28,9 @@ export class BlockDetailPage { constructor(public navCtrl: NavController, private http: Http, public navParams: NavParams, private api: ApiProvider, public currency: CurrencyProvider) { this.blockHash = navParams.get('blockHash'); + } + public ionViewDidLoad(): void { this.http.get(this.api.apiPrefix + 'block/' + this.blockHash).subscribe( (data) => { this.block = JSON.parse(data['_body']); @@ -41,10 +43,6 @@ export class BlockDetailPage { ); } - public ionViewWillLeave(): void { - this.loading = true; - } - public goToPreviousBlock(): void { this.navCtrl.push('block-detail', { 'blockHash': this.block.previousblockhash diff --git a/app/src/pipes/split/split.ts b/app/src/pipes/split/split.ts index ab08efd..1f2e7ca 100644 --- a/app/src/pipes/split/split.ts +++ b/app/src/pipes/split/split.ts @@ -15,7 +15,6 @@ export class SplitPipe implements PipeTransform { */ public transform(value: string, delimiter: string): Array { let array: Array = value.split(delimiter); - console.log('split is', array); return array; } }