Browse Source

Merge branch 'ghostfolio:main' into UI_tweaks

pull/5530/head
Batwam 3 days ago
committed by GitHub
parent
commit
f4d9a632e4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 29
      apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts
  3. 12
      apps/client/src/app/pages/api/api-page.component.ts
  4. 4
      apps/client/src/app/pages/api/api-page.html
  5. 2
      libs/common/src/lib/permissions.ts
  6. 1
      libs/ui/src/lib/activities-table/activities-table.component.html
  7. 4
      package-lock.json
  8. 2
      package.json
  9. 17
      prisma/migrations/20250915163323_added_asset_profile_resolution/migration.sql
  10. 14
      prisma/schema.prisma

6
CHANGELOG.md

@ -5,13 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased ## 2.200.0 - 2025-09-17
### Changed ### Changed
- Refactored the show access token dialog component to standalone - Refactored the show access token dialog component to standalone
- Upgraded `prisma` from version `6.15.0` to `6.16.1` - Upgraded `prisma` from version `6.15.0` to `6.16.1`
### Fixed
- Removed a temporary element from the activities table component
## 2.199.0 - 2025-09-14 ## 2.199.0 - 2025-09-14
### Added ### Added

29
apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts

@ -56,11 +56,36 @@ export class GhostfolioService {
requestTimeout, requestTimeout,
symbol symbol
}) })
.then((assetProfile) => { .then(async (assetProfile) => {
const dataSourceOrigin = DataSource.GHOSTFOLIO;
if (assetProfile) {
await this.prismaService.assetProfileResolution.upsert({
create: {
dataSourceOrigin,
currency: assetProfile.currency,
dataSourceTarget: assetProfile.dataSource,
symbolOrigin: symbol,
symbolTarget: assetProfile.symbol
},
update: {
requestCount: {
increment: 1
}
},
where: {
dataSourceOrigin_symbolOrigin: {
dataSourceOrigin,
symbolOrigin: symbol
}
}
});
}
result = { result = {
...result, ...result,
...assetProfile, ...assetProfile,
dataSource: DataSource.GHOSTFOLIO dataSource: dataSourceOrigin
}; };
return assetProfile; return assetProfile;

12
apps/client/src/app/pages/api/api-page.component.ts

@ -4,6 +4,7 @@ import {
} from '@ghostfolio/common/config'; } from '@ghostfolio/common/config';
import { DATE_FORMAT } from '@ghostfolio/common/helper'; import { DATE_FORMAT } from '@ghostfolio/common/helper';
import { import {
DataProviderGhostfolioAssetProfileResponse,
DataProviderGhostfolioStatusResponse, DataProviderGhostfolioStatusResponse,
DividendsResponse, DividendsResponse,
HistoricalResponse, HistoricalResponse,
@ -25,6 +26,7 @@ import { map, Observable, Subject, takeUntil } from 'rxjs';
templateUrl: './api-page.html' templateUrl: './api-page.html'
}) })
export class GfApiPageComponent implements OnInit { export class GfApiPageComponent implements OnInit {
public assetProfile$: Observable<DataProviderGhostfolioAssetProfileResponse>;
public dividends$: Observable<DividendsResponse['dividends']>; public dividends$: Observable<DividendsResponse['dividends']>;
public historicalData$: Observable<HistoricalResponse['historicalData']>; public historicalData$: Observable<HistoricalResponse['historicalData']>;
public isinLookupItems$: Observable<LookupResponse['items']>; public isinLookupItems$: Observable<LookupResponse['items']>;
@ -40,6 +42,7 @@ export class GfApiPageComponent implements OnInit {
public ngOnInit() { public ngOnInit() {
this.apiKey = prompt($localize`Please enter your Ghostfolio API key:`); this.apiKey = prompt($localize`Please enter your Ghostfolio API key:`);
this.assetProfile$ = this.fetchAssetProfile({ symbol: 'AAPL' });
this.dividends$ = this.fetchDividends({ symbol: 'KO' }); this.dividends$ = this.fetchDividends({ symbol: 'KO' });
this.historicalData$ = this.fetchHistoricalData({ symbol: 'AAPL' }); this.historicalData$ = this.fetchHistoricalData({ symbol: 'AAPL' });
this.isinLookupItems$ = this.fetchLookupItems({ query: 'US0378331005' }); this.isinLookupItems$ = this.fetchLookupItems({ query: 'US0378331005' });
@ -53,6 +56,15 @@ export class GfApiPageComponent implements OnInit {
this.unsubscribeSubject.complete(); this.unsubscribeSubject.complete();
} }
private fetchAssetProfile({ symbol }: { symbol: string }) {
return this.http
.get<DataProviderGhostfolioAssetProfileResponse>(
`/api/v1/data-providers/ghostfolio/asset-profile/${symbol}`,
{ headers: this.getHeaders() }
)
.pipe(takeUntil(this.unsubscribeSubject));
}
private fetchDividends({ symbol }: { symbol: string }) { private fetchDividends({ symbol }: { symbol: string }) {
const params = new HttpParams() const params = new HttpParams()
.set('from', format(startOfYear(new Date()), DATE_FORMAT)) .set('from', format(startOfYear(new Date()), DATE_FORMAT))

4
apps/client/src/app/pages/api/api-page.html

@ -3,6 +3,10 @@
<h2 class="text-center">Status</h2> <h2 class="text-center">Status</h2>
<div>{{ status$ | async | json }}</div> <div>{{ status$ | async | json }}</div>
</div> </div>
<div class="mb-3">
<h2 class="text-center">Asset Profile</h2>
<div>{{ assetProfile$ | async | json }}</div>
</div>
<div> <div>
<h2 class="text-center">Lookup</h2> <h2 class="text-center">Lookup</h2>
@if (lookupItems$) { @if (lookupItems$) {

2
libs/common/src/lib/permissions.ts

@ -197,5 +197,5 @@ export function hasRole(aUser: UserWithSettings, aRole: Role) {
} }
export function isRestrictedView(aUser: UserWithSettings) { export function isRestrictedView(aUser: UserWithSettings) {
return aUser.settings.settings.isRestrictedView ?? false; return aUser?.settings?.settings?.isRestrictedView ?? false;
} }

1
libs/ui/src/lib/activities-table/activities-table.component.html

@ -129,7 +129,6 @@
[symbol]="element.SymbolProfile?.symbol" [symbol]="element.SymbolProfile?.symbol"
[tooltip]="element.SymbolProfile?.name" [tooltip]="element.SymbolProfile?.name"
/> />
<div>{{ element.dataSource }}</div>
</td> </td>
</ng-container> </ng-container>

4
package-lock.json

@ -1,12 +1,12 @@
{ {
"name": "ghostfolio", "name": "ghostfolio",
"version": "2.199.0", "version": "2.200.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ghostfolio", "name": "ghostfolio",
"version": "2.199.0", "version": "2.200.0",
"hasInstallScript": true, "hasInstallScript": true,
"license": "AGPL-3.0", "license": "AGPL-3.0",
"dependencies": { "dependencies": {

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "ghostfolio", "name": "ghostfolio",
"version": "2.199.0", "version": "2.200.0",
"homepage": "https://ghostfol.io", "homepage": "https://ghostfol.io",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"repository": "https://github.com/ghostfolio/ghostfolio", "repository": "https://github.com/ghostfolio/ghostfolio",

17
prisma/migrations/20250915163323_added_asset_profile_resolution/migration.sql

@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "public"."AssetProfileResolution" (
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"currency" TEXT NOT NULL,
"dataSourceOrigin" "public"."DataSource" NOT NULL,
"dataSourceTarget" "public"."DataSource" NOT NULL,
"id" TEXT NOT NULL,
"requestCount" INTEGER NOT NULL DEFAULT 1,
"symbolOrigin" TEXT NOT NULL,
"symbolTarget" TEXT NOT NULL,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "AssetProfileResolution_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "AssetProfileResolution_dataSourceOrigin_symbolOrigin_key" ON "public"."AssetProfileResolution"("dataSourceOrigin", "symbolOrigin");

14
prisma/schema.prisma

@ -88,6 +88,20 @@ model ApiKey {
@@index([userId]) @@index([userId])
} }
model AssetProfileResolution {
createdAt DateTime @default(now())
currency String
dataSourceOrigin DataSource
dataSourceTarget DataSource
id String @id @default(uuid())
requestCount Int @default(1)
symbolOrigin String
symbolTarget String
updatedAt DateTime @updatedAt
@@unique([dataSourceOrigin, symbolOrigin])
}
model AuthDevice { model AuthDevice {
createdAt DateTime @default(now()) createdAt DateTime @default(now())
credentialId Bytes credentialId Bytes

Loading…
Cancel
Save