diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ba1b1fb02..e68f9e4f7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,3 +13,7 @@ updates: directory: "/" schedule: interval: "monthly" + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "monthly" diff --git a/docs/more/development.md b/docs/more/development.md index b12521120..8e3fac130 100644 --- a/docs/more/development.md +++ b/docs/more/development.md @@ -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. - 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 - 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. diff --git a/docs/widgets/info/glances.md b/docs/widgets/info/glances.md index e6fc2a616..b7fd7efd4 100644 --- a/docs/widgets/info/glances.md +++ b/docs/widgets/info/glances.md @@ -17,6 +17,7 @@ The Glances widget allows you to monitor the resources (CPU, memory, storage, te cputemp: 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) + diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk expanded: true # show the expanded view label: MyMachine # optional ``` diff --git a/docs/widgets/info/resources.md b/docs/widgets/info/resources.md index 35f2177b4..b4f85d695 100644 --- a/docs/widgets/info/resources.md +++ b/docs/widgets/info/resources.md @@ -22,6 +22,7 @@ _Note: unfortunately, the package used for getting CPU temp ([systeminformation] uptime: true units: imperial # only used by cpu temp 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, diff --git a/docs/widgets/services/gitea.md b/docs/widgets/services/gitea.md new file mode 100644 index 000000000..bf75aa69b --- /dev/null +++ b/docs/widgets/services/gitea.md @@ -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 +``` diff --git a/docs/widgets/services/glances.md b/docs/widgets/services/glances.md index d8f9e9ca0..134dcb5f6 100644 --- a/docs/widgets/services/glances.md +++ b/docs/widgets/services/glances.md @@ -18,6 +18,7 @@ widget: username: user # optional if auth enabled in Glances password: pass # optional if auth enabled in Glances 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:_ diff --git a/mkdocs.yml b/mkdocs.yml index e9d531ba0..c6ecfda95 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -57,6 +57,7 @@ nav: - widgets/services/gamedig.md - widgets/services/gatus.md - widgets/services/ghostfolio.md + - widgets/services/gitea.md - widgets/services/glances.md - widgets/services/gluetun.md - widgets/services/gotify.md diff --git a/public/locales/en/common.json b/public/locales/en/common.json index cc6846a00..7d5097fb2 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -831,5 +831,10 @@ "plants": "Plants", "photos": "Photos", "species": "Species" + }, + "gitea": { + "notifications": "Notifications", + "issues": "Issues", + "pulls": "Pull Requests" } } diff --git a/src/components/widgets/glances/glances.jsx b/src/components/widgets/glances/glances.jsx index 0834b7756..905a179a8 100644 --- a/src/components/widgets/glances/glances.jsx +++ b/src/components/widgets/glances/glances.jsx @@ -21,6 +21,7 @@ function convertToFahrenheit(t) { export default function Widget({ options }) { const { t, i18n } = useTranslation(); const { settings } = useContext(SettingsContext); + const diskUnits = options.diskUnits === "bbytes" ? "common.bbytes" : "common.bytes"; const { data, error } = useSWR( `/api/widgets/glances?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`, @@ -132,9 +133,9 @@ export default function Widget({ options }) { } {options.memory && } {Array.isArray(options.disk) - ? options.disk.map((disk) => ) - : options.disk && } + ? options.disk.map((disk) => ( + + )) + : options.disk && } {options.cputemp && } {options.uptime && } diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 67502a7a7..9f9979150 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -395,6 +395,7 @@ export function cleanServiceGroups(groups) { chart, metric, pointsLimit, + diskUnits, // glances, customapi, iframe refreshInterval, @@ -533,6 +534,7 @@ export function cleanServiceGroups(groups) { } if (refreshInterval) cleanedService.widget.refreshInterval = refreshInterval; if (pointsLimit) cleanedService.widget.pointsLimit = pointsLimit; + if (diskUnits) cleanedService.widget.diskUnits = diskUnits; } if (type === "mjpeg") { if (stream) cleanedService.widget.stream = stream; diff --git a/src/utils/proxy/api-helpers.js b/src/utils/proxy/api-helpers.js index cfb4307e6..5fc22e1e5 100644 --- a/src/utils/proxy/api-helpers.js +++ b/src/utils/proxy/api-helpers.js @@ -57,7 +57,7 @@ export function jsonArrayFilter(data, filter) { export function sanitizeErrorURL(errorURL) { // Dont display sensitive params on frontend 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, "***"); }); return url.toString(); diff --git a/src/widgets/components.js b/src/widgets/components.js index 784f05b20..9054c4d2f 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -31,6 +31,7 @@ const components = { gamedig: dynamic(() => import("./gamedig/component")), gatus: dynamic(() => import("./gatus/component")), ghostfolio: dynamic(() => import("./ghostfolio/component")), + gitea: dynamic(() => import("./gitea/component")), glances: dynamic(() => import("./glances/component")), gluetun: dynamic(() => import("./gluetun/component")), gotify: dynamic(() => import("./gotify/component")), diff --git a/src/widgets/gitea/component.jsx b/src/widgets/gitea/component.jsx new file mode 100644 index 000000000..b193efd2e --- /dev/null +++ b/src/widgets/gitea/component.jsx @@ -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 ; + } + + if (!giteaNotifications || !giteaIssues) { + return ( + + + + + + ); + } + + return ( + + + + + + ); +} diff --git a/src/widgets/gitea/widget.js b/src/widgets/gitea/widget.js new file mode 100644 index 000000000..32871b006 --- /dev/null +++ b/src/widgets/gitea/widget.js @@ -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; diff --git a/src/widgets/glances/metrics/fs.jsx b/src/widgets/glances/metrics/fs.jsx index 9cd0cec6d..16d8d153b 100644 --- a/src/widgets/glances/metrics/fs.jsx +++ b/src/widgets/glances/metrics/fs.jsx @@ -13,6 +13,7 @@ export default function Component({ service }) { const { widget } = service; const { chart, refreshInterval = defaultInterval } = widget; const [, fsName] = widget.metric.split("fs:"); + const diskUnits = widget.diskUnits === "bbytes" ? "common.bbytes" : "common.bytes"; const { data, error } = useWidgetAPI(widget, "fs", { refreshInterval: Math.max(defaultInterval, refreshInterval), @@ -60,7 +61,7 @@ export default function Component({ service }) { {fsData.used && chart && (
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.used, maximumFractionDigits: 0, })}{" "} @@ -69,7 +70,7 @@ export default function Component({ service }) { )}
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.free, maximumFractionDigits: 1, })}{" "} @@ -81,7 +82,7 @@ export default function Component({ service }) { {fsData.used && (
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.used, maximumFractionDigits: 0, })}{" "} @@ -93,7 +94,7 @@ export default function Component({ service }) {
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.size, maximumFractionDigits: 1, })}{" "} diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 6f50d9ef5..5804253d6 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -25,6 +25,7 @@ import fritzbox from "./fritzbox/widget"; import gamedig from "./gamedig/widget"; import gatus from "./gatus/widget"; import ghostfolio from "./ghostfolio/widget"; +import gitea from "./gitea/widget"; import glances from "./glances/widget"; import gluetun from "./gluetun/widget"; import gotify from "./gotify/widget"; @@ -133,6 +134,7 @@ const widgets = { gamedig, gatus, ghostfolio, + gitea, glances, gluetun, gotify,