Commit ce03cf34 authored by Pieterjan Vanhoof's avatar Pieterjan Vanhoof Committed by GitHub

Merge pull request #119 from stratisproject/ui

Spawn API when in production mode
parents 896fcfa5 14dca061
...@@ -241,6 +241,7 @@ ModelManifest.xml ...@@ -241,6 +241,7 @@ ModelManifest.xml
# UI ignores # UI ignores
# compiled output # compiled output
**/app-builds **/app-builds
**/assets/daemon
**/dist **/dist
**/tmp **/tmp
**/build **/build
......
...@@ -33,6 +33,8 @@ npm install -g @angular/cli ...@@ -33,6 +33,8 @@ npm install -g @angular/cli
## To build for development ## To build for development
- **in a terminal window** -> npm start - **in a terminal window** -> npm start
This will compile the Angular code and spawn the Electron process in parallel.
After compilation has completed the Electron UI will refresh.
If you want to seperate the build process from the Electron process you can use: If you want to seperate the build process from the Electron process you can use:
- **in a terminal window** -> npm start:webpack - **in a terminal window** -> npm start:webpack
......
...@@ -51,7 +51,12 @@ function createWindow() { ...@@ -51,7 +51,12 @@ function createWindow() {
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.on('ready', function () { app.on('ready', function () {
//startApi(); if (serve) {
console.log("Breeze UI was started in development mode. This requires the user to be running the Breeze Daemon himself.")
}
else {
startApi();
}
createTray(); createTray();
createWindow(); createWindow();
}) })
...@@ -74,16 +79,16 @@ app.on('activate', function () { ...@@ -74,16 +79,16 @@ app.on('activate', function () {
}); });
function startApi() { function startApi() {
let apiProcess; var apiProcess;
var spawn = require('child_process').spawn; const spawn = require('child_process').spawn;
//Start Breeze Daemon //Start Breeze Daemon
apipath = path.join(__dirname, ''); let apipath = path.join(__dirname, '..//..//daemon//Breeze.Daemon');
if (os.platform() === 'win32') { if (os.platform() === 'win32') {
var apipath = path.join(__dirname, ''); apipath = path.join(__dirname, '.\\assets\\daemon\\Breeze.Daemon.exe');
} }
apiProcess = spawn(apipath, { apiProcess = spawn(apipath + ' light -testnet', {
detached: true detached: true
}); });
......
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
"electron:test": "electron ./dist", "electron:test": "electron ./dist",
"electron:dev": "npm run build && electron ./dist", "electron:dev": "npm run build && electron ./dist",
"electron:prod": "npm run build:prod && electron ./dist", "electron:prod": "npm run build:prod && electron ./dist",
"package:linux": "npm run build:prod && node package.js --asar --platform=linux --arch=x64", "package:linux": "npm run build:prod && node package.js --platform=linux --arch=x64",
"package:windows": "npm run build:prod && node package.js --asar --platform=win32 --arch=ia32", "package:windows": "npm run build:prod && node package.js --platform=win32 --arch=ia32",
"package:mac": "npm run build:prod && node package.js --asar --platform=darwin --arch=x64", "package:mac": "npm run build:prod && node package.js --platform=darwin --arch=x64",
"test": "karma start ./karma.conf.js", "test": "karma start ./karma.conf.js",
"pree2e": "webdriver-manager update --standalone false --gecko false --quiet && npm run build", "pree2e": "webdriver-manager update --standalone false --gecko false --quiet && npm run build",
"e2e": "protractor ./protractor.conf.js" "e2e": "protractor ./protractor.conf.js"
......
...@@ -16,25 +16,5 @@ export class AppComponent implements OnInit { ...@@ -16,25 +16,5 @@ export class AppComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.router.navigate(['/login']); this.router.navigate(['/login']);
//this.checkWalletStatus();
} }
}
// private checkWalletStatus(){
// this.apiService.getWalletStatus()
// .subscribe(
// response => {
// if (response.status >= 200 && response.status < 400) {
// this.responseMessage = response;
// this.router.navigate(['/login']);
// }
// },
// error => {
// this.errorMessage = <any>error;
// if (error.status === 400 || error.status === 404) {
// this.router.navigate(['/setup']);
// console.log(this.errorMessage);
// }
// }
// );
// }
}
\ No newline at end of file
...@@ -11,10 +11,11 @@ import { WalletLoad } from '../shared/classes/wallet-load'; ...@@ -11,10 +11,11 @@ import { WalletLoad } from '../shared/classes/wallet-load';
templateUrl: './login.component.html', templateUrl: './login.component.html',
styleUrls: ['./login.component.css'] styleUrls: ['./login.component.css']
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
constructor(private globalService: GlobalService, private apiService: ApiService, private router: Router, private fb: FormBuilder) { constructor(private globalService: GlobalService, private apiService: ApiService, private router: Router, private fb: FormBuilder) {
this.buildDecryptForm(); this.buildDecryptForm();
} }
private openWalletForm: FormGroup; private openWalletForm: FormGroup;
private hasWallet: boolean = false; private hasWallet: boolean = false;
...@@ -109,7 +110,8 @@ export class LoginComponent implements OnInit { ...@@ -109,7 +110,8 @@ export class LoginComponent implements OnInit {
console.log(errorMessage); console.log(errorMessage);
} }
} }
); )
;
} }
private loadWallet(walletLoad: WalletLoad) { private loadWallet(walletLoad: WalletLoad) {
...@@ -131,6 +133,7 @@ export class LoginComponent implements OnInit { ...@@ -131,6 +133,7 @@ export class LoginComponent implements OnInit {
console.log(errorMessage); console.log(errorMessage);
} }
} }
); )
;
} }
} }
...@@ -21,7 +21,6 @@ export class CreateComponent { ...@@ -21,7 +21,6 @@ export class CreateComponent {
private createWalletForm: FormGroup; private createWalletForm: FormGroup;
private newWallet: WalletCreation; private newWallet: WalletCreation;
private mnemonic: string; private mnemonic: string;
private buildCreateForm(): void { private buildCreateForm(): void {
...@@ -104,6 +103,7 @@ export class CreateComponent { ...@@ -104,6 +103,7 @@ export class CreateComponent {
console.log(errorMessage); console.log(errorMessage);
} }
} }
); )
;
} }
} }
import { CoinAbbreviationPipe } from './coin-abbreviation.pipe';
describe('CoinAbbreviationPipe', () => {
it('create an instance', () => {
const pipe = new CoinAbbreviationPipe();
expect(pipe).toBeTruthy();
});
});
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'coinAbbreviation'
})
export class CoinAbbreviationPipe implements PipeTransform {
transform(value: any): any {
if (!value) return value;
let abbreviationAdded = value + " BTC"
return abbreviationAdded;
}
}
...@@ -7,22 +7,28 @@ export class CoinNotationPipe implements PipeTransform { ...@@ -7,22 +7,28 @@ export class CoinNotationPipe implements PipeTransform {
private coinUnit = "BTC"; private coinUnit = "BTC";
private coinNotation: number; private coinNotation: number;
private decimalLimit = 8;
transform(value: any): any { transform(value: any): any {
if (!value) return value; let temp;
if (typeof value === 'number') {
this.coinNotation = value; switch (this.getCoinUnit()) {
case "BTC":
switch (this.coinUnit) { temp = value / 100000000;
case "BTC": return temp.toFixed(this.decimalLimit) + " TBTC";
this.coinNotation = Number(value.toFixed(8)); case "mBTC":
return this.coinNotation = this.coinNotation / 100000000; temp = value / 100000;
case "mBTC": return temp.toFixed(this.decimalLimit) + " TmBTC";
this.coinNotation = Number(value.toFixed(8)); case "uBTC":
return this.coinNotation = this.coinNotation / 100000; temp = value / 100;
case "uBTC": return temp.toFixed(this.decimalLimit) + " TuBTC";
this.coinNotation = Number(value.toFixed(8)); }
return this.coinNotation = this.coinNotation / 100;
} }
} }
getCoinUnit() {
return this.coinUnit;
}
} }
...@@ -2,33 +2,33 @@ import {Injectable} from "@angular/core"; ...@@ -2,33 +2,33 @@ import {Injectable} from "@angular/core";
@Injectable() @Injectable()
export class GlobalService { export class GlobalService {
constructor() {} constructor() {}
private walletPath: string; private walletPath: string;
private currentWalletName: string; private currentWalletName: string;
private coinType: number; private coinType: number;
getWalletPath() { getWalletPath() {
return this.walletPath; return this.walletPath;
} }
setWalletPath(walletPath: string) { setWalletPath(walletPath: string) {
this.walletPath = walletPath; this.walletPath = walletPath;
} }
getWalletName() { getWalletName() {
return this.currentWalletName; return this.currentWalletName;
} }
setWalletName(currentWalletName: string) { setWalletName(currentWalletName: string) {
this.currentWalletName = currentWalletName; this.currentWalletName = currentWalletName;
} }
getCoinType () { getCoinType () {
return this.coinType; return this.coinType;
} }
setCoinType (coinType: number) { setCoinType (coinType: number) {
this.coinType = coinType; this.coinType = coinType;
} }
} }
import { NgModule, ModuleWithProviders } from '@angular/core'; import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { CoinNotationPipe } from './pipes/coin-notation.pipe'; import { CoinNotationPipe } from './pipes/coin-notation.pipe';
import { CoinAbbreviationPipe } from './pipes/coin-abbreviation.pipe';
@NgModule({ @NgModule({
imports: [CommonModule], imports: [CommonModule],
declarations: [CoinNotationPipe, CoinAbbreviationPipe], declarations: [CoinNotationPipe],
exports: [CoinNotationPipe, CoinAbbreviationPipe] exports: [CoinNotationPipe]
}) })
export class SharedModule { export class SharedModule {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<div class="d-flex flex-row align-items-center nopadding" id="dashboard"> <div class="d-flex flex-row align-items-center nopadding" id="dashboard">
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<div class="p">Active Balance</div> <div class="p">Active Balance</div>
<div class="p">Balance: {{confirmedBalance | coinNotation | coinAbbreviation}}</div> <div class="p">Balance: {{confirmedBalance | coinNotation }}</div>
<div class="p">Unconfirmed Balance: {{unconfirmedBalance | coinNotation | coinAbbreviation}}</div> <div class="p">Unconfirmed Balance: {{unconfirmedBalance | coinNotation }}</div>
</div> </div>
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<!--<div>Current Value</div> <!--<div>Current Value</div>
...@@ -28,13 +28,13 @@ ...@@ -28,13 +28,13 @@
<th>Timestamp</th> <th>Timestamp</th>
</thead> </thead>
<tr *ngFor="let transaction of transactions; let i=index"> <tr *ngFor="let transaction of transactions; let i=index">
<!--<td *ngIf="{{ transaction.amount }} < 0">SENT</td> <!--<td *ngIf="{{ transaction.amount }} < 0">SENT</td>
<td *ngIf="{{ transaction.amount }} > 0">RECEIVED</td>--> <td *ngIf="{{ transaction.amount }} > 0">RECEIVED</td>-->
<td *ngIf="i<5">{{ transaction.type }}</td> <td *ngIf="i<5">{{ transaction.type }}</td>
<td *ngIf="i<5">{{ transaction.amount | coinNotation | coinAbbreviation }}</td> <td *ngIf="i<5">{{ transaction.amount | coinNotation }}</td>
<td *ngIf="i<5">{{ transaction.id }}</td> <td *ngIf="i<5">{{ transaction.id }}</td>
<td *ngIf="i<5">{{ transaction.confirmedInBlock }}</td> <td *ngIf="i<5">{{ transaction.confirmedInBlock }}</td>
<td *ngIf="i<5">{{ transaction.timestamp * 1000 | date:'medium' }}</td> <td *ngIf="i<5">{{ transaction.timestamp * 1000 | date:'medium' }}</td>
</tr> </tr>
</table> </table>
<ng-template #noTransactions>Looks like you haven't made any transactions yet</ng-template> <ng-template #noTransactions>Looks like you haven't made any transactions yet</ng-template>
......
...@@ -49,20 +49,21 @@ export class DashboardComponent { ...@@ -49,20 +49,21 @@ export class DashboardComponent {
let walletInfo = new WalletInfo(this.globalService.getWalletName(), this.globalService.getCoinType()) let walletInfo = new WalletInfo(this.globalService.getWalletName(), this.globalService.getCoinType())
this.walletBalanceSubscription = this.apiService.getWalletBalance(walletInfo) this.walletBalanceSubscription = this.apiService.getWalletBalance(walletInfo)
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
let balanceResponse = response.json(); let balanceResponse = response.json();
this.confirmedBalance = balanceResponse.balances[0].amountConfirmed; this.confirmedBalance = balanceResponse.balances[0].amountConfirmed;
this.unconfirmedBalance = balanceResponse.balances[0].amountUnconfirmed; this.unconfirmedBalance = balanceResponse.balances[0].amountUnconfirmed;
}
},
error => {
if (error.status >= 400) {
let errorMessage = <any>error;
console.log(errorMessage);
}
} }
); },
error => {
if (error.status >= 400) {
let errorMessage = <any>error;
console.log(errorMessage);
}
}
)
;
}; };
private getHistory() { private getHistory() {
...@@ -82,6 +83,7 @@ export class DashboardComponent { ...@@ -82,6 +83,7 @@ export class DashboardComponent {
console.log(errorMessage); console.log(errorMessage);
} }
} }
); )
;
}; };
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<!--<td *ngIf="{{ transaction.amount }} < 0; else received">SENT</td> <!--<td *ngIf="{{ transaction.amount }} < 0; else received">SENT</td>
<td #received>RECEIVED</td>--> <td #received>RECEIVED</td>-->
<td>{{ transaction.type }}</td> <td>{{ transaction.type }}</td>
<td>{{ transaction.amount | coinNotation | coinAbbreviation }}</td> <td>{{ transaction.amount | coinNotation }}</td>
<td>{{ transaction.id }}</td> <td>{{ transaction.id }}</td>
<td>{{ transaction.confirmedInBlock }}</td> <td>{{ transaction.confirmedInBlock }}</td>
<td>{{ transaction.timestamp * 1000 | date:'medium' }}</td> <td>{{ transaction.timestamp * 1000 | date:'medium' }}</td>
......
...@@ -46,6 +46,7 @@ export class HistoryComponent { ...@@ -46,6 +46,7 @@ export class HistoryComponent {
console.log(this.errorMessage); console.log(this.errorMessage);
} }
} }
); )
;
} }
} }
...@@ -23,10 +23,6 @@ export class ReceiveComponent { ...@@ -23,10 +23,6 @@ export class ReceiveComponent {
this.getUnusedReceiveAddresses(); this.getUnusedReceiveAddresses();
} }
private copyAddress() {
}
private getUnusedReceiveAddresses() { private getUnusedReceiveAddresses() {
let walletInfo = new WalletInfo(this.globalService.getWalletName(), this.globalService.getCoinType()) let walletInfo = new WalletInfo(this.globalService.getWalletName(), this.globalService.getCoinType())
this.apiService.getUnusedReceiveAddress(walletInfo) this.apiService.getUnusedReceiveAddress(walletInfo)
...@@ -42,6 +38,7 @@ export class ReceiveComponent { ...@@ -42,6 +38,7 @@ export class ReceiveComponent {
console.log(this.errorMessage); console.log(this.errorMessage);
} }
} }
); )
;
} }
} }
...@@ -103,7 +103,8 @@ export class SendComponent { ...@@ -103,7 +103,8 @@ export class SendComponent {
} }
}, },
() => this.sendTransaction(this.responseMessage.hex) () => this.sendTransaction(this.responseMessage.hex)
); )
;
}; };
private getFeeType(){ private getFeeType(){
...@@ -136,6 +137,7 @@ export class SendComponent { ...@@ -136,6 +137,7 @@ export class SendComponent {
console.log(this.errorMessage); console.log(this.errorMessage);
} }
} }
); )
;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment