From 17c9b2631ed80b0512c3c2d98c6b95669cbf1ebe Mon Sep 17 00:00:00 2001
From: qmph22 <66791972+qmph22@users.noreply.github.com>
Date: Wed, 12 Nov 2025 19:31:55 -0500
Subject: [PATCH] Enhancement: add net worth field for ghostfolio (#5958)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
---
docs/widgets/services/ghostfolio.md | 2 +-
public/locales/en/common.json | 3 ++-
src/widgets/ghostfolio/component.jsx | 15 ++++++++++++---
src/widgets/ghostfolio/widget.js | 11 +++++++----
4 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/docs/widgets/services/ghostfolio.md b/docs/widgets/services/ghostfolio.md
index 42e03bb58..95de13ee1 100644
--- a/docs/widgets/services/ghostfolio.md
+++ b/docs/widgets/services/ghostfolio.md
@@ -15,7 +15,7 @@ See the [official docs](https://github.com/ghostfolio/ghostfolio#authorization-b
_Note that the Bearer token is valid for 6 months, after which a new one must be generated._
-Allowed fields: `["gross_percent_today", "gross_percent_1y", "gross_percent_max"]`
+Allowed fields: `["gross_percent_today", "gross_percent_1y", "gross_percent_max", "net_worth"]`
```yaml
widget:
diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index 97ee9988b..05582127c 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -759,7 +759,8 @@
"ghostfolio": {
"gross_percent_today": "Today",
"gross_percent_1y": "One year",
- "gross_percent_max": "All time"
+ "gross_percent_max": "All time",
+ "net_worth": "Net Worth"
},
"audiobookshelf": {
"podcasts": "Podcasts",
diff --git a/src/widgets/ghostfolio/component.jsx b/src/widgets/ghostfolio/component.jsx
index f25875864..dd0ee16a6 100644
--- a/src/widgets/ghostfolio/component.jsx
+++ b/src/widgets/ghostfolio/component.jsx
@@ -20,13 +20,15 @@ function getPerformancePercent(t, performanceRange) {
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
+ const includeNetWorth = widget.fields?.includes("net_worth");
const { data: performanceToday, error: ghostfolioErrorToday } = useWidgetAPI(widget, "today");
const { data: performanceYear, error: ghostfolioErrorYear } = useWidgetAPI(widget, "year");
const { data: performanceMax, error: ghostfolioErrorMax } = useWidgetAPI(widget, "max");
+ const { data: userInfo, error: ghostfolioErrorUserInfo } = useWidgetAPI(widget, includeNetWorth ? "userInfo" : "");
- if (ghostfolioErrorToday || ghostfolioErrorYear || ghostfolioErrorMax) {
- const finalError = ghostfolioErrorToday ?? ghostfolioErrorYear ?? ghostfolioErrorMax;
+ if (ghostfolioErrorToday || ghostfolioErrorYear || ghostfolioErrorMax || ghostfolioErrorUserInfo) {
+ const finalError = ghostfolioErrorToday ?? ghostfolioErrorYear ?? ghostfolioErrorMax ?? ghostfolioErrorUserInfo;
return ;
}
@@ -34,12 +36,13 @@ export default function Component({ service }) {
return ;
}
- if (!performanceToday || !performanceYear || !performanceMax) {
+ if (!performanceToday || !performanceYear || !performanceMax || (includeNetWorth && !userInfo)) {
return (
+ {includeNetWorth && }
);
}
@@ -49,6 +52,12 @@ export default function Component({ service }) {
+ {includeNetWorth && (
+
+ )}
);
}
diff --git a/src/widgets/ghostfolio/widget.js b/src/widgets/ghostfolio/widget.js
index 497292907..34a304220 100644
--- a/src/widgets/ghostfolio/widget.js
+++ b/src/widgets/ghostfolio/widget.js
@@ -1,18 +1,21 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
- api: "{url}/api/v2/portfolio/performance?range={endpoint}",
+ api: "{url}/api/{endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
today: {
- endpoint: "1d",
+ endpoint: "v2/portfolio/performance?range=1d",
},
year: {
- endpoint: "1y",
+ endpoint: "v2/portfolio/performance?range=1y",
},
max: {
- endpoint: "max",
+ endpoint: "v2/portfolio/performance?range=max",
+ },
+ userInfo: {
+ endpoint: "v1/user",
},
},
};