Merge branch 'gethomepage:dev' into vikunja

This commit is contained in:
vhsdream
2024-10-11 17:19:22 -04:00
committed by GitHub
6 changed files with 34 additions and 13 deletions

View File

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

View File

@@ -1,18 +1,24 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "{url}/api/server-info/{endpoint}",
api: "{url}/api/{endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
version: {
endpoint: "version",
endpoint: "server-info/version",
},
statistics: {
endpoint: "statistics",
endpoint: "server-info/statistics",
},
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}>
<Block label="wgeasy.connected" value={connected} />
<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} />
</Container>
);