Skip to content

Commit 318300d

Browse files
authored
Merge pull request bitpay#2057 from rastajpa/feat/migration
[insight-previous] FEAT: Migration to Angular 5
2 parents c5db7a4 + c480718 commit 318300d

File tree

23 files changed

+10878
-10869
lines changed

23 files changed

+10878
-10869
lines changed

packages/insight-previous/package-lock.json

Lines changed: 10701 additions & 10674 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/insight-previous/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838
"fix:tslint": "tslint --type-check --fix --project ."
3939
},
4040
"dependencies": {
41-
"@angular/common": "4.4.7",
42-
"@angular/compiler": "4.4.7",
43-
"@angular/core": "4.4.7",
44-
"@angular/forms": "4.4.7",
45-
"@angular/http": "4.4.7",
46-
"@angular/platform-browser": "4.4.7",
47-
"@angular/platform-browser-dynamic": "4.4.7",
48-
"angular2-moment": "1.6.0",
41+
"@angular/common": "5.2.10",
42+
"@angular/compiler": "5.2.10",
43+
"@angular/core": "5.2.10",
44+
"@angular/forms": "5.2.10",
45+
"@angular/http": "5.2.10",
46+
"@angular/platform-browser": "5.2.10",
47+
"@angular/platform-browser-dynamic": "5.2.10",
48+
"angular2-moment": "1.7.1",
4949
"angular2-qrcode": "2.0.1",
5050
"bitcore-lib": "8.1.0",
5151
"bitcore-lib-cash": "8.1.0",
@@ -56,9 +56,9 @@
5656
"zone.js": "0.8.12"
5757
},
5858
"devDependencies": {
59-
"@angular/cli": "^1.7.4",
60-
"@angular/compiler-cli": "4.4.7",
61-
"@ionic/app-scripts": "3.2.1",
59+
"@angular/cli": "7.3.4",
60+
"@angular/compiler-cli": "5.2.10",
61+
"@ionic/app-scripts": "3.2.3",
6262
"@types/jasmine": "2.5.41",
6363
"@types/lodash": "4.14.104",
6464
"@types/node": "7.0.4",
@@ -73,7 +73,7 @@
7373
"karma-jasmine-html-reporter": "0.2.2",
7474
"prettier": "^1.15.3",
7575
"serve": "^10.1.1",
76-
"serve-static": "1.12.3",
76+
"serve-static": "1.13.2",
7777
"ts-node": "3.0.4",
7878
"tslint": "5.3.2",
7979
"tslint-angular": "^1.1.2",

packages/insight-previous/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { HttpClientModule } from '@angular/common/http';
12
import { ErrorHandler, NgModule } from '@angular/core';
2-
import { HttpModule } from '@angular/http';
33
import { BrowserModule } from '@angular/platform-browser';
44
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
55
import { BlocksPage, HomePage, PagesModule } from '../pages';
@@ -19,7 +19,7 @@ import { InsightApp } from './app.component';
1919
declarations: [InsightApp],
2020
imports: [
2121
BrowserModule,
22-
HttpModule,
22+
HttpClientModule,
2323
PagesModule,
2424
IonicModule.forRoot(InsightApp, {
2525
mode: 'md',

packages/insight-previous/src/components/denomination/denomination.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class DenominationComponent {
2121
public ionViewDidLoad() {
2222
this.currencySymbol = this.navParams.data.currencySymbol;
2323
this.api.getAvailableNetworks().subscribe(data => {
24-
this.availableNetworks = data.json() as ChainNetwork[];
24+
this.availableNetworks = data;
2525
this.showUnits = _.some(
2626
this.availableNetworks,
2727
this.api.networkSettings.value.selectedNetwork

packages/insight-previous/src/components/latest-blocks/latest-blocks.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, Input, NgZone, OnDestroy, OnInit } from '@angular/core';
22
import { Subscription } from 'rxjs';
33
import { ApiProvider } from '../../providers/api/api';
4-
import { BlocksProvider } from '../../providers/blocks/blocks';
4+
import { AppBlock, BlocksProvider } from '../../providers/blocks/blocks';
55
import { CurrencyProvider } from '../../providers/currency/currency';
66
import { DefaultProvider } from '../../providers/default/default';
77
import { Logger } from '../../providers/logger/logger';
@@ -12,8 +12,6 @@ import { RedirProvider } from '../../providers/redir/redir';
1212
templateUrl: 'latest-blocks.html'
1313
})
1414
export class LatestBlocksComponent implements OnInit, OnDestroy {
15-
public loading = true;
16-
public blocks: any[] = [];
1715
@Input()
1816
public numBlocks: number;
1917
@Input()
@@ -22,19 +20,21 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
2220
public showLoadMoreButton = false;
2321
@Input()
2422
public showTimeAs: string;
25-
private reloadInterval: any;
26-
23+
public loading = true;
24+
public blocks: AppBlock[] = [];
2725
public subscriber: Subscription;
2826
public errorMessage: string;
2927

28+
private reloadInterval: any;
29+
3030
constructor(
31+
public currency: CurrencyProvider,
32+
public defaults: DefaultProvider,
33+
public redirProvider: RedirProvider,
3134
private blocksProvider: BlocksProvider,
3235
private apiProvider: ApiProvider,
3336
private ngZone: NgZone,
34-
public currency: CurrencyProvider,
35-
public defaults: DefaultProvider,
36-
private logger: Logger,
37-
public redirProvider: RedirProvider
37+
private logger: Logger
3838
) {
3939
this.numBlocks = parseInt(defaults.getDefault('%NUM_BLOCKS%'), 10);
4040
}
@@ -53,15 +53,18 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
5353

5454
private loadBlocks(): void {
5555
this.subscriber = this.blocksProvider.getBlocks(this.numBlocks).subscribe(
56-
({ blocks }) => {
56+
response => {
57+
const blocks = response.map(block =>
58+
this.blocksProvider.toAppBlock(block)
59+
);
5760
this.blocks = blocks;
5861
this.loading = false;
5962
},
6063
err => {
6164
this.subscriber.unsubscribe();
6265
clearInterval(this.reloadInterval);
63-
this.logger.error(err._body);
64-
this.errorMessage = err;
66+
this.logger.error(err.message);
67+
this.errorMessage = err.message;
6568
this.loading = false;
6669
}
6770
);
@@ -72,14 +75,17 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
7275
const since: number =
7376
this.blocks.length > 0 ? this.blocks[this.blocks.length - 1].height : 0;
7477
return this.blocksProvider.pageBlocks(since, this.numBlocks).subscribe(
75-
({ blocks }) => {
78+
response => {
79+
const blocks = response.map(block =>
80+
this.blocksProvider.toAppBlock(block)
81+
);
7682
this.blocks = this.blocks.concat(blocks);
7783
this.loading = false;
7884
infiniteScroll.complete();
7985
},
8086
err => {
81-
this.logger.error(err);
82-
this.errorMessage = err;
87+
this.logger.error(err.message);
88+
this.errorMessage = err.message;
8389
this.loading = false;
8490
}
8591
);
@@ -93,10 +99,6 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
9399
});
94100
}
95101

96-
public getBlocks(): any[] {
97-
return this.blocks;
98-
}
99-
100102
public goToBlocks(): void {
101103
this.redirProvider.redir('blocks', {
102104
chain: this.apiProvider.networkSettings.value.selectedNetwork.chain,

packages/insight-previous/src/components/latest-transactions/latest-transactions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { HttpClient } from '@angular/common/http';
12
import { Component, Input, NgZone, OnChanges } from '@angular/core';
2-
import { Http } from '@angular/http';
33
import { ApiProvider } from '../../providers/api/api';
44
import { CurrencyProvider } from '../../providers/currency/currency';
55
import { Logger } from '../../providers/logger/logger';
@@ -17,7 +17,7 @@ export class LatestTransactionsComponent implements OnChanges {
1717
private transactions = [];
1818

1919
constructor(
20-
private http: Http,
20+
private httpClient: HttpClient,
2121
private apiProvider: ApiProvider,
2222
public currency: CurrencyProvider,
2323
private ngZone: NgZone,
@@ -44,7 +44,7 @@ export class LatestTransactionsComponent implements OnChanges {
4444
private loadTransactions(): void {
4545
const url: string = this.apiProvider.getUrl() + 'txs';
4646

47-
this.http.get(url).subscribe(
47+
this.httpClient.get(url).subscribe(
4848
(data: any) => {
4949
this.transactions = JSON.parse(data._body);
5050
this.loading = false;

packages/insight-previous/src/components/transaction-list/transaction-list.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export class TransactionListComponent implements OnInit {
1616
public queryValue?: string;
1717
@Input()
1818
public transactions?: any = [];
19-
2019
public limit = 10;
2120
public chunkSize = 100;
2221

@@ -25,9 +24,10 @@ export class TransactionListComponent implements OnInit {
2524
public ngOnInit(): void {
2625
if (this.transactions && this.transactions.length === 0) {
2726
this.txProvider.getTxs({ [this.queryType]: this.queryValue }).subscribe(
28-
data => {
27+
response => {
2928
// Newly Generated Coins (Coinbase) First
30-
const sortedTxs = _.sortBy(data.txs, (tx: any) => {
29+
const txs = response.map(tx => this.txProvider.toAppTx(tx));
30+
const sortedTxs = _.sortBy(txs, (tx: any) => {
3131
return tx.isCoinBase ? 0 : 1;
3232
});
3333
this.transactions = sortedTxs;

packages/insight-previous/src/components/transaction/transaction.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767

6868
<div class="ellipsis">
6969
<p>
70-
<a (click)="goToAddress(vin.address)">{{ vin.address }}</a>
70+
<a (click)="goToAddress(vin.address)"
71+
[ngClass]="{'disabled-link': getAddress(vin) === 'Unparsed address' }">{{ getAddress(vin) }}</a>
7172
</p>
7273
</div>
7374
<div [hidden]="!expanded">

packages/insight-previous/src/components/transaction/transaction.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ import {
1919
templateUrl: 'transaction.html'
2020
})
2121
export class TransactionComponent implements OnInit {
22-
private COIN = 100000000;
23-
2422
public expanded = false;
2523
@Input()
2624
public tx: any = {};
2725
@Input()
2826
public showCoins = false;
2927
public confirmations: number;
3028

29+
private COIN = 100000000;
30+
3131
constructor(
3232
public currencyProvider: CurrencyProvider,
3333
public apiProvider: ApiProvider,
@@ -50,18 +50,20 @@ export class TransactionComponent implements OnInit {
5050
});
5151
}
5252

53-
public getAddress(vout: ApiCoin): string {
54-
if (vout.address === 'false') {
53+
public getAddress(v: ApiCoin): string {
54+
if (v.address === 'false') {
5555
return 'Unparsed address';
5656
}
5757

58-
return vout.address;
58+
return v.address;
5959
}
6060

6161
public getConfirmations() {
6262
this.txProvider
6363
.getConfirmations(this.tx.blockheight)
64-
.subscribe(confirmations => (this.confirmations = confirmations));
64+
.subscribe(confirmations => {
65+
this.confirmations = confirmations;
66+
});
6567
}
6668

6769
public goToTx(txId: string, vout?: number, fromVout?: boolean): void {

packages/insight-previous/src/pages/address/address.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ import { TxsProvider } from '../../providers/transactions/transactions';
1919
})
2020
export class AddressPage {
2121
public loading = true;
22-
private addrStr: string;
23-
private chainNetwork: ChainNetwork;
2422
public address: any = {};
2523
public nroTransactions = 0;
2624
public errorMessage: string;
2725

26+
private addrStr: string;
27+
private chainNetwork: ChainNetwork;
28+
2829
constructor(
2930
public navParams: NavParams,
3031
public currencyProvider: CurrencyProvider,
@@ -67,8 +68,8 @@ export class AddressPage {
6768
this.loading = false;
6869
},
6970
err => {
70-
this.logger.error(err);
71-
this.errorMessage = err;
71+
this.logger.error(err.message);
72+
this.errorMessage = err.message;
7273
this.loading = false;
7374
}
7475
);

0 commit comments

Comments
 (0)