Browse Source

feat: implements frontend logic

pull/4469/head
tobikugel 4 weeks ago
committed by Thomas Kaul
parent
commit
d3fe2c0720
  1. 9
      apps/api/src/app/admin/admin.controller.ts
  2. 37
      apps/api/src/app/admin/admin.service.ts
  3. 52
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  4. 54
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
  5. 34
      apps/client/src/app/services/admin.service.ts

9
apps/api/src/app/admin/admin.controller.ts

@ -338,12 +338,9 @@ export class AdminController {
@Param('dataSource') dataSource: DataSource,
@Param('symbol') symbol: string
): Promise<EnhancedSymbolProfile> {
return this.adminService.patchAssetProfileData(
{ dataSource, symbol },
{
...assetProfileData
}
);
return this.adminService.patchAssetProfileData(dataSource, symbol, {
...assetProfileData
});
}
@HasPermission(permissions.accessAdminControl)

37
apps/api/src/app/admin/admin.service.ts

@ -464,42 +464,48 @@ export class AdminService {
}
public async patchAssetProfileData(
assetProfileIdentifier: AssetProfileIdentifier,
dataSource: DataSource,
symbol: string,
{
assetClass,
assetSubClass,
comment,
countries,
currency,
dataSource,
dataSource: newDataSource,
holdings,
name,
scraperConfiguration,
sectors,
symbol,
symbol: newSymbol,
symbolMapping,
url
}: Prisma.SymbolProfileUpdateInput
) {
if (
symbol &&
dataSource &&
assetProfileIdentifier.symbol !== symbol &&
assetProfileIdentifier.dataSource !== dataSource
newSymbol &&
newDataSource &&
(newSymbol !== symbol || newDataSource !== dataSource)
) {
await this.symbolProfileService.updateAssetProfileIdentifier(
assetProfileIdentifier,
{
dataSource: dataSource as DataSource, // TODO change
symbol: symbol as string
dataSource,
symbol
},
{
dataSource: newDataSource as DataSource,
symbol: newSymbol as string
}
);
await this.marketDataService.updateAssetProfileIdentifier(
assetProfileIdentifier,
{
dataSource: dataSource as DataSource,
symbol: symbol as string
dataSource,
symbol
},
{
dataSource: newDataSource as DataSource,
symbol: newSymbol as string
}
);
@ -544,7 +550,10 @@ export class AdminService {
};
await this.symbolProfileService.updateSymbolProfile(
assetProfileIdentifier,
{
dataSource,
symbol
},
updatedSymbolProfile
);

52
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -55,7 +55,12 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
return { id: assetSubClass, label: translate(assetSubClass) };
});
public assetProfile: AdminMarketDataDetails['assetProfile'];
public assetProfileIdentifierForm;
public assetProfileIdentifierForm = this.formBuilder.group({
editedSearchSymbol: new FormControl<AssetProfileIdentifier>(
{ symbol: null, dataSource: null },
[Validators.required]
)
});
public assetProfileForm = this.formBuilder.group({
assetClass: new FormControl<AssetClass>(undefined),
assetSubClass: new FormControl<AssetSubClass>(undefined),
@ -225,6 +230,14 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
});
}
public get isSymbolEditable() {
return !this.assetProfileForm.dirty;
}
public get isSymbolEditButtonInvisible() {
return this.assetProfile?.dataSource === 'MANUAL';
}
public onClose() {
this.dialogRef.close();
}
@ -284,9 +297,40 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.assetProfileForm.enable();
this.assetProfileIdentifierForm.reset();
this.changeDetectorRef.markForCheck();
}
public async onSubmitAssetProfileIdentifierForm() {
const assetProfileIdentifierData: UpdateAssetProfileDto = {
dataSource:
this.assetProfileIdentifierForm.get('editedSearchSymbol').value
.dataSource,
symbol:
this.assetProfileIdentifierForm.get('editedSearchSymbol').value.symbol
};
try {
await validateObjectForForm({
classDto: UpdateAssetProfileDto,
form: this.assetProfileIdentifierForm,
object: assetProfileIdentifierData
});
} catch (error) {
console.error(error);
return;
}
this.adminService
.patchAssetProfile(this.data.dataSource, this.data.symbol, {
...assetProfileIdentifierData
})
.subscribe(() => {
this.initialize();
});
}
public async onSubmitAssetProfileForm() {
let countries = [];
let scraperConfiguration = {};
@ -360,10 +404,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}
this.adminService
.patchAssetProfile({
...assetProfileData,
dataSource: this.data.dataSource,
symbol: this.data.symbol
.patchAssetProfile(this.data.dataSource, this.data.symbol, {
...assetProfileData
})
.subscribe(() => {
this.initialize();

54
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html

@ -88,24 +88,39 @@
<div class="row">
@if (isEditSymbolMode) {
<div class="col-12 mb-3">
<mat-form-field appearance="outline">
<mat-label i18n>Name, symbol or ISIN</mat-label>
<gf-symbol-autocomplete
formControlName="searchSymbol"
[includeIndices]="true"
/>
</mat-form-field>
<button class="mx-1 no-min-width px-2" mat-button type="button">
Apply
</button>
<button
class="mx-1 no-min-width px-2"
mat-button
type="button"
(click)="onCancelEditSymboleMode()"
<form
[formGroup]="assetProfileIdentifierForm"
(keyup.enter)="
assetProfileIdentifierForm.valid &&
onSubmitAssetProfileIdentifierForm()
"
(ngSubmit)="onSubmitAssetProfileIdentifierForm()"
>
Cancel
</button>
<mat-form-field appearance="outline">
<mat-label i18n>Name, symbol or ISIN</mat-label>
<gf-symbol-autocomplete
formControlName="editedSearchSymbol"
[includeIndices]="true"
/>
</mat-form-field>
<button
class="mx-1 no-min-width px-2"
color="primary"
mat-flat-button
type="submit"
[disabled]="!assetProfileIdentifierForm.valid"
>
Apply
</button>
<button
class="mx-1 no-min-width px-2"
mat-button
type="button"
(click)="onCancelEditSymboleMode()"
>
Cancel
</button>
</form>
</div>
} @else {
<div class="col-6 mb-3">
@ -128,7 +143,10 @@
class="mx-1 no-min-width px-2"
mat-button
type="button"
[disabled]="assetProfileForm.dirty"
[disabled]="!isSymbolEditable"
[ngClass]="{
'd-none': isSymbolEditButtonInvisible
}"
(click)="onSetEditSymboleMode()"
>
<ion-icon name="create-outline"></ion-icon>

34
apps/client/src/app/services/admin.service.ts

@ -203,20 +203,24 @@ export class AdminService {
return this.http.get<IDataProviderHistoricalResponse>(url);
}
public patchAssetProfile({
assetClass,
assetSubClass,
comment,
countries,
currency,
dataSource,
name,
scraperConfiguration,
sectors,
symbol,
symbolMapping,
url
}: AssetProfileIdentifier & UpdateAssetProfileDto) {
public patchAssetProfile(
dataSource: DataSource,
symbol: string,
{
assetClass,
assetSubClass,
comment,
countries,
currency,
dataSource: newDataSource,
name,
scraperConfiguration,
sectors,
symbol: newSymbol,
symbolMapping,
url
}: UpdateAssetProfileDto
) {
return this.http.patch<EnhancedSymbolProfile>(
`/api/v1/admin/profile-data/${dataSource}/${symbol}`,
{
@ -226,6 +230,8 @@ export class AdminService {
countries,
currency,
name,
newDataSource,
newSymbol,
scraperConfiguration,
sectors,
symbolMapping,

Loading…
Cancel
Save