mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-11-04 00:10:57 +00:00 
			
		
		
		
	
						commit
						711dde6741
					
				@ -535,5 +535,10 @@
 | 
				
			|||||||
        "targets_up": "Targets Up",
 | 
					        "targets_up": "Targets Up",
 | 
				
			||||||
        "targets_down": "Targets Down",
 | 
					        "targets_down": "Targets Down",
 | 
				
			||||||
        "targets_total": "Total Targets"
 | 
					        "targets_total": "Total Targets"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "ghostfolio": {
 | 
				
			||||||
 | 
					        "gross_percent_today": "Today",
 | 
				
			||||||
 | 
					        "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}`;
 | 
					        headers.Authorization = `Bearer ${widget.key}`;
 | 
				
			||||||
      } else if (widget.type === "pterodactyl") {
 | 
					      } else if (widget.type === "pterodactyl") {
 | 
				
			||||||
        headers.Authorization = `Bearer ${widget.key}`;
 | 
					        headers.Authorization = `Bearer ${widget.key}`;
 | 
				
			||||||
 | 
					      } else if (widget.type === "ghostfolio") {
 | 
				
			||||||
 | 
					        headers.Authorization = `Bearer ${widget.key}`;
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        headers["X-API-Key"] = `${widget.key}`;
 | 
					        headers["X-API-Key"] = `${widget.key}`;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,7 @@ const components = {
 | 
				
			|||||||
  emby: dynamic(() => import("./emby/component")),
 | 
					  emby: dynamic(() => import("./emby/component")),
 | 
				
			||||||
  fileflows: dynamic(() => import("./fileflows/component")),
 | 
					  fileflows: dynamic(() => import("./fileflows/component")),
 | 
				
			||||||
  flood: dynamic(() => import("./flood/component")),
 | 
					  flood: dynamic(() => import("./flood/component")),
 | 
				
			||||||
 | 
					  ghostfolio: dynamic(() => import("./ghostfolio/component")),
 | 
				
			||||||
  gluetun: dynamic(() => import("./gluetun/component")),
 | 
					  gluetun: dynamic(() => import("./gluetun/component")),
 | 
				
			||||||
  gotify: dynamic(() => import("./gotify/component")),
 | 
					  gotify: dynamic(() => import("./gotify/component")),
 | 
				
			||||||
  grafana: dynamic(() => import("./grafana/component")),
 | 
					  grafana: dynamic(() => import("./grafana/component")),
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										41
									
								
								src/widgets/ghostfolio/component.jsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/widgets/ghostfolio/component.jsx
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					import { useTranslation } from "next-i18next";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import Container from "components/services/widget/container";
 | 
				
			||||||
 | 
					import Block from "components/services/widget/block";
 | 
				
			||||||
 | 
					import useWidgetAPI from "utils/proxy/use-widget-api";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function getPerformancePercent(t, performanceRange) {
 | 
				
			||||||
 | 
					  return `${(performanceRange.performance.currentGrossPerformancePercent > 0 ? "+" : "")}${t("common.percent", { value: performanceRange.performance.currentGrossPerformancePercent * 100, maximumFractionDigits: 2 })}`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default function Component({ service }) {
 | 
				
			||||||
 | 
					  const { t } = useTranslation();
 | 
				
			||||||
 | 
					  const { widget } = service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const { data: performanceToday, error: ghostfolioErrorToday } = useWidgetAPI(widget, "today");
 | 
				
			||||||
 | 
					  const { data: performanceYear, error: ghostfolioErrorYear } = useWidgetAPI(widget, "year");
 | 
				
			||||||
 | 
					  const { data: performanceMax, error: ghostfolioErrorMax } = useWidgetAPI(widget, "max");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (ghostfolioErrorToday || ghostfolioErrorYear || ghostfolioErrorMax) {
 | 
				
			||||||
 | 
					    const finalError = ghostfolioErrorToday ?? ghostfolioErrorYear ?? ghostfolioErrorMax
 | 
				
			||||||
 | 
					    return <Container error={finalError} />;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!performanceToday || !performanceYear || !performanceMax) {
 | 
				
			||||||
 | 
					    return (
 | 
				
			||||||
 | 
					      <Container service={service}>
 | 
				
			||||||
 | 
					        <Block label="ghostfolio.gross_percent_today" />
 | 
				
			||||||
 | 
					        <Block label="ghostfolio.gross_percent_1y" />
 | 
				
			||||||
 | 
					        <Block label="ghostfolio.gross_percent_max" />
 | 
				
			||||||
 | 
					      </Container>
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return (
 | 
				
			||||||
 | 
					    <Container service={service}>
 | 
				
			||||||
 | 
					      <Block label="ghostfolio.gross_percent_today" value={getPerformancePercent(t, performanceToday)} />
 | 
				
			||||||
 | 
					      <Block label="ghostfolio.gross_percent_1y" value={getPerformancePercent(t, performanceYear)} />
 | 
				
			||||||
 | 
					      <Block label="ghostfolio.gross_percent_max" value={getPerformancePercent(t, performanceMax)} />
 | 
				
			||||||
 | 
					    </Container>
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										20
									
								
								src/widgets/ghostfolio/widget.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/widgets/ghostfolio/widget.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const widget = {
 | 
				
			||||||
 | 
					  api: "{url}/api/v2/portfolio/performance?range={endpoint}",
 | 
				
			||||||
 | 
					  proxyHandler: credentialedProxyHandler,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  mappings: {
 | 
				
			||||||
 | 
					    today: {
 | 
				
			||||||
 | 
					      endpoint: "1d"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    year: {
 | 
				
			||||||
 | 
					      endpoint: "1y"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    max: {
 | 
				
			||||||
 | 
					      endpoint: "max"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default widget;
 | 
				
			||||||
@ -11,6 +11,7 @@ import downloadstation from "./downloadstation/widget";
 | 
				
			|||||||
import emby from "./emby/widget";
 | 
					import emby from "./emby/widget";
 | 
				
			||||||
import fileflows from "./fileflows/widget";
 | 
					import fileflows from "./fileflows/widget";
 | 
				
			||||||
import flood from "./flood/widget";
 | 
					import flood from "./flood/widget";
 | 
				
			||||||
 | 
					import ghostfolio from "./ghostfolio/widget"
 | 
				
			||||||
import gluetun from "./gluetun/widget";
 | 
					import gluetun from "./gluetun/widget";
 | 
				
			||||||
import gotify from "./gotify/widget";
 | 
					import gotify from "./gotify/widget";
 | 
				
			||||||
import grafana from "./grafana/widget";
 | 
					import grafana from "./grafana/widget";
 | 
				
			||||||
@ -86,6 +87,7 @@ const widgets = {
 | 
				
			|||||||
  emby,
 | 
					  emby,
 | 
				
			||||||
  fileflows,
 | 
					  fileflows,
 | 
				
			||||||
  flood,
 | 
					  flood,
 | 
				
			||||||
 | 
					  ghostfolio,
 | 
				
			||||||
  gluetun,
 | 
					  gluetun,
 | 
				
			||||||
  gotify,
 | 
					  gotify,
 | 
				
			||||||
  grafana,
 | 
					  grafana,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user