diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 0d1368a69..063e33b55 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -349,5 +349,9 @@ "passed": "Passed", "failed": "Failed", "unknown": "Unknown" + }, + "paperlessngx": { + "inbox": "Inbox", + "total": "Total" } } diff --git a/src/widgets/components.js b/src/widgets/components.js index d645d80d9..eb7c8127e 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -23,6 +23,7 @@ const components = { nzbget: dynamic(() => import("./nzbget/component")), ombi: dynamic(() => import("./ombi/component")), overseerr: dynamic(() => import("./overseerr/component")), + paperlessngx: dynamic(() => import("./paperlessngx/component")), pihole: dynamic(() => import("./pihole/component")), plex: dynamic(() => import("./plex/component")), portainer: dynamic(() => import("./portainer/component")), diff --git a/src/widgets/paperlessngx/component.jsx b/src/widgets/paperlessngx/component.jsx new file mode 100644 index 000000000..d0c2e12f3 --- /dev/null +++ b/src/widgets/paperlessngx/component.jsx @@ -0,0 +1,29 @@ +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 { widget } = service; + + const { data: statisticsData, error: statisticsError } = useWidgetAPI(widget, "statistics"); + + if (statisticsError) { + return ; + } + + if (!statisticsData) { + return ( + + + + + ); + } + + return ( + + {statisticsData.documents_inbox !== undefined && } + + + ); +} diff --git a/src/widgets/paperlessngx/widget.js b/src/widgets/paperlessngx/widget.js new file mode 100644 index 000000000..8af8079db --- /dev/null +++ b/src/widgets/paperlessngx/widget.js @@ -0,0 +1,17 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/api/{endpoint}", + proxyHandler: genericProxyHandler, + + mappings: { + "statistics": { + endpoint: "statistics/?format=json", + validate: [ + "documents_total" + ] + }, + }, +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 3f1c6e08b..2d2f453d4 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -18,6 +18,7 @@ import npm from "./npm/widget"; import nzbget from "./nzbget/widget"; import ombi from "./ombi/widget"; import overseerr from "./overseerr/widget"; +import paperlessngx from "./paperlessngx/widget"; import pihole from "./pihole/widget"; import plex from "./plex/widget"; import portainer from "./portainer/widget"; @@ -63,6 +64,7 @@ const widgets = { nzbget, ombi, overseerr, + paperlessngx, pihole, plex, portainer,