Add Kopia widget
This commit is contained in:
parent
08f5cd8ef2
commit
6b4885c248
@ -495,5 +495,10 @@
|
|||||||
"memoryusage": "Memory Usage",
|
"memoryusage": "Memory Usage",
|
||||||
"freespace": "Free Space",
|
"freespace": "Free Space",
|
||||||
"activeusers": "Active Users"
|
"activeusers": "Active Users"
|
||||||
|
},
|
||||||
|
"kopia": {
|
||||||
|
"status": "Status",
|
||||||
|
"backupsize": "Backup Size",
|
||||||
|
"backuptime": "Backup Time"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,6 +25,7 @@ const components = {
|
|||||||
jellyfin: dynamic(() => import("./emby/component")),
|
jellyfin: dynamic(() => import("./emby/component")),
|
||||||
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
||||||
komga: dynamic(() => import("./komga/component")),
|
komga: dynamic(() => import("./komga/component")),
|
||||||
|
kopia: dynamic(() => import("./kopia/component")),
|
||||||
lidarr: dynamic(() => import("./lidarr/component")),
|
lidarr: dynamic(() => import("./lidarr/component")),
|
||||||
mastodon: dynamic(() => import("./mastodon/component")),
|
mastodon: dynamic(() => import("./mastodon/component")),
|
||||||
medusa: dynamic(() => import("./medusa/component")),
|
medusa: dynamic(() => import("./medusa/component")),
|
||||||
|
|||||||
42
src/widgets/kopia/component.jsx
Executable file
42
src/widgets/kopia/component.jsx
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
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: kopiaData, error: kopiaError } = useWidgetAPI(widget, "api");
|
||||||
|
|
||||||
|
if (kopiaError) {
|
||||||
|
return <Container error={kopiaError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!kopiaData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="kopia.status" />
|
||||||
|
<Block label="kopia.backupsize" />
|
||||||
|
<Block label="kopia.backuptime" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const startTime = new Date(kopiaData.sources[0].lastSnapshot.startTime);
|
||||||
|
const endTime = new Date(kopiaData.sources[0].lastSnapshot.endTime);
|
||||||
|
const duration = new Date(endTime - startTime);
|
||||||
|
const hours = duration.getUTCHours().toString().padStart(2, '0');
|
||||||
|
const minutes = duration.getUTCMinutes().toString().padStart(2, '0');
|
||||||
|
const seconds = duration.getSeconds().toString().padStart(2, '0');
|
||||||
|
const time = (hours + minutes + seconds).split(':');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="kopia.status" value={ kopiaData.sources[0].status } />
|
||||||
|
<Block label="kopia.backupsize" value={t("common.bbytes", { value: kopiaData.sources[0].lastSnapshot.stats.totalSize, maximumFractionDigits: 1 })} />
|
||||||
|
<Block label="kopia.backuptime" value={ time } />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
14
src/widgets/kopia/widget.js
Executable file
14
src/widgets/kopia/widget.js
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/{endpoint}",
|
||||||
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
api: {
|
||||||
|
endpoint: "api/v1/sources",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
||||||
@ -19,6 +19,7 @@ import homebridge from "./homebridge/widget";
|
|||||||
import jackett from "./jackett/widget";
|
import jackett from "./jackett/widget";
|
||||||
import jellyseerr from "./jellyseerr/widget";
|
import jellyseerr from "./jellyseerr/widget";
|
||||||
import komga from "./komga/widget";
|
import komga from "./komga/widget";
|
||||||
|
import kopia from "./kopia/widget";
|
||||||
import lidarr from "./lidarr/widget";
|
import lidarr from "./lidarr/widget";
|
||||||
import mastodon from "./mastodon/widget";
|
import mastodon from "./mastodon/widget";
|
||||||
import medusa from "./medusa/widget";
|
import medusa from "./medusa/widget";
|
||||||
@ -89,6 +90,7 @@ const widgets = {
|
|||||||
jellyfin: emby,
|
jellyfin: emby,
|
||||||
jellyseerr,
|
jellyseerr,
|
||||||
komga,
|
komga,
|
||||||
|
kopia,
|
||||||
lidarr,
|
lidarr,
|
||||||
mastodon,
|
mastodon,
|
||||||
medusa,
|
medusa,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user