Add Mastodon widget
This commit is contained in:
parent
539e0f005a
commit
586ded6b3f
5 changed files with 46 additions and 0 deletions
|
@ -168,5 +168,10 @@
|
||||||
"jackett": {
|
"jackett": {
|
||||||
"configured": "Configured",
|
"configured": "Configured",
|
||||||
"errored": "Errored"
|
"errored": "Errored"
|
||||||
|
},
|
||||||
|
"mastodon": {
|
||||||
|
"user_count": "Users",
|
||||||
|
"status_count": "Posts",
|
||||||
|
"domain_count": "Domains"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import Gotify from "./widgets/service/gotify";
|
||||||
import Prowlarr from "./widgets/service/prowlarr";
|
import Prowlarr from "./widgets/service/prowlarr";
|
||||||
import Jackett from "./widgets/service/jackett";
|
import Jackett from "./widgets/service/jackett";
|
||||||
import AdGuard from "./widgets/service/adguard";
|
import AdGuard from "./widgets/service/adguard";
|
||||||
|
import Mastodon from "./widgets/service/mastodon";
|
||||||
|
|
||||||
const widgetMappings = {
|
const widgetMappings = {
|
||||||
docker: Docker,
|
docker: Docker,
|
||||||
|
@ -56,6 +57,7 @@ const widgetMappings = {
|
||||||
prowlarr: Prowlarr,
|
prowlarr: Prowlarr,
|
||||||
jackett: Jackett,
|
jackett: Jackett,
|
||||||
adguard: AdGuard,
|
adguard: AdGuard,
|
||||||
|
mastodon: Mastodon,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Widget({ service }) {
|
export default function Widget({ service }) {
|
||||||
|
|
37
src/components/services/widgets/service/mastodon.jsx
Normal file
37
src/components/services/widgets/service/mastodon.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 Mastodon({ service }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const config = service.widget;
|
||||||
|
|
||||||
|
const { data: statsData, error: statsError } = useSWR(formatApiUrl(config, `instance`));
|
||||||
|
|
||||||
|
if (statsError) {
|
||||||
|
return <Widget error={t("widget.api_error")} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!statsData) {
|
||||||
|
return (
|
||||||
|
<Widget>
|
||||||
|
<Block label={t("mastodon.user_count")} />
|
||||||
|
<Block label={t("mastodon.status_count")} />
|
||||||
|
<Block label={t("mastodon.domain_count")} />
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Widget>
|
||||||
|
<Block label={t("mastodon.user_count")} value={t("common.number", { value: statsData.stats.user_count })} />
|
||||||
|
<Block label={t("mastodon.status_count")} value={t("common.number", { value: statsData.stats.status_count })} />
|
||||||
|
<Block label={t("mastodon.domain_count")} value={t("common.number", { value: statsData.stats.domain_count })} />
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
}
|
|
@ -81,6 +81,7 @@ const serviceProxyHandlers = {
|
||||||
sabnzbd: genericProxyHandler,
|
sabnzbd: genericProxyHandler,
|
||||||
jackett: genericProxyHandler,
|
jackett: genericProxyHandler,
|
||||||
adguard: genericProxyHandler,
|
adguard: genericProxyHandler,
|
||||||
|
mastodon: genericProxyHandler,
|
||||||
// uses X-API-Key (or similar) header auth
|
// uses X-API-Key (or similar) header auth
|
||||||
gotify: credentialedProxyHandler,
|
gotify: credentialedProxyHandler,
|
||||||
portainer: credentialedProxyHandler,
|
portainer: credentialedProxyHandler,
|
||||||
|
|
|
@ -24,6 +24,7 @@ const formats = {
|
||||||
prowlarr: `{url}/api/v1/{endpoint}`,
|
prowlarr: `{url}/api/v1/{endpoint}`,
|
||||||
jackett: `{url}/api/v2.0/{endpoint}?apikey={key}&configured=true`,
|
jackett: `{url}/api/v2.0/{endpoint}?apikey={key}&configured=true`,
|
||||||
adguard: `{url}/control/{endpoint}`,
|
adguard: `{url}/control/{endpoint}`,
|
||||||
|
mastodon: `{url}/api/v1/{endpoint}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function formatApiCall(api, args) {
|
export function formatApiCall(api, args) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue