Merge pull request #887 from Zlendy/immich

Add Immich Widget
pull/895/head v0.6.4
shamoon 2 years ago committed by GitHub
commit 5af01d2436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -439,5 +439,11 @@
"failed_tasks_24h": "Failed Tasks 24h", "failed_tasks_24h": "Failed Tasks 24h",
"cpu_usage": "CPU", "cpu_usage": "CPU",
"memory_usage": "Memory" "memory_usage": "Memory"
},
"immich": {
"users": "Users",
"photos": "Photos",
"videos": "Videos",
"storage": "Storage"
} }
} }

@ -62,6 +62,7 @@ const components = {
unifi: dynamic(() => import("./unifi/component")), unifi: dynamic(() => import("./unifi/component")),
watchtower: dynamic(() => import("./watchtower/component")), watchtower: dynamic(() => import("./watchtower/component")),
xteve: dynamic(() => import("./xteve/component")), xteve: dynamic(() => import("./xteve/component")),
immich: dynamic(() => import("./immich/component")),
}; };
export default components; export default components;

@ -0,0 +1,33 @@
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 { widget } = service;
const { data: immichData, error: immichError } = useWidgetAPI(widget);
if (immichError || immichData?.statusCode === 401) {
return <Container error={immichError ?? immichData} />;
}
if (!immichData) {
return (
<Container service={service}>
<Block label="immich.users" />
<Block label="immich.photos" />
<Block label="immich.videos" />
<Block label="immich.storage" />
</Container>
);
}
return (
<Container service={service}>
<Block label="immich.users" value={immichData.usageByUser.length} />
<Block label="immich.photos" value={immichData.photos} />
<Block label="immich.videos" value={immichData.videos} />
<Block label="immich.storage" value={immichData.usage} />
</Container>
);
}

@ -0,0 +1,8 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "{url}/api/server-info/stats",
proxyHandler: credentialedProxyHandler,
};
export default widget;

@ -56,6 +56,7 @@ import truenas from "./truenas/widget";
import unifi from "./unifi/widget"; import unifi from "./unifi/widget";
import watchtower from "./watchtower/widget"; import watchtower from "./watchtower/widget";
import xteve from "./xteve/widget"; import xteve from "./xteve/widget";
import immich from "./immich/widget";
const widgets = { const widgets = {
adguard, adguard,
@ -119,6 +120,7 @@ const widgets = {
unifi_console: unifi, unifi_console: unifi,
watchtower, watchtower,
xteve, xteve,
immich,
}; };
export default widgets; export default widgets;

Loading…
Cancel
Save