From a23c145ccc8b9383a095aa6dc28e5992bc7f018f Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 4 Jun 2018 19:20:59 +1000 Subject: [PATCH] Wallet management/Settings improvements (#130) * New Branch Splits settings out into their own areas for performance reasons * Formatting * Adds cutout logo for navbar * Better settings loading screen Better cache handling * Adds snackbar support Adds error websocketmessage support * pushing from one pc to another * Rejoins settings after failure to be able to seperate them without big rewrites * Wallet manipulation in settings * Reformats wallet page Updates menu to be 'wallets' * Lists enabled exchanges in settings before you click for modal * Fixes currency list issue * Fixes object reference bug in exchange-grid.component.html * password text --- web/src/app/app-routing.module.ts | 16 +- web/src/app/app.component.html | 12 +- web/src/app/app.component.scss | 1 - web/src/app/app.module.ts | 17 +- .../currency-list.component.html | 4 +- .../currency-list/currency-list.component.ts | 2 - .../exchange-grid.component.html | 10 +- .../pages/settings/settings.component.html | 83 +++++++-- .../pages/settings/settings.component.scss | 13 ++ .../app/pages/settings/settings.component.ts | 70 ++++++- .../app/pages/wallet/wallet.component.html | 172 ++++++++---------- .../app/pages/wallet/wallet.component.scss | 26 ++- web/src/app/pages/wallet/wallet.component.ts | 1 + .../websocket-response-handler.service.ts | 13 +- .../all-updates-ticker.component.html | 2 +- .../all-updates-ticker.component.ts | 106 ++++------- web/src/app/shared/classes/config.ts | 41 +++-- web/src/app/shared/classes/ticker.ts | 24 +++ web/src/app/shared/classes/websocket.ts | 1 + .../app/shared/navbar/navbar.component.html | 4 +- .../assets/images/gctlogo-small-cutoutt.png | Bin 0 -> 9373 bytes web/src/styles.scss | 6 +- 22 files changed, 382 insertions(+), 242 deletions(-) create mode 100644 web/src/app/shared/classes/ticker.ts create mode 100644 web/src/assets/images/gctlogo-small-cutoutt.png diff --git a/web/src/app/app-routing.module.ts b/web/src/app/app-routing.module.ts index 35a7973c..fe793a37 100644 --- a/web/src/app/app-routing.module.ts +++ b/web/src/app/app-routing.module.ts @@ -1,5 +1,4 @@ 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'; @@ -9,6 +8,9 @@ import { TradingComponent } from './pages/trading/trading.component'; import { ExchangeGridComponent } from './pages/exchange-grid/exchange-grid.component'; import { CurrencyListComponent } from './pages/currency-list/currency-list.component'; +//Settings +import { SettingsComponent } from './pages/settings/settings.component'; + import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -25,10 +27,6 @@ const routes: Routes = [ path:'dashboard', component: DashboardComponent }, - { - path: 'settings', - component: SettingsComponent - }, { path: 'wallet', component: WalletComponent @@ -57,8 +55,12 @@ const routes: Routes = [ { path: 'help', component: CurrencyListComponent - } - + }, + //Settings + { + path: 'settings', + component: SettingsComponent + }, ]; @NgModule({ diff --git a/web/src/app/app.component.html b/web/src/app/app.component.html index 2d75b1f9..1679c45f 100644 --- a/web/src/app/app.component.html +++ b/web/src/app/app.component.html @@ -9,7 +9,7 @@ account_balance_wallet  -

Wallet

+

Wallets

swap_horiz  @@ -58,11 +58,11 @@ - network_wifi  - - - signal_wifi_off  - + network_wifi  + + + signal_wifi_off  + diff --git a/web/src/app/app.component.scss b/web/src/app/app.component.scss index dc426a65..ddf5030f 100644 --- a/web/src/app/app.component.scss +++ b/web/src/app/app.component.scss @@ -1,5 +1,4 @@ .container { - height: 100vh; min-height: 100%; } diff --git a/web/src/app/app.module.ts b/web/src/app/app.module.ts index 1c590a40..3f53b844 100644 --- a/web/src/app/app.module.ts +++ b/web/src/app/app.module.ts @@ -27,16 +27,20 @@ import { MatLineModule, MatTooltipModule, MatTabsModule, + MatSnackBarModule, + MatDialogModule, } from '@angular/material'; - +//Pages import { AppComponent } from './app.component'; 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 { DonateComponent } from './pages/donate/donate.component'; +import { HelpComponent } from './pages/help/help.component'; + +import { SettingsComponent, EnabledCurrenciesDialogueComponent } from './pages/settings/settings.component'; //Shared import { NavbarComponent } from './shared/navbar/navbar.component'; @@ -70,7 +74,6 @@ import { BuyFormComponent } from './shared/buy-form/buy-form.component'; import { ExchangeGridComponent } from './pages/exchange-grid/exchange-grid.component'; import { CurrencyListComponent } from './pages/currency-list/currency-list.component'; import { SellFormComponent } from './shared/sell-form/sell-form.component'; -import { HelpComponent } from './pages/help/help.component'; @NgModule({ @@ -99,7 +102,11 @@ import { HelpComponent } from './pages/help/help.component'; SellFormComponent, HelpComponent, IterateMapPipe, - EnabledCurrenciesPipe + EnabledCurrenciesPipe, + EnabledCurrenciesDialogueComponent + ], + entryComponents: [ + EnabledCurrenciesDialogueComponent ], imports: [ BrowserModule, @@ -124,6 +131,8 @@ import { HelpComponent } from './pages/help/help.component'; MatLineModule, MatTooltipModule, MatTabsModule, + MatSnackBarModule, + MatDialogModule, AmChartsModule, ], providers: [ diff --git a/web/src/app/pages/currency-list/currency-list.component.html b/web/src/app/pages/currency-list/currency-list.component.html index 23689d3f..eb2e7ade 100644 --- a/web/src/app/pages/currency-list/currency-list.component.html +++ b/web/src/app/pages/currency-list/currency-list.component.html @@ -1,3 +1,5 @@ +

Currency List

+

Select and monitor currencies of the same type

@@ -13,7 +15,7 @@
- +

{{exchange}}

diff --git a/web/src/app/pages/currency-list/currency-list.component.ts b/web/src/app/pages/currency-list/currency-list.component.ts index 4f6a546b..0202fb4e 100644 --- a/web/src/app/pages/currency-list/currency-list.component.ts +++ b/web/src/app/pages/currency-list/currency-list.component.ts @@ -58,7 +58,6 @@ export class CurrencyListComponent implements OnInit { } } } - this.exchangeCurrencies.forEach((value: string[], key: string) => {}); } private getSettings(): void { @@ -69,5 +68,4 @@ export class CurrencyListComponent implements OnInit { this.ws.messages.next(WebSocketMessage.GetSettingsMessage()); } } - } diff --git a/web/src/app/pages/exchange-grid/exchange-grid.component.html b/web/src/app/pages/exchange-grid/exchange-grid.component.html index f2a7d275..52da1a71 100644 --- a/web/src/app/pages/exchange-grid/exchange-grid.component.html +++ b/web/src/app/pages/exchange-grid/exchange-grid.component.html @@ -1,11 +1,11 @@ +

Exchange List

+

Select and monitor currencies from the same exchange

- + - {{exchange.value}} + {{exchange.value}} - - image and blurb
@@ -13,7 +13,7 @@
- +

{{currency.ParsedName}}

diff --git a/web/src/app/pages/settings/settings.component.html b/web/src/app/pages/settings/settings.component.html index fd20ec75..9a806bff 100644 --- a/web/src/app/pages/settings/settings.component.html +++ b/web/src/app/pages/settings/settings.component.html @@ -1,19 +1,42 @@
-
- +
- - + - SMS Global + Credentials - SMS configuration and contact management - phone_iphone + User Settings + person + + + + + + + + + + + + + Allow Insecure Websocket Origin + + + + + + + + SMS Notifications + + + Notification Settings + sms
@@ -23,9 +46,9 @@ - + - +
Enabled
@@ -37,9 +60,39 @@
+ + +
+ + + + Wallets + + + Wallet Address Settings + account_balance_wallet + + +
+ + + + + + + + + + +
+ + + +
+ @@ -47,7 +100,7 @@ Exchange Settings - attach_money + poll
@@ -57,7 +110,7 @@ - + @@ -66,12 +119,10 @@

Enabled currencies

-
-

{{currency.Name}}

- -
+

{{pair.Name}}{{isLast ? '' : ', '}}

+
-
+
\ No newline at end of file diff --git a/web/src/app/pages/settings/settings.component.scss b/web/src/app/pages/settings/settings.component.scss index 91b50f73..e48d5281 100644 --- a/web/src/app/pages/settings/settings.component.scss +++ b/web/src/app/pages/settings/settings.component.scss @@ -9,4 +9,17 @@ .form-content { margin: 20px; +} + +.main { + margin-top: 20px; +} + +.mat-card { + height: 100%; + width: 100%; +} + +.long { + width:450px; } \ No newline at end of file diff --git a/web/src/app/pages/settings/settings.component.ts b/web/src/app/pages/settings/settings.component.ts index 3b35c6b0..48cd8a10 100644 --- a/web/src/app/pages/settings/settings.component.ts +++ b/web/src/app/pages/settings/settings.component.ts @@ -1,7 +1,9 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Component, OnInit, OnDestroy, Inject } from '@angular/core'; import { WebsocketResponseHandlerService } from './../../services/websocket-response-handler/websocket-response-handler.service'; import { WebSocketMessageType, WebSocketMessage } from './../../shared/classes/websocket'; -import { Config, CurrencyPairRedux } from './../../shared/classes/config'; +import { Config, CurrencyPairRedux, Wallet } from './../../shared/classes/config'; +import { MatSnackBar, MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; +import { WalletComponent } from '../wallet/wallet.component'; @Component({ selector: 'app-settings', @@ -9,36 +11,68 @@ import { Config, CurrencyPairRedux } from './../../shared/classes/config'; styleUrls: ['./settings.component.scss'], }) -export class SettingsComponent implements OnInit { +export class SettingsComponent { public settings: Config = new Config(); private ws: WebsocketResponseHandlerService; + public ready: boolean = false; + private snackBar: MatSnackBar; + private dialogue; - constructor(private websocketHandler: WebsocketResponseHandlerService) { + constructor(private websocketHandler: WebsocketResponseHandlerService, snackBar: MatSnackBar, public dialog: MatDialog) { this.ws = websocketHandler; - + this.snackBar = snackBar; } ngOnInit() { this.ws.shared.subscribe(msg => { if (msg.event === WebSocketMessageType.GetConfig) { this.settings.setConfig(msg.data); + this.ready = true; } else if (msg.event === WebSocketMessageType.SaveConfig) { - // check if err is returned, then display some notification + if(msg.error !== null || msg.error.length > 0) { + this.snackBar.open(msg.error, '', { + duration: 4000, + }); + } + if (msg.error === null || msg.error === '') { + this.settings.clearCache(); + this.getSettings(); + this.snackBar.open('Success', msg.data, { + duration: 1000, + }); + } } }); this.getSettings(); } + public addWallet() :void { + this.settings.PortfolioAddresses.Addresses.push({}); + } + + public removeWallet(wallet:any) { + this.settings.PortfolioAddresses.Addresses.splice(this.settings.PortfolioAddresses.Addresses.indexOf(wallet), 1); + } + + + public openModal(pairs: any): void { + let dialogRef = this.dialog.open(EnabledCurrenciesDialogueComponent, { + width: '20%', + height: '40%', + data: { pairs: pairs } + }); + } private getSettings(): void { if(this.settings.isConfigCacheValid()) { this.settings.setConfig(JSON.parse(window.localStorage['config'])) + this.ready = true; } else { + this.settings.clearCache(); this.ws.messages.next(WebSocketMessage.GetSettingsMessage()); } } private saveSettings(): void { - this.settings.fromReduxToArray() var settingsSave = { Event: 'SaveConfig', @@ -48,3 +82,25 @@ export class SettingsComponent implements OnInit { } } +@Component({ + selector: 'dialog-overview-example-dialog', + template: '

Enabled Currencies

{{currency.Name}}
', +}) +export class EnabledCurrenciesDialogueComponent { + + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any) { } + + onNoClick(): void { + this.dialogRef.close(); + } + + public close(): void { + this.dialogRef.close(); + + } + +} + + diff --git a/web/src/app/pages/wallet/wallet.component.html b/web/src/app/pages/wallet/wallet.component.html index 5546b764..30cdaff4 100644 --- a/web/src/app/pages/wallet/wallet.component.html +++ b/web/src/app/pages/wallet/wallet.component.html @@ -1,114 +1,84 @@
- +
- - - - - Coin Totals - - - - +
+ + + +

Coin Totals

+ - -

{{coin.coin}}

-

{{coin.balance}}

+

{{coin.coin}}

+

{{coin.balance}}

-
- + - - - - Online Summary - - - + +

Offline Coins

+ + +

{{coin.coin}}

+

{{coin.balance}}

+
+
+ +

Offline Summary

+ + + +

Address: {{coin.address}}

+

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

+
+ + + +

Address: {{coin.address}}

+

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

+
+ + + +

Address: {{coin.address}}

+

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

+
+
+ + + +

Online Coins

+ + + +

{{coin.coin}}

+

{{coin.balance}}

+
+
+ +

Online Summary

+ - -

Address: {{coin.address}}

-

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

+ +

Address: {{coin.address}}

+

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

- - -

Address: {{coin.address}}

-

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

+ +

Address: {{coin.address}}

+

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

- - -

Address: {{coin.address}}

-

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

+ +

Address: {{coin.address}}

+

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

-
-
- - - - - Offline Summary - - - - - -

Address: {{coin.address}}

-

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

-
- - - - -

Address: {{coin.address}}

-

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

-
- - - - -

Address: {{coin.address}}

-

{{coin.balance}}{{coin.coin}} - {{coin.percentage}}%

-
-
-
- - - - - Online Coins - - - - - - -

{{coin.coin}}

-

{{coin.balance}}

-
-
-
- - - - - Offline Coins - - - - - - -

{{coin.coin}}

-

{{coin.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 index e5989f67..59e9c810 100644 --- a/web/src/app/pages/wallet/wallet.component.scss +++ b/web/src/app/pages/wallet/wallet.component.scss @@ -1,7 +1,3 @@ -.wallet-card { - width: 80%; - margin: 10px auto; -} .BTC { color:orange; @@ -11,4 +7,24 @@ } .ETH { color:darkslategrey; -} \ No newline at end of file +} +// FAB +.mat-fab { + top: auto; + right: 30px; + bottom: 20px; + left: auto; + position: fixed; + z-index:9; +} +mat-grid-list { + height: 90vh; + } + + mat-card { + width:90%; + } + + mat-grid-tile { + box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.37); + } \ No newline at end of file diff --git a/web/src/app/pages/wallet/wallet.component.ts b/web/src/app/pages/wallet/wallet.component.ts index 1219ae86..e97f3179 100644 --- a/web/src/app/pages/wallet/wallet.component.ts +++ b/web/src/app/pages/wallet/wallet.component.ts @@ -28,6 +28,7 @@ export class WalletComponent implements OnInit { this.ws.shared.subscribe(msg => { if (msg.event === WebSocketMessageType.GetPortfolio) { this.wallet = msg.data; + console.log(msg.data); this.attachIcon(this.wallet.coin_totals); this.attachIcon(this.wallet.coins_offline); this.attachIcon(this.wallet.coins_online); diff --git a/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts b/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts index 23d6e4ac..526e981b 100644 --- a/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts +++ b/web/src/app/services/websocket-response-handler/websocket-response-handler.service.ts @@ -10,14 +10,18 @@ const WEBSOCKET_URL = 'ws://localhost:9050/ws'; export class WebsocketResponseHandlerService { public messages: Subject; public shared: Observable; - public isConnected :boolean = false; + public isConnected: boolean = false; + private ws: WebsocketService; constructor(@Optional() @SkipSelf() parentModule: WebsocketResponseHandlerService, wsService: WebsocketService) { - this.messages = >wsService + this.ws = wsService; + this.messages = >this.ws .connect(WEBSOCKET_URL) .map((response: MessageEvent): WebSocketMessage => { - this.isConnected = wsService.isConnected; + var interval = setInterval(() => { + this.isConnected = this.ws.isConnected; + }, 2000); let websocketResponseMessage = JSON.parse(response.data); var websocketResponseData = websocketResponseMessage.Data === undefined ? websocketResponseMessage.data : websocketResponseMessage.Data; var websocketResponseEvent = websocketResponseMessage.Event === undefined ? websocketResponseMessage.event : websocketResponseMessage.Event; @@ -27,10 +31,11 @@ export class WebsocketResponseHandlerService { responseMessage.data = websocketResponseData; responseMessage.exchange = websocketResponseMessage.exchange; responseMessage.assetType = websocketResponseMessage.assetType; + responseMessage.error = websocketResponseMessage.error; return responseMessage; }); - this.isConnected = wsService.isConnected; + this.isConnected = this.ws.isConnected; this.shared = this.messages.share(); //multicast } diff --git a/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.html b/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.html index 6d118e95..40f4c87b 100644 --- a/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.html +++ b/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.html @@ -1 +1 @@ -{{tickerCard.Exchange}} {{tickerCard.CurrencyPair}} Last: {{this.tickerCard.Last}} \ No newline at end of file +{{tickerCard.Exchange}} {{tickerCard.CurrencyPair}} Last: {{tickerCard.Last}} \ No newline at end of file diff --git a/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.ts b/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.ts index e2b58be8..41b8279f 100644 --- a/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.ts +++ b/web/src/app/shared/all-updates-ticker/all-updates-ticker.component.ts @@ -1,86 +1,56 @@ -import {Component, OnInit, OnDestroy }from '@angular/core'; -import {WebsocketResponseHandlerService }from './../../services/websocket-response-handler/websocket-response-handler.service'; -import {WebSocketMessageType }from './../../shared/classes/websocket'; +import { Component, OnInit, OnDestroy} from '@angular/core'; +import { WebsocketResponseHandlerService } from './../../services/websocket-response-handler/websocket-response-handler.service'; +import { WebSocketMessageType } from './../../shared/classes/websocket'; +import { ExchangeCurrency, TickerUpdate } from './../../shared/classes/ticker'; -@Component( { - selector:'app-all-updates-ticker', - templateUrl:'./all-updates-ticker.component.html', - styleUrls:['./all-updates-ticker.component.scss'], +@Component({ + selector: 'app-all-updates-ticker', + templateUrl: './all-updates-ticker.component.html', + styleUrls: ['./all-updates-ticker.component.scss'], }) export class AllEnabledCurrencyTickersComponent implements OnInit { - allCurrencies:ExchangeCurrency[] = < ExchangeCurrency[] > []; ; - private ws:WebsocketResponseHandlerService; - tickerCard:TickerUpdate = new TickerUpdate(); - showTicker:boolean = true; - message:string; + allCurrencies: ExchangeCurrency[] = < ExchangeCurrency[] > [];; + private ws: WebsocketResponseHandlerService; + tickerCard: TickerUpdate = new TickerUpdate(); constructor(private websocketHandler: WebsocketResponseHandlerService) { - this.tickerCard.Exchange = "Loading"; - this.tickerCard.CurrencyPair = "..."; - this.tickerCard.Last = -1; - this.ws = websocketHandler; - this.ws.shared.subscribe(msg => { + this.tickerCard.Exchange = "Loading"; + this.tickerCard.CurrencyPair = "..."; + this.tickerCard.Last = -1; + this.ws = websocketHandler; + this.ws.shared.subscribe(msg => { if (msg.event === WebSocketMessageType.TickerUpdate) { - if (window.localStorage["selectedExchange"] !== undefined && - window.localStorage["selectedCurrency"] !== undefined) { - this.tickerCard.Exchange = window.localStorage["selectedExchange"]; - this.tickerCard.CurrencyPair = window.localStorage["selectedCurrency"]; - if (msg.exchange == window.localStorage["selectedExchange"]) { - if (this.stripCurrencyCharacters(msg.data.CurrencyPair) == window.localStorage["selectedCurrency"]) { - - this.updateTicker(msg) + if (window.localStorage["selectedExchange"] !== undefined && + window.localStorage["selectedCurrency"] !== undefined) { + + this.tickerCard.Exchange = window.localStorage["selectedExchange"]; + this.tickerCard.CurrencyPair = window.localStorage["selectedCurrency"]; + + if (msg.exchange == this.tickerCard.Exchange && + this.stripCurrencyCharacters(msg.data.CurrencyPair) == this.tickerCard.CurrencyPair) { + this.updateTicker(msg) } - } - }else { + } else { this.updateTicker(msg) } } - }); - } + }); + } - private updateTicker(msg:any):void { - var modal = < ExchangeCurrency > {}; - modal.currencyPair = msg.data.CurrencyPair; - modal.exchangeName = msg.exchange; - var ticker = < TickerUpdate > msg.data; - this.tickerCard = ticker; - this.tickerCard.Exchange = msg.exchange; - this.message = this.tickerCard.Exchange + " " + this.tickerCard.CurrencyPair + " Last: " + this.tickerCard.Last; + private updateTicker(msg: any): void { + var ticker = msg.data; + this.tickerCard = ticker; + this.tickerCard.Exchange = msg.exchange; } ngOnInit() { - } - private stripCurrencyCharacters(name:string):string { - name = name.replace('_', ''); - name = name.replace('-', ''); - name = name.replace(' ', ''); - name = name.toLocaleUpperCase(); - return name; + private stripCurrencyCharacters(name: string): string { + name = name.replace('_', ''); + name = name.replace('-', ''); + name = name.replace(' ', ''); + name = name.toLocaleUpperCase(); + return name; } -} - -export interface ExchangeCurrency { - currencyPair:string; - exchangeName:string; -} - -export interface CurrencyPair { - delimiter:string; - first_currency:string; - second_currency:string; -} - -export class TickerUpdate { - Pair:CurrencyPair; - CurrencyPair:string; - Last:number; - High:number; - Low:number; - Bid:number; - Ask:number; - Volume:number; - PriceATH:number; - Exchange:string; } \ No newline at end of file diff --git a/web/src/app/shared/classes/config.ts b/web/src/app/shared/classes/config.ts index a45d717b..9f2970d4 100644 --- a/web/src/app/shared/classes/config.ts +++ b/web/src/app/shared/classes/config.ts @@ -37,7 +37,25 @@ this.PortfolioAddresses = configData.PortfolioAddresses this.SMSGlobal = configData.SMSGlobal this.Webserver = configData.Webserver - this.fromArrayToRedux() + if(configData.Exchanges.length > 0 + && configData.Exchanges[0].Pairs + && configData.Exchanges[0].Pairs.length > 0) { + console.log('Successfully retrieved well-formed pairs'); + return; + } + this.fromArrayToRedux(); + //Rewrite to cache on parsing to redux array + this.saveToCache(); + } + + public saveToCache() : void { + window.localStorage['config'] = JSON.stringify(this); + window.localStorage['configDate'] = new Date().toString(); + } + + public clearCache() : void { + window.localStorage['config'] = null; + window.localStorage['configDate'] = null; } public fromArrayToRedux() : void { @@ -57,8 +75,7 @@ this.Exchanges[i].Pairs.push(currencyPair); } } - window.localStorage['config'] = JSON.stringify(this); - window.localStorage['configDate'] = new Date().toString(); + } public parseSettings() : void { @@ -82,23 +99,17 @@ if (enabled.indexOf(this.Exchanges[i].Pairs[j].Name) == -1) { // Step 3 if its not in the enabled list, add it enabled.push(this.Exchanges[i].Pairs[j].Name); - } else { - - } + } } else { if (enabled.indexOf(this.Exchanges[i].Pairs[j].Name) > -1) { enabled.splice(enabled.indexOf(this.Exchanges[i].Pairs[j].Name), 1); - } else { } } } - //Step 4 JSONifiy the enabled list and set it to the this.settings.Exchanges[i].EnabledPairs this.Exchanges[i].EnabledPairs = enabled.join(); } - } - } export class CurrencyPairRedux { @@ -113,7 +124,15 @@ export class CurrencyPairRedux { } export interface PortfolioAddresses { - Addresses?: any; + Addresses?: Wallet[]; + } + + export interface Wallet { + Address:string; + CoinType:string; + Balance:number; + Description:string + } export interface Contact { diff --git a/web/src/app/shared/classes/ticker.ts b/web/src/app/shared/classes/ticker.ts new file mode 100644 index 00000000..56a9dd17 --- /dev/null +++ b/web/src/app/shared/classes/ticker.ts @@ -0,0 +1,24 @@ +export interface ExchangeCurrency { + currencyPair: string; + exchangeName: string; + } + + export interface CurrencyPair { + delimiter: string; + first_currency: string; + second_currency: string; + } + + export class TickerUpdate { + Pair: CurrencyPair; + CurrencyPair: string; + Last: number; + High: number; + Low: number; + Bid: number; + Ask: number; + Volume: number; + PriceATH: number; + Exchange: string; + } + \ No newline at end of file diff --git a/web/src/app/shared/classes/websocket.ts b/web/src/app/shared/classes/websocket.ts index e83a7184..57d94da5 100644 --- a/web/src/app/shared/classes/websocket.ts +++ b/web/src/app/shared/classes/websocket.ts @@ -3,6 +3,7 @@ export class WebSocketMessage { public data: any; public exchange: string; public assetType: string; + public error: string; public static CreateAuthenticationMessage(): WebSocketMessage { var response = new WebSocketMessage(); diff --git a/web/src/app/shared/navbar/navbar.component.html b/web/src/app/shared/navbar/navbar.component.html index 291b660d..897bd6e9 100644 --- a/web/src/app/shared/navbar/navbar.component.html +++ b/web/src/app/shared/navbar/navbar.component.html @@ -2,8 +2,8 @@