mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-05 06:53:39 +01:00
add Tautulli widget
This commit is contained in:
parent
e72efe7fd0
commit
975f79f6cc
@ -12,6 +12,7 @@ import Speedtest from "./widgets/service/speedtest";
|
|||||||
import Traefik from "./widgets/service/traefik";
|
import Traefik from "./widgets/service/traefik";
|
||||||
import Jellyseerr from "./widgets/service/jellyseerr";
|
import Jellyseerr from "./widgets/service/jellyseerr";
|
||||||
import Npm from "./widgets/service/npm";
|
import Npm from "./widgets/service/npm";
|
||||||
|
import Tautulli from "./widgets/service/tautulli";
|
||||||
|
|
||||||
const widgetMappings = {
|
const widgetMappings = {
|
||||||
docker: Docker,
|
docker: Docker,
|
||||||
@ -28,6 +29,7 @@ const widgetMappings = {
|
|||||||
traefik: Traefik,
|
traefik: Traefik,
|
||||||
jellyseerr: Jellyseerr,
|
jellyseerr: Jellyseerr,
|
||||||
npm: Npm,
|
npm: Npm,
|
||||||
|
tautulli: Tautulli,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Widget({ service }) {
|
export default function Widget({ service }) {
|
||||||
|
43
src/components/services/widgets/service/tautulli.jsx
Normal file
43
src/components/services/widgets/service/tautulli.jsx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import useSWR from "swr";
|
||||||
|
|
||||||
|
import Widget from "../widget";
|
||||||
|
import Block from "../block";
|
||||||
|
|
||||||
|
export default function Tautulli({ service }) {
|
||||||
|
const config = service.widget;
|
||||||
|
|
||||||
|
function buildApiUrl(endpoint) {
|
||||||
|
const { url, key } = config;
|
||||||
|
const fullUrl = `${url}/api/v2?apikey=${key}&cmd=${endpoint}`;
|
||||||
|
return "/api/proxy?url=" + encodeURIComponent(fullUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: statsData, error: statsError } = useSWR(buildApiUrl("get_activity"), {
|
||||||
|
refreshInterval: 1000,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (statsError) {
|
||||||
|
return <Widget error="Tautulli API Error" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!statsData) {
|
||||||
|
return (
|
||||||
|
<Widget>
|
||||||
|
<Block label="Playing" />
|
||||||
|
<Block label="Transcoding" />
|
||||||
|
<Block label="Bitrate" />
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = statsData.response.data;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Widget>
|
||||||
|
<Block label="Playing" value={data.stream_count} />
|
||||||
|
<Block label="Transcoding" value={data.stream_count_transcode} />
|
||||||
|
{/* We divide by 1000 here because thats how Tautulli reports it on its own dashboard */}
|
||||||
|
<Block label="Bitrate" value={`${Math.round((data.total_bandwidth / 1000) * 100) / 100} Mbps`} />
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user