diff --git a/web/src/app/app-routing.module.ts b/web/src/app/app-routing.module.ts index 7b4eee36..cd01b7d1 100644 --- a/web/src/app/app-routing.module.ts +++ b/web/src/app/app-routing.module.ts @@ -2,6 +2,7 @@ import { HomeComponent } from './pages/home/home.component'; import { SettingsComponent } from './pages/settings/settings.component'; import { AboutComponent } from './pages/about/about.component'; import { DashboardComponent } from './pages/dashboard/dashboard.component'; +import { WalletComponent } from './pages/wallet/wallet.component'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -22,6 +23,10 @@ const routes: Routes = [ { path: 'settings', component: SettingsComponent + }, + { + path: 'wallet', + component: WalletComponent } ]; diff --git a/web/src/app/app.component.scss b/web/src/app/app.component.scss index f1d75fc1..7eb898db 100644 --- a/web/src/app/app.component.scss +++ b/web/src/app/app.component.scss @@ -8,6 +8,7 @@ display: flex; align-items: center; justify-content: center; + padding: 20px 70px 0; min-width:80%; } diff --git a/web/src/app/app.module.ts b/web/src/app/app.module.ts index 25687efd..71b13fe5 100644 --- a/web/src/app/app.module.ts +++ b/web/src/app/app.module.ts @@ -29,6 +29,7 @@ import { HomeComponent } from './pages/home/home.component'; import { AboutComponent } from './pages/about/about.component'; import { SettingsComponent } from './pages/settings/settings.component'; import { DashboardComponent } from './pages/dashboard/dashboard.component'; +import { WalletComponent } from './pages/wallet/wallet.component'; import { NavbarComponent } from './shared/navbar/navbar.component'; import { SidebarComponent } from './shared/sidebar/sidebar.component'; @@ -42,6 +43,9 @@ import { ElectronService } from './providers/electron.service'; //Routing import { AppRoutingModule } from './app-routing.module'; +import { Wallet } from './shared/classes/wallet'; + + import * as Rx from 'rxjs/Rx'; @@ -55,7 +59,8 @@ import * as Rx from 'rxjs/Rx'; DashboardComponent, ExchangeCurrencyTickerComponent, AllEnabledCurrencyTickersComponent, - SidebarComponent + SidebarComponent, + WalletComponent ], imports: [ BrowserModule, diff --git a/web/src/app/pages/settings/settings.component.html b/web/src/app/pages/settings/settings.component.html index 8869352b..102c948c 100644 --- a/web/src/app/pages/settings/settings.component.html +++ b/web/src/app/pages/settings/settings.component.html @@ -4,7 +4,7 @@
- + SMS Global Settings @@ -48,7 +48,7 @@
- + {{exchange.Name}} Exchange Settings diff --git a/web/src/app/pages/settings/settings.component.scss b/web/src/app/pages/settings/settings.component.scss index 98c47c43..7fe9904a 100644 --- a/web/src/app/pages/settings/settings.component.scss +++ b/web/src/app/pages/settings/settings.component.scss @@ -7,14 +7,11 @@ width: 100%; } -.exchange-card { - margin-bottom: 20px; - width: 1000px; -} - +// FAB .md-fab { - margin: 0; - position: fixed; + top: auto; right: 20px; - bottom: 10px; + bottom: 20px; + left: auto; + position: fixed; } \ No newline at end of file diff --git a/web/src/app/pages/wallet/wallet.component.html b/web/src/app/pages/wallet/wallet.component.html new file mode 100644 index 00000000..1380a1f1 --- /dev/null +++ b/web/src/app/pages/wallet/wallet.component.html @@ -0,0 +1,28 @@ + + + Wallet Summary + + + + + + +
+
+ + + + + + + + + {{total.coin}} - {{total.balance}} + + + + + + +
+
\ No newline at end of file diff --git a/web/src/app/pages/wallet/wallet.component.scss b/web/src/app/pages/wallet/wallet.component.scss new file mode 100644 index 00000000..0adfea4e --- /dev/null +++ b/web/src/app/pages/wallet/wallet.component.scss @@ -0,0 +1,4 @@ +.wallet-card { + width: 80%; + margin: 10px auto; +} \ No newline at end of file diff --git a/web/src/app/pages/wallet/wallet.component.spec.ts b/web/src/app/pages/wallet/wallet.component.spec.ts new file mode 100644 index 00000000..5eb8a39c --- /dev/null +++ b/web/src/app/pages/wallet/wallet.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WalletComponent } from './wallet.component'; + +describe('WalletComponent', () => { + let component: WalletComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WalletComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WalletComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/web/src/app/pages/wallet/wallet.component.ts b/web/src/app/pages/wallet/wallet.component.ts new file mode 100644 index 00000000..b5283e63 --- /dev/null +++ b/web/src/app/pages/wallet/wallet.component.ts @@ -0,0 +1,55 @@ +import { Component, OnInit } from '@angular/core'; +import { WebsocketHandlerService } from './../../services/websocket-handler/websocket-handler.service'; +import { Wallet } from './../../shared/classes/wallet'; + + +@Component({ + selector: 'app-wallet', + templateUrl: './wallet.component.html', + styleUrls: ['./wallet.component.scss'] +}) +export class WalletComponent implements OnInit { + private ws: WebsocketHandlerService; + private failCount = 0; + private timer: any; + public wallet: Wallet; + + private getWalletMessage = { + Event: 'GetPortfolio', + data: null, + }; + + constructor(private websocketHandler: WebsocketHandlerService) { + this.ws = websocketHandler; + this.ws.messages.subscribe(msg => { + if (msg.Event === 'GetPortfolio') { + console.log(JSON.stringify(msg.data)); + this.wallet = msg.data; + } + }); + } + ngOnInit() { + this.setWallet(); + } + +//there has to be a better way + private resendMessageIfPageRefreshed(): void { + if (this.failCount <= 10) { + setTimeout(() => { + if (this.wallet === null || this.wallet === undefined) { + this.failCount++; + this.setWallet(); + } + }, 1000); + } else { + console.log('Could not load wallet. Check if GocryptoTrader server is running, otherwise open a ticket'); + } + } + + private setWallet():void { + this.ws.messages.next(this.getWalletMessage); + this.resendMessageIfPageRefreshed(); + } +} + + diff --git a/web/src/app/shared/classes/config.ts b/web/src/app/shared/classes/config.ts new file mode 100644 index 00000000..e69de29b diff --git a/web/src/app/shared/classes/wallet.ts b/web/src/app/shared/classes/wallet.ts new file mode 100644 index 00000000..cb2af252 --- /dev/null +++ b/web/src/app/shared/classes/wallet.ts @@ -0,0 +1,49 @@ + +export interface CoinTotal { + coin: string; + balance: number; + } + + export interface CoinsOffline { + coin: string; + balance: number; + percentage: number; + } + + export interface BTC { + address: string; + balance: number; + percentage: number; + } + + export interface ETH { + address: string; + balance: number; + percentage: number; + } + + export interface LTC { + address: string; + balance: number; + percentage: number; + } + + export interface OfflineSummary { + BTC: BTC[]; + ETH: ETH[]; + LTC: LTC[]; + } + + export interface OnlineSummary { + BTC: BTC[]; + ETH: ETH[]; + LTC: LTC[]; + } + + export interface Wallet { + coin_totals: CoinTotal[]; + coins_offline: CoinsOffline[]; + offline_summary: OfflineSummary; + coins_online?: any; + online_summary: OnlineSummary; + } \ No newline at end of file diff --git a/web/src/app/shared/navbar/navbar.component.html b/web/src/app/shared/navbar/navbar.component.html index 78d6fa7a..1cf33e16 100644 --- a/web/src/app/shared/navbar/navbar.component.html +++ b/web/src/app/shared/navbar/navbar.component.html @@ -1,6 +1,6 @@