diff --git a/apps/api/src/app/admin/admin.controller.ts b/apps/api/src/app/admin/admin.controller.ts index d8c05b0cc..1c8cd55c0 100644 --- a/apps/api/src/app/admin/admin.controller.ts +++ b/apps/api/src/app/admin/admin.controller.ts @@ -371,7 +371,8 @@ export class AdminController { tags: { connect: assetProfileData.tags?.map(({ id }) => { return { id }; - }) + }), + disconnect: assetProfileData.tagsDisconnected?.map(({ id }) => ({ id })) } }); } 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 f24b4501a..ca203760c 100644 --- a/apps/api/src/app/admin/update-asset-profile.dto.ts +++ b/apps/api/src/app/admin/update-asset-profile.dto.ts @@ -39,6 +39,10 @@ export class UpdateAssetProfileDto { @IsOptional() tags?: Tag[]; + @IsArray() + @IsOptional() + tagsDisconnected?: Tag[]; + @IsObject() @IsOptional() scraperConfiguration?: Prisma.InputJsonObject; diff --git a/apps/api/src/services/data-provider/manual/manual.service.ts b/apps/api/src/services/data-provider/manual/manual.service.ts index 8d6e6012c..dbd589447 100644 --- a/apps/api/src/services/data-provider/manual/manual.service.ts +++ b/apps/api/src/services/data-provider/manual/manual.service.ts @@ -30,7 +30,7 @@ import * as cheerio from 'cheerio'; import { isUUID } from 'class-validator'; import { addDays, format, isBefore } from 'date-fns'; import got, { Headers } from 'got'; -import jsonpath from 'jsonpath'; +import * as jsonpath from 'jsonpath'; @Injectable() export class ManualService implements DataProviderInterface { 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 d3025ba81..ccf19545b 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 @@ -71,6 +71,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit { }), name: ['', Validators.required], tags: new FormControl(undefined), + tagsDisconnected: new FormControl(undefined), scraperConfiguration: '', sectors: '', symbolMapping: '', @@ -172,6 +173,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit { assetSubClass: this.assetProfile.assetSubClass ?? null, comment: this.assetProfile?.comment ?? '', tags: this.assetProfile?.tags ?? [], + tagsDisconnected: [], countries: JSON.stringify( this.assetProfile?.countries?.map(({ code, weight }) => { return { code, weight }; @@ -328,6 +330,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit { assetSubClass: this.assetProfileForm.get('assetSubClass').value, comment: this.assetProfileForm.get('comment').value || null, tags: this.assetProfileForm.get('tags').value, + tagsDisconnected: this.assetProfileForm.get('tagsDisconnected').value, currency: this.assetProfileForm.get('currency').value, name: this.assetProfileForm.get('name').value, url: this.assetProfileForm.get('url').value @@ -404,6 +407,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit { return id !== aTag.id; }) ); + this.assetProfileForm.controls['tagsDisconnected'].setValue([ + ...(this.assetProfileForm.controls['tagsDisconnected'].value ?? []), + aTag + ]); this.assetProfileForm.markAsDirty(); } diff --git a/apps/client/src/app/components/header/header.component.ts b/apps/client/src/app/components/header/header.component.ts index 004fa5f3f..9da995e8b 100644 --- a/apps/client/src/app/components/header/header.component.ts +++ b/apps/client/src/app/components/header/header.component.ts @@ -176,15 +176,19 @@ export class HeaderComponent implements OnChanges { for (const filter of filters) { if (filter.type === 'ACCOUNT') { - userSetting['filters.accounts'] = filter.id ? [filter.id] : null; + userSetting['filters.accounts'] = filter.id?.length + ? [filter.id] + : null; } else if (filter.type === 'ASSET_CLASS') { - userSetting['filters.assetClasses'] = filter.id ? [filter.id] : null; + userSetting['filters.assetClasses'] = filter.id?.length + ? [filter.id] + : null; } else if (filter.type === 'DATA_SOURCE') { userSetting['filters.dataSource'] = filter.id ? filter.id : null; } else if (filter.type === 'SYMBOL') { userSetting['filters.symbol'] = filter.id ? filter.id : null; } else if (filter.type === 'TAG') { - userSetting['filters.tags'] = filter.id ? [filter.id] : null; + userSetting['filters.tags'] = filter.id?.length ? [filter.id] : null; } } diff --git a/apps/client/src/app/services/admin.service.ts b/apps/client/src/app/services/admin.service.ts index dc8eb2478..8142b5a47 100644 --- a/apps/client/src/app/services/admin.service.ts +++ b/apps/client/src/app/services/admin.service.ts @@ -245,6 +245,7 @@ export class AdminService { symbol, symbolMapping, tags, + tagsDisconnected, url }: AssetProfileIdentifier & UpdateAssetProfileDto) { return this.http.patch( @@ -260,6 +261,7 @@ export class AdminService { sectors, symbolMapping, tags, + tagsDisconnected, url } );