Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/fix reload of position detail dialog (#603)
Thomas Kaul124bdc028d66
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 707896b008..0a9f5ebb31 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed- Fixed an exception with the market state caused by a failed data provider request+- Fixed the reload of the position detail dialog (with query parameters)## 1.98.0 - 29.12.2021diff --git a/apps/client/src/app/components/home-holdings/home-holdings.component.ts b/apps/client/src/app/components/home-holdings/home-holdings.component.tsindex 13b6ffe0de..3d26b373e0 100644--- a/apps/client/src/app/components/home-holdings/home-holdings.component.ts+++ b/apps/client/src/app/components/home-holdings/home-holdings.component.ts@@ -48,7 +48,7 @@ export class HomeHoldingsComponent implements OnDestroy, OnInit {.pipe(takeUntil(this.unsubscribeSubject)).subscribe((params) => {if (params['positionDetailDialog'] && params['symbol']) {- this.openDialog(params['symbol']);+ this.openPositionDialog({ symbol: params['symbol'] });}});@@ -91,24 +91,31 @@ export class HomeHoldingsComponent implements OnDestroy, OnInit {this.unsubscribeSubject.complete();}- private openDialog(aSymbol: string): void {- const dialogRef = this.dialog.open(PositionDetailDialog, {- autoFocus: false,- data: {- baseCurrency: this.user?.settings?.baseCurrency,- deviceType: this.deviceType,- locale: this.user?.settings?.locale,- symbol: aSymbol- },- height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',- width: this.deviceType === 'mobile' ? '100vw' : '50rem'- });-- dialogRef- .afterClosed()+ private openPositionDialog({ symbol }: { symbol: string }) {+ this.userService+ .get().pipe(takeUntil(this.unsubscribeSubject))- .subscribe(() => {- this.router.navigate(['.'], { relativeTo: this.route });+ .subscribe((user) => {+ this.user = user;++ const dialogRef = this.dialog.open(PositionDetailDialog, {+ autoFocus: false,+ data: {+ symbol,+ baseCurrency: this.user?.settings?.baseCurrency,+ deviceType: this.deviceType,+ locale: this.user?.settings?.locale+ },+ height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',+ width: this.deviceType === 'mobile' ? '100vw' : '50rem'+ });++ dialogRef+ .afterClosed()+ .pipe(takeUntil(this.unsubscribeSubject))+ .subscribe(() => {+ this.router.navigate(['.'], { relativeTo: this.route });+ });});}diff --git a/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html b/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.htmlindex 00d949263b..3bd2b780b0 100644--- a/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html+++ b/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html@@ -12,7 +12,7 @@<div class="col-12 d-flex justify-content-center mb-3"><gf-valuesize="large"- [currency]="data.baseCurrency"+ [currency]="currency"[locale]="data.locale"[value]="value"></gf-value>diff --git a/apps/client/src/app/components/positions-table/positions-table.component.ts b/apps/client/src/app/components/positions-table/positions-table.component.tsindex da6fe7f54f..b06a052bed 100644--- a/apps/client/src/app/components/positions-table/positions-table.component.ts+++ b/apps/client/src/app/components/positions-table/positions-table.component.ts@@ -9,16 +9,13 @@ import {Output,ViewChild} from '@angular/core';-import { MatDialog } from '@angular/material/dialog';import { MatPaginator } from '@angular/material/paginator';import { MatSort } from '@angular/material/sort';import { MatTableDataSource } from '@angular/material/table';-import { ActivatedRoute, Router } from '@angular/router';-import { PositionDetailDialog } from '@ghostfolio/client/components/position/position-detail-dialog/position-detail-dialog.component';+import { Router } from '@angular/router';import { PortfolioPosition } from '@ghostfolio/common/interfaces';import { AssetClass, Order as OrderModel } from '@prisma/client';import { Subject, Subscription } from 'rxjs';-import { takeUntil } from 'rxjs/operators';@Component({selector: 'gf-positions-table',@@ -48,21 +45,7 @@ export class PositionsTableComponent implements OnChanges, OnDestroy, OnInit {private unsubscribeSubject = new Subject<void>();- public constructor(- private dialog: MatDialog,- private route: ActivatedRoute,- private router: Router- ) {- this.routeQueryParams = route.queryParams- .pipe(takeUntil(this.unsubscribeSubject))- .subscribe((params) => {- if (params['positionDetailDialog'] && params['symbol']) {- this.openPositionDialog({- symbol: params['symbol']- });- }- });- }+ public constructor(private router: Router) {}public ngOnInit() {}@@ -105,27 +88,6 @@ export class PositionsTableComponent implements OnChanges, OnDestroy, OnInit {});}- public openPositionDialog({ symbol }: { symbol: string }): void {- const dialogRef = this.dialog.open(PositionDetailDialog, {- autoFocus: false,- data: {- symbol,- baseCurrency: this.baseCurrency,- deviceType: this.deviceType,- locale: this.locale- },- height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',- width: this.deviceType === 'mobile' ? '100vw' : '50rem'- });-- dialogRef- .afterClosed()- .pipe(takeUntil(this.unsubscribeSubject))- .subscribe(() => {- this.router.navigate(['.'], { relativeTo: this.route });- });- }-public ngOnDestroy() {this.unsubscribeSubject.next();this.unsubscribeSubject.complete();diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.tsindex 482313244e..678c87801b 100644--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts@@ -1,4 +1,7 @@import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';+import { MatDialog } from '@angular/material/dialog';+import { ActivatedRoute, Router } from '@angular/router';+import { PositionDetailDialog } from '@ghostfolio/client/components/position/position-detail-dialog/position-detail-dialog.component';import { DataService } from '@ghostfolio/client/services/data.service';import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';import { UserService } from '@ghostfolio/client/services/user/user.service';@@ -12,7 +15,7 @@ import {import { ToggleOption } from '@ghostfolio/common/types';import { AssetClass } from '@prisma/client';import { DeviceDetectorService } from 'ngx-device-detector';-import { Subject } from 'rxjs';+import { Subject, Subscription } from 'rxjs';import { takeUntil } from 'rxjs/operators';@Component({@@ -51,6 +54,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {>;};public positionsArray: PortfolioPosition[];+ public routeQueryParams: Subscription;public sectors: {[name: string]: { name: string; value: number };};@@ -69,9 +73,22 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {private changeDetectorRef: ChangeDetectorRef,private dataService: DataService,private deviceService: DeviceDetectorService,+ private dialog: MatDialog,private impersonationStorageService: ImpersonationStorageService,+ private route: ActivatedRoute,+ private router: Router,private userService: UserService- ) {}+ ) {+ this.routeQueryParams = route.queryParams+ .pipe(takeUntil(this.unsubscribeSubject))+ .subscribe((params) => {+ if (params['positionDetailDialog'] && params['symbol']) {+ this.openPositionDialog({+ symbol: params['symbol']+ });+ }+ });+ }/*** Initializes the controller@@ -266,4 +283,32 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {this.unsubscribeSubject.next();this.unsubscribeSubject.complete();}++ private openPositionDialog({ symbol }: { symbol: string }) {+ this.userService+ .get()+ .pipe(takeUntil(this.unsubscribeSubject))+ .subscribe((user) => {+ this.user = user;++ const dialogRef = this.dialog.open(PositionDetailDialog, {+ autoFocus: false,+ data: {+ symbol,+ baseCurrency: this.user?.settings?.baseCurrency,+ deviceType: this.deviceType,+ locale: this.user?.settings?.locale+ },+ height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',+ width: this.deviceType === 'mobile' ? '100vw' : '50rem'+ });++ dialogRef+ .afterClosed()+ .pipe(takeUntil(this.unsubscribeSubject))+ .subscribe(() => {+ this.router.navigate(['.'], { relativeTo: this.route });+ });+ });+ }}diff --git a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.tsindex 59342f3356..2b9f85a0df 100644--- a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts+++ b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts@@ -255,27 +255,6 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {});}- public openPositionDialog({ symbol }: { symbol: string }): void {- const dialogRef = this.dialog.open(PositionDetailDialog, {- autoFocus: false,- data: {- symbol,- baseCurrency: this.user?.settings?.baseCurrency,- deviceType: this.deviceType,- locale: this.user?.settings?.locale- },- height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',- width: this.deviceType === 'mobile' ? '100vw' : '50rem'- });-- dialogRef- .afterClosed()- .pipe(takeUntil(this.unsubscribeSubject))- .subscribe(() => {- this.router.navigate(['.'], { relativeTo: this.route });- });- }-public openUpdateTransactionDialog({accountId,currency,@@ -412,4 +391,32 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {this.router.navigate(['.'], { relativeTo: this.route });});}++ private openPositionDialog({ symbol }: { symbol: string }) {+ this.userService+ .get()+ .pipe(takeUntil(this.unsubscribeSubject))+ .subscribe((user) => {+ this.user = user;++ const dialogRef = this.dialog.open(PositionDetailDialog, {+ autoFocus: false,+ data: {+ symbol,+ baseCurrency: this.user?.settings?.baseCurrency,+ deviceType: this.deviceType,+ locale: this.user?.settings?.locale+ },+ height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',+ width: this.deviceType === 'mobile' ? '100vw' : '50rem'+ });++ dialogRef+ .afterClosed()+ .pipe(takeUntil(this.unsubscribeSubject))+ .subscribe(() => {+ this.router.navigate(['.'], { relativeTo: this.route });+ });+ });+ }}