test
This commit is contained in:
@@ -1,8 +1,42 @@
|
|||||||
import { InMemoryDbService } from 'angular-in-memory-web-api';
|
import { InMemoryDbService } from 'angular-in-memory-web-api';
|
||||||
|
|
||||||
export class InMemoryDataService2 implements InMemoryDbService {
|
export class InMemoryDataService implements InMemoryDbService {
|
||||||
createDb() {
|
createDb() {
|
||||||
const nasdaq = [
|
|
||||||
|
let users = [
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
firstName: "Christopher",
|
||||||
|
lastName: "Koch",
|
||||||
|
role: "B5",
|
||||||
|
email: "ckochXlazypug.net",
|
||||||
|
userName: "ckoch",
|
||||||
|
password: "test",
|
||||||
|
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJsYXp5cHVnLm5ldCIsImlhdCI6MTUzNjE4NzUwMSwiZXhwIjoxNTY3NzIzNTAxLCJhdWQiOiJ3d3cubGF6eXB1Zy5uZXQiLCJzdWIiOiJja29jaEBsYXp5cHVnLm5ldCIsImZpcnN0TmFtZSI6IkNocmlzdG9waGVyIiwiTGFzdE5hbWUiOiJLb2NoIiwiZW1haWwiOiJja29jaEBsYXp5cHVnLm5ldCIsInJvbGUiOiJCNSIsImlkIjoiMTEifQ.UcIStKvZdYqWKho1I1tVta8zNLQD7KpP4n8l93wStEI"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
firstName: "Rebecca",
|
||||||
|
lastName: "Koch",
|
||||||
|
role: "B4",
|
||||||
|
email: "rkoch@lazypug.net",
|
||||||
|
userName: "rkoch",
|
||||||
|
password: "test2",
|
||||||
|
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJsYXp5cHVnLm5ldCIsImlhdCI6MTUzNjE4NzUwMSwiZXhwIjoxNTY3NzIzNTAxLCJhdWQiOiJ3d3cubGF6eXB1Zy5uZXQiLCJzdWIiOiJya29jaEBsYXp5cHVnLm5ldCIsImZpcnN0TmFtZSI6IlJlYmVjY2EiLCJMYXN0TmFtZSI6IktvY2giLCJlbWFpbCI6InJrb2NoQGxhenlwdWcubmV0Iiwicm9sZSI6IkI0IiwiaWQiOiIxMiJ9.baXMibtXAEUbbm1Nf4VP0yefFovR2-QHpRqzLQO7CtM"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
firstName: "Henry",
|
||||||
|
lastName: "Koch",
|
||||||
|
role: "B2",
|
||||||
|
email: "hkoch@lazypug.net",
|
||||||
|
userName: "hkoch",
|
||||||
|
password: "test3",
|
||||||
|
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJsYXp5cHVnLm5ldCIsImlhdCI6MTUzNjE4NzUwMSwiZXhwIjoxNTY3NzIzNTAxLCJhdWQiOiJ3d3cubGF6eXB1Zy5uZXQiLCJzdWIiOiJoa29jaEBsYXp5cHVnLm5ldCIsImZpcnN0TmFtZSI6IkhlbnJ5IiwiTGFzdE5hbWUiOiJLb2NoIiwiZW1haWwiOiJoa29jaEBsYXp5cHVnLm5ldCIsInJvbGUiOiJCMiIsImlkIjoiMTMifQ.Y6g9h4knKoawHmQEqT9A0UGOwYr4fKENyJ1O3MP6H5g"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
let nasdaq = [
|
||||||
{
|
{
|
||||||
"Symbol": "PIH",
|
"Symbol": "PIH",
|
||||||
"Name": "1347 Property Insurance Holdings, Inc."
|
"Name": "1347 Property Insurance Holdings, Inc."
|
||||||
@@ -13564,6 +13598,7 @@ export class InMemoryDataService2 implements InMemoryDbService {
|
|||||||
"Name": "Zynga Inc."
|
"Name": "Zynga Inc."
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
return {nasdaq};
|
|
||||||
|
return {nasdaq, users};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import 'rxjs/add/operator/map'
|
import 'rxjs/add/operator/map'
|
||||||
|
|||||||
@@ -1,9 +1,43 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import 'rxjs/add/operator/map'
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class StockService {
|
export class StockService {
|
||||||
|
|
||||||
constructor() { }
|
constructor(
|
||||||
|
private http: HttpClient
|
||||||
|
) { }
|
||||||
|
|
||||||
|
getLogos( symbols ) {
|
||||||
|
|
||||||
|
var symbolsComma = "";
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
//console.log(symbols)
|
||||||
|
for( var symbol in symbols ){
|
||||||
|
if( count != 0 ){
|
||||||
|
symbolsComma += ",";
|
||||||
|
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
//console.log(symbols[symbol].Symbol)
|
||||||
|
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<any>(url)
|
||||||
|
.map(logos => {
|
||||||
|
return logos;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import { StockViewComponent } from './stock-view/stock-view.component';
|
|||||||
|
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
|
import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
|
||||||
import { InMemoryDataService } from './_mockdata/mock-data-users';
|
//import { InMemoryDataService } from './_mockdata/mock-data-users';
|
||||||
import { InMemoryDataService2 } from './_mockdata/mock-data-nasdaq';
|
import { InMemoryDataService } from './_mockdata/mock-data-nasdaq';
|
||||||
|
|
||||||
import { AlertComponent } from './_helpers/alert.component';
|
import { AlertComponent } from './_helpers/alert.component';
|
||||||
import { AlertService } from './_services/alert.service';
|
import { AlertService } from './_services/alert.service';
|
||||||
@@ -26,6 +26,8 @@ import { MatInputModule } from '@angular/material/input';
|
|||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatIconRegistry } from "@angular/material";
|
import { MatIconRegistry } from "@angular/material";
|
||||||
|
import {MatDividerModule} from '@angular/material/divider';
|
||||||
|
import {MatListModule} from '@angular/material/list';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -43,10 +45,7 @@ import { MatIconRegistry } from "@angular/material";
|
|||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
HttpClientInMemoryWebApiModule.forRoot(
|
HttpClientInMemoryWebApiModule.forRoot(
|
||||||
InMemoryDataService, { dataEncapsulation: false }
|
InMemoryDataService
|
||||||
),
|
|
||||||
HttpClientInMemoryWebApiModule.forRoot(
|
|
||||||
InMemoryDataService2, { dataEncapsulation: false }
|
|
||||||
),
|
),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
@@ -54,7 +53,9 @@ import { MatIconRegistry } from "@angular/material";
|
|||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatIconModule
|
MatIconModule,
|
||||||
|
MatDividerModule,
|
||||||
|
MatListModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AlertService,
|
AlertService,
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
<p>
|
<div class="lrContainer">
|
||||||
search-view works!
|
<mat-card class="lrCard">
|
||||||
</p>
|
<mat-card-header>
|
||||||
|
<mat-card-title>
|
||||||
|
<h2>Search IPO's</h2>
|
||||||
|
</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-form-field class="fullWidth">
|
||||||
|
<input matInput placeholder="Company"
|
||||||
|
[id]="'company'"
|
||||||
|
[type]="'text'"
|
||||||
|
[name]="'company'"
|
||||||
|
(keyup)="searchCompany($event.target.value)">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-divider></mat-divider>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<mat-list>
|
||||||
|
<mat-list-item *ngFor="let company of searchResults" (click)="onSelect(company.Symbol)"> {{company.Name}} </mat-list-item>
|
||||||
|
</mat-list>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -2,6 +2,7 @@ import { Component, OnInit, HostListener } from '@angular/core';
|
|||||||
|
|
||||||
import { EmitcomService } from '../_services/emitcom.service';
|
import { EmitcomService } from '../_services/emitcom.service';
|
||||||
import { NasdaqSearchService } from '../_services/nasdaq-search.service';
|
import { NasdaqSearchService } from '../_services/nasdaq-search.service';
|
||||||
|
import { StockService } from '../_services/stock.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-search-view',
|
selector: 'app-search-view',
|
||||||
@@ -10,15 +11,21 @@ import { NasdaqSearchService } from '../_services/nasdaq-search.service';
|
|||||||
})
|
})
|
||||||
export class SearchViewComponent implements OnInit {
|
export class SearchViewComponent implements OnInit {
|
||||||
|
|
||||||
|
searchResults;
|
||||||
|
searchResultLogos;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private emitcomService: EmitcomService,
|
private emitcomService: EmitcomService,
|
||||||
private nasdaqSearchService: NasdaqSearchService
|
private nasdaqSearchService: NasdaqSearchService,
|
||||||
|
private stockService: StockService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.nasdaqSearchService.query( "advanced m" )
|
}
|
||||||
|
|
||||||
|
searchCompany( searchData ){
|
||||||
|
this.nasdaqSearchService.query( searchData )
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => {
|
data => {
|
||||||
if( Object.keys(data).length === 0 ){
|
if( Object.keys(data).length === 0 ){
|
||||||
@@ -27,19 +34,58 @@ export class SearchViewComponent implements OnInit {
|
|||||||
//console.log(data[0].userName);
|
//console.log(data[0].userName);
|
||||||
//localStorage.setItem('currentUser', JSON.stringify(data[0]));
|
//localStorage.setItem('currentUser', JSON.stringify(data[0]));
|
||||||
//this.router.navigate(["home"]);
|
//this.router.navigate(["home"]);
|
||||||
console.log( data );
|
|
||||||
|
//console.log( data );
|
||||||
|
//this.searchResults = data;
|
||||||
|
if( data.length > 0 ){
|
||||||
|
this.getLogos( data );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
//console.log(error)
|
//console.log(error)
|
||||||
//this.alertService.error( "Bad username or password" );
|
//this.alertService.error( "Bad username or password" );
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getLogos( companySearchResults ){
|
||||||
|
|
||||||
|
this.stockService.getLogos( companySearchResults )
|
||||||
|
.subscribe(
|
||||||
|
data => {
|
||||||
|
if( Object.keys(data).length === 0 ){
|
||||||
|
//this.alertService.error( "Bad username or password" );
|
||||||
|
console.log("FAIL1");
|
||||||
|
}else{
|
||||||
|
//console.log(data[0].userName);
|
||||||
|
//localStorage.setItem('currentUser', JSON.stringify(data[0]));
|
||||||
|
//this.router.navigate(["home"]);
|
||||||
|
|
||||||
|
console.log( data );
|
||||||
|
//this.searchResults = data;
|
||||||
|
//this.companySearchResults( data );
|
||||||
|
//this.searchResults = companySearchResults;
|
||||||
|
//this.searchResultLogos = data;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log("FAIL2");
|
||||||
|
console.log(error)
|
||||||
|
//this.alertService.error( "Bad username or password" );
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSelect( selectedSymbol ){
|
||||||
|
this.emitcomService.sendData( selectedSymbol );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
@HostListener('click')
|
@HostListener('click')
|
||||||
click() {
|
click() {
|
||||||
this.emitcomService.sendData( 42 );
|
this.emitcomService.sendData( 42 );
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user