From 3611684f17bb3f14a89068357c8d1fdf8a7d913f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 21 Nov 2022 20:14:36 +0100 Subject: [PATCH] Feature/extend asset profile details dialog (#1469) * Extend asset profile details dialog * Update changelog --- CHANGELOG.md | 6 ++ apps/api/src/app/admin/admin.service.ts | 17 +++- .../src/services/symbol-profile.service.ts | 26 +++++- apps/client/src/app/app.module.ts | 2 +- .../admin-market-data.component.ts | 4 +- .../admin-market-data/admin-market-data.html | 20 ++--- .../asset-profile-dialog.component.ts | 35 +++++++- .../asset-profile-dialog.html | 90 ++++++++++++++++++- .../assset-profile-dialog.module.ts | 4 + .../admin-market-data-details.interface.ts | 3 + .../enhanced-symbol-profile.interface.ts | 1 + 11 files changed, 186 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfbdfd917..2efe5eb22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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 + +### Changed + +- Extended the asset profile details dialog in the admin control panel + ## 1.214.0 - 19.11.2022 ### Added diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts index 5c7f8698a..dbf50c767 100644 --- a/apps/api/src/app/admin/admin.service.ts +++ b/apps/api/src/app/admin/admin.service.ts @@ -147,7 +147,7 @@ export class AdminService { countriesCount, marketDataItemCount, sectorsCount, - activityCount: symbolProfile._count.Order, + activitiesCount: symbolProfile._count.Order, assetClass: symbolProfile.assetClass, assetSubClass: symbolProfile.assetSubClass, dataSource: symbolProfile.dataSource, @@ -165,8 +165,14 @@ export class AdminService { dataSource, symbol }: UniqueAsset): Promise { - return { - marketData: await this.marketDataService.marketDataItems({ + const [[assetProfile], marketData] = await Promise.all([ + this.symbolProfileService.getSymbolProfiles([ + { + dataSource, + symbol + } + ]), + this.marketDataService.marketDataItems({ orderBy: { date: 'asc' }, @@ -175,6 +181,11 @@ export class AdminService { symbol } }) + ]); + + return { + assetProfile, + marketData }; } diff --git a/apps/api/src/services/symbol-profile.service.ts b/apps/api/src/services/symbol-profile.service.ts index 62bc38aab..ebd388825 100644 --- a/apps/api/src/services/symbol-profile.service.ts +++ b/apps/api/src/services/symbol-profile.service.ts @@ -43,7 +43,12 @@ export class SymbolProfileService { ): Promise { return this.prismaService.symbolProfile .findMany({ - include: { SymbolProfileOverrides: true }, + include: { + _count: { + select: { Order: true } + }, + SymbolProfileOverrides: true + }, where: { AND: [ { @@ -69,7 +74,12 @@ export class SymbolProfileService { ): Promise { return this.prismaService.symbolProfile .findMany({ - include: { SymbolProfileOverrides: true }, + include: { + _count: { + select: { Order: true } + }, + SymbolProfileOverrides: true + }, where: { id: { in: symbolProfileIds.map((symbolProfileId) => { @@ -89,7 +99,12 @@ export class SymbolProfileService { ): Promise { return this.prismaService.symbolProfile .findMany({ - include: { SymbolProfileOverrides: true }, + include: { + _count: { + select: { Order: true } + }, + SymbolProfileOverrides: true + }, where: { symbol: { in: symbols @@ -101,12 +116,14 @@ export class SymbolProfileService { private getSymbols( symbolProfiles: (SymbolProfile & { + _count: { Order: number }; SymbolProfileOverrides: SymbolProfileOverrides; })[] ): EnhancedSymbolProfile[] { return symbolProfiles.map((symbolProfile) => { const item = { ...symbolProfile, + activitiesCount: 0, countries: this.getCountries( symbolProfile?.countries as unknown as Prisma.JsonArray ), @@ -115,6 +132,9 @@ export class SymbolProfileService { symbolMapping: this.getSymbolMapping(symbolProfile) }; + item.activitiesCount = symbolProfile._count.Order; + delete item._count; + if (item.SymbolProfileOverrides) { item.assetClass = item.SymbolProfileOverrides.assetClass ?? item.assetClass; diff --git a/apps/client/src/app/app.module.ts b/apps/client/src/app/app.module.ts index b805a458f..2d1f4cc5a 100644 --- a/apps/client/src/app/app.module.ts +++ b/apps/client/src/app/app.module.ts @@ -13,6 +13,7 @@ import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatTooltipModule } from '@angular/material/tooltip'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { ServiceWorkerModule } from '@angular/service-worker'; import { MaterialCssVarsModule } from 'angular-material-css-vars'; import { MarkdownModule } from 'ngx-markdown'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @@ -27,7 +28,6 @@ import { GfHeaderModule } from './components/header/header.module'; import { authInterceptorProviders } from './core/auth.interceptor'; import { httpResponseInterceptorProviders } from './core/http-response.interceptor'; import { LanguageService } from './core/language.service'; -import { ServiceWorkerModule } from '@angular/service-worker'; export function NgxStripeFactory(): string { return environment.stripePublicKey; 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 281489f4a..7ce9dda44 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 @@ -63,10 +63,10 @@ export class AdminMarketDataComponent implements OnDestroy, OnInit { 'assetClass', 'assetSubClass', 'date', - 'activityCount', + 'activitiesCount', 'marketDataItemCount', - 'countriesCount', 'sectorsCount', + 'countriesCount', '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 226929b4d..f835b8af2 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 @@ -64,12 +64,12 @@ - + - Activity Count + Activities Count - {{ element.activityCount }} + {{ element.activitiesCount }} @@ -82,21 +82,21 @@ - + - Countries Count + Sectors Count - {{ element.countriesCount }} + {{ element.sectorsCount }} - + - Sectors Count + Countries Count - {{ element.sectorsCount }} + {{ element.countriesCount }} @@ -146,7 +146,7 @@