From b5b7af774157ef0583706c868b0bbe5cb23e8915 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 30 Nov 2022 20:01:17 +0100 Subject: [PATCH] Feature/improve asset profile management (#1485) * Improve asset profile management (Add note, fix filter) * Update changelog --- CHANGELOG.md | 12 +++++- apps/api/src/app/admin/admin.service.ts | 4 ++ .../src/app/admin/update-asset-profile.dto.ts | 6 ++- .../src/services/symbol-profile.service.ts | 3 +- .../admin-market-data.component.ts | 8 ++-- .../admin-market-data/admin-market-data.html | 16 ++++++++ .../asset-profile-dialog.component.ts | 5 ++- .../asset-profile-dialog.html | 12 ++++++ apps/client/src/app/services/admin.service.ts | 3 +- apps/client/src/app/services/data.service.ts | 12 ++++++ .../enhanced-symbol-profile.interface.ts | 1 + .../activities-table.component.html | 38 ++++++++++++++----- .../activities-table.component.ts | 1 + .../migration.sql | 2 + prisma/schema.prisma | 1 + 15 files changed, 107 insertions(+), 17 deletions(-) create mode 100644 prisma/migrations/20221128064317_added_comment_to_symbol_profile/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c5123b8f..6d94b78a9 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 d7235e9e6..87b9b9cc6 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 f21785f5b..228aa6f2c 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 edf6528ba..6cbbd8a4e 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 7ce9dda44..856382e5b 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(); 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 f835b8af2..cea4bd684 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 @@ + + + + + + + + + + +