Browse Source

chore(refactor): change patch function arguments

pull/4469/head
tobikugel 4 weeks ago
committed by Thomas Kaul
parent
commit
6c84e7d9a8
  1. 9
      apps/api/src/app/admin/admin.controller.ts
  2. 3
      apps/api/src/app/admin/admin.service.ts
  3. 10
      apps/api/src/app/admin/update-asset-profile.dto.ts
  4. 65
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  5. 4
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
  6. 2
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.module.ts
  7. 7
      apps/client/src/app/services/admin.service.ts
  8. 3
      libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts

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

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

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

@ -470,8 +470,7 @@ export class AdminService {
} }
public async patchAssetProfileData( public async patchAssetProfileData(
dataSource: DataSource, { dataSource, symbol }: AssetProfileIdentifier,
symbol: string,
{ {
assetClass, assetClass,
assetSubClass, assetSubClass,

10
apps/api/src/app/admin/update-asset-profile.dto.ts

@ -31,17 +31,13 @@ export class UpdateAssetProfileDto {
@IsOptional() @IsOptional()
currency?: string; currency?: string;
@IsString()
@IsOptional()
name?: string;
@IsEnum(DataSource, { each: true }) @IsEnum(DataSource, { each: true })
@IsOptional() @IsOptional()
dataSource?: DataSource; dataSource?: DataSource;
@IsString() @IsString()
@IsOptional() @IsOptional()
symbol?: string; name?: string;
@IsObject() @IsObject()
@IsOptional() @IsOptional()
@ -51,6 +47,10 @@ export class UpdateAssetProfileDto {
@IsOptional() @IsOptional()
sectors?: Prisma.InputJsonArray; sectors?: Prisma.InputJsonArray;
@IsString()
@IsOptional()
symbol?: string;
@IsObject() @IsObject()
@IsOptional() @IsOptional()
symbolMapping?: { symbolMapping?: {

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

@ -36,7 +36,6 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
import { import {
AssetClass, AssetClass,
AssetSubClass, AssetSubClass,
@ -146,7 +145,6 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
public dialogRef: MatDialogRef<AssetProfileDialog>, public dialogRef: MatDialogRef<AssetProfileDialog>,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private notificationService: NotificationService, private notificationService: NotificationService,
private router: Router,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private userService: UserService private userService: UserService
) {} ) {}
@ -256,14 +254,13 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
private isNewSymbolValid(control: AbstractControl): ValidationErrors { private isNewSymbolValid(control: AbstractControl): ValidationErrors {
const currentAssetProfileIdentifier: AssetProfileIdentifier | undefined = const currentAssetProfileIdentifier: AssetProfileIdentifier | undefined =
control.get('editedSearchSymbol').value; control.get('editedSearchSymbol').value;
console.log(this.assetProfileIdentifierForm?.valid);
if ( if (
currentAssetProfileIdentifier.dataSource === this.data?.dataSource && currentAssetProfileIdentifier.dataSource === this.data?.dataSource &&
currentAssetProfileIdentifier.symbol === this.data?.symbol currentAssetProfileIdentifier.symbol === this.data?.symbol
) { ) {
return { return {
isPreviousIdentifier: true equalsPreviousSymbol: true
}; };
} }
} }
@ -276,6 +273,16 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
return this.assetProfile?.dataSource === 'MANUAL'; return this.assetProfile?.dataSource === 'MANUAL';
} }
public onCancelEditSymboleMode() {
this.isEditSymbolMode = false;
this.assetProfileForm.enable();
this.assetProfileIdentifierForm.reset();
this.changeDetectorRef.markForCheck();
}
public onClose() { public onClose() {
this.dialogRef.close(); this.dialogRef.close();
} }
@ -330,16 +337,6 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
public onCancelEditSymboleMode() {
this.isEditSymbolMode = false;
this.assetProfileForm.enable();
this.assetProfileIdentifierForm.reset();
this.changeDetectorRef.markForCheck();
}
public async onSubmitAssetProfileIdentifierForm() { public async onSubmitAssetProfileIdentifierForm() {
const assetProfileIdentifierData: UpdateAssetProfileDto = { const assetProfileIdentifierData: UpdateAssetProfileDto = {
dataSource: dataSource:
@ -357,13 +354,20 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}); });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return; return;
} }
this.adminService this.adminService
.patchAssetProfile(this.data.dataSource, this.data.symbol, { .patchAssetProfile(
...assetProfileIdentifierData {
}) dataSource: this.data.dataSource,
symbol: this.data.symbol
},
{
...assetProfileIdentifierData
}
)
.pipe( .pipe(
catchError((error: HttpErrorResponse) => { catchError((error: HttpErrorResponse) => {
if (error.status === 409) { if (error.status === 409) {
@ -471,9 +475,15 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
} }
this.adminService this.adminService
.patchAssetProfile(this.data.dataSource, this.data.symbol, { .patchAssetProfile(
...assetProfileData {
}) dataSource: this.data.dataSource,
symbol: this.data.symbol
},
{
...assetProfileData
}
)
.subscribe(() => { .subscribe(() => {
this.initialize(); this.initialize();
}); });
@ -550,20 +560,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.unsubscribeSubject.complete(); this.unsubscribeSubject.complete();
} }
public onOpenAssetProfileDialog({ public onTriggerSubmitAssetProfileForm() {
dataSource,
symbol
}: AssetProfileIdentifier) {
this.router.navigate([], {
queryParams: {
dataSource,
symbol,
assetProfileDialog: true
}
});
}
public triggerProfileFormSubmit() {
if (this.assetProfileForm) { if (this.assetProfileForm) {
this.assetProfileFormElement.nativeElement.requestSubmit(); this.assetProfileFormElement.nativeElement.requestSubmit();
} }

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

@ -113,7 +113,7 @@
assetProfileIdentifierForm.hasError( assetProfileIdentifierForm.hasError(
'invalidData', 'invalidData',
'editedSearchSymbol' 'editedSearchSymbol'
) || assetProfileIdentifierForm.hasError('isPreviousIdentifier') ) || assetProfileIdentifierForm.hasError('equalsPreviousSymbol')
" "
> >
Apply Apply
@ -512,7 +512,7 @@
color="primary" color="primary"
mat-flat-button mat-flat-button
[disabled]="!(assetProfileForm.dirty && assetProfileForm.valid)" [disabled]="!(assetProfileForm.dirty && assetProfileForm.valid)"
(click)="triggerProfileFormSubmit()" (click)="onTriggerSubmitAssetProfileForm()"
> >
<ng-container i18n>Save</ng-container> <ng-container i18n>Save</ng-container>
</button> </button>

2
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.module.ts

@ -31,8 +31,8 @@ import { AssetProfileDialog } from './asset-profile-dialog.component';
GfCurrencySelectorComponent, GfCurrencySelectorComponent,
GfHistoricalMarketDataEditorComponent, GfHistoricalMarketDataEditorComponent,
GfLineChartComponent, GfLineChartComponent,
GfSymbolAutocompleteComponent,
GfPortfolioProportionChartComponent, GfPortfolioProportionChartComponent,
GfSymbolAutocompleteComponent,
GfValueComponent, GfValueComponent,
MatButtonModule, MatButtonModule,
MatCheckboxModule, MatCheckboxModule,

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

@ -204,8 +204,7 @@ export class AdminService {
} }
public patchAssetProfile( public patchAssetProfile(
dataSource: DataSource, { dataSource, symbol }: AssetProfileIdentifier,
symbol: string,
{ {
assetClass, assetClass,
assetSubClass, assetSubClass,
@ -229,11 +228,11 @@ export class AdminService {
comment, comment,
countries, countries,
currency, currency,
name,
dataSource: newDataSource, dataSource: newDataSource,
symbol: newSymbol, name,
scraperConfiguration, scraperConfiguration,
sectors, sectors,
symbol: newSymbol,
symbolMapping, symbolMapping,
url url
} }

3
libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts

@ -194,9 +194,6 @@ export class GfSymbolAutocompleteComponent
} }
private validateRequired() { private validateRequired() {
console.log(`dataSource: ${super.value?.dataSource}`);
console.log(`symbol: ${super.value?.symbol}`);
const requiredCheck = super.required const requiredCheck = super.required
? !super.value?.dataSource || !super.value?.symbol ? !super.value?.dataSource || !super.value?.symbol
: false; : false;

Loading…
Cancel
Save