diff --git a/app/src/app/app.module.ts b/app/src/app/app.module.ts index 8e5cca9..ca547f3 100644 --- a/app/src/app/app.module.ts +++ b/app/src/app/app.module.ts @@ -7,6 +7,7 @@ import { SplashScreen } from '@ionic-native/splash-screen'; import { InsightApp } from './app.component'; import { PagesModule, BlocksPage, BroadcastTxPage, NodeStatusPage, VerifyMessagePage } from '../pages'; import { BlocksService, StorageService } from '../services'; +import { ApiProvider } from '../providers/api/api'; @NgModule({ declarations: [ @@ -31,7 +32,8 @@ import { BlocksService, StorageService } from '../services'; SplashScreen, StorageService, BlocksService, - {provide: ErrorHandler, useClass: IonicErrorHandler} + {provide: ErrorHandler, useClass: IonicErrorHandler}, + ApiProvider ] }) diff --git a/app/src/components/transaction-list/transaction-list.html b/app/src/components/transaction-list/transaction-list.html index 69d901b..6620fc2 100644 --- a/app/src/components/transaction-list/transaction-list.html +++ b/app/src/components/transaction-list/transaction-list.html @@ -1,5 +1,7 @@ -
-
- -
-
+ + + + + + + diff --git a/app/src/components/transaction-list/transaction-list.ts b/app/src/components/transaction-list/transaction-list.ts index 8a8940c..cd7b235 100644 --- a/app/src/components/transaction-list/transaction-list.ts +++ b/app/src/components/transaction-list/transaction-list.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { Input } from '@angular/core'; import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; /** * Generated class for the TransactionListComponent component. @@ -19,13 +20,11 @@ export class TransactionListComponent { @Input() public queryValue: string; public transactions: any = []; - constructor(private http: Http) { + constructor(private http: Http, private api: ApiProvider) { } private ngOnInit(): void { - let apiPrefix: string = 'http://localhost:3001/insight-api/'; - - let url: string = apiPrefix + 'txs?' + this.queryType + '=' + this.queryValue; + let url: string = this.api.apiPrefix + 'txs?' + this.queryType + '=' + this.queryValue; this.http.get(url).subscribe( (data) => { diff --git a/app/src/components/transaction/transaction.html b/app/src/components/transaction/transaction.html index 715f017..1e31754 100644 --- a/app/src/components/transaction/transaction.html +++ b/app/src/components/transaction/transaction.html @@ -1,46 +1,57 @@ -
-

{{ tx.txid }}

-
- first seen at - -
-
- mined - -
- -
-
-
- No Inputs (Newly Generated Coins) + + + + {{ tx.txid }} + + +
+ first seen at +
-
- -
- > -
- -
-
-

{{ getAddress(vout) }} {{ vout.value + ' BTC' }} (S)(U)

+
+ mined +
-
-
+ + -
-
- -

{{ vin.value + ' BTC' }}

-
- -
- > -
- -
-
-

{{ getAddress(vout) }} {{ vout.value + ' BTC' }} (S)(U)

+ + +
+
+
+ No Inputs (Newly Generated Coins) +
+
-
-
-
+ +
+
+ +

{{ vin.value + ' BTC' }}

+
+
+ + +
+ > +
+
+ +
+
+

{{ getAddress(vout) }} {{ vout.value + ' BTC' }} (S)(U)

+
+
+
+ + + + + Fee + + + Confirmations + + + diff --git a/app/src/pages/address/address.html b/app/src/pages/address/address.html index 8c0d204..7399a57 100644 --- a/app/src/pages/address/address.html +++ b/app/src/pages/address/address.html @@ -49,5 +49,5 @@ - + diff --git a/app/src/pages/address/address.ts b/app/src/pages/address/address.ts index 453678c..e392a33 100644 --- a/app/src/pages/address/address.ts +++ b/app/src/pages/address/address.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; /** * Generated class for the AddressPage page. @@ -22,14 +23,12 @@ export class AddressPage { private addrStr: string; public address: any = {}; - constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http) { + constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http, private api: ApiProvider) { this.addrStr = navParams.get('addrStr'); } public ionViewDidLoad(): void { - let apiPrefix: string = 'http://localhost:3001/insight-api/'; - - this.http.get(apiPrefix + 'addr/' + this.addrStr + '/?noTxList=1').subscribe( + this.http.get(this.api.apiPrefix + 'addr/' + this.addrStr + '/?noTxList=1').subscribe( (data) => { this.address = JSON.parse(data['_body']); this.loading = false; diff --git a/app/src/pages/block-detail/block-detail.ts b/app/src/pages/block-detail/block-detail.ts index bcd5983..66053d5 100644 --- a/app/src/pages/block-detail/block-detail.ts +++ b/app/src/pages/block-detail/block-detail.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; /** * Generated class for the BlockDetailPage page. @@ -24,12 +25,10 @@ export class BlockDetailPage { tx: [] }; - constructor(public navCtrl: NavController, private http: Http, public navParams: NavParams) { + constructor(public navCtrl: NavController, private http: Http, public navParams: NavParams, private api: ApiProvider) { this.blockHash = navParams.get('blockHash'); - let apiPrefix: string = 'http://localhost:3001/insight-api/'; - - this.http.get(apiPrefix + 'block/' + this.blockHash).subscribe( + this.http.get(this.api.apiPrefix + 'block/' + this.blockHash).subscribe( (data) => { this.block = JSON.parse(data['_body']); this.loading = false; diff --git a/app/src/pages/blocksPage/blocksPage.ts b/app/src/pages/blocksPage/blocksPage.ts index cd06daf..4d5bd44 100644 --- a/app/src/pages/blocksPage/blocksPage.ts +++ b/app/src/pages/blocksPage/blocksPage.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; import { Block } from '../../models'; import { BlocksService } from '../../services'; import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; @Component({ templateUrl: './blocksPage.html' @@ -17,7 +18,7 @@ export class BlocksPage { public q: string; public badQuery: boolean = false; - constructor(private navCtrl: NavController, private http: Http, private blocksService: BlocksService) { + constructor(private navCtrl: NavController, private http: Http, private blocksService: BlocksService, private api: ApiProvider) { this.title = 'Blocks'; this.blocks = blocksService.latestBlocks; // this.blocks.subscribe((blocks) => { @@ -27,8 +28,8 @@ export class BlocksPage { } public search(): void { - console.log('q is', this.q); - let apiPrefix: string = 'http://localhost:3001/insight-api/'; + let apiPrefix: string = this.api.apiPrefix; + this.http.get(apiPrefix + 'block/' + this.q).subscribe( (data) => { this.resetSearch(); diff --git a/app/src/pages/transaction/transaction.ts b/app/src/pages/transaction/transaction.ts index 37c4b74..8e817ea 100644 --- a/app/src/pages/transaction/transaction.ts +++ b/app/src/pages/transaction/transaction.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; /** * Generated class for the TransactionPage page. @@ -22,14 +23,12 @@ export class TransactionPage { private txId: string; public tx: any = {}; - constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http) { + constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http, private api: ApiProvider) { this.txId = navParams.get('txId'); } public ionViewDidLoad(): void { - let apiPrefix: string = 'http://localhost:3001/insight-api/'; - - this.http.get(apiPrefix + 'tx/' + this.txId).subscribe( + this.http.get(this.api.apiPrefix + 'tx/' + this.txId).subscribe( (data) => { this.tx = JSON.parse(data['_body']); console.log('tx', this.tx); diff --git a/app/src/providers/api/api.ts b/app/src/providers/api/api.ts new file mode 100644 index 0000000..31c1966 --- /dev/null +++ b/app/src/providers/api/api.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@angular/core'; +import { Http } from '@angular/http'; +import 'rxjs/add/operator/map'; + +/* + Generated class for the ApiProvider provider. + + See https://angular.io/docs/ts/latest/guide/dependency-injection.html + for more info on providers and Angular DI. +*/ +@Injectable() +export class ApiProvider { + + public apiPrefix: string = 'http://localhost:3001/insight-api/'; + + constructor(public http: Http) { + } + +}