Browse Source

Improve usability

pull/6406/head
Thomas Kaul 2 days ago
parent
commit
b655e63d4f
  1. 6
      apps/api/src/app/admin/admin.service.ts
  2. 21
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  3. 11
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html

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

@ -470,7 +470,9 @@ export class AdminService {
let currency: EnhancedSymbolProfile['currency'] = '-'; let currency: EnhancedSymbolProfile['currency'] = '-';
let dateOfFirstActivity: EnhancedSymbolProfile['dateOfFirstActivity']; let dateOfFirstActivity: EnhancedSymbolProfile['dateOfFirstActivity'];
if (isCurrency(getCurrencyFromSymbol(symbol))) { const isCurrencyAssetProfile = isCurrency(getCurrencyFromSymbol(symbol));
if (isCurrencyAssetProfile) {
currency = getCurrencyFromSymbol(symbol); currency = getCurrencyFromSymbol(symbol);
({ activitiesCount, dateOfFirstActivity } = ({ activitiesCount, dateOfFirstActivity } =
await this.orderService.getStatisticsByCurrency(currency)); await this.orderService.getStatisticsByCurrency(currency));
@ -508,6 +510,8 @@ export class AdminService {
dataSource, dataSource,
dateOfFirstActivity, dateOfFirstActivity,
symbol, symbol,
assetClass: isCurrencyAssetProfile ? AssetClass.LIQUIDITY : undefined,
assetSubClass: isCurrencyAssetProfile ? AssetSubClass.CASH : undefined,
isActive: true isActive: true
} }
}; };

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

@ -5,7 +5,11 @@ import {
PROPERTY_IS_DATA_GATHERING_ENABLED PROPERTY_IS_DATA_GATHERING_ENABLED
} from '@ghostfolio/common/config'; } from '@ghostfolio/common/config';
import { UpdateAssetProfileDto } from '@ghostfolio/common/dtos'; import { UpdateAssetProfileDto } from '@ghostfolio/common/dtos';
import { DATE_FORMAT } from '@ghostfolio/common/helper'; import {
DATE_FORMAT,
getCurrencyFromSymbol,
isCurrency
} from '@ghostfolio/common/helper';
import { import {
AdminMarketDataDetails, AdminMarketDataDetails,
AssetClassSelectorOption, AssetClassSelectorOption,
@ -138,7 +142,6 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
}); });
public assetSubClassOptions: AssetClassSelectorOption[] = []; public assetSubClassOptions: AssetClassSelectorOption[] = [];
public assetProfile: AdminMarketDataDetails['assetProfile']; public assetProfile: AdminMarketDataDetails['assetProfile'];
public assetProfileForm = this.formBuilder.group({ public assetProfileForm = this.formBuilder.group({
@ -180,12 +183,14 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
); );
public benchmarks: Partial<SymbolProfile>[]; public benchmarks: Partial<SymbolProfile>[];
public canEditAssetProfile = true;
public countries: { public countries: {
[code: string]: { name: string; value: number }; [code: string]: { name: string; value: number };
}; };
public currencies: string[] = []; public currencies: string[] = [];
public dateRangeOptions = [ public dateRangeOptions = [
{ {
label: $localize`Current week` + ' (' + $localize`WTD` + ')', label: $localize`Current week` + ' (' + $localize`WTD` + ')',
@ -260,7 +265,7 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
} }
public get canSaveAssetProfileIdentifier() { public get canSaveAssetProfileIdentifier() {
return !this.assetProfileForm.dirty; return !this.assetProfileForm.dirty && this.canEditAssetProfile;
} }
public ngOnInit() { public ngOnInit() {
@ -322,6 +327,10 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
.subscribe(({ assetProfile, marketData }) => { .subscribe(({ assetProfile, marketData }) => {
this.assetProfile = assetProfile; this.assetProfile = assetProfile;
this.canEditAssetProfile = !isCurrency(
getCurrencyFromSymbol(this.data.symbol)
);
this.assetClassLabel = translate(this.assetProfile?.assetClass); this.assetClassLabel = translate(this.assetProfile?.assetClass);
this.assetSubClassLabel = translate(this.assetProfile?.assetSubClass); this.assetSubClassLabel = translate(this.assetProfile?.assetSubClass);
this.countries = {}; this.countries = {};
@ -390,6 +399,10 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
url: this.assetProfile?.url ?? '' url: this.assetProfile?.url ?? ''
}); });
if (!this.canEditAssetProfile) {
this.assetProfileForm.disable();
}
this.assetProfileForm.markAsPristine(); this.assetProfileForm.markAsPristine();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
@ -399,7 +412,9 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
public onCancelEditAssetProfileIdentifierMode() { public onCancelEditAssetProfileIdentifierMode() {
this.isEditAssetProfileIdentifierMode = false; this.isEditAssetProfileIdentifierMode = false;
if (this.canEditAssetProfile) {
this.assetProfileForm.enable(); this.assetProfileForm.enable();
}
this.assetProfileIdentifierForm.reset(); this.assetProfileIdentifierForm.reset();
} }

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

@ -300,6 +300,7 @@
</div> </div>
<form <form
#assetProfileFormElement #assetProfileFormElement
[class.d-none]="!canEditAssetProfile"
[formGroup]="assetProfileForm" [formGroup]="assetProfileForm"
(keyup.enter)="assetProfileForm.valid && onSubmitAssetProfileForm()" (keyup.enter)="assetProfileForm.valid && onSubmitAssetProfileForm()"
(ngSubmit)="onSubmitAssetProfileForm()" (ngSubmit)="onSubmitAssetProfileForm()"
@ -358,7 +359,9 @@
<mat-checkbox <mat-checkbox
color="primary" color="primary"
[checked]="isBenchmark" [checked]="isBenchmark"
[disabled]="isEditAssetProfileIdentifierMode" [disabled]="
!canEditAssetProfile || isEditAssetProfileIdentifierMode
"
(change)=" (change)="
isBenchmark isBenchmark
? onUnsetBenchmark({ ? onUnsetBenchmark({
@ -581,7 +584,11 @@
<mat-checkbox <mat-checkbox
color="primary" color="primary"
[checked]="isDataGatheringEnabled && (assetProfile?.isActive ?? false)" [checked]="isDataGatheringEnabled && (assetProfile?.isActive ?? false)"
[disabled]="!isDataGatheringEnabled || isEditAssetProfileIdentifierMode" [disabled]="
!canEditAssetProfile ||
!isDataGatheringEnabled ||
isEditAssetProfileIdentifierMode
"
(change)="onToggleIsActive($event)" (change)="onToggleIsActive($event)"
> >
<ng-container i18n>Data Gathering</ng-container> <ng-container i18n>Data Gathering</ng-container>

Loading…
Cancel
Save