Skip to content

Commit

Permalink
Enhancement: beszel widget compatibility with v0.9.0 (#4439)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon authored Dec 18, 2024
1 parent 6753843 commit 4a4ca95
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/widgets/services/beszel.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ 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
url: http://beszel.host.or.ip
username: username # email
password: password
systemId: systemId # optional
version: 2 # optional, default is 1
```
4 changes: 2 additions & 2 deletions src/utils/config/service-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export function cleanServiceGroups(groups) {
// frigate
enableRecentEvents,

// glances, immich, mealie, pihole, pfsense
// beszel, glances, immich, mealie, pihole, pfsense
version,

// glances
Expand Down Expand Up @@ -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") {
Expand Down
7 changes: 6 additions & 1 deletion src/widgets/beszel/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/widgets/beszel/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down

0 comments on commit 4a4ca95

Please sign in to comment.