Skip to content

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

Feature/add data gathering toggle to asset profile details dialog (#4497)

Tobias Kugel57748a18effd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b8581363c..bb2809b7ec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
+### Added
+
+- Added support to toggle the data gathering for individual asset profiles in the asset profile details dialog of the admin control panel
+
### Changed
- Improved the check for duplicates in the preview step of the activities import (allow different comments)
diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts
index d73e2b8781..6a8906c17e 100644
--- a/apps/api/src/app/admin/admin.service.ts
+++ b/apps/api/src/app/admin/admin.service.ts
@@ -480,6 +480,7 @@ export class AdminService {
currency,
dataSource: newDataSource,
holdings,
+ isActive,
name,
scraperConfiguration,
sectors,
@@ -557,6 +558,7 @@ export class AdminService {
currency,
dataSource,
holdings,
+ isActive,
scraperConfiguration,
sectors,
symbol,
diff --git a/apps/api/src/app/admin/update-asset-profile.dto.ts b/apps/api/src/app/admin/update-asset-profile.dto.ts
index b28fe3cdcb..45923410ab 100644
--- a/apps/api/src/app/admin/update-asset-profile.dto.ts
+++ b/apps/api/src/app/admin/update-asset-profile.dto.ts
@@ -3,6 +3,7 @@ import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code';
import { AssetClass, AssetSubClass, DataSource, Prisma } from '@prisma/client';
import {
IsArray,
+ IsBoolean,
IsEnum,
IsObject,
IsOptional,
@@ -35,6 +36,10 @@ export class UpdateAssetProfileDto {
@IsOptional()
dataSource?: DataSource;
+ @IsBoolean()
+ @IsOptional()
+ isActive?: boolean;
+
@IsOptional()
@IsString()
name?: string;
diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts
index 9a4fff5eda..c72420417c 100644
--- a/apps/api/src/app/import/import.service.ts
+++ b/apps/api/src/app/import/import.service.ts
@@ -555,6 +555,7 @@ export class ImportService {
createdAt: undefined,
holdings: undefined,
id: undefined,
+ isActive: true,
sectors: undefined,
updatedAt: undefined
}
diff --git a/apps/api/src/app/order/create-order.dto.ts b/apps/api/src/app/order/create-order.dto.ts
index 6f52e70324..f40e65ba1e 100644
--- a/apps/api/src/app/order/create-order.dto.ts
+++ b/apps/api/src/app/order/create-order.dto.ts
@@ -27,12 +27,12 @@ export class CreateOrderDto {
@IsString()
accountId?: string;
- @IsOptional()
@IsEnum(AssetClass, { each: true })
+ @IsOptional()
assetClass?: AssetClass;
- @IsOptional()
@IsEnum(AssetSubClass, { each: true })
+ @IsOptional()
assetSubClass?: AssetSubClass;
@IsOptional()
@@ -49,8 +49,8 @@ export class CreateOrderDto {
@IsOptional()
customCurrency?: string;
- @IsOptional()
@IsEnum(DataSource, { each: true })
+ @IsOptional()
dataSource?: DataSource;
@IsISO8601()
diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts
index 217ec499b5..c5a902c29e 100644
--- a/apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts
+++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts
@@ -24,6 +24,7 @@ export const symbolProfileDummyData = {
createdAt: undefined,
holdings: [],
id: undefined,
+ isActive: true,
sectors: [],
updatedAt: undefined
};
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 14aa3a19e0..d9b3446990 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
@@ -34,6 +34,7 @@ import {
ValidationErrors,
Validators
} from '@angular/forms';
+import { MatCheckboxChange } from '@angular/material/checkbox';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import {
@@ -88,6 +89,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
historicalData: this.formBuilder.group({
csvString: ''
}),
+ isActive: [true],
name: ['', Validators.required],
scraperConfiguration: this.formBuilder.group({
defaultMarketPrice: null,
@@ -254,6 +256,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
historicalData: {
csvString: AssetProfileDialog.HISTORICAL_DATA_TEMPLATE
},
+ isActive: this.assetProfile?.isActive,
name: this.assetProfile.name ?? this.assetProfile.symbol,
scraperConfiguration: {
defaultMarketPrice:
@@ -395,6 +398,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
assetSubClass: this.assetProfileForm.get('assetSubClass').value,
comment: this.assetProfileForm.get('comment').value || null,
currency: this.assetProfileForm.get('currency').value,
+ isActive: this.assetProfileForm.get('isActive').value,
name: this.assetProfileForm.get('name').value,
url: this.assetProfileForm.get('url').value || null
};
@@ -538,6 +542,20 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
});
}
+ public onToggleIsActive({ checked }: MatCheckboxChange) {
+ if (checked) {
+ this.assetProfileForm.get('isActive')?.setValue(true);
+ } else {
+ this.assetProfileForm.get('isActive')?.setValue(false);
+ }
+
+ if (checked === this.assetProfile.isActive) {
+ this.assetProfileForm.get('isActive')?.markAsPristine();
+ } else {
+ this.assetProfileForm.get('isActive')?.markAsDirty();
+ }
+ }
+
public onUnsetBenchmark({ dataSource, symbol }: AssetProfileIdentifier) {
this.dataService
.deleteBenchmark({ dataSource, symbol })
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 f1e8a40bd0..c58a40a51b 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
@@ -512,7 +512,17 @@
</form>
</div>
- <div class="d-flex justify-content-end" mat-dialog-actions>
+ <div class="d-flex" mat-dialog-actions>
+ <div class="gf-spacer">
+ <mat-checkbox
+ color="primary"
+ [checked]="assetProfile?.isActive ?? false"
+ [disabled]="isEditAssetProfileIdentifierMode"
+ (change)="onToggleIsActive($event)"
+ >
+ <ng-container i18n>Data Gathering</ng-container>
+ </mat-checkbox>
+ </div>
<button i18n mat-button type="button" (click)="onClose()">Cancel</button>
<button
color="primary"
diff --git a/apps/client/src/app/services/admin.service.ts b/apps/client/src/app/services/admin.service.ts
index d03eb44e34..89769122d0 100644
--- a/apps/client/src/app/services/admin.service.ts
+++ b/apps/client/src/app/services/admin.service.ts
@@ -212,6 +212,7 @@ export class AdminService {
countries,
currency,
dataSource: newDataSource,
+ isActive,
name,
scraperConfiguration,
sectors,
@@ -229,6 +230,7 @@ export class AdminService {
countries,
currency,
dataSource: newDataSource,
+ isActive,
name,
scraperConfiguration,
sectors,
diff --git a/libs/common/src/lib/interfaces/enhanced-symbol-profile.interface.ts b/libs/common/src/lib/interfaces/enhanced-symbol-profile.interface.ts
index ce585c6a39..b810728d6c 100644
--- a/libs/common/src/lib/interfaces/enhanced-symbol-profile.interface.ts
+++ b/libs/common/src/lib/interfaces/enhanced-symbol-profile.interface.ts
@@ -22,6 +22,7 @@ export interface EnhancedSymbolProfile {
figiShareClass?: string;
holdings: Holding[];
id: string;
+ isActive: boolean;
isin?: string;
name?: string;
scraperConfiguration?: ScraperConfiguration;