mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 06:48:47 +00:00
Plex service widget without Tautulli
This commit is contained in:
parent
91795f2d07
commit
2440da8e08
8 changed files with 182 additions and 1 deletions
37
src/widgets/plex/component.jsx
Normal file
37
src/widgets/plex/component.jsx
Normal file
|
@ -0,0 +1,37 @@
|
|||
import useSWR from "swr";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
import { formatProxyUrl } from "utils/proxy/api-helpers";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: plexData, error: plexAPIError } = useSWR(formatProxyUrl(widget, "unified"), {
|
||||
refreshInterval: 5000,
|
||||
});
|
||||
|
||||
if (plexAPIError) {
|
||||
return <Container error={t("widget.api_error")} />;
|
||||
}
|
||||
|
||||
if (!plexData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="plex.streams" />
|
||||
<Block label="plex.movies" />
|
||||
<Block label="plex.tv" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="plex.streams" value={t("common.number", { value: plexData.streams })} />
|
||||
<Block label="plex.movies" value={t("common.number", { value: plexData.movies })} />
|
||||
<Block label="plex.tv" value={t("common.number", { value: plexData.tv })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue