Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With or without docker #947

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions app/.docker/docker-insight.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:8.11.1
MAINTAINER SonicWizard
COPY . /var/www
#WORKDIR /var/www

COPY ./.docker/scripts /scripts
RUN chmod +rx /scripts/replace.sh

EXPOSE 8100
ENTRYPOINT ["/scripts/replace.sh"]
5 changes: 5 additions & 0 deletions app/.docker/env/btc.production.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RUN_DIR=/var/www
DEFAULT_CURRENCY=BTC
API_PREFIX=/api
IONIC_PATH=/api
IONIC_PROXY_URL=https://insight.bitpay.com/api
17 changes: 17 additions & 0 deletions app/.docker/scripts/replace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

echo "current directory is $PWD"
echo "run directory is ${RUN_DIR}"
echo "running in..."
cd ${RUN_DIR}
pwd
echo "copying ionic.config.json template..."
cp .docker/templates/ionic.config.json .
npm install
npm rebuild node-sass
npm install -g replace
replace '%DEFAULT_CURRENCY%' ${DEFAULT_CURRENCY} src/providers/currency/currency.ts
replace '%API_PREFIX%' ${API_PREFIX} src/providers/api/api.ts
replace '%IONIC_PATH%' ${IONIC_PATH} ionic.config.json
replace '%IONIC_PROXY_URL%' ${IONIC_PROXY_URL} ionic.config.json
npm start
14 changes: 14 additions & 0 deletions app/.docker/templates/ionic.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "insight",
"app_id": "",
"type": "ionic-angular",
"integrations": {
"cordova": {}
},
"proxies": [
{
"path": "%IONIC_PATH%",
"proxyUrl": "%IONIC_PROXY_URL%"
}
]
}
3 changes: 3 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ $RECYCLE.BIN/
.DS_Store
Thumbs.db
UserInterfaceState.xcuserstate

# .docker env
.docker/env/*.env
30 changes: 30 additions & 0 deletions app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '2'

services:
insight-ui-btc:
container_name: insight-ui-btc-${ENV}
build:
context: .
dockerfile: .docker/docker-insight.dockerfile
ports:
- "4447:8100"
env_file:
- ./.docker/env/btc.${ENV}.env
networks:
- insight-network

insight-ui-bch:
container_name: insight-ui-bch-${ENV}
build:
context: .
dockerfile: .docker/docker-insight.dockerfile
ports:
- "4448:8100"
env_file:
- ./.docker/env/bch.${ENV}.env
networks:
- insight-network

networks:
insight-network:
driver: bridge
2 changes: 1 addition & 1 deletion app/ionic.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"proxies": [
{
"path": "/api",
"proxyUrl": "https://bch-insight.bitpay.com/api"
"proxyUrl": "https://insight.bitpay.com/api"
}
]
}
6 changes: 3 additions & 3 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, ViewChild } from '@angular/core';
import { Platform, MenuController, Nav } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { CurrencyProvider } from '../providers/currency/currency';
import {
HomePage
} from '../pages';
Expand All @@ -24,6 +25,7 @@ export class InsightApp {
platform: Platform,
menu: MenuController,
splash: SplashScreen,
public currency: CurrencyProvider,
status: StatusBar
) {
this.menu = menu;
Expand All @@ -39,8 +41,6 @@ export class InsightApp {
{ title: 'Home', component: HomePage },
{ title: 'Blocks', component: 'blocks' },
{ title: 'Broadcast Transaction', component: 'BroadcastTxPage' }
// { title: 'Verify Signed Message', component: VerifyMessagePage },
// { title: 'Node Status', component: NodeStatusPage }
];
}

Expand All @@ -57,6 +57,8 @@ export class InsightApp {
// close the menu when clicking a link from the menu
this.menu.close();
// navigate to the new page if it is not the current page
this.nav.setRoot(page.component);
this.nav.setRoot(page.component, {
'selectedCurrency': this.currency.selectedCurrency
});
}
}
10 changes: 5 additions & 5 deletions app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { InsightApp } from './app.component';
import { PagesModule, HomePage, BlocksPage, NodeStatusPage, VerifyMessagePage } from '../pages';
import { PagesModule, HomePage, BlocksPage } from '../pages';
import { BlocksService, StorageService } from '../services';
import { ApiProvider } from '../providers/api/api';
import { CurrencyProvider } from '../providers/currency/currency';
import { BlocksProvider } from '../providers/blocks/blocks';
import { DefaultProvider } from '../providers/default/default';

@NgModule({
declarations: [
Expand All @@ -25,9 +26,7 @@ import { BlocksProvider } from '../providers/blocks/blocks';
entryComponents: [
InsightApp,
HomePage,
BlocksPage,
NodeStatusPage,
VerifyMessagePage
BlocksPage
],
providers: [
StatusBar,
Expand All @@ -37,7 +36,8 @@ import { BlocksProvider } from '../providers/blocks/blocks';
{provide: ErrorHandler, useClass: IonicErrorHandler},
ApiProvider,
CurrencyProvider,
BlocksProvider
BlocksProvider,
DefaultProvider
]
})

Expand Down
12 changes: 11 additions & 1 deletion app/src/app/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,30 @@ import { NavMock } from '../mocks';
import { PopoverController, MenuController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { ApiProvider } from '../providers/api/api';
import { CurrencyProvider } from '../providers/currency/currency';
import { DefaultProvider } from '../providers/default/default';
import { HttpModule } from '@angular/http';

describe('InsightApp', () => {
let injector: TestBed;
let app: InsightApp;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpModule
],
providers: [
PopoverController,
InsightApp,
Platform,
MenuController,
SplashScreen,
StatusBar
StatusBar,
ApiProvider,
CurrencyProvider,
DefaultProvider
]
});
injector = getTestBed();
Expand Down
30 changes: 18 additions & 12 deletions app/src/components/head-nav/head-nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ApiProvider } from '../../providers/api/api';
import { CurrencyProvider } from '../../providers/currency/currency';
import { ActionSheetController } from 'ionic-angular';
import { PopoverController } from 'ionic-angular';
import { ToastController } from 'ionic-angular';
import { DenominationComponent } from '../denomination/denomination';

/**
Expand All @@ -24,15 +25,15 @@ export class HeadNavComponent {
public loading: boolean;
@Input() public title: string;
public q: string;
public badQuery: boolean = false;

constructor(
private navCtrl: NavController,
private http: Http,
private api: ApiProvider,
public currency: CurrencyProvider,
public actionSheetCtrl: ActionSheetController,
public popoverCtrl: PopoverController
public popoverCtrl: PopoverController,
public toastCtrl: ToastController
) {
}

Expand All @@ -46,6 +47,7 @@ export class HeadNavComponent {
console.log('block', data);
let parsedData: any = JSON.parse(data._body);
this.navCtrl.push('block-detail', {
'selectedCurrency': this.currency.selectedCurrency,
'blockHash': parsedData.hash
});
}.bind(this),
Expand All @@ -56,6 +58,7 @@ export class HeadNavComponent {
console.log('tx', data);
let parsedData: any = JSON.parse(data._body);
this.navCtrl.push('transaction', {
'selectedCurrency': this.currency.selectedCurrency,
'txId': parsedData.txid
});
}.bind(this),
Expand All @@ -66,15 +69,18 @@ export class HeadNavComponent {
console.log('addr', data);
let parsedData: any = JSON.parse(data._body);
this.navCtrl.push('address', {
'selectedCurrency': this.currency.selectedCurrency,
'addrStr': parsedData.addrStr
});
}.bind(this),
() => {
this.http.get(apiPrefix + 'block-index/' + this.q).subscribe(
function (data: any): void {
this.resetSearch();
console.log('height', data);
let parsedData: any = JSON.parse(data._body);
this.navCtrl.push('block-detail', {
'selectedCurrency': this.currency.selectedCurrency,
'blockHash': parsedData.blockHash
});
}.bind(this),
Expand All @@ -93,17 +99,17 @@ export class HeadNavComponent {

/* tslint:disable:no-unused-variable */
private reportBadQuery(): void {
this.badQuery = true;
console.log('badQuery', this.badQuery);
this.presentToast();
}

setTimeout(
function (): void {
this.badQuery = false;
console.log('badQuery', this.badQuery);
}.bind(this),
2000
);
};
private presentToast(): void {
const toast: any = this.toastCtrl.create({
message: 'No matching records found!',
duration: 3000,
position: 'top'
});
toast.present();
}

private resetSearch(): void {
this.q = '';
Expand Down
8 changes: 6 additions & 2 deletions app/src/components/latest-blocks/latest-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, NgZone, Input } from '@angular/core';
import { BlocksProvider } from '../../providers/blocks/blocks';
import { NavController } from 'ionic-angular';
import { CurrencyProvider } from '../../providers/currency/currency';

/**
* Generated class for the LatestBlocksComponent component.
Expand All @@ -21,7 +22,7 @@ export class LatestBlocksComponent {
@Input() public showTimeAs: string;
private reloadInterval: any;

constructor(private blocksProvider: BlocksProvider, private navCtrl: NavController, ngZone: NgZone) {
constructor(private blocksProvider: BlocksProvider, private navCtrl: NavController, ngZone: NgZone, public currency: CurrencyProvider) {
this.loadBlocks();
const seconds: number = 15;
ngZone.runOutsideAngular(() => {
Expand Down Expand Up @@ -51,6 +52,7 @@ export class LatestBlocksComponent {

public goToBlock(blockHash: string): void {
this.navCtrl.push('block-detail', {
'selectedCurrency': this.currency.selectedCurrency,
'blockHash': blockHash
});
}
Expand All @@ -62,7 +64,9 @@ export class LatestBlocksComponent {
}

public goToBlocks(): void {
this.navCtrl.push('blocks');
this.navCtrl.push('blocks', {
'selectedCurrency': this.currency.selectedCurrency
});
}

private ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class LatestTransactionsComponent {

public goToTx(txId: string): void {
this.navCtrl.push('transaction', {
'selectedCurrency': this.currency.selectedCurrency,
'txId': txId
});
}
Expand Down
10 changes: 4 additions & 6 deletions app/src/components/transaction/transaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@
</p>
<div *ngFor="let item of vin.items">
<div *ngIf="item.scriptSig">
<div *ngFor="let scriptSig of item.scriptSig.asm | split:' '">
<div class="unlocking-script">
<p>{{ scriptSig }}</p>
</div>
<div class="unlocking-script">
<p>{{ item.scriptSig.asm }}
</div>
</div>
</div>
Expand Down Expand Up @@ -87,7 +85,7 @@
<b>Locking Script</b>
</p>
<div class="locking-script">
<p>{{vout.scriptPubKey.asm}}</p>
<p>{{ vout.scriptPubKey.asm }}</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -128,4 +126,4 @@
</ion-chip>
</ion-col>
</ion-row>
</ion-grid>
</ion-grid>
2 changes: 2 additions & 0 deletions app/src/components/transaction/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ export class TransactionComponent {

public goToTx(txId: string): void {
this.navCtrl.push('transaction', {
'selectedCurrency': this.currency.selectedCurrency,
'txId': txId
});
}

public goToAddress(addrStr: string): void {
this.navCtrl.push('address', {
'selectedCurrency': this.currency.selectedCurrency,
'addrStr': addrStr
});
}
Expand Down
Loading