mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 23:08:48 +00:00
Enhancement: Better handle some beszel errors (#4493)
This commit is contained in:
parent
cc9b4782f2
commit
fd05ae377c
2 changed files with 18 additions and 8 deletions
|
@ -20,8 +20,20 @@ export default function Component({ service }) {
|
|||
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
|
||||
}
|
||||
|
||||
if (systemsError) {
|
||||
return <Container service={service} error={systemsError} />;
|
||||
let system = null;
|
||||
let finalError = systemsError;
|
||||
|
||||
if (systems && !systems.items) {
|
||||
finalError = { message: "No items returned from beszel API" };
|
||||
} else if (systems && systems.items && systemId) {
|
||||
system = systems.items.find((item) => item.id === systemId);
|
||||
if (!system) {
|
||||
finalError = { message: `System with id ${systemId} not found` };
|
||||
}
|
||||
}
|
||||
|
||||
if (finalError) {
|
||||
return <Container service={service} error={finalError} />;
|
||||
}
|
||||
|
||||
if (!systems) {
|
||||
|
@ -33,9 +45,7 @@ export default function Component({ service }) {
|
|||
);
|
||||
}
|
||||
|
||||
if (systemId) {
|
||||
const system = systems.items.find((item) => item.id === systemId);
|
||||
|
||||
if (system) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="beszel.name" value={system.name} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue