Add Peertube widget
This commit is contained in:
parent
586ded6b3f
commit
e06a67076e
@ -173,5 +173,10 @@
|
||||
"user_count": "Users",
|
||||
"status_count": "Posts",
|
||||
"domain_count": "Domains"
|
||||
},
|
||||
"peertube": {
|
||||
"totalUsers": "Users",
|
||||
"totalVideos": "Videos",
|
||||
"totalLocalVideoFilesSize": "Video Storaged"
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ import Prowlarr from "./widgets/service/prowlarr";
|
||||
import Jackett from "./widgets/service/jackett";
|
||||
import AdGuard from "./widgets/service/adguard";
|
||||
import Mastodon from "./widgets/service/mastodon";
|
||||
import Peertube from "./widgets/service/peertube";
|
||||
|
||||
const widgetMappings = {
|
||||
docker: Docker,
|
||||
@ -58,6 +59,7 @@ const widgetMappings = {
|
||||
jackett: Jackett,
|
||||
adguard: AdGuard,
|
||||
mastodon: Mastodon,
|
||||
peertube: Peertube
|
||||
};
|
||||
|
||||
export default function Widget({ service }) {
|
||||
|
||||
37
src/components/services/widgets/service/peertube.jsx
Normal file
37
src/components/services/widgets/service/peertube.jsx
Normal file
@ -0,0 +1,37 @@
|
||||
import useSWR from "swr";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import Widget from "../widget";
|
||||
import Block from "../block";
|
||||
|
||||
import { formatApiUrl } from "utils/api-helpers";
|
||||
|
||||
export default function Peertube({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const config = service.widget;
|
||||
|
||||
const { data: statsData, error: statsError } = useSWR(formatApiUrl(config, `server/stats`));
|
||||
|
||||
if (statsError) {
|
||||
return <Widget error={t("widget.api_error")} />;
|
||||
}
|
||||
|
||||
if (!statsData) {
|
||||
return (
|
||||
<Widget>
|
||||
<Block label={t("peertube.totalUsers")} />
|
||||
<Block label={t("peertube.totalVideos")} />
|
||||
<Block label={t("peertube.totalLocalVideoFilesSize")} />
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Widget>
|
||||
<Block label={t("peertube.totalUsers")} value={t("common.number", { value: statsData.totalUsers })} />
|
||||
<Block label={t("peertube.totalVideos")} value={t("common.number", { value: statsData.totalVideos })} />
|
||||
<Block label={t("peertube.totalLocalVideoFilesSize")} value={t("common.bytes", { value: statsData.totalLocalVideoFilesSize })} />
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@ -82,6 +82,7 @@ const serviceProxyHandlers = {
|
||||
jackett: genericProxyHandler,
|
||||
adguard: genericProxyHandler,
|
||||
mastodon: genericProxyHandler,
|
||||
peertube: genericProxyHandler,
|
||||
// uses X-API-Key (or similar) header auth
|
||||
gotify: credentialedProxyHandler,
|
||||
portainer: credentialedProxyHandler,
|
||||
|
||||
@ -25,6 +25,7 @@ const formats = {
|
||||
jackett: `{url}/api/v2.0/{endpoint}?apikey={key}&configured=true`,
|
||||
adguard: `{url}/control/{endpoint}`,
|
||||
mastodon: `{url}/api/v1/{endpoint}`,
|
||||
peertube: `{url}/api/v1/{endpoint}`,
|
||||
};
|
||||
|
||||
export function formatApiCall(api, args) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user