mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 07:26:50 +00:00
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
This commit is contained in:
@@ -1 +1 @@
|
||||
{{tickerCard.Exchange}} {{tickerCard.CurrencyPair}} Last: {{this.tickerCard.Last}}
|
||||
{{tickerCard.Exchange}} {{tickerCard.CurrencyPair}} Last: {{tickerCard.Last}}
|
||||
@@ -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 = <TickerUpdate> 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;
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
24
web/src/app/shared/classes/ticker.ts
Normal file
24
web/src/app/shared/classes/ticker.ts
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<nav class="docs-navbar">
|
||||
<mat-toolbar color="primary">
|
||||
<a (click)="sidebarService.toggle()" class="material-icons"></a>
|
||||
<a mat-button class="docs-button" routerLink="/" aria-label="Angular Material">
|
||||
<span>GoCryptoTrader</span>
|
||||
<a mat-button class="docs-button" style="width:1rem;" routerLink="/" aria-label="Angular Material">
|
||||
<span ><img style="width:100%; vertical-align:middle;" src="assets/images/gctlogo-small-cutoutt.png" /></span>
|
||||
</a>
|
||||
<app-selected-currency></app-selected-currency>
|
||||
<div class="flex-spacer"></div>
|
||||
|
||||
Reference in New Issue
Block a user