diff --git a/src/app/_services/stock.service.ts b/src/app/_services/stock.service.ts index 67bda10..27dccdd 100644 --- a/src/app/_services/stock.service.ts +++ b/src/app/_services/stock.service.ts @@ -1,9 +1,14 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; +import {JsonpModule, Jsonp, Response} from '@angular/http'; + import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map' +const httpOptions = { + headers: new HttpHeaders({ 'Content-Type': 'text/html' }) +} @Injectable({ providedIn: 'root' @@ -11,32 +16,28 @@ import 'rxjs/add/operator/map' export class StockService { constructor( - private http: HttpClient + private http: HttpClient, + private jsonp: Jsonp ) { } getLogos( symbols ) { var symbolsComma = ""; - var count = 0; + var commaCheck = false; - //console.log(symbols) for( var symbol in symbols ){ - if( count != 0 ){ + if( commaCheck ){ symbolsComma += ","; - } - count++; - //console.log(symbols[symbol].Symbol) + commaCheck = true; symbolsComma += symbols[symbol].Symbol; } - console.log(symbolsComma); - - - const url = "https://api.iextrading.com/1.0/stock/market/batch?symbols=" + symbolsComma + "&types=logo"; - return this.http.get(url) + + const url = "https://api.iextrading.com/1.0/stock/market/batch?symbols=" + symbolsComma + "&types=logo&callback=JSONP_CALLBACK"; + return this.jsonp.request(url) .map(logos => { - return logos; + return logos["_body"]; }); } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8fd1ccf..fa3c899 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,8 +9,8 @@ import { SearchViewComponent } from './search-view/search-view.component'; import { StockViewComponent } from './stock-view/stock-view.component'; import { HttpClientModule } from '@angular/common/http'; +import { JsonpModule } from '@angular/http'; import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api'; -//import { InMemoryDataService } from './_mockdata/mock-data-users'; import { InMemoryDataService } from './_mockdata/mock-data-nasdaq'; import { AlertComponent } from './_helpers/alert.component'; @@ -55,7 +55,8 @@ import {MatListModule} from '@angular/material/list'; MatButtonModule, MatIconModule, MatDividerModule, - MatListModule + MatListModule, + JsonpModule ], providers: [ AlertService, diff --git a/src/app/search-view/search-view.component.html b/src/app/search-view/search-view.component.html index 845f2f1..796984a 100644 --- a/src/app/search-view/search-view.component.html +++ b/src/app/search-view/search-view.component.html @@ -17,7 +17,13 @@
- {{company.Name}} + +
+

{{company.Name}}

+ +
+
+
diff --git a/src/app/search-view/search-view.component.ts b/src/app/search-view/search-view.component.ts index 029be4d..92bb9b1 100644 --- a/src/app/search-view/search-view.component.ts +++ b/src/app/search-view/search-view.component.ts @@ -25,7 +25,8 @@ export class SearchViewComponent implements OnInit { } searchCompany( searchData ){ - this.nasdaqSearchService.query( searchData ) + if( searchData.length > 3 ){ + this.nasdaqSearchService.query( searchData ) .subscribe( data => { if( Object.keys(data).length === 0 ){ @@ -46,6 +47,7 @@ export class SearchViewComponent implements OnInit { //console.log(error) //this.alertService.error( "Bad username or password" ); }); + } } getLogos( companySearchResults ){ @@ -60,12 +62,12 @@ export class SearchViewComponent implements OnInit { //console.log(data[0].userName); //localStorage.setItem('currentUser', JSON.stringify(data[0])); //this.router.navigate(["home"]); - + console.log("good?"); console.log( data ); //this.searchResults = data; //this.companySearchResults( data ); - //this.searchResults = companySearchResults; - //this.searchResultLogos = data; + this.searchResults = companySearchResults; + this.searchResultLogos = data; } }, error => { diff --git a/src/styles.css b/src/styles.css index 8cbee25..12ac91d 100644 --- a/src/styles.css +++ b/src/styles.css @@ -30,4 +30,11 @@ .alert-danger mat-card{ background-color: pink; +} + +.ipoMiniLogo{ + width:35px; + height: auto; + border-radius: 50%; + text-align: right; } \ No newline at end of file