Merge pull request #1010 from Mbarmem/main

Add Nextcloud widget
pull/1019/head
shamoon 2 years ago committed by GitHub
commit 21a4751289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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"
}
}

@ -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")),

@ -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 <Container error={nextcloudError} />;
}
if (!nextcloudData) {
return (
<Container service={service}>
<Block label="nextcloud.cpuload" />
<Block label="nextcloud.memoryusage" />
<Block label="nextcloud.freespace" />
<Block label="nextcloud.activeusers" />
</Container>
);
}
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 (
<Container service={service}>
<Block label="nextcloud.cpuload" value={t("common.percent", { value: nextcloudInfo.system.cpuload[0] })} />
<Block label="nextcloud.memoryusage" value={t("common.percent", { value:memoryUsage })} />
<Block label="nextcloud.freespace" value={t("common.bbytes", { value: nextcloudInfo.system.freespace, maximumFractionDigits: 1 })} />
<Block label="nextcloud.activeusers" value={t("common.number", { value: nextcloudData.ocs.data.activeUsers.last5minutes })} />
</Container>
);
}

@ -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;

@ -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,

Loading…
Cancel
Save