Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: beszel widget compatibility with v0.9.0 #4439

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
shamoon marked this conversation as resolved.
Show resolved Hide resolved
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
Loading