Skip to content

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

Feature/improve asset profile management (#1485)

Thomas Kaulb5b7af774157
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c5123b8f0..6d94b78a9c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Added
+
+- Supported a note for asset profiles
+
+### Fixed
+
+- Fixed the filter by asset sub class for the asset profiles in the admin control
+
## 1.215.0 - 2022-11-27
### Changed
@@ -538,7 +548,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
-- Support a note for activities
+- Supported a note for activities
### Todo
diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts
index d7235e9e6e..87b9b9cc60 100644
--- a/apps/api/src/app/admin/admin.service.ts
+++ b/apps/api/src/app/admin/admin.service.ts
@@ -116,6 +116,7 @@ export class AdminService {
},
assetClass: true,
assetSubClass: true,
+ comment: true,
countries: true,
dataSource: true,
Order: {
@@ -150,6 +151,7 @@ export class AdminService {
activitiesCount: symbolProfile._count.Order,
assetClass: symbolProfile.assetClass,
assetSubClass: symbolProfile.assetSubClass,
+ comment: symbolProfile.comment,
dataSource: symbolProfile.dataSource,
date: symbolProfile.Order?.[0]?.date,
symbol: symbolProfile.symbol
@@ -190,11 +192,13 @@ export class AdminService {
}
public async patchAssetProfileData({
+ comment,
dataSource,
symbol,
symbolMapping
}: Prisma.SymbolProfileUpdateInput & UniqueAsset) {
await this.symbolProfileService.updateSymbolProfile({
+ comment,
dataSource,
symbol,
symbolMapping
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 f21785f5be..228aa6f2ce 100644
--- a/apps/api/src/app/admin/update-asset-profile.dto.ts
+++ b/apps/api/src/app/admin/update-asset-profile.dto.ts
@@ -1,6 +1,10 @@
-import { IsObject, IsOptional } from 'class-validator';
+import { IsObject, IsOptional, IsString } from 'class-validator';
export class UpdateAssetProfileDto {
+ @IsString()
+ @IsOptional()
+ comment?: string;
+
@IsObject()
@IsOptional()
symbolMapping?: {
diff --git a/apps/api/src/services/symbol-profile.service.ts b/apps/api/src/services/symbol-profile.service.ts
index edf6528baf..6cbbd8a4e9 100644
--- a/apps/api/src/services/symbol-profile.service.ts
+++ b/apps/api/src/services/symbol-profile.service.ts
@@ -104,12 +104,13 @@ export class SymbolProfileService {
}
public updateSymbolProfile({
+ comment,
dataSource,
symbol,
symbolMapping
}: Prisma.SymbolProfileUpdateInput & UniqueAsset) {
return this.prismaService.symbolProfile.update({
- data: { symbolMapping },
+ data: { comment, symbolMapping },
where: { dataSource_symbol: { dataSource, symbol } }
});
}
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 7ce9dda44f..856382e5bc 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
@@ -16,6 +16,7 @@ import { UserService } from '@ghostfolio/client/services/user/user.service';
import { DATE_FORMAT, getDateFormatString } from '@ghostfolio/common/helper';
import { Filter, UniqueAsset, User } from '@ghostfolio/common/interfaces';
import { AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface';
+import { translate } from '@ghostfolio/ui/i18n';
import { AssetSubClass, DataSource } from '@prisma/client';
import { format, parseISO } from 'date-fns';
import { DeviceDetectorService } from 'ngx-device-detector';
@@ -44,10 +45,10 @@ export class AdminMarketDataComponent implements OnDestroy, OnInit {
AssetSubClass.PRECIOUS_METAL,
AssetSubClass.PRIVATE_EQUITY,
AssetSubClass.STOCK
- ].map((id) => {
+ ].map((assetSubClass) => {
return {
- id,
- label: id,
+ id: assetSubClass,
+ label: translate(assetSubClass),
type: 'ASSET_SUB_CLASS'
};
});
@@ -67,6 +68,7 @@ export class AdminMarketDataComponent implements OnDestroy, OnInit {
'marketDataItemCount',
'sectorsCount',
'countriesCount',
+ 'comment',
'actions'
];
public filters$ = new Subject<Filter[]>();
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 f835b8af25..cea4bd6840 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
@@ -100,6 +100,22 @@
</td>
</ng-container>
+ <ng-container matColumnDef="comment">
+ <th
+ *matHeaderCellDef
+ class="px-1"
+ mat-header-cell
+ mat-sort-header
+ ></th>
+ <td *matCellDef="let element" class="px-1" mat-cell>
+ <ion-icon
+ *ngIf="element.comment"
+ class="d-block"
+ name="document-text-outline"
+ ></ion-icon>
+ </td>
+ </ng-container>
+
<ng-container matColumnDef="actions">
<th *matHeaderCellDef class="px-1 text-center" mat-header-cell>
<button
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 622f5d3c70..3d7a539b39 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
@@ -30,6 +30,7 @@ import { AssetProfileDialogParams } from './interfaces/interfaces';
export class AssetProfileDialog implements OnDestroy, OnInit {
public assetProfile: EnhancedSymbolProfile;
public assetProfileForm = this.formBuilder.group({
+ comment: '',
symbolMapping: ''
});
public countries: {
@@ -86,6 +87,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}
this.assetProfileForm.setValue({
+ comment: this.assetProfile?.comment,
symbolMapping: JSON.stringify(this.assetProfile?.symbolMapping)
});
@@ -129,7 +131,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
} catch {}
const assetProfileData: UpdateAssetProfileDto = {
- symbolMapping
+ symbolMapping,
+ comment: this.assetProfileForm.controls['comment'].value ?? null
};
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 63c49d76a4..e4ada64d6b 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
@@ -148,6 +148,18 @@
></textarea>
</mat-form-field>
</div>
+ <div>
+ <mat-form-field appearance="outline" class="w-100">
+ <mat-label i18n>Note</mat-label>
+ <textarea
+ cdkAutosizeMinRows="2"
+ cdkTextareaAutosize
+ formControlName="comment"
+ matInput
+ (keyup.enter)="$event.stopPropagation()"
+ ></textarea>
+ </mat-form-field>
+ </div>
</div>
<div class="d-flex justify-content-end" mat-dialog-actions>
diff --git a/apps/client/src/app/services/admin.service.ts b/apps/client/src/app/services/admin.service.ts
index a897df97f2..07ed3a75c5 100644
--- a/apps/client/src/app/services/admin.service.ts
+++ b/apps/client/src/app/services/admin.service.ts
@@ -127,13 +127,14 @@ export class AdminService {
}
public patchAssetProfile({
+ comment,
dataSource,
symbol,
symbolMapping
}: UniqueAsset & UpdateAssetProfileDto) {
return this.http.patch<EnhancedSymbolProfile>(
`/api/v1/admin/profile-data/${dataSource}/${symbol}`,
- { symbolMapping }
+ { comment, symbolMapping }
);
}
diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts
index b41daf2d8a..6bb4b0dba1 100644
--- a/apps/client/src/app/services/data.service.ts
+++ b/apps/client/src/app/services/data.service.ts
@@ -360,6 +360,7 @@ export class DataService {
const {
ACCOUNT: filtersByAccount,
ASSET_CLASS: filtersByAssetClass,
+ ASSET_SUB_CLASS: filtersByAssetSubClass,
TAG: filtersByTag
} = groupBy(filters, (filter) => {
return filter.type;
@@ -387,6 +388,17 @@ export class DataService {
);
}
+ if (filtersByAssetSubClass) {
+ params = params.append(
+ 'assetSubClasses',
+ filtersByAssetSubClass
+ .map(({ id }) => {
+ return id;
+ })
+ .join(',')
+ );
+ }
+
if (filtersByTag) {
params = params.append(
'tags',
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 a370f947ef..499e638a40 100644
--- a/libs/common/src/lib/interfaces/enhanced-symbol-profile.interface.ts
+++ b/libs/common/src/lib/interfaces/enhanced-symbol-profile.interface.ts
@@ -8,6 +8,7 @@ export interface EnhancedSymbolProfile {
activitiesCount: number;
assetClass: AssetClass;
assetSubClass: AssetSubClass;
+ comment?: string;
countries: Country[];
createdAt: Date;
currency: string | null;
diff --git a/libs/ui/src/lib/activities-table/activities-table.component.html b/libs/ui/src/lib/activities-table/activities-table.component.html
index a650089eba..b5a7d11a50 100644
--- a/libs/ui/src/lib/activities-table/activities-table.component.html
+++ b/libs/ui/src/lib/activities-table/activities-table.component.html
@@ -299,6 +299,35 @@
<td *matFooterCellDef class="px-1" mat-footer-cell></td>
</ng-container>
+ <ng-container matColumnDef="comment">
+ <th
+ *matHeaderCellDef
+ class="d-none d-lg-table-cell px-1"
+ mat-header-cell
+ mat-sort-header
+ ></th>
+ <td
+ *matCellDef="let element"
+ class="d-none d-lg-table-cell px-1"
+ mat-cell
+ >
+ <button
+ *ngIf="element.comment"
+ class="mx-1 no-min-width px-2"
+ mat-button
+ title="Note"
+ (click)="onOpenComment(element.comment); $event.stopPropagation()"
+ >
+ <ion-icon name="document-text-outline"></ion-icon>
+ </button>
+ </td>
+ <td
+ *matFooterCellDef
+ class="d-none d-lg-table-cell px-1"
+ mat-footer-cell
+ ></td>
+ </ng-container>
+
<ng-container matColumnDef="actions">
<th *matHeaderCellDef class="px-1 text-center" mat-header-cell>
<button
@@ -345,15 +374,6 @@
</mat-menu>
</th>
<td *matCellDef="let element" class="px-1 text-center" mat-cell>
- <button
- *ngIf="element.comment && !this.showActions"
- class="mx-1 no-min-width px-2"
- mat-button
- title="Note"
- (click)="onOpenComment(element.comment)"
- >
- <ion-icon name="document-text-outline"></ion-icon>
- </button>
<button
*ngIf="this.showActions"
class="mx-1 no-min-width px-2"
diff --git a/libs/ui/src/lib/activities-table/activities-table.component.ts b/libs/ui/src/lib/activities-table/activities-table.component.ts
index c6099806e7..b1ddc683a3 100644
--- a/libs/ui/src/lib/activities-table/activities-table.component.ts
+++ b/libs/ui/src/lib/activities-table/activities-table.component.ts
@@ -94,6 +94,7 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
'currency',
'valueInBaseCurrency',
'account',
+ 'comment',
'actions'
];
diff --git a/prisma/migrations/20221128064317_added_comment_to_symbol_profile/migration.sql b/prisma/migrations/20221128064317_added_comment_to_symbol_profile/migration.sql
new file mode 100644
index 0000000000..d78222d04f
--- /dev/null
+++ b/prisma/migrations/20221128064317_added_comment_to_symbol_profile/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "SymbolProfile" ADD COLUMN "comment" TEXT;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 062d59b06e..2520172d1b 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -112,6 +112,7 @@ model Settings {
model SymbolProfile {
assetClass AssetClass?
assetSubClass AssetSubClass?
+ comment String?
countries Json?
createdAt DateTime @default(now())
currency String