additional door states

This commit is contained in:
kritzl 2026-05-11 11:49:10 +02:00
commit 7935c54a60
Signed by: kritzl
SSH key fingerprint: SHA256:5BmINP9VjZWaUk5Z+2CTut1KFhwLtd0ZynMekKbtViM
3 changed files with 75 additions and 32 deletions

View file

@ -59,8 +59,10 @@ const t = useTranslations(lang)
type DoorType = {
id: string;
label: string;
state: "open" | "closed" | "unknown" | "moving";
state: "unlocked" | "locked" | "unknown" | "unlocking" | "locking";
batteryLow: boolean;
unreachable: boolean;
jammed: boolean;
}
type AuthType = {
username: string;
@ -79,14 +81,18 @@ const t = useTranslations(lang)
{
id: "abcdef",
label: "Hauptraum",
state: "open",
state: "unlocked",
batteryLow: false,
unreachable: false,
jammed: false,
},
{
id: "12345",
label: "Werkstatt",
state: "closed",
state: "locked",
batteryLow: true,
unreachable: false,
jammed: false,
},
]
@ -94,12 +100,10 @@ const t = useTranslations(lang)
const getUserInfo = fetcher.path("/api/user-info/").method("get").create()
try {
const {status, data: userInfo} = await getUserInfo({
status: ["available", "pending"],
})
const {status, data: userInfo} = await getUserInfo({})
auth.authenticated = userInfo.is_logged_in
auth.authorized = false
auth.authorized = true
auth.until = userInfo.guaranteed_session_until ? new Date(userInfo.guaranteed_session_until) : null
auth.username = userInfo.user_info?.username ?? ''
} catch (e) {
@ -140,10 +144,22 @@ const t = useTranslations(lang)
delete doorElement.dataset.battery
}
if (door.unreachable) {
doorElement.dataset.unreachable = ""
} else {
delete doorElement.dataset.unreachable
}
if (door.jammed) {
doorElement.dataset.jammed = ""
} else {
delete doorElement.dataset.jammed
}
labelElement.innerHTML = door.label
buttonElements.forEach(button => {
button.disabled = door.state === "moving"
button.disabled = ["unlocking", "locking"].includes(door.state)
})
}
@ -184,13 +200,17 @@ const t = useTranslations(lang)
id: "abcdef",
label: "Hauptraum",
state: "unknown",
batteryLow: false,
batteryLow: true,
unreachable: false,
jammed: true,
}
doors[1] = {
id: "12345",
label: "Werkstatt",
state: "moving",
batteryLow: true,
state: "unlocking",
batteryLow: false,
unreachable: true,
jammed: false,
}
refresh()
}, 2000)