Commit f4030dc4 authored by dev0tion's avatar dev0tion

Add balance dashboard in menu

parent 34fdd115
......@@ -10,5 +10,31 @@
"trackedScriptPubKeyCount": "100",
"walletState": "syncingBlocks",
"historyChangeBump": "231321"
}
},
"balance":
{
"success": "true",
"synced": "true",
"confirmed": "0.144",
"unconfirmed": "-6.23"
},
"history":
{
"success": "true",
"history":
[
{
"txid": "9a9949476b629b4075b31d8faad64dad352586a18df8f2810c5a7bb900478c60",
"amount": "0.1",
"confirmed": "true",
"timestamp": "2016.12.19. 23:15:05"
},
{
"txid": "9a9949476b629b4075b31d8faad64dad352586a18df8f2810c5a7bb900478c60",
"amount": "-0.1",
"confirmed": "false",
"timestamp": "2016.12.20. 1:15:36"
}
]
}
}
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { remote } from 'electron';
import { ApiService } from './shared/api/api.service';
@Component({
......
......@@ -28,6 +28,20 @@ export class ApiService {
.catch(this.handleError);
}
getWalletBalance(): Observable<any> {
return this.http
.get(this.webApiUrl + '/wallet/balance')
.map((response:Response) => response.json())
.catch(this.handleError);
}
getWalletHistory(): Observable<any> {
return this.http
.get(this.webApiUrl + '/wallet/history')
.map((response:Response) => response.json())
.catch(this.handleError);
}
createWallet(data: SafeCreation): Observable<any> {
console.log(JSON.stringify(data));
return this.http
......
<p>Balance: {{confirmedBalance}}</p>
<p>Unconfirmed: {{unconfirmedBalance}}<p>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { ApiService } from '../../shared/api/api.service';
@Component({
selector: 'dashboard-component',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css'],
})
export class DashboardComponent {
constructor(private apiService: ApiService) {}
private balanceResponse: any;
private confirmedBalance: number;
private unconfirmedBalance: number;
private errorMessage: string;
ngOnInit() {
this.getWalletBalance();
}
private getWalletBalance() {
this.apiService.getWalletBalance()
.subscribe(
response => this.balanceResponse = response,
error => this.errorMessage = <any>error,
() => this.setBalance()
);
}
private setBalance() {
this.confirmedBalance = this.balanceResponse.confirmed;
this.unconfirmedBalance = this.balanceResponse.unconfirmed;
}
}
<nav class="navbar navbar-fixed-top">
<div class="container">
<a class="navbar-brand">Breeze</a>
<dashboard-component></dashboard-component>
<ul class="nav navbar-nav" routerLinkActive="active">
<li class="nav-item"><a class="nav-link" routerLink="send">Send</a></li>
<li class="nav-item"><a class="nav-link" routerLink="receive">Receive</a></li>
......
......@@ -5,6 +5,7 @@ import { RouterModule } from '@angular/router';
import { WalletComponent } from './wallet.component';
import { MenuComponent } from './menu/menu.component';
import { DashboardComponent } from './menu/dashboard.component';
import { SendComponent } from './send/send.component';
import { ReceiveComponent } from './receive/receive.component';
import { HistoryComponent } from './history/history.component';
......@@ -23,6 +24,7 @@ import { WalletRoutingModule } from './wallet-routing.module';
declarations: [
WalletComponent,
MenuComponent,
DashboardComponent,
ReceiveComponent,
SendComponent,
HistoryComponent,
......
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