From 4a4ca95fe547b6aa96d0c045616dd3da725ad4de Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:04:18 -0800 Subject: [PATCH] Enhancement: beszel widget compatibility with v0.9.0 (#4439) --- docs/widgets/services/beszel.md | 6 ++++++ src/utils/config/service-helpers.js | 4 ++-- src/widgets/beszel/proxy.js | 7 ++++++- src/widgets/beszel/widget.js | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/widgets/services/beszel.md b/docs/widgets/services/beszel.md index 6a5cc2691..c53915689 100644 --- a/docs/widgets/services/beszel.md +++ b/docs/widgets/services/beszel.md @@ -12,6 +12,11 @@ The `systemID` in the `id` field on the collections page of Beszel. Allowed fields for 'overview' mode: `["systems", "up"]` Allowed fields for a single system: `["name", "status", "updated", "cpu", "memory", "disk", "network"]` +| Beszel Version | Homepage Widget Version | +| -------------- | ----------------------- | +| < 0.9.0 | 1 (default) | +| >= 0.9.0 | 2 | + ```yaml widget: type: beszel @@ -19,4 +24,5 @@ widget: username: username # email password: password systemId: systemId # optional + version: 2 # optional, default is 1 ``` diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 5aec29f7a..0e3f6e3d7 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -428,7 +428,7 @@ export function cleanServiceGroups(groups) { // frigate enableRecentEvents, - // glances, immich, mealie, pihole, pfsense + // beszel, glances, immich, mealie, pihole, pfsense version, // glances @@ -606,7 +606,7 @@ export function cleanServiceGroups(groups) { if (snapshotHost) widget.snapshotHost = snapshotHost; if (snapshotPath) widget.snapshotPath = snapshotPath; } - if (["glances", "immich", "mealie", "pfsense", "pihole"].includes(type)) { + if (["beszel", "glances", "immich", "mealie", "pfsense", "pihole"].includes(type)) { if (version) widget.version = parseInt(version, 10); } if (type === "glances") { diff --git a/src/widgets/beszel/proxy.js b/src/widgets/beszel/proxy.js index fde60bfe3..7af70bd34 100644 --- a/src/widgets/beszel/proxy.js +++ b/src/widgets/beszel/proxy.js @@ -45,7 +45,12 @@ export default async function beszelProxyHandler(req, res) { if (widget) { const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget })); - const loginUrl = formatApiCall(widgets[widget.type].api, { endpoint: "admins/auth-with-password", ...widget }); + let authEndpointVersion = "authv1"; + if (widget.version === 2) authEndpointVersion = "authv2"; + const loginUrl = formatApiCall(widgets[widget.type].api, { + endpoint: widgets[widget.type].mappings[authEndpointVersion].endpoint, + ...widget, + }); let status; let data; diff --git a/src/widgets/beszel/widget.js b/src/widgets/beszel/widget.js index 508c1debb..d1496daa6 100644 --- a/src/widgets/beszel/widget.js +++ b/src/widgets/beszel/widget.js @@ -5,6 +5,12 @@ const widget = { proxyHandler: beszelProxyHandler, mappings: { + authv1: { + endpoint: "admins/auth-with-password", + }, + authv2: { + endpoint: "collections/_superusers/auth-with-password", + }, systems: { endpoint: "collections/systems/records?page=1&perPage=500&sort=%2Bcreated", },