Browse Source
Feature/add edit exchange rate button to admin control (#2577)
* Ad edit button
* Update changelog
pull/2579/head
Thomas Kaul
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
46 additions and
8 deletions
-
CHANGELOG.md
-
apps/api/src/app/admin/admin.service.ts
-
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
-
apps/client/src/app/components/admin-overview/admin-overview.html
-
apps/client/src/app/components/admin-overview/admin-overview.module.ts
-
libs/common/src/lib/interfaces/admin-data.interface.ts
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
## Unreleased |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
|
|
- Added a button to edit the exchange rates in the admin control panel |
|
|
|
|
|
|
|
### Changed |
|
|
|
|
|
|
|
- Improved the language localization for German (`de`) |
|
|
|
|
|
@ -23,7 +23,13 @@ import { |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { MarketDataPreset } from '@ghostfolio/common/types'; |
|
|
|
import { BadRequestException, Injectable } from '@nestjs/common'; |
|
|
|
import { AssetSubClass, Prisma, Property, SymbolProfile } from '@prisma/client'; |
|
|
|
import { |
|
|
|
AssetSubClass, |
|
|
|
DataSource, |
|
|
|
Prisma, |
|
|
|
Property, |
|
|
|
SymbolProfile |
|
|
|
} from '@prisma/client'; |
|
|
|
import { differenceInDays } from 'date-fns'; |
|
|
|
import { groupBy } from 'lodash'; |
|
|
|
|
|
|
@ -94,9 +100,17 @@ export class AdminService { |
|
|
|
return currency !== DEFAULT_CURRENCY; |
|
|
|
}) |
|
|
|
.map((currency) => { |
|
|
|
const label1 = DEFAULT_CURRENCY; |
|
|
|
const label2 = currency; |
|
|
|
|
|
|
|
return { |
|
|
|
label1: DEFAULT_CURRENCY, |
|
|
|
label2: currency, |
|
|
|
label1, |
|
|
|
label2, |
|
|
|
dataSource: |
|
|
|
DataSource[ |
|
|
|
this.configurationService.get('DATA_SOURCE_EXCHANGE_RATES') |
|
|
|
], |
|
|
|
symbol: `${label1}${label2}`, |
|
|
|
value: this.exchangeRateDataService.toCurrency( |
|
|
|
1, |
|
|
|
DEFAULT_CURRENCY, |
|
|
|
|
|
@ -128,10 +128,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
this.assetProfileForm.setValue({ |
|
|
|
name: this.assetProfile.name, |
|
|
|
assetClass: this.assetProfile.assetClass, |
|
|
|
assetSubClass: this.assetProfile.assetSubClass, |
|
|
|
assetClass: this.assetProfile.assetClass ?? null, |
|
|
|
assetSubClass: this.assetProfile.assetSubClass ?? null, |
|
|
|
comment: this.assetProfile?.comment ?? '', |
|
|
|
name: this.assetProfile.name ?? this.assetProfile.symbol, |
|
|
|
scraperConfiguration: JSON.stringify( |
|
|
|
this.assetProfile?.scraperConfiguration ?? {} |
|
|
|
), |
|
|
|
|
|
@ -55,6 +55,18 @@ |
|
|
|
</td> |
|
|
|
<td class="pl-1">{{ exchangeRate.label2 }}</td> |
|
|
|
<td> |
|
|
|
<a |
|
|
|
class="h-100 mx-1 no-min-width px-2" |
|
|
|
mat-button |
|
|
|
[queryParams]="{ |
|
|
|
assetProfileDialog: true, |
|
|
|
dataSource: exchangeRate.dataSource, |
|
|
|
symbol: exchangeRate.symbol |
|
|
|
}" |
|
|
|
[routerLink]="['/admin', 'market-data']" |
|
|
|
> |
|
|
|
<ion-icon name="create-outline"></ion-icon> |
|
|
|
</a> |
|
|
|
<button |
|
|
|
*ngIf="customCurrencies.includes(exchangeRate.label2)" |
|
|
|
class="h-100 mx-1 no-min-width px-2" |
|
|
|
|
|
@ -5,6 +5,7 @@ import { MatButtonModule } from '@angular/material/button'; |
|
|
|
import { MatCardModule } from '@angular/material/card'; |
|
|
|
import { MatSelectModule } from '@angular/material/select'; |
|
|
|
import { MatSlideToggleModule } from '@angular/material/slide-toggle'; |
|
|
|
import { RouterModule } from '@angular/router'; |
|
|
|
import { CacheService } from '@ghostfolio/client/services/cache.service'; |
|
|
|
import { GfValueModule } from '@ghostfolio/ui/value'; |
|
|
|
|
|
|
@ -21,7 +22,8 @@ import { AdminOverviewComponent } from './admin-overview.component'; |
|
|
|
MatCardModule, |
|
|
|
MatSelectModule, |
|
|
|
MatSlideToggleModule, |
|
|
|
ReactiveFormsModule |
|
|
|
ReactiveFormsModule, |
|
|
|
RouterModule |
|
|
|
], |
|
|
|
providers: [CacheService], |
|
|
|
schemas: [CUSTOM_ELEMENTS_SCHEMA] |
|
|
|
|
|
@ -1,5 +1,11 @@ |
|
|
|
import { UniqueAsset } from './unique-asset.interface'; |
|
|
|
|
|
|
|
export interface AdminData { |
|
|
|
exchangeRates: { label1: string; label2: string; value: number }[]; |
|
|
|
exchangeRates: ({ |
|
|
|
label1: string; |
|
|
|
label2: string; |
|
|
|
value: number; |
|
|
|
} & UniqueAsset)[]; |
|
|
|
settings: { [key: string]: boolean | object | string | string[] }; |
|
|
|
transactionCount: number; |
|
|
|
userCount: number; |
|
|
|