forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a new component to render all enabled currency tickers. Will sor…
…t out later. Reduces currency ticker to accept a ticker object so that it doesn't need to listen to events
- Loading branch information
1 parent
67d7409
commit e0921a8
Showing
9 changed files
with
144 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<app-exchange-currency-ticker [exchange]="exchange" [currency]="currency"></app-exchange-currency-ticker> | ||
<app-all-enabled-currency-tickers></app-all-enabled-currency-tickers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
web/src/app/shared/all-enabled-currency-tickers/all-enabled-currency-tickers.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div style="width:1000px"> | ||
<md-grid-list cols="3" rowHeight="2:1" > | ||
<md-grid-tile *ngFor="let ticker of tickerCards"> | ||
<app-exchange-currency-ticker [ticker]="ticker" ></app-exchange-currency-ticker> | ||
</md-grid-tile> | ||
</md-grid-list> | ||
</div> |
18 changes: 18 additions & 0 deletions
18
web/src/app/shared/all-enabled-currency-tickers/all-enabled-currency-tickers.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.example-form { | ||
min-width: 150px; | ||
width: 100%; | ||
} | ||
|
||
.example-full-width { | ||
width: 100%; | ||
} | ||
|
||
.exchange-card { | ||
margin-bottom: 20px; | ||
width: 300px; | ||
} | ||
|
||
md-grid-tile { | ||
width:300px; | ||
padding:10px; | ||
} |
25 changes: 25 additions & 0 deletions
25
...rc/app/shared/all-enabled-currency-tickers/all-enabled-currency-tickers.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AllEnabledCurrencyTickersComponent } from './all-enabled-currency-tickers.component'; | ||
|
||
describe('AllEnabledCurrencyTickersComponent', () => { | ||
let component: AllEnabledCurrencyTickersComponent; | ||
let fixture: ComponentFixture<AllEnabledCurrencyTickersComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ AllEnabledCurrencyTickersComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AllEnabledCurrencyTickersComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
82 changes: 82 additions & 0 deletions
82
web/src/app/shared/all-enabled-currency-tickers/all-enabled-currency-tickers.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { WebsocketHandlerService } from './../../services/websocket-handler/websocket-handler.service'; | ||
|
||
@Component({ | ||
selector: 'app-all-enabled-currency-tickers', | ||
templateUrl: './all-enabled-currency-tickers.component.html', | ||
styleUrls: ['./all-enabled-currency-tickers.component.scss'] | ||
}) | ||
export class AllEnabledCurrencyTickersComponent implements OnInit { | ||
private ws: WebsocketHandlerService; | ||
allCurrencies:ExchangeCurrency[]; | ||
tickerCards: TickerUpdate[]; | ||
|
||
|
||
|
||
constructor(private websocketHandler: WebsocketHandlerService) { | ||
this.ws = websocketHandler; | ||
this.allCurrencies = <ExchangeCurrency[]>[]; | ||
this.tickerCards = <TickerUpdate[]>[]; | ||
this.ws.messages.subscribe(msg => { | ||
if (msg.Event === 'ticker_update') { | ||
var modal = <ExchangeCurrency>{}; | ||
modal.currencyPair = msg.data.CurrencyPair; | ||
modal.exchangeName = msg.Exchange; | ||
var found = false; | ||
|
||
for(var i = 0; i< this.allCurrencies.length; i++) { | ||
if(this.allCurrencies[i].currencyPair === msg.data.CurrencyPair && | ||
this.allCurrencies[i].exchangeName === msg.Exchange) { | ||
found = true; | ||
} | ||
} | ||
if(!found) { | ||
//time to add | ||
var ticker = <TickerUpdate>msg.data; | ||
ticker.Exchange = msg.Exchange; | ||
this.tickerCards.push(ticker); | ||
this.allCurrencies.push(modal); | ||
console.log(JSON.stringify(this.allCurrencies)); | ||
} else { | ||
console.log('deleting'); | ||
for(var i = 0; i< this.tickerCards.length; i++) { | ||
if(this.tickerCards[i].Exchange === msg.Exchange | ||
&& this.tickerCards[i].CurrencyPair === msg.data.CurrencyPair) { | ||
this.tickerCards.slice(this.tickerCards.indexOf(this.tickerCards[i])); | ||
var ticker = <TickerUpdate>msg.data; | ||
this.tickerCards.splice(i,0,ticker); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} | ||
|
||
export interface ExchangeCurrency { | ||
currencyPair: string; | ||
exchangeName:string; | ||
} | ||
|
||
export interface CurrencyPair { | ||
delimiter: string; | ||
first_currency: string; | ||
second_currency: string; | ||
} | ||
|
||
export interface TickerUpdate { | ||
Pair: CurrencyPair; | ||
CurrencyPair: string; | ||
Last: number; | ||
High: number; | ||
Low: number; | ||
Bid: number; | ||
Ask: number; | ||
Volume: number; | ||
PriceATH: number; | ||
Exchange:string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
.exchange-card { | ||
margin-bottom: 20px; | ||
width: 500px; | ||
width: 300px; | ||
} | ||
|
||
.md-fab { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters