Enhancement: beszel widget compatibility with v0.9.0 (#4439)

pull/4330/head
shamoon 4 days ago committed by GitHub
parent 6753843202
commit 4a4ca95fe5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 'overview' mode: `["systems", "up"]`
Allowed fields for a single system: `["name", "status", "updated", "cpu", "memory", "disk", "network"]` 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 ```yaml
widget: widget:
type: beszel type: beszel
@ -19,4 +24,5 @@ widget:
username: username # email username: username # email
password: password password: password
systemId: systemId # optional systemId: systemId # optional
version: 2 # optional, default is 1
``` ```

@ -428,7 +428,7 @@ export function cleanServiceGroups(groups) {
// frigate // frigate
enableRecentEvents, enableRecentEvents,
// glances, immich, mealie, pihole, pfsense // beszel, glances, immich, mealie, pihole, pfsense
version, version,
// glances // glances
@ -606,7 +606,7 @@ export function cleanServiceGroups(groups) {
if (snapshotHost) widget.snapshotHost = snapshotHost; if (snapshotHost) widget.snapshotHost = snapshotHost;
if (snapshotPath) widget.snapshotPath = snapshotPath; 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 (version) widget.version = parseInt(version, 10);
} }
if (type === "glances") { if (type === "glances") {

@ -45,7 +45,12 @@ export default async function beszelProxyHandler(req, res) {
if (widget) { if (widget) {
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...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 status;
let data; let data;

@ -5,6 +5,12 @@ const widget = {
proxyHandler: beszelProxyHandler, proxyHandler: beszelProxyHandler,
mappings: { mappings: {
authv1: {
endpoint: "admins/auth-with-password",
},
authv2: {
endpoint: "collections/_superusers/auth-with-password",
},
systems: { systems: {
endpoint: "collections/systems/records?page=1&perPage=500&sort=%2Bcreated", endpoint: "collections/systems/records?page=1&perPage=500&sort=%2Bcreated",
}, },

Loading…
Cancel
Save