Browse Source

Initial setup

pull/5533/head
Thomas Kaul 6 days ago
parent
commit
55b6f07862
  1. 12
      apps/client/src/app/pages/api/api-page.component.ts
  2. 4
      apps/client/src/app/pages/api/api-page.html
  3. 15
      prisma/migrations/20250915163323_added_data_provider_ghostfolio_resolved_asset_profile/migration.sql
  4. 12
      prisma/schema.prisma

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

@ -4,6 +4,7 @@ import {
} from '@ghostfolio/common/config';
import { DATE_FORMAT } from '@ghostfolio/common/helper';
import {
DataProviderGhostfolioAssetProfileResponse,
DataProviderGhostfolioStatusResponse,
DividendsResponse,
HistoricalResponse,
@ -25,6 +26,7 @@ import { map, Observable, Subject, takeUntil } from 'rxjs';
templateUrl: './api-page.html'
})
export class GfApiPageComponent implements OnInit {
public assetProfile$: Observable<DataProviderGhostfolioAssetProfileResponse>;
public dividends$: Observable<DividendsResponse['dividends']>;
public historicalData$: Observable<HistoricalResponse['historicalData']>;
public isinLookupItems$: Observable<LookupResponse['items']>;
@ -40,6 +42,7 @@ export class GfApiPageComponent implements OnInit {
public ngOnInit() {
this.apiKey = prompt($localize`Please enter your Ghostfolio API key:`);
this.assetProfile$ = this.fetchAssetProfile({ symbol: 'AAPL' });
this.dividends$ = this.fetchDividends({ symbol: 'KO' });
this.historicalData$ = this.fetchHistoricalData({ symbol: 'AAPL' });
this.isinLookupItems$ = this.fetchLookupItems({ query: 'US0378331005' });
@ -53,6 +56,15 @@ export class GfApiPageComponent implements OnInit {
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 }) {
const params = new HttpParams()
.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>
<div>{{ status$ | async | json }}</div>
</div>
<div class="mb-3">
<h2 class="text-center">Asset Profile</h2>
<div>{{ assetProfile$ | async | json }}</div>
</div>
<div>
<h2 class="text-center">Lookup</h2>
@if (lookupItems$) {

15
prisma/migrations/20250915163323_added_data_provider_ghostfolio_resolved_asset_profile/migration.sql

@ -0,0 +1,15 @@
-- CreateTable
CREATE TABLE "public"."DataProviderGhostfolioResolvedAssetProfile" (
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"currency" TEXT NOT NULL,
"dataSource" "public"."DataSource" NOT NULL,
"id" TEXT NOT NULL,
"requestCount" INTEGER NOT NULL DEFAULT 1,
"symbol" TEXT NOT NULL,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "DataProviderGhostfolioResolvedAssetProfile_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "DataProviderGhostfolioResolvedAssetProfile_dataSource_symbo_key" ON "public"."DataProviderGhostfolioResolvedAssetProfile"("dataSource", "symbol");

12
prisma/schema.prisma

@ -101,6 +101,18 @@ model AuthDevice {
@@index([userId])
}
model DataProviderGhostfolioResolvedAssetProfile {
createdAt DateTime @default(now())
currency String
dataSource DataSource
id String @id @default(uuid())
requestCount Int @default(1)
symbol String
updatedAt DateTime @updatedAt
@@unique([dataSource, symbol])
}
model MarketData {
createdAt DateTime @default(now())
dataSource DataSource

Loading…
Cancel
Save