Merge branch 'gethomepage:main' into main
This commit is contained in:
commit
013dc1c478
4
.github/dependabot.yml
vendored
4
.github/dependabot.yml
vendored
@ -13,3 +13,7 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "monthly"
|
interval: "monthly"
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
|||||||
@ -51,6 +51,7 @@ To ensure cohesiveness of various widgets, the following should be used as a gui
|
|||||||
|
|
||||||
- Please only submit widgets that have been requested and have at least 10 'up-votes'. The purpose of this requirement is to avoid the addition (and maintenance) of service widgets that might only benefit a small number of users.
|
- Please only submit widgets that have been requested and have at least 10 'up-votes'. The purpose of this requirement is to avoid the addition (and maintenance) of service widgets that might only benefit a small number of users.
|
||||||
- Widgets should be only one row of blocks
|
- Widgets should be only one row of blocks
|
||||||
- Widgets should be no more than 4 blocks wide
|
- Widgets should be no more than 4 blocks wide and generally conform to the styling / design choices of other widgets
|
||||||
- Minimize the number of API calls
|
- Minimize the number of API calls
|
||||||
- Avoid the use of custom proxy unless absolutely necessary
|
- Avoid the use of custom proxy unless absolutely necessary
|
||||||
|
- Widgets should be 'read-only', as in they should not make write changes using the relevant tool's API. Homepage widgets are designed to surface information, not to be a (usually worse) replacement for the tool itself.
|
||||||
|
|||||||
@ -17,6 +17,7 @@ The Glances widget allows you to monitor the resources (CPU, memory, storage, te
|
|||||||
cputemp: true # disabled by default
|
cputemp: true # disabled by default
|
||||||
uptime: true # disabled by default
|
uptime: true # disabled by default
|
||||||
disk: / # disabled by default, use mount point of disk(s) in glances. Can also be a list (see below)
|
disk: / # disabled by default, use mount point of disk(s) in glances. Can also be a list (see below)
|
||||||
|
diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk
|
||||||
expanded: true # show the expanded view
|
expanded: true # show the expanded view
|
||||||
label: MyMachine # optional
|
label: MyMachine # optional
|
||||||
```
|
```
|
||||||
|
|||||||
@ -22,6 +22,7 @@ _Note: unfortunately, the package used for getting CPU temp ([systeminformation]
|
|||||||
uptime: true
|
uptime: true
|
||||||
units: imperial # only used by cpu temp
|
units: imperial # only used by cpu temp
|
||||||
refresh: 3000 # optional, in ms
|
refresh: 3000 # optional, in ms
|
||||||
|
diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also pass a `label` option, which allows you to group resources under named sections,
|
You can also pass a `label` option, which allows you to group resources under named sections,
|
||||||
|
|||||||
17
docs/widgets/services/gitea.md
Normal file
17
docs/widgets/services/gitea.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: Gitea
|
||||||
|
description: Gitea Widget Configuration
|
||||||
|
---
|
||||||
|
|
||||||
|
Learn more about [Gitea](https://gitea.com).
|
||||||
|
|
||||||
|
API token requires `notifications` and `repository` permissions. See the [gitea documentation](https://docs.gitea.com/development/api-usage#generating-and-listing-api-tokens) for details on generating tokens.
|
||||||
|
|
||||||
|
Allowed fields: ["notifications", "issues", "pulls"]
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
widget:
|
||||||
|
type: gitea
|
||||||
|
url: http://gitea.host.or.ip:port
|
||||||
|
key: giteaapitoken
|
||||||
|
```
|
||||||
@ -18,6 +18,7 @@ widget:
|
|||||||
username: user # optional if auth enabled in Glances
|
username: user # optional if auth enabled in Glances
|
||||||
password: pass # optional if auth enabled in Glances
|
password: pass # optional if auth enabled in Glances
|
||||||
metric: cpu
|
metric: cpu
|
||||||
|
diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk
|
||||||
```
|
```
|
||||||
|
|
||||||
_Please note, this widget does not need an `href`, `icon` or `description` on its parent service. To achieve the same effect as the examples above, see as an example:_
|
_Please note, this widget does not need an `href`, `icon` or `description` on its parent service. To achieve the same effect as the examples above, see as an example:_
|
||||||
|
|||||||
@ -57,6 +57,7 @@ nav:
|
|||||||
- widgets/services/gamedig.md
|
- widgets/services/gamedig.md
|
||||||
- widgets/services/gatus.md
|
- widgets/services/gatus.md
|
||||||
- widgets/services/ghostfolio.md
|
- widgets/services/ghostfolio.md
|
||||||
|
- widgets/services/gitea.md
|
||||||
- widgets/services/glances.md
|
- widgets/services/glances.md
|
||||||
- widgets/services/gluetun.md
|
- widgets/services/gluetun.md
|
||||||
- widgets/services/gotify.md
|
- widgets/services/gotify.md
|
||||||
|
|||||||
@ -831,5 +831,10 @@
|
|||||||
"plants": "Plants",
|
"plants": "Plants",
|
||||||
"photos": "Photos",
|
"photos": "Photos",
|
||||||
"species": "Species"
|
"species": "Species"
|
||||||
|
},
|
||||||
|
"gitea": {
|
||||||
|
"notifications": "Notifications",
|
||||||
|
"issues": "Issues",
|
||||||
|
"pulls": "Pull Requests"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ function convertToFahrenheit(t) {
|
|||||||
export default function Widget({ options }) {
|
export default function Widget({ options }) {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const { settings } = useContext(SettingsContext);
|
const { settings } = useContext(SettingsContext);
|
||||||
|
const diskUnits = options.diskUnits === "bbytes" ? "common.bbytes" : "common.bytes";
|
||||||
|
|
||||||
const { data, error } = useSWR(
|
const { data, error } = useSWR(
|
||||||
`/api/widgets/glances?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
|
`/api/widgets/glances?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`,
|
||||||
@ -132,9 +133,9 @@ export default function Widget({ options }) {
|
|||||||
<Resource
|
<Resource
|
||||||
key={`disk_${disk.mnt_point ?? disk.device_name}`}
|
key={`disk_${disk.mnt_point ?? disk.device_name}`}
|
||||||
icon={FiHardDrive}
|
icon={FiHardDrive}
|
||||||
value={t("common.bytes", { value: disk.free })}
|
value={t(diskUnits, { value: disk.free })}
|
||||||
label={t("glances.free")}
|
label={t("glances.free")}
|
||||||
expandedValue={t("common.bytes", { value: disk.size })}
|
expandedValue={t(diskUnits, { value: disk.size })}
|
||||||
expandedLabel={t("glances.total")}
|
expandedLabel={t("glances.total")}
|
||||||
percentage={disk.percent}
|
percentage={disk.percent}
|
||||||
expanded={options.expanded}
|
expanded={options.expanded}
|
||||||
|
|||||||
@ -5,8 +5,9 @@ import { useTranslation } from "next-i18next";
|
|||||||
import Resource from "../widget/resource";
|
import Resource from "../widget/resource";
|
||||||
import Error from "../widget/error";
|
import Error from "../widget/error";
|
||||||
|
|
||||||
export default function Disk({ options, expanded, refresh = 1500 }) {
|
export default function Disk({ options, expanded, diskUnits, refresh = 1500 }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const diskUnitsName = diskUnits === "bbytes" ? "common.bbytes" : "common.bytes";
|
||||||
|
|
||||||
const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, {
|
const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, {
|
||||||
refreshInterval: refresh,
|
refreshInterval: refresh,
|
||||||
@ -36,9 +37,9 @@ export default function Disk({ options, expanded, refresh = 1500 }) {
|
|||||||
return (
|
return (
|
||||||
<Resource
|
<Resource
|
||||||
icon={FiHardDrive}
|
icon={FiHardDrive}
|
||||||
value={t("common.bytes", { value: data.drive.available })}
|
value={t(diskUnitsName, { value: data.drive.available })}
|
||||||
label={t("resources.free")}
|
label={t("resources.free")}
|
||||||
expandedValue={t("common.bytes", { value: data.drive.size })}
|
expandedValue={t(diskUnitsName, { value: data.drive.size })}
|
||||||
expandedLabel={t("resources.total")}
|
expandedLabel={t("resources.total")}
|
||||||
percentage={percent}
|
percentage={percent}
|
||||||
expanded={expanded}
|
expanded={expanded}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import CpuTemp from "./cputemp";
|
|||||||
import Uptime from "./uptime";
|
import Uptime from "./uptime";
|
||||||
|
|
||||||
export default function Resources({ options }) {
|
export default function Resources({ options }) {
|
||||||
const { expanded, units } = options;
|
const { expanded, units, diskUnits } = options;
|
||||||
let { refresh } = options;
|
let { refresh } = options;
|
||||||
if (!refresh) refresh = 1500;
|
if (!refresh) refresh = 1500;
|
||||||
refresh = Math.max(refresh, 1000);
|
refresh = Math.max(refresh, 1000);
|
||||||
@ -19,8 +19,10 @@ export default function Resources({ options }) {
|
|||||||
{options.cpu && <Cpu expanded={expanded} refresh={refresh} />}
|
{options.cpu && <Cpu expanded={expanded} refresh={refresh} />}
|
||||||
{options.memory && <Memory expanded={expanded} refresh={refresh} />}
|
{options.memory && <Memory expanded={expanded} refresh={refresh} />}
|
||||||
{Array.isArray(options.disk)
|
{Array.isArray(options.disk)
|
||||||
? options.disk.map((disk) => <Disk key={disk} options={{ disk }} expanded={expanded} refresh={refresh} />)
|
? options.disk.map((disk) => (
|
||||||
: options.disk && <Disk options={options} expanded={expanded} refresh={refresh} />}
|
<Disk key={disk} options={{ disk }} expanded={expanded} diskUnits={diskUnits} refresh={refresh} />
|
||||||
|
))
|
||||||
|
: options.disk && <Disk options={options} expanded={expanded} diskUnits={diskUnits} refresh={refresh} />}
|
||||||
{options.cputemp && <CpuTemp expanded={expanded} units={units} refresh={refresh} />}
|
{options.cputemp && <CpuTemp expanded={expanded} units={units} refresh={refresh} />}
|
||||||
{options.uptime && <Uptime refresh={refresh} />}
|
{options.uptime && <Uptime refresh={refresh} />}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -395,6 +395,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
chart,
|
chart,
|
||||||
metric,
|
metric,
|
||||||
pointsLimit,
|
pointsLimit,
|
||||||
|
diskUnits,
|
||||||
|
|
||||||
// glances, customapi, iframe
|
// glances, customapi, iframe
|
||||||
refreshInterval,
|
refreshInterval,
|
||||||
@ -533,6 +534,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
}
|
}
|
||||||
if (refreshInterval) cleanedService.widget.refreshInterval = refreshInterval;
|
if (refreshInterval) cleanedService.widget.refreshInterval = refreshInterval;
|
||||||
if (pointsLimit) cleanedService.widget.pointsLimit = pointsLimit;
|
if (pointsLimit) cleanedService.widget.pointsLimit = pointsLimit;
|
||||||
|
if (diskUnits) cleanedService.widget.diskUnits = diskUnits;
|
||||||
}
|
}
|
||||||
if (type === "mjpeg") {
|
if (type === "mjpeg") {
|
||||||
if (stream) cleanedService.widget.stream = stream;
|
if (stream) cleanedService.widget.stream = stream;
|
||||||
|
|||||||
@ -57,7 +57,7 @@ export function jsonArrayFilter(data, filter) {
|
|||||||
export function sanitizeErrorURL(errorURL) {
|
export function sanitizeErrorURL(errorURL) {
|
||||||
// Dont display sensitive params on frontend
|
// Dont display sensitive params on frontend
|
||||||
const url = new URL(errorURL);
|
const url = new URL(errorURL);
|
||||||
["apikey", "api_key", "token", "t"].forEach((key) => {
|
["apikey", "api_key", "token", "t", "access_token"].forEach((key) => {
|
||||||
if (url.searchParams.has(key)) url.searchParams.set(key, "***");
|
if (url.searchParams.has(key)) url.searchParams.set(key, "***");
|
||||||
});
|
});
|
||||||
return url.toString();
|
return url.toString();
|
||||||
|
|||||||
@ -31,6 +31,7 @@ const components = {
|
|||||||
gamedig: dynamic(() => import("./gamedig/component")),
|
gamedig: dynamic(() => import("./gamedig/component")),
|
||||||
gatus: dynamic(() => import("./gatus/component")),
|
gatus: dynamic(() => import("./gatus/component")),
|
||||||
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
||||||
|
gitea: dynamic(() => import("./gitea/component")),
|
||||||
glances: dynamic(() => import("./glances/component")),
|
glances: dynamic(() => import("./glances/component")),
|
||||||
gluetun: dynamic(() => import("./gluetun/component")),
|
gluetun: dynamic(() => import("./gluetun/component")),
|
||||||
gotify: dynamic(() => import("./gotify/component")),
|
gotify: dynamic(() => import("./gotify/component")),
|
||||||
|
|||||||
32
src/widgets/gitea/component.jsx
Normal file
32
src/widgets/gitea/component.jsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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: giteaNotifications, error: giteaNotificationsError } = useWidgetAPI(widget, "notifications");
|
||||||
|
const { data: giteaIssues, error: giteaIssuesError } = useWidgetAPI(widget, "issues");
|
||||||
|
|
||||||
|
if (giteaNotificationsError || giteaIssuesError) {
|
||||||
|
return <Container service={service} error={giteaNotificationsError ?? giteaIssuesError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!giteaNotifications || !giteaIssues) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="gitea.notifications" />
|
||||||
|
<Block label="gitea.issues" />
|
||||||
|
<Block label="gitea.pulls" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="gitea.notifications" value={giteaNotifications.length} />
|
||||||
|
<Block label="gitea.issues" value={giteaIssues.issues.length} />
|
||||||
|
<Block label="gitea.pulls" value={giteaIssues.pulls.length} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
22
src/widgets/gitea/widget.js
Normal file
22
src/widgets/gitea/widget.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { asJson } from "utils/proxy/api-helpers";
|
||||||
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/v1/{endpoint}?access_token={key}",
|
||||||
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
notifications: {
|
||||||
|
endpoint: "notifications",
|
||||||
|
},
|
||||||
|
issues: {
|
||||||
|
endpoint: "repos/issues/search",
|
||||||
|
map: (data) => ({
|
||||||
|
pulls: asJson(data).filter((issue) => issue.pull_request),
|
||||||
|
issues: asJson(data).filter((issue) => !issue.pull_request),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
||||||
@ -13,6 +13,7 @@ export default function Component({ service }) {
|
|||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
const { chart, refreshInterval = defaultInterval } = widget;
|
const { chart, refreshInterval = defaultInterval } = widget;
|
||||||
const [, fsName] = widget.metric.split("fs:");
|
const [, fsName] = widget.metric.split("fs:");
|
||||||
|
const diskUnits = widget.diskUnits === "bbytes" ? "common.bbytes" : "common.bytes";
|
||||||
|
|
||||||
const { data, error } = useWidgetAPI(widget, "fs", {
|
const { data, error } = useWidgetAPI(widget, "fs", {
|
||||||
refreshInterval: Math.max(defaultInterval, refreshInterval),
|
refreshInterval: Math.max(defaultInterval, refreshInterval),
|
||||||
@ -60,7 +61,7 @@ export default function Component({ service }) {
|
|||||||
<Block position="bottom-3 left-3">
|
<Block position="bottom-3 left-3">
|
||||||
{fsData.used && chart && (
|
{fsData.used && chart && (
|
||||||
<div className="text-xs opacity-50">
|
<div className="text-xs opacity-50">
|
||||||
{t("common.bbytes", {
|
{t(diskUnits, {
|
||||||
value: fsData.used,
|
value: fsData.used,
|
||||||
maximumFractionDigits: 0,
|
maximumFractionDigits: 0,
|
||||||
})}{" "}
|
})}{" "}
|
||||||
@ -69,7 +70,7 @@ export default function Component({ service }) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="text-xs opacity-75">
|
<div className="text-xs opacity-75">
|
||||||
{t("common.bbytes", {
|
{t(diskUnits, {
|
||||||
value: fsData.free,
|
value: fsData.free,
|
||||||
maximumFractionDigits: 1,
|
maximumFractionDigits: 1,
|
||||||
})}{" "}
|
})}{" "}
|
||||||
@ -81,7 +82,7 @@ export default function Component({ service }) {
|
|||||||
<Block position="top-3 right-3">
|
<Block position="top-3 right-3">
|
||||||
{fsData.used && (
|
{fsData.used && (
|
||||||
<div className="text-xs opacity-50">
|
<div className="text-xs opacity-50">
|
||||||
{t("common.bbytes", {
|
{t(diskUnits, {
|
||||||
value: fsData.used,
|
value: fsData.used,
|
||||||
maximumFractionDigits: 0,
|
maximumFractionDigits: 0,
|
||||||
})}{" "}
|
})}{" "}
|
||||||
@ -93,7 +94,7 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
<Block position="bottom-3 right-3">
|
<Block position="bottom-3 right-3">
|
||||||
<div className="text-xs opacity-75">
|
<div className="text-xs opacity-75">
|
||||||
{t("common.bbytes", {
|
{t(diskUnits, {
|
||||||
value: fsData.size,
|
value: fsData.size,
|
||||||
maximumFractionDigits: 1,
|
maximumFractionDigits: 1,
|
||||||
})}{" "}
|
})}{" "}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import fritzbox from "./fritzbox/widget";
|
|||||||
import gamedig from "./gamedig/widget";
|
import gamedig from "./gamedig/widget";
|
||||||
import gatus from "./gatus/widget";
|
import gatus from "./gatus/widget";
|
||||||
import ghostfolio from "./ghostfolio/widget";
|
import ghostfolio from "./ghostfolio/widget";
|
||||||
|
import gitea from "./gitea/widget";
|
||||||
import glances from "./glances/widget";
|
import glances from "./glances/widget";
|
||||||
import gluetun from "./gluetun/widget";
|
import gluetun from "./gluetun/widget";
|
||||||
import gotify from "./gotify/widget";
|
import gotify from "./gotify/widget";
|
||||||
@ -133,6 +134,7 @@ const widgets = {
|
|||||||
gamedig,
|
gamedig,
|
||||||
gatus,
|
gatus,
|
||||||
ghostfolio,
|
ghostfolio,
|
||||||
|
gitea,
|
||||||
glances,
|
glances,
|
||||||
gluetun,
|
gluetun,
|
||||||
gotify,
|
gotify,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user