diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 6466727f9..3681f9de6 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -246,6 +246,10 @@ "status_count": "Posts", "domain_count": "Domains" }, + "miniflux": { + "read": "Read", + "unread": "Unread" + }, "authentik": { "users": "Users", "loginsLast24H": "Logins (24h)", @@ -379,4 +383,4 @@ "inbox": "Inbox", "total": "Total" } -} \ No newline at end of file +} diff --git a/src/utils/proxy/handlers/credentialed.js b/src/utils/proxy/handlers/credentialed.js index 4d2007bae..5d34264df 100644 --- a/src/utils/proxy/handlers/credentialed.js +++ b/src/utils/proxy/handlers/credentialed.js @@ -36,6 +36,8 @@ export default async function credentialedProxyHandler(req, res, map) { headers["X-API-Token"] = `${widget.key}`; } else if (widget.type === "tubearchivist") { headers.Authorization = `Token ${widget.key}`; + } else if (widget.type === "miniflux") { + headers["X-Auth-Token"] = `${widget.key}`; } else { headers["X-API-Key"] = `${widget.key}`; } diff --git a/src/widgets/components.js b/src/widgets/components.js index e6021f17d..0ecce683f 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -21,6 +21,7 @@ const components = { jellyseerr: dynamic(() => import("./jellyseerr/component")), lidarr: dynamic(() => import("./lidarr/component")), mastodon: dynamic(() => import("./mastodon/component")), + miniflux: dynamic(() => import("./miniflux/component")), navidrome: dynamic(() => import("./navidrome/component")), npm: dynamic(() => import("./npm/component")), nzbget: dynamic(() => import("./nzbget/component")), diff --git a/src/widgets/miniflux/component.jsx b/src/widgets/miniflux/component.jsx new file mode 100644 index 000000000..dbfd60483 --- /dev/null +++ b/src/widgets/miniflux/component.jsx @@ -0,0 +1,33 @@ +import { useTranslation } from "next-i18next"; + +import Container from "components/services/widget/container"; +import Block from "components/services/widget/block"; +import useWidgetAPI from "utils/proxy/use-widget-api"; + +export default function Component({ service }) { + const { t } = useTranslation(); + + const { widget } = service; + + const { data: minifluxData, error: minifluxError } = useWidgetAPI(widget, "counters"); + + if (minifluxError) { + return ; + } + + if (!minifluxData) { + return ( + + + + + ); + } + + return ( + + + + + ); +} diff --git a/src/widgets/miniflux/widget.js b/src/widgets/miniflux/widget.js new file mode 100644 index 000000000..d4efbe2f6 --- /dev/null +++ b/src/widgets/miniflux/widget.js @@ -0,0 +1,19 @@ +import { asJson } from "utils/proxy/api-helpers"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; + +const widget = { + api: "{url}/v1/{endpoint}", + proxyHandler: credentialedProxyHandler, + + mappings: { + counters: { + endpoint: "feeds/counters", + map: (data) => ({ + read: Object.values(asJson(data).reads).reduce((acc, i) => acc + i, 0), + unread: Object.values(asJson(data).unreads).reduce((acc, i) => acc + i, 0) + }), + }, + } +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index cda52cc04..7bb3c95da 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -16,6 +16,7 @@ import jackett from "./jackett/widget"; import jellyseerr from "./jellyseerr/widget"; import lidarr from "./lidarr/widget"; import mastodon from "./mastodon/widget"; +import miniflux from "./miniflux/widget"; import navidrome from "./navidrome/widget"; import npm from "./npm/widget"; import nzbget from "./nzbget/widget"; @@ -66,6 +67,7 @@ const widgets = { jellyseerr, lidarr, mastodon, + miniflux, navidrome, npm, nzbget,