From 3194ed2145fb4dbdc4f1dc94841a9e4ce7516cbe Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 30 Nov 2024 17:30:49 +0100 Subject: [PATCH] Feature/improve usability of Ghostfolio data provider (#4086) * Improve usability --- .../ghostfolio/ghostfolio.controller.ts | 5 +--- .../ghostfolio/ghostfolio.service.ts | 9 ++++++ .../admin-settings.component.html | 30 +++++++++++++++---- .../admin-settings.component.ts | 6 ++++ .../admin-settings/admin-settings.module.ts | 2 ++ ...er-ghostfolio-status-response.interface.ts | 3 ++ 6 files changed, 46 insertions(+), 9 deletions(-) diff --git a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts index 3ccef28c8..788cfd1bc 100644 --- a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts +++ b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts @@ -191,9 +191,6 @@ export class GhostfolioController { @HasPermission(permissions.enableDataProviderGhostfolio) @UseGuards(AuthGuard('jwt'), HasPermissionGuard) public async getStatus(): Promise { - return { - dailyRequests: this.request.user.dataProviderGhostfolioDailyRequests, - dailyRequestsMax: await this.ghostfolioService.getMaxDailyRequests() - }; + return this.ghostfolioService.getStatus({ user: this.request.user }); } } diff --git a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts index 875a13c98..7858e24f0 100644 --- a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts +++ b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts @@ -22,6 +22,7 @@ import { LookupResponse, QuotesResponse } from '@ghostfolio/common/interfaces'; +import { UserWithSettings } from '@ghostfolio/common/types'; import { Injectable, Logger } from '@nestjs/common'; import { DataSource } from '@prisma/client'; @@ -208,6 +209,14 @@ export class GhostfolioService { } } + public async getStatus({ user }: { user: UserWithSettings }) { + return { + dailyRequests: user.dataProviderGhostfolioDailyRequests, + dailyRequestsMax: await this.getMaxDailyRequests(), + subscription: user.subscription + }; + } + public async incrementDailyRequests({ userId }: { userId: string }) { await this.prismaService.analytics.update({ data: { diff --git a/apps/client/src/app/components/admin-settings/admin-settings.component.html b/apps/client/src/app/components/admin-settings/admin-settings.component.html index 35ed556b6..f9a6084cc 100644 --- a/apps/client/src/app/components/admin-settings/admin-settings.component.html +++ b/apps/client/src/app/components/admin-settings/admin-settings.component.html @@ -20,23 +20,43 @@ [enableLink]="false" /> + @if (isGhostfolioApiKeyValid === true) { +
+ + Valid until + {{ + ghostfolioApiStatus?.subscription?.expiresAt + | date: defaultDateFormat + }} +
+ }
@if (isGhostfolioApiKeyValid === true) {
-
+
{{ ghostfolioApiStatus.dailyRequests }} of {{ ghostfolioApiStatus.dailyRequestsMax }} daily requests
+ + +
} @else if (isGhostfolioApiKeyValid === false) {