Added Ghostfolio widget

pull/1071/head
Mathias R 1 year ago
parent cb554f269c
commit e97fdc17be

@ -535,5 +535,11 @@
"targets_up": "Targets Up",
"targets_down": "Targets Down",
"targets_total": "Total Targets"
},
"ghostfolio": {
"gross_percent_today": "Today",
"gross_percent_ytd": "This year",
"gross_percent_1y": "One year",
"gross_percent_max": "All time"
}
}

@ -47,6 +47,8 @@ export default async function credentialedProxyHandler(req, res, map) {
headers.Authorization = `Bearer ${widget.key}`;
} else if (widget.type === "pterodactyl") {
headers.Authorization = `Bearer ${widget.key}`;
} else if (widget.type === "ghostfolio") {
headers.Authorization = `Bearer ${widget.key}`;
} else {
headers["X-API-Key"] = `${widget.key}`;
}

@ -16,6 +16,7 @@ const components = {
emby: dynamic(() => import("./emby/component")),
fileflows: dynamic(() => import("./fileflows/component")),
flood: dynamic(() => import("./flood/component")),
ghostfolio: dynamic(() => import("./ghostfolio/component")),
gluetun: dynamic(() => import("./gluetun/component")),
gotify: dynamic(() => import("./gotify/component")),
grafana: dynamic(() => import("./grafana/component")),

@ -0,0 +1,45 @@
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
// import { useTranslation } from "next-i18next";
export default function Component({ service }) {
// const { t } = useTranslation();
const { widget } = service;
const { data: performanceToday, error: ghostfolioErrorToday } = useWidgetAPI(widget, "today");
const { data: performanceYtd, error: ghostfolioErrorYtd } = useWidgetAPI(widget, "ytd", { refreshInterval: 36000 });
const { data: performanceYear, error: ghostfolioErrorYear } = useWidgetAPI(widget, "year", { refreshInterval: 36000 });
const { data: performanceMax, error: ghostfolioErrorMax } = useWidgetAPI(widget, "max", { refreshInterval: 36000 });
if (ghostfolioErrorToday) {
return <Container error={ghostfolioErrorToday} />;
}
if (ghostfolioErrorYtd) {
return <Container error={ghostfolioErrorYtd} />;
}
if (ghostfolioErrorYear) {
return <Container error={ghostfolioErrorYear} />;
}
if (ghostfolioErrorMax) {
return <Container error={ghostfolioErrorMax} />;
}
return (
<Container service={service}>
{/* <Block label="ghostfolio.gross_percent_today" value={performanceToday && t("common.percent", { value: Math.round(performanceToday.performance.currentGrossPerformancePercent * 10000) / 100 }) || false} />
<Block label="ghostfolio.gross_percent_ytd" value={performanceYtd && t("common.percent", { value: Math.round(performanceYtd.performance.currentGrossPerformancePercent * 10000) / 100 }) || false} />
<Block label="ghostfolio.gross_percent_1y" value={performanceYear && t("common.percent", { value: Math.round(performanceYear.performance.currentGrossPerformancePercent * 10000) / 100 }) || false} />
<Block label="ghostfolio.gross_percent_max" value={performanceMax && t("common.percent", { value: Math.round(performanceMax.performance.currentGrossPerformancePercent * 10000) / 100 }) || false} /> */}
<Block label="ghostfolio.gross_percent_today" value={performanceToday && `${(performanceToday.performance.currentGrossPerformancePercent > 0 ? "+" : "")}${(Math.round(performanceToday.performance.currentGrossPerformancePercent * 10000) / 100)}%` || false} />
<Block label="ghostfolio.gross_percent_ytd" value={performanceYtd && `${(performanceYtd.performance.currentGrossPerformancePercent > 0 ? "+" : "")}${(Math.round(performanceYtd.performance.currentGrossPerformancePercent * 10000) / 100)}%` || false} />
<Block label="ghostfolio.gross_percent_1y" value={performanceYear && `${(performanceYear.performance.currentGrossPerformancePercent > 0 ? "+" : "")}${(Math.round(performanceYear.performance.currentGrossPerformancePercent * 10000) / 100)}%` || false} />
<Block label="ghostfolio.gross_percent_max" value={performanceMax && `${(performanceMax.performance.currentGrossPerformancePercent > 0 ? "+" : "")}${(Math.round(performanceMax.performance.currentGrossPerformancePercent * 10000) / 100)}%` || false} />
</Container>
);
}

@ -0,0 +1,23 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "{url}/api/v2/portfolio/performance?range={endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
today: {
endpoint: "1d"
},
ytd: {
endpoint: "ytd"
},
year: {
endpoint: "1y"
},
max: {
endpoint: "max"
},
},
};
export default widget;

@ -11,6 +11,7 @@ import downloadstation from "./downloadstation/widget";
import emby from "./emby/widget";
import fileflows from "./fileflows/widget";
import flood from "./flood/widget";
import ghostfolio from "./ghostfolio/widget"
import gluetun from "./gluetun/widget";
import gotify from "./gotify/widget";
import grafana from "./grafana/widget";
@ -86,6 +87,7 @@ const widgets = {
emby,
fileflows,
flood,
ghostfolio,
gluetun,
gotify,
grafana,

Loading…
Cancel
Save