mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-19 02:59:50 +00:00
Add AdGuard, Bazarr, and Coin Market Cap widgets
- Allow setting HTTP method in widget.js - Allow sending allow listed query params to proxy
This commit is contained in:
parent
f999f4a467
commit
03fa2f86d7
10 changed files with 251 additions and 9 deletions
35
src/widgets/bazarr/component.jsx
Normal file
35
src/widgets/bazarr/component.jsx
Normal file
|
@ -0,0 +1,35 @@
|
|||
import useSWR from "swr";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Widget from "components/services/widgets/widget";
|
||||
import Block from "components/services/widgets/block";
|
||||
import { formatProxyUrl } from "utils/api-helpers";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const config = service.widget;
|
||||
|
||||
const { data: episodesData, error: episodesError } = useSWR(formatProxyUrl(config, "episodes"));
|
||||
const { data: moviesData, error: moviesError } = useSWR(formatProxyUrl(config, "movies"));
|
||||
|
||||
if (episodesError || moviesError) {
|
||||
return <Widget error={t("widget.api_error")} />;
|
||||
}
|
||||
|
||||
if (!episodesData || !moviesData) {
|
||||
return (
|
||||
<Widget>
|
||||
<Block label={t("bazarr.missingEpisodes")} />
|
||||
<Block label={t("bazarr.missingMovies")} />
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Widget>
|
||||
<Block label={t("bazarr.missingEpisodes")} value={t("common.number", { value: episodesData.total })} />
|
||||
<Block label={t("bazarr.missingMovies")} value={t("common.number", { value: moviesData.total })} />
|
||||
</Widget>
|
||||
);
|
||||
}
|
24
src/widgets/bazarr/widget.js
Normal file
24
src/widgets/bazarr/widget.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import genericProxyHandler from "utils/proxies/generic";
|
||||
import { asJson } from "utils/api-helpers";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/{endpoint}/wanted?apikey={key}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"movies": {
|
||||
endpoint: "movies",
|
||||
map: (data) => ({
|
||||
total: asJson(data).total,
|
||||
}),
|
||||
},
|
||||
"episodes": {
|
||||
endpoint: "episodes",
|
||||
map: (data) => ({
|
||||
total: asJson(data).total,
|
||||
}),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
Loading…
Add table
Add a link
Reference in a new issue