Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/improve usability to delete currency asset profile (#3541)

Thomas Kaulfad1adb91ba1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c7531c698a..f696b3b21d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the allocations by ETF holding on the allocations page for the impersonation mode (experimental)
- Improved the detection of REST APIs (`JSON`) used via the scraper configuration
+- Improved the usability to delete an asset profile of type currency in the historical market data table and the asset profile details dialog of the admin control
- Refreshed the cryptocurrencies list
- Refactored the thresholds of the rules in the _X-ray_ section
- Removed the obsolete `version` from the `docker-compose` files
diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts b/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts
index add0e998fb..5494e6842a 100644
--- a/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts
+++ b/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts
@@ -124,7 +124,7 @@ export class AdminMarketDataComponent
private unsubscribeSubject = new Subject<void>();
public constructor(
- private adminMarketDataService: AdminMarketDataService,
+ public adminMarketDataService: AdminMarketDataService,
private adminService: AdminService,
private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService,
diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.html b/apps/client/src/app/components/admin-market-data/admin-market-data.html
index 5a7312026e..00931d77c5 100644
--- a/apps/client/src/app/components/admin-market-data/admin-market-data.html
+++ b/apps/client/src/app/components/admin-market-data/admin-market-data.html
@@ -24,11 +24,11 @@
<th *matHeaderCellDef class="px-1" mat-header-cell></th>
<td *matCellDef="let element" class="px-1" mat-cell>
@if (
- !(
- element.activitiesCount !== 0 ||
- element.isBenchmark ||
- element.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
- )
+ adminMarketDataService.hasPermissionToDeleteAssetProfile({
+ activitiesCount: element.activitiesCount,
+ isBenchmark: element.isBenchmark,
+ symbol: element.symbol
+ })
) {
<mat-checkbox
color="primary"
@@ -209,9 +209,11 @@
<button
mat-menu-item
[disabled]="
- element.activitiesCount !== 0 ||
- element.isBenchmark ||
- element.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
+ !adminMarketDataService.hasPermissionToDeleteAssetProfile({
+ activitiesCount: element.activitiesCount,
+ isBenchmark: element.isBenchmark,
+ symbol: element.symbol
+ })
"
(click)="
onDeleteAssetProfile({
diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
index 4ea6dd82e7..ded1a22632 100644
--- a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
+++ b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
@@ -1,5 +1,10 @@
import { AdminService } from '@ghostfolio/client/services/admin.service';
-import { UniqueAsset } from '@ghostfolio/common/interfaces';
+import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config';
+import { getCurrencyFromSymbol, isCurrency } from '@ghostfolio/common/helper';
+import {
+ AdminMarketDataItem,
+ UniqueAsset
+} from '@ghostfolio/common/interfaces';
import { Injectable } from '@angular/core';
import { EMPTY, catchError, finalize, forkJoin, takeUntil } from 'rxjs';
@@ -50,4 +55,17 @@ export class AdminMarketDataService {
.subscribe(() => {});
}
}
+
+ public hasPermissionToDeleteAssetProfile({
+ activitiesCount,
+ isBenchmark,
+ symbol
+ }: Pick<AdminMarketDataItem, 'activitiesCount' | 'isBenchmark' | 'symbol'>) {
+ return (
+ activitiesCount === 0 &&
+ !isBenchmark &&
+ !isCurrency(getCurrencyFromSymbol(symbol)) &&
+ !symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
+ );
+ }
}
diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
index 0fbacb8155..18b73a0cb6 100644
--- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
+++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
@@ -87,7 +87,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
private unsubscribeSubject = new Subject<void>();
public constructor(
- private adminMarketDataService: AdminMarketDataService,
+ public adminMarketDataService: AdminMarketDataService,
private adminService: AdminService,
private changeDetectorRef: ChangeDetectorRef,
@Inject(MAT_DIALOG_DATA) public data: AssetProfileDialogParams,
diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
index 2e0de0e656..3e39109610 100644
--- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
+++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
@@ -48,9 +48,11 @@
mat-menu-item
type="button"
[disabled]="
- assetProfile?.activitiesCount !== 0 ||
- isBenchmark ||
- data.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
+ !adminMarketDataService.hasPermissionToDeleteAssetProfile({
+ activitiesCount: assetProfile?.activitiesCount,
+ isBenchmark: isBenchmark,
+ symbol: data.symbol
+ })
"
(click)="
onDeleteProfileData({