Prechádzať zdrojové kódy

Merge pull request #121 from xicopitz/main

Gotify
Ben Phelps 2 rokov pred
rodič
commit
ea55cde043

+ 5 - 0
public/locales/de/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/en/common.json

@@ -120,5 +120,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/es/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/fr/common.json

@@ -120,5 +120,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/it/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/nb-NO/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/nl/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/pt/common.json

@@ -120,5 +120,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/ru/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/vi/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Applications",
+        "clients": "Clients",
+        "messages": "Messages"
     }
 }

+ 5 - 0
public/locales/zh-CN/common.json

@@ -109,5 +109,10 @@
     },
     "coinmarketcap": {
         "configure": "Configure one or more crypto currencies to track"
+    },
+    "gotify": {
+        "apps": "Aplicações",
+        "clients": "Clientes",
+        "messages": "Mensagens"
     }
 }

+ 3 - 1
src/components/services/widget.jsx

@@ -19,6 +19,7 @@ import Overseerr from "./widgets/service/overseerr";
 import Npm from "./widgets/service/npm";
 import Tautulli from "./widgets/service/tautulli";
 import CoinMarketCap from "./widgets/service/coinmarketcap";
+import Gotify from "./widgets/service/gotify";
 
 const widgetMappings = {
   docker: Docker,
@@ -30,7 +31,6 @@ const widgetMappings = {
   emby: Emby,
   jellyfin: Jellyfin,
   nzbget: Nzbget,
-  sabnzbd: SABnzbd,
   pihole: Pihole,
   rutorrent: Rutorrent,
   speedtest: Speedtest,
@@ -40,6 +40,8 @@ const widgetMappings = {
   coinmarketcap: CoinMarketCap,
   npm: Npm,
   tautulli: Tautulli,
+  gotify: Gotify,
+  sabnzbd: SABnzbd
 };
 
 export default function Widget({ service }) {

+ 29 - 0
src/components/services/widgets/service/gotify.jsx

@@ -0,0 +1,29 @@
+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 Gotify({ service }) {
+  const { t } = useTranslation();
+
+  const config = service.widget;
+
+  const { data: appsData, error: appsError } = useSWR(formatApiUrl(config, `application`));
+  const { data: messagesData, error: messagesError } = useSWR(formatApiUrl(config, `message`));
+  const { data: clientsData, error: clientsError } = useSWR(formatApiUrl(config, `client`));
+
+  if (appsError || messagesError || clientsError) {
+    return <Widget error={t("widget.api_error")} />;
+  }
+
+  return (
+    <Widget>
+      <Block label={t("gotify.apps")} value={appsData?.length} />
+      <Block label={t("gotify.clients")} value={clientsData?.length} />
+      <Block label={t("gotify.messages")} value={messagesData?.messages?.length} />
+    </Widget>
+  );
+}

+ 1 - 0
src/pages/api/services/proxy.js

@@ -17,6 +17,7 @@ const serviceProxyHandlers = {
   traefik: genericProxyHandler,
   sabnzbd: genericProxyHandler,
   // uses X-API-Key (or similar) header auth
+  gotify: credentialedProxyHandler,
   portainer: credentialedProxyHandler,
   jellyseerr: credentialedProxyHandler,
   overseerr: credentialedProxyHandler,

+ 1 - 0
src/utils/api-helpers.js

@@ -16,6 +16,7 @@ const formats = {
   readarr: `{url}/api/v1/{endpoint}?apikey={key}`,
   sabnzbd: `{url}/api/?apikey={key}&output=json&mode={endpoint}`,
   coinmarketcap: `{url}/{endpoint}`,
+  gotify: `{url}/{endpoint}`,
 };
 
 export function formatApiCall(api, args) {

+ 3 - 0
src/utils/proxies/credentialed.js

@@ -17,6 +17,9 @@ export default async function credentialedProxyHandler(req, res) {
 
       if (widget.type === "coinmarketcap") {
         headers["X-CMC_PRO_API_KEY"] = `${widget.key}`;
+      } 
+      if(widget.type === "gotify"){
+        headers["X-gotify-Key"] = `${widget.key}`;
       } else {
         headers["X-API-Key"] = `${widget.key}`;
       }