Added Ghostfolio widget
This commit is contained in:
parent
cb554f269c
commit
e97fdc17be
6 changed files with 79 additions and 0 deletions
|
@ -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")),
|
||||
|
|
45
src/widgets/ghostfolio/component.jsx
Normal file
45
src/widgets/ghostfolio/component.jsx
Normal file
|
@ -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>
|
||||
);
|
||||
}
|
23
src/widgets/ghostfolio/widget.js
Normal file
23
src/widgets/ghostfolio/widget.js
Normal file
|
@ -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…
Add table
Reference in a new issue