diff --git a/public/locales/en/common.json b/public/locales/en/common.json old mode 100644 new mode 100755 index 98f2b7962..a24ca8778 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -489,5 +489,11 @@ "datasources": "Data Sources", "totalalerts": "Total Alerts", "alertstriggered": "Alerts Triggered" + }, + "nextcloud": { + "cpuload": "Cpu Load", + "memoryusage": "Memory Usage", + "freespace": "Free Space", + "activeusers": "Active Users" } } \ No newline at end of file diff --git a/src/widgets/components.js b/src/widgets/components.js index 8c5c42e7d..d39a7cc79 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -33,6 +33,7 @@ const components = { moonraker: dynamic(() => import("./moonraker/component")), mylar: dynamic(() => import("./mylar/component")), navidrome: dynamic(() => import("./navidrome/component")), + nextcloud: dynamic(() => import("./nextcloud/component")), nextdns: dynamic(() => import("./nextdns/component")), npm: dynamic(() => import("./npm/component")), nzbget: dynamic(() => import("./nzbget/component")), diff --git a/src/widgets/nextcloud/component.jsx b/src/widgets/nextcloud/component.jsx new file mode 100755 index 000000000..1dc9fbff6 --- /dev/null +++ b/src/widgets/nextcloud/component.jsx @@ -0,0 +1,39 @@ +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: nextcloudData, error: nextcloudError } = useWidgetAPI(widget, "serverinfo"); + + if (nextcloudError) { + return ; + } + + if (!nextcloudData) { + return ( + + + + + + + ); + } + + const nextcloudInfo = nextcloudData.ocs.data.nextcloud; + const memoryUsage = 100 * ((parseFloat(nextcloudInfo.system.mem_total) - parseFloat(nextcloudInfo.system.mem_free)) / parseFloat(nextcloudInfo.system.mem_total)); + + return ( + + + + + + + ); +} diff --git a/src/widgets/nextcloud/widget.js b/src/widgets/nextcloud/widget.js new file mode 100755 index 000000000..0500f59e6 --- /dev/null +++ b/src/widgets/nextcloud/widget.js @@ -0,0 +1,14 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/{endpoint}", + proxyHandler: genericProxyHandler, + + mappings: { + serverinfo: { + endpoint: "ocs/v2.php/apps/serverinfo/api/v1/info?format=json", + }, + }, +}; + +export default widget; \ No newline at end of file diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 111da7eb7..72fe803b4 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -27,6 +27,7 @@ import mikrotik from "./mikrotik/widget"; import moonraker from "./moonraker/widget"; import mylar from "./mylar/widget"; import navidrome from "./navidrome/widget"; +import nextcloud from "./nextcloud/widget"; import nextdns from "./nextdns/widget"; import npm from "./npm/widget"; import nzbget from "./nzbget/widget"; @@ -96,6 +97,7 @@ const widgets = { moonraker, mylar, navidrome, + nextcloud, nextdns, npm, nzbget,