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('symbol') symbol: string
): Promise<EnhancedSymbolProfile> {
return this.adminService.patchAssetProfileData(dataSource, symbol, {
...assetProfileData
});
return this.adminService.patchAssetProfileData(
{ dataSource, symbol },
{
...assetProfileData
}
);
}
@HasPermission(permissions.accessAdminControl)

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

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

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

@ -31,17 +31,13 @@ export class UpdateAssetProfileDto {
@IsOptional()
currency?: string;
@IsString()
@IsOptional()
name?: string;
@IsEnum(DataSource, { each: true })
@IsOptional()
dataSource?: DataSource;
@IsString()
@IsOptional()
symbol?: string;
name?: string;
@IsObject()
@IsOptional()
@ -51,6 +47,10 @@ export class UpdateAssetProfileDto {
@IsOptional()
sectors?: Prisma.InputJsonArray;
@IsString()
@IsOptional()
symbol?: string;
@IsObject()
@IsOptional()
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';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
import {
AssetClass,
AssetSubClass,
@ -146,7 +145,6 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
public dialogRef: MatDialogRef<AssetProfileDialog>,
private formBuilder: FormBuilder,
private notificationService: NotificationService,
private router: Router,
private snackBar: MatSnackBar,
private userService: UserService
) {}
@ -256,14 +254,13 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
private isNewSymbolValid(control: AbstractControl): ValidationErrors {
const currentAssetProfileIdentifier: AssetProfileIdentifier | undefined =
control.get('editedSearchSymbol').value;
console.log(this.assetProfileIdentifierForm?.valid);
if (
currentAssetProfileIdentifier.dataSource === this.data?.dataSource &&
currentAssetProfileIdentifier.symbol === this.data?.symbol
) {
return {
isPreviousIdentifier: true
equalsPreviousSymbol: true
};
}
}
@ -276,6 +273,16 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
return this.assetProfile?.dataSource === 'MANUAL';
}
public onCancelEditSymboleMode() {
this.isEditSymbolMode = false;
this.assetProfileForm.enable();
this.assetProfileIdentifierForm.reset();
this.changeDetectorRef.markForCheck();
}
public onClose() {
this.dialogRef.close();
}
@ -330,16 +337,6 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.changeDetectorRef.markForCheck();
}
public onCancelEditSymboleMode() {
this.isEditSymbolMode = false;
this.assetProfileForm.enable();
this.assetProfileIdentifierForm.reset();
this.changeDetectorRef.markForCheck();
}
public async onSubmitAssetProfileIdentifierForm() {
const assetProfileIdentifierData: UpdateAssetProfileDto = {
dataSource:
@ -357,13 +354,20 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
});
} catch (error) {
console.error(error);
return;
}
this.adminService
.patchAssetProfile(this.data.dataSource, this.data.symbol, {
...assetProfileIdentifierData
})
.patchAssetProfile(
{
dataSource: this.data.dataSource,
symbol: this.data.symbol
},
{
...assetProfileIdentifierData
}
)
.pipe(
catchError((error: HttpErrorResponse) => {
if (error.status === 409) {
@ -471,9 +475,15 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}
this.adminService
.patchAssetProfile(this.data.dataSource, this.data.symbol, {
...assetProfileData
})
.patchAssetProfile(
{
dataSource: this.data.dataSource,
symbol: this.data.symbol
},
{
...assetProfileData
}
)
.subscribe(() => {
this.initialize();
});
@ -550,20 +560,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.unsubscribeSubject.complete();
}
public onOpenAssetProfileDialog({
dataSource,
symbol
}: AssetProfileIdentifier) {
this.router.navigate([], {
queryParams: {
dataSource,
symbol,
assetProfileDialog: true
}
});
}
public triggerProfileFormSubmit() {
public onTriggerSubmitAssetProfileForm() {
if (this.assetProfileForm) {
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(
'invalidData',
'editedSearchSymbol'
) || assetProfileIdentifierForm.hasError('isPreviousIdentifier')
) || assetProfileIdentifierForm.hasError('equalsPreviousSymbol')
"
>
Apply
@ -512,7 +512,7 @@
color="primary"
mat-flat-button
[disabled]="!(assetProfileForm.dirty && assetProfileForm.valid)"
(click)="triggerProfileFormSubmit()"
(click)="onTriggerSubmitAssetProfileForm()"
>
<ng-container i18n>Save</ng-container>
</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,
GfHistoricalMarketDataEditorComponent,
GfLineChartComponent,
GfSymbolAutocompleteComponent,
GfPortfolioProportionChartComponent,
GfSymbolAutocompleteComponent,
GfValueComponent,
MatButtonModule,
MatCheckboxModule,

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

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

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

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

Loading…
Cancel
Save