Feature/improve asset profile management (#1485)

* Improve asset profile management (Add note, fix filter)

* Update changelog
This commit is contained in:
Thomas Kaul
2022-11-30 20:01:17 +01:00
committed by GitHub
parent de3e0fad83
commit b5b7af7741
15 changed files with 107 additions and 17 deletions

View File

@@ -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[]>();

View File

@@ -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

View File

@@ -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

View File

@@ -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>

View File

@@ -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 }
);
}

View File

@@ -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',