mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 16:56:33 +00:00
feat(os-ota): add Push OS update now button + os_check WS message
This commit is contained in:
parent
d6e65a4168
commit
0be9665458
5 changed files with 24 additions and 1 deletions
|
|
@ -28,6 +28,8 @@ pub enum ServerMsg {
|
|||
},
|
||||
/// Server-pushed "go check for a firmware update now".
|
||||
FirmwareCheck,
|
||||
/// Server-pushed "go check for an OS update now".
|
||||
OsCheck,
|
||||
/// Show terminal auth code on screen (overlay).
|
||||
ShowTerminalCode(String),
|
||||
/// Dismiss the terminal code overlay.
|
||||
|
|
|
|||
|
|
@ -265,6 +265,9 @@ fn activate(app: &Application) {
|
|||
ServerMsg::FirmwareCheck => {
|
||||
maybe_apply_firmware_update(&server_for_reload, &key_for_reload);
|
||||
}
|
||||
ServerMsg::OsCheck => {
|
||||
maybe_apply_os_update(&server_for_reload, &key_for_reload);
|
||||
}
|
||||
ServerMsg::ShowTerminalCode(code) => {
|
||||
let _ = tx_for_reload.send(WorkerMsg::ShowTerminalCode(code));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ async fn handle_message(
|
|||
}
|
||||
} else if text.contains("\"type\":\"firmware_check\"") {
|
||||
let _ = tx.send(ServerMsg::FirmwareCheck);
|
||||
} else if text.contains("\"type\":\"os_check\"") {
|
||||
let _ = tx.send(ServerMsg::OsCheck);
|
||||
} else if text.contains("\"type\":\"fan\"") {
|
||||
let Ok(msg) = serde_json::from_str::<serde_json::Value>(text) else { return };
|
||||
let pwm = if msg.get("mode").and_then(|v| v.as_str()) == Some("auto") {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,14 @@ export function registerOsUpdateRoutes(app: H3, deps: AdminDeps): void {
|
|||
return htmlFragment(KioskOsUpdatePanel({ kiosk: k, releases }));
|
||||
});
|
||||
|
||||
// Push OS update now: server pings the kiosk via WS coordinator.
|
||||
app.post("/admin/kiosks/:id/os-update/push", (event) => {
|
||||
const id = Number(getRouterParam(event, "id"));
|
||||
const { getCoordinator } = require("../../shared/coordinator-registry.js");
|
||||
const dispatched = getCoordinator().sendToKiosk(id, { type: "os_check" });
|
||||
return { ok: true, dispatched };
|
||||
});
|
||||
|
||||
// ---- Rollouts -----------------------------------------------------------
|
||||
app.get("/admin/os-updates/rollouts", (event) => {
|
||||
const user = event.context.user!;
|
||||
|
|
|
|||
|
|
@ -3827,8 +3827,16 @@ export function KioskOsUpdatePanel(props: KioskOsUpdatePanelProps) {
|
|||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div style="grid-column:1/-1">
|
||||
<div style="grid-column:1/-1; display:flex; gap:0.5rem">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn"
|
||||
{...{
|
||||
"hx-post": `/admin/kiosks/${String(k.id)}/os-update/push`,
|
||||
"hx-swap": "none",
|
||||
}}
|
||||
>Push OS update now</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue