Merge branch 'vikunja' of github.com:vhsdream/homepage-dev into vikunja

This commit is contained in:
vhsdream 2024-10-11 23:29:26 -04:00
commit 7176cbf483
6 changed files with 34 additions and 13 deletions

View File

@ -5,6 +5,11 @@ description: Immich Widget Configuration
Learn more about [Immich](https://github.com/immich-app/immich). Learn more about [Immich](https://github.com/immich-app/immich).
| Immich Version | Homepage Widget Version |
| -------------- | ----------------------- |
| < v1.118 | 1 (default) |
| >= v1.118 | 2 |
Find your API key under `Account Settings > API Keys`. Find your API key under `Account Settings > API Keys`.
Allowed fields: `["users" ,"photos", "videos", "storage"]`. Allowed fields: `["users" ,"photos", "videos", "storage"]`.
@ -16,4 +21,5 @@ widget:
type: immich type: immich
url: http://immich.host.or.ip url: http://immich.host.or.ip
key: adminapikeyadminapikeyadminapikey key: adminapikeyadminapikeyadminapikey
version: 2 # optional, default is 1
``` ```

View File

@ -13,6 +13,7 @@ export default function Item({ bookmark }) {
<a <a
href={bookmark.href} href={bookmark.href}
title={bookmark.name} title={bookmark.name}
rel="noreferrer"
target={bookmark.target ?? settings.target ?? "_blank"} target={bookmark.target ?? settings.target ?? "_blank"}
className={classNames( className={classNames(
settings.cardBlur !== undefined && `backdrop-blur${settings.cardBlur.length ? "-" : ""}${settings.cardBlur}`, settings.cardBlur !== undefined && `backdrop-blur${settings.cardBlur.length ? "-" : ""}${settings.cardBlur}`,

View File

@ -406,7 +406,7 @@ export function cleanServiceGroups(groups) {
// frigate // frigate
enableRecentEvents, enableRecentEvents,
// glances, mealie, pihole, pfsense // glances, immich, mealie, pihole, pfsense
version, version,
// glances // glances
@ -571,8 +571,8 @@ export function cleanServiceGroups(groups) {
if (snapshotHost) cleanedService.widget.snapshotHost = snapshotHost; if (snapshotHost) cleanedService.widget.snapshotHost = snapshotHost;
if (snapshotPath) cleanedService.widget.snapshotPath = snapshotPath; if (snapshotPath) cleanedService.widget.snapshotPath = snapshotPath;
} }
if (["glances", "mealie", "pfsense", "pihole"].includes(type)) { if (["glances", "immich", "mealie", "pfsense", "pihole"].includes(type)) {
if (version) cleanedService.widget.version = version; if (version) cleanedService.widget.version = parseInt(version, 10);
} }
if (type === "glances") { if (type === "glances") {
if (metric) cleanedService.widget.metric = metric; if (metric) cleanedService.widget.metric = metric;

View File

@ -8,11 +8,19 @@ export default function Component({ service }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { widget } = service; const { widget } = service;
const { data: versionData, error: versionError } = useWidgetAPI(widget, "version"); const { version = 1 } = widget;
// see https://github.com/gethomepage/homepage/issues/2282
const endpoint = const versionEndpoint = version === 2 ? "version_v2" : "version";
versionData?.major > 1 || (versionData?.major === 1 && versionData?.minor > 84) ? "statistics" : "stats";
const { data: immichData, error: immichError } = useWidgetAPI(widget, endpoint); const { data: versionData, error: versionError } = useWidgetAPI(widget, versionEndpoint);
let statsEndpoint = version === 2 ? "statistics_v2" : "stats";
if (version === 1) {
// see https://github.com/gethomepage/homepage/issues/2282
statsEndpoint =
versionData?.major > 1 || (versionData?.major === 1 && versionData?.minor > 84) ? "statistics" : "stats";
}
const { data: immichData, error: immichError } = useWidgetAPI(widget, statsEndpoint);
if (immichError || versionError || immichData?.statusCode === 401) { if (immichError || versionError || immichData?.statusCode === 401) {
return <Container service={service} error={immichData ?? immichError ?? versionError} />; return <Container service={service} error={immichData ?? immichError ?? versionError} />;

View File

@ -1,18 +1,24 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = { const widget = {
api: "{url}/api/server-info/{endpoint}", api: "{url}/api/{endpoint}",
proxyHandler: credentialedProxyHandler, proxyHandler: credentialedProxyHandler,
mappings: { mappings: {
version: { version: {
endpoint: "version", endpoint: "server-info/version",
}, },
statistics: { statistics: {
endpoint: "statistics", endpoint: "server-info/statistics",
}, },
stats: { stats: {
endpoint: "stats", endpoint: "server-info/stats",
},
version_v2: {
endpoint: "server/version",
},
statistics_v2: {
endpoint: "server/statistics",
}, },
}, },
}; };

View File

@ -38,7 +38,7 @@ export default function Component({ service }) {
<Container service={service}> <Container service={service}>
<Block label="wgeasy.connected" value={connected} /> <Block label="wgeasy.connected" value={connected} />
<Block label="wgeasy.enabled" value={enabled} /> <Block label="wgeasy.enabled" value={enabled} />
<Block label="wgeasy.diabled" value={disabled} /> <Block label="wgeasy.disabled" value={disabled} />
<Block label="wgeasy.total" value={infoData.length} /> <Block label="wgeasy.total" value={infoData.length} />
</Container> </Container>
); );