Browse Source

Fix review comments

pull/4157/head
Amandee Ellawala 7 months ago
committed by Thomas Kaul
parent
commit
8719524441
  1. 18
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  2. 43
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html

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

@ -66,8 +66,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}), }),
name: ['', Validators.required], name: ['', Validators.required],
scraperConfiguration: this.formBuilder.group({ scraperConfiguration: this.formBuilder.group({
defaultMarketPrice: 0, defaultMarketPrice: undefined,
headers: '', headers: JSON.stringify({}),
locale: '', locale: '',
mode: '', mode: '',
selector: '', selector: '',
@ -88,13 +88,14 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
public isBenchmark = false; public isBenchmark = false;
public marketDataItems: MarketData[] = []; public marketDataItems: MarketData[] = [];
public modeValues = [ public modeValues = [
{ value: 'lazy', viewValue: 'Lazy' }, { value: 'lazy', viewValue: $localize`Lazy` },
{ value: 'instant', viewValue: 'Instant' } { value: 'instant', viewValue: $localize`Instant` }
]; ];
public selectedModeValue: string;
public scraperConfiguationIsExpanded = signal(false);
public sectors: { public sectors: {
[name: string]: { name: string; value: number }; [name: string]: { name: string; value: number };
}; };
readonly panelOpenState = signal(false);
public user: User; public user: User;
private static readonly HISTORICAL_DATA_TEMPLATE = `date;marketPrice\n${format( private static readonly HISTORICAL_DATA_TEMPLATE = `date;marketPrice\n${format(
@ -126,6 +127,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
public initialize() { public initialize() {
this.historicalDataItems = undefined; this.historicalDataItems = undefined;
this.selectedModeValue = 'lazy';
this.userService.stateChanged this.userService.stateChanged
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -196,12 +198,14 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
name: this.assetProfile.name ?? this.assetProfile.symbol, name: this.assetProfile.name ?? this.assetProfile.symbol,
scraperConfiguration: { scraperConfiguration: {
defaultMarketPrice: defaultMarketPrice:
this.assetProfile?.scraperConfiguration?.defaultMarketPrice ?? 0, this.assetProfile?.scraperConfiguration?.defaultMarketPrice,
headers: JSON.stringify( headers: JSON.stringify(
this.assetProfile?.scraperConfiguration?.headers ?? {} this.assetProfile?.scraperConfiguration?.headers ?? {}
), ),
locale: this.assetProfile?.scraperConfiguration?.locale ?? '', locale: this.assetProfile?.scraperConfiguration?.locale ?? '',
mode: this.assetProfile?.scraperConfiguration?.mode ?? '', mode:
this.assetProfile?.scraperConfiguration?.mode ??
this.selectedModeValue,
selector: this.assetProfile?.scraperConfiguration?.selector ?? '', selector: this.assetProfile?.scraperConfiguration?.selector ?? '',
url: this.assetProfile?.scraperConfiguration?.url ?? '' url: this.assetProfile?.scraperConfiguration?.url ?? ''
}, },

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

@ -281,11 +281,11 @@
<div class="mb-3"> <div class="mb-3">
<mat-accordion class="my-3"> <mat-accordion class="my-3">
<mat-expansion-panel <mat-expansion-panel
(closed)="panelOpenState.set(false)" (closed)="scraperConfiguationIsExpanded.set(false)"
(opened)="panelOpenState.set(true)" (opened)="scraperConfiguationIsExpanded.set(true)"
> >
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> Scraper Configuration </mat-panel-title> <mat-panel-title i18n> Scraper Configuration </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div formGroupName="scraperConfiguration"> <div formGroupName="scraperConfiguration">
<div class="mt-3"> <div class="mt-3">
@ -296,13 +296,11 @@
matInput matInput
type="number" type="number"
/> />
<div class="align-items-end d-flex"></div>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="mt-3"> <div class="mt-3">
<mat-form-field appearance="outline" class="w-100 without-hint"> <mat-form-field appearance="outline" class="w-100 without-hint">
<mat-label i18n>Headers</mat-label> <mat-label i18n>Headers</mat-label>
<div class="align-items-end d-flex">
<textarea <textarea
cdkTextareaAutosize cdkTextareaAutosize
formControlName="headers" formControlName="headers"
@ -310,25 +308,24 @@
type="text" type="text"
[matAutocomplete]="auto" [matAutocomplete]="auto"
></textarea> ></textarea>
</div>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="mt-3"> <div class="mt-3">
<mat-form-field appearance="outline" class="w-100 without-hint"> <mat-form-field appearance="outline" class="w-100 without-hint">
<mat-label i18n>Locale</mat-label> <mat-label i18n>Locale</mat-label>
<div class="align-items-end d-flex">
<input formControlName="locale" matInput type="text" /> <input formControlName="locale" matInput type="text" />
</div>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="mt-3"> <div class="mt-3">
<mat-form-field appearance="outline" class="w-100 without-hint"> <mat-form-field appearance="outline" class="w-100 without-hint">
<mat-label i18n>Mode</mat-label> <mat-label i18n>Mode</mat-label>
<mat-select formControlName="mode"> <mat-select
<mat-option [value]="null" /> formControlName="mode"
@for (modeVal of modeValues; track modeVal) { [(ngModel)]="selectedModeValue"
<mat-option [value]="modeVal.value">{{ >
modeVal.viewValue @for (modeValue of modeValues; track modeValue) {
<mat-option [value]="modeValue.value">{{
modeValue.viewValue
}}</mat-option> }}</mat-option>
} }
</mat-select> </mat-select>
@ -337,32 +334,38 @@
<div class="mt-3"> <div class="mt-3">
<mat-form-field appearance="outline" class="w-100 without-hint"> <mat-form-field appearance="outline" class="w-100 without-hint">
<mat-label i18n>Selector</mat-label> <mat-label i18n>Selector</mat-label>
<div class="align-items-end d-flex">
<textarea <textarea
cdkTextareaAutosize cdkTextareaAutosize
formControlName="selector" formControlName="selector"
matInput matInput
type="text" type="text"
(keyup.enter)="$event.stopPropagation()"
></textarea> ></textarea>
</div>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="mt-3"> <div class="mt-3">
<mat-form-field appearance="outline" class="w-100 without-hint"> <mat-form-field appearance="outline" class="w-100 without-hint">
<mat-label i18n>URL</mat-label> <mat-label i18n>URL</mat-label>
<div class="align-items-end d-flex">
<input formControlName="url" matInput type="text" /> <input formControlName="url" matInput type="text" />
</div>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="m-3"> <div class="my-3">
<button <button
color="accent" color="accent"
mat-flat-button mat-flat-button
type="button" type="button"
[disabled]=" [disabled]="
assetProfileForm.get('scraperConfiguration').value === '{}' assetProfileForm.controls.scraperConfiguration.controls
.defaultMarketPrice.value === null &&
assetProfileForm.controls.scraperConfiguration.controls
.headers.value === '{}' &&
assetProfileForm.controls.scraperConfiguration.controls
.locale.value === '' &&
!assetProfileForm.controls.scraperConfiguration.controls
.mode.dirty &&
assetProfileForm.controls.scraperConfiguration.controls
.selector.value === '' &&
assetProfileForm.controls.scraperConfiguration.controls.url
.value === ''
" "
(click)="onTestMarketData()" (click)="onTestMarketData()"
> >

Loading…
Cancel
Save