mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-05 21:47:48 +01:00
Enhancement: Add issues field to Jellyseerr widget (#5725)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -3,21 +3,27 @@ import Container from "components/services/widget/container";
|
||||
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export const jellyseerrDefaultFields = ["pending", "approved", "available"];
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
const { data: statsData, error: statsError } = useWidgetAPI(widget, "request/count");
|
||||
widget.fields = widget?.fields?.length ? widget.fields : jellyseerrDefaultFields;
|
||||
const isIssueEnabled = widget.fields.includes("issues");
|
||||
|
||||
if (statsError) {
|
||||
return <Container service={service} error={statsError} />;
|
||||
const { data: statsData, error: statsError } = useWidgetAPI(widget, "request/count");
|
||||
const { data: issueData, error: issueError } = useWidgetAPI(widget, isIssueEnabled ? "issue/count" : "");
|
||||
if (statsError || (isIssueEnabled && issueError)) {
|
||||
return <Container service={service} error={statsError ? statsError : issueError} />;
|
||||
}
|
||||
|
||||
if (!statsData) {
|
||||
if (!statsData || (isIssueEnabled && !issueData)) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="jellyseerr.pending" />
|
||||
<Block label="jellyseerr.approved" />
|
||||
<Block label="jellyseerr.available" />
|
||||
<Block label="jellyseerr.issues" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
@@ -27,6 +33,7 @@ export default function Component({ service }) {
|
||||
<Block label="jellyseerr.pending" value={statsData.pending} />
|
||||
<Block label="jellyseerr.approved" value={statsData.approved} />
|
||||
<Block label="jellyseerr.available" value={statsData.available} />
|
||||
<Block label="jellyseerr.issues" value={`${issueData?.open} / ${issueData?.total}`} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ const widget = {
|
||||
endpoint: "request/count",
|
||||
validate: ["pending", "approved", "available"],
|
||||
},
|
||||
"issue/count": {
|
||||
endpoint: "issue/count",
|
||||
validate: ["open", "total"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user