mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-11 23:58:46 +00:00
Merge branch 'main' into Mylar
This commit is contained in:
commit
77e02e6729
43 changed files with 380 additions and 79 deletions
|
@ -21,6 +21,7 @@ const components = {
|
|||
jackett: dynamic(() => import("./jackett/component")),
|
||||
jellyfin: dynamic(() => import("./emby/component")),
|
||||
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
||||
komga: dynamic(() => import("./komga/component")),
|
||||
lidarr: dynamic(() => import("./lidarr/component")),
|
||||
mastodon: dynamic(() => import("./mastodon/component")),
|
||||
medusa: dynamic(() => import("./medusa/component")),
|
||||
|
|
37
src/widgets/komga/component.jsx
Normal file
37
src/widgets/komga/component.jsx
Normal file
|
@ -0,0 +1,37 @@
|
|||
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";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
|
||||
const { data: libraryData, error: libraryError } = useWidgetAPI(widget, "libraries");
|
||||
const { data: seriesData, error: seriesError } = useWidgetAPI(widget, "series");
|
||||
const { data: bookData, error: bookError } = useWidgetAPI(widget, "books");
|
||||
|
||||
if (libraryError || seriesError || bookError) {
|
||||
const finalError = libraryError ?? seriesError ?? bookError;
|
||||
return <Container error={finalError} />;
|
||||
}
|
||||
|
||||
if (!libraryData || !seriesData || !bookData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="komga.libraries" />
|
||||
<Block label="komga.series" />
|
||||
<Block label="komga.books" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="komga.libraries" value={t("common.number", { value: libraryData.total })} />
|
||||
<Block label="komga.series" value={t("common.number", { value: seriesData.totalElements })} />
|
||||
<Block label="komga.books" value={t("common.number", { value: bookData.totalElements })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
30
src/widgets/komga/widget.js
Normal file
30
src/widgets/komga/widget.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
import { jsonArrayFilter } from "utils/proxy/api-helpers";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/v1/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
libraries: {
|
||||
endpoint: "libraries",
|
||||
map: (data) => ({
|
||||
total: jsonArrayFilter(data, (item) => !item.unavailable).length,
|
||||
}),
|
||||
},
|
||||
series: {
|
||||
endpoint: "series",
|
||||
validate: [
|
||||
"totalElements"
|
||||
]
|
||||
},
|
||||
books: {
|
||||
endpoint: "books",
|
||||
validate: [
|
||||
"totalElements"
|
||||
]
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -22,7 +22,7 @@ export default function Component({ service }) {
|
|||
return (
|
||||
<Container service={service}>
|
||||
<Block label="proxmoxbackupserver.datastore_usage" />
|
||||
<Block label="proxmoxbackupserver.failed_tasks" />
|
||||
<Block label="proxmoxbackupserver.failed_tasks_24h" />
|
||||
<Block label="proxmoxbackupserver.cpu_usage" />
|
||||
<Block label="proxmoxbackupserver.memory_usage" />
|
||||
</Container>
|
||||
|
|
|
@ -15,7 +15,7 @@ export default function Component({ service }) {
|
|||
return <Container error={statsError} />;
|
||||
}
|
||||
|
||||
const defaultSite = statsData?.data?.find(s => s.name === "default");
|
||||
const defaultSite = widget.site ? statsData?.data.find(s => s.desc === widget.site) : statsData?.data?.find(s => s.name === "default");
|
||||
|
||||
if (!defaultSite) {
|
||||
return (
|
||||
|
@ -38,6 +38,14 @@ export default function Component({ service }) {
|
|||
|
||||
const uptime = wan["gw_system-stats"] ? `${t("common.number", { value: wan["gw_system-stats"].uptime / 86400, maximumFractionDigits: 1 })} ${t("unifi.days")}` : null;
|
||||
|
||||
if (!(wan.show || lan.show || wlan.show || uptime)) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block value={ t("unifi.empty_data") } />
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
{uptime && <Block label="unifi.uptime" value={ uptime } />}
|
||||
|
|
|
@ -15,6 +15,7 @@ import hdhomerun from "./hdhomerun/widget";
|
|||
import homebridge from "./homebridge/widget";
|
||||
import jackett from "./jackett/widget";
|
||||
import jellyseerr from "./jellyseerr/widget";
|
||||
import komga from "./komga/widget";
|
||||
import lidarr from "./lidarr/widget";
|
||||
import mastodon from "./mastodon/widget";
|
||||
import medusa from "./medusa/widget";
|
||||
|
@ -80,6 +81,7 @@ const widgets = {
|
|||
jackett,
|
||||
jellyfin: emby,
|
||||
jellyseerr,
|
||||
komga,
|
||||
lidarr,
|
||||
mastodon,
|
||||
medusa,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue