|
@ -12,10 +12,10 @@ import { |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { ActivatedRoute, Router } from '@angular/router'; |
|
|
import { ActivatedRoute, Router } from '@angular/router'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { forkJoin, Subject } from 'rxjs'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { map, takeUntil } from 'rxjs/operators'; |
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
import { CreateWatchlistItemDialog } from './create-watchlist-item-dialog/create-watchlist-item-dialog.component'; |
|
|
import { CreateWatchlistItemDialogComponent } from './create-watchlist-item-dialog/create-watchlist-item-dialog.component'; |
|
|
import { CreateWatchlistItemDialogParams } from './create-watchlist-item-dialog/interfaces/interfaces'; |
|
|
import { CreateWatchlistItemDialogParams } from './create-watchlist-item-dialog/interfaces/interfaces'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
@ -72,28 +72,21 @@ export class HomeWatchlistComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private loadWatchlistData() { |
|
|
private loadWatchlistData() { |
|
|
forkJoin({ |
|
|
this.dataService |
|
|
watchlistItems: this.dataService.fetchWatchlist(), |
|
|
.fetchWatchlist() |
|
|
allBenchmarks: this.dataService |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.fetchBenchmarks() |
|
|
.subscribe(({ watchlist }) => { |
|
|
.pipe(map((response) => response.benchmarks)) |
|
|
this.watchlist = watchlist.map((item) => ({ |
|
|
}) |
|
|
dataSource: item.dataSource, |
|
|
.pipe( |
|
|
symbol: item.symbol, |
|
|
takeUntil(this.unsubscribeSubject), |
|
|
name: item.symbol, |
|
|
map(({ watchlistItems, allBenchmarks }) => { |
|
|
marketCondition: null, |
|
|
const watchlistLookup = new Set( |
|
|
performances: null, |
|
|
watchlistItems.map((item) => `${item.dataSource}:${item.symbol}`) |
|
|
trend200d: 'UNKNOWN', |
|
|
); |
|
|
trend50d: 'UNKNOWN' |
|
|
return allBenchmarks.filter((benchmark) => |
|
|
})); |
|
|
watchlistLookup.has(`${benchmark.dataSource}:${benchmark.symbol}`) |
|
|
|
|
|
); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}) |
|
|
|
|
|
) |
|
|
|
|
|
.subscribe({ |
|
|
|
|
|
next: (filteredBenchmarks) => { |
|
|
|
|
|
this.watchlist = filteredBenchmarks; |
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -104,7 +97,7 @@ export class HomeWatchlistComponent implements OnDestroy, OnInit { |
|
|
.subscribe((user) => { |
|
|
.subscribe((user) => { |
|
|
this.user = user; |
|
|
this.user = user; |
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(CreateWatchlistItemDialog, { |
|
|
const dialogRef = this.dialog.open(CreateWatchlistItemDialogComponent, { |
|
|
autoFocus: false, |
|
|
autoFocus: false, |
|
|
data: { |
|
|
data: { |
|
|
deviceType: this.deviceType, |
|
|
deviceType: this.deviceType, |
|
@ -119,7 +112,7 @@ export class HomeWatchlistComponent implements OnDestroy, OnInit { |
|
|
.subscribe(({ dataSource, symbol } = {}) => { |
|
|
.subscribe(({ dataSource, symbol } = {}) => { |
|
|
if (dataSource && symbol) { |
|
|
if (dataSource && symbol) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.postWatchlist({ dataSource, symbol }) |
|
|
.postWatchlistItem({ dataSource, symbol }) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.subscribe({ |
|
|
.subscribe({ |
|
|
next: () => this.loadWatchlistData() |
|
|
next: () => this.loadWatchlistData() |
|
|