Skip to content

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

Feature/add support to override asset (sub) class and url in admin control panel (#3218)

Fedron82fe1de1a750
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6513785b0..f2b8c35b29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added the dividend yield to the position detail dialog (experimental)
+- Added support to override the asset class of an asset profile in the asset profile details dialog of the admin control
+- Added support to override the asset sub class of an asset profile in the asset profile details dialog of the admin control
+- Added support to override the url of an asset profile in the asset profile details dialog of the admin control
## 2.70.0 - 2024-04-02
diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts
index e8a2432e8c..2aac43a18f 100644
--- a/apps/api/src/app/admin/admin.service.ts
+++ b/apps/api/src/app/admin/admin.service.ts
@@ -25,6 +25,7 @@ import { MarketDataPreset } from '@ghostfolio/common/types';
import { BadRequestException, Injectable } from '@nestjs/common';
import {
+ AssetClass,
AssetSubClass,
DataSource,
Prisma,
@@ -332,12 +333,18 @@ export class AdminService {
scraperConfiguration,
sectors,
symbol,
- symbolMapping
+ symbolMapping,
+ url
}: Prisma.SymbolProfileUpdateInput & UniqueAsset) {
+ const symbolProfileOverrides = {
+ assetClass: assetClass as AssetClass,
+ assetSubClass: assetSubClass as AssetSubClass,
+ name: name as string,
+ url: url as string
+ };
+
const updatedSymbolProfile: Prisma.SymbolProfileUpdateInput & UniqueAsset =
{
- assetClass,
- assetSubClass,
comment,
countries,
currency,
@@ -347,16 +354,12 @@ export class AdminService {
symbol,
symbolMapping,
...(dataSource === 'MANUAL'
- ? { name }
+ ? { assetClass, assetSubClass, name, url }
: {
SymbolProfileOverrides: {
upsert: {
- create: {
- name: name as string
- },
- update: {
- name: name as string
- }
+ create: symbolProfileOverrides,
+ update: symbolProfileOverrides
}
}
})
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 4a04571949..e3de3cab1b 100644
--- a/apps/api/src/app/admin/update-asset-profile.dto.ts
+++ b/apps/api/src/app/admin/update-asset-profile.dto.ts
@@ -5,7 +5,8 @@ import {
IsISO4217CurrencyCode,
IsObject,
IsOptional,
- IsString
+ IsString,
+ IsUrl
} from 'class-validator';
export class UpdateAssetProfileDto {
@@ -46,4 +47,11 @@ export class UpdateAssetProfileDto {
symbolMapping?: {
[dataProvider: string]: string;
};
+
+ @IsOptional()
+ @IsUrl({
+ protocols: ['https'],
+ require_protocol: true
+ })
+ url?: string;
}
diff --git a/apps/api/src/services/symbol-profile/symbol-profile.service.ts b/apps/api/src/services/symbol-profile/symbol-profile.service.ts
index 656b7b7e41..915b2f7161 100644
--- a/apps/api/src/services/symbol-profile/symbol-profile.service.ts
+++ b/apps/api/src/services/symbol-profile/symbol-profile.service.ts
@@ -98,7 +98,8 @@ export class SymbolProfileService {
sectors,
symbol,
symbolMapping,
- SymbolProfileOverrides
+ SymbolProfileOverrides,
+ url
}: Prisma.SymbolProfileUpdateInput & UniqueAsset) {
return this.prismaService.symbolProfile.update({
data: {
@@ -111,7 +112,8 @@ export class SymbolProfileService {
scraperConfiguration,
sectors,
symbolMapping,
- SymbolProfileOverrides
+ SymbolProfileOverrides,
+ url
},
where: { dataSource_symbol: { dataSource, symbol } }
});
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 352e709bd3..2f0c2546bc 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
@@ -64,7 +64,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
name: ['', Validators.required],
scraperConfiguration: '',
sectors: '',
- symbolMapping: ''
+ symbolMapping: '',
+ url: ''
});
public assetProfileSubClass: string;
public benchmarks: Partial<SymbolProfile>[];
@@ -163,7 +164,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.assetProfile?.scraperConfiguration ?? {}
),
sectors: JSON.stringify(this.assetProfile?.sectors ?? []),
- symbolMapping: JSON.stringify(this.assetProfile?.symbolMapping ?? {})
+ symbolMapping: JSON.stringify(this.assetProfile?.symbolMapping ?? {}),
+ url: this.assetProfile?.url ?? ''
});
this.assetProfileForm.markAsPristine();
@@ -293,7 +295,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
currency: (<Currency>(
(<unknown>this.assetProfileForm.controls['currency'].value)
))?.value,
- name: this.assetProfileForm.controls['name'].value
+ name: this.assetProfileForm.controls['name'].value,
+ url: this.assetProfileForm.controls['url'].value
};
this.adminService
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 93240ba3a2..bc6327f0ef 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
@@ -224,7 +224,7 @@
/>
</mat-form-field>
</div>
- <div *ngIf="assetProfile?.dataSource === 'MANUAL'" class="mt-3">
+ <div class="mt-3">
<mat-form-field appearance="outline" class="w-100 without-hint">
<mat-label i18n>Asset Class</mat-label>
<mat-select formControlName="assetClass">
@@ -237,7 +237,7 @@
</mat-select>
</mat-form-field>
</div>
- <div *ngIf="assetProfile?.dataSource === 'MANUAL'" class="mt-3">
+ <div class="mt-3">
<mat-form-field appearance="outline" class="w-100 without-hint">
<mat-label i18n>Asset Sub Class</mat-label>
<mat-select formControlName="assetSubClass">
@@ -330,6 +330,12 @@
</mat-form-field>
</div>
<div>
+ <mat-form-field appearance="outline" class="w-100 without-hint">
+ <mat-label i18n>Url</mat-label>
+ <input formControlName="url" matInput type="text" />
+ </mat-form-field>
+ </div>
+ <div class="mt-3">
<mat-form-field appearance="outline" class="w-100">
<mat-label i18n>Note</mat-label>
<textarea
diff --git a/apps/client/src/app/services/admin.service.ts b/apps/client/src/app/services/admin.service.ts
index c850527a89..df2c0b603e 100644
--- a/apps/client/src/app/services/admin.service.ts
+++ b/apps/client/src/app/services/admin.service.ts
@@ -211,7 +211,8 @@ export class AdminService {
scraperConfiguration,
sectors,
symbol,
- symbolMapping
+ symbolMapping,
+ url
}: UniqueAsset & UpdateAssetProfileDto) {
return this.http.patch<EnhancedSymbolProfile>(
`/api/v1/admin/profile-data/${dataSource}/${symbol}`,
@@ -224,7 +225,8 @@ export class AdminService {
name,
scraperConfiguration,
sectors,
- symbolMapping
+ symbolMapping,
+ url
}
);
}