Skip to content
Open
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
20 changes: 17 additions & 3 deletions src/roborock_local_server/standalone_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,20 @@ def _admin_dashboard_html(project_support: dict[str, Any]) -> str:
container.appendChild(card);
}}
}}
// The page refreshes every 2 seconds. Until Save is pressed, a changed checkbox keeps the
// user's choice instead of snapping back to the saved setting.
let connectionsEdited = false;
document.getElementById("newConnectionsEnabled").addEventListener("change", () => {{
connectionsEdited = true;
document.getElementById("authMeta").textContent = "Unsaved change: press Save to apply it.";
}});
function renderAuth(auth) {{
const enabled = Boolean(auth.new_connections_enabled);
document.getElementById("newConnectionsEnabled").checked = enabled;
document.getElementById("authMeta").textContent =
`New connections: ${{enabled ? "Allowed" : "Blocked"}}. Persisted sessions: ${{Number(auth.protocol_session_count || 0)}}.`;
if (!connectionsEdited) {{
document.getElementById("newConnectionsEnabled").checked = enabled;
document.getElementById("authMeta").textContent =
`New connections: ${{enabled ? "Allowed" : "Blocked"}}. Persisted sessions: ${{Number(auth.protocol_session_count || 0)}}.`;
}}
const sessionSecret = String(auth.admin_session_secret || "");
document.getElementById("adminSessionSecret").value = sessionSecret;
document.getElementById("syncSecretMeta").textContent = sessionSecret
Expand Down Expand Up @@ -266,6 +275,11 @@ def _admin_dashboard_html(project_support: dict[str, Any]) -> str:
new_connections_enabled: document.getElementById("newConnectionsEnabled").checked
}})
}});
// Only a choice the server now holds stops being unsaved; a change made while Save
// was in flight stays unsaved.
if (document.getElementById("newConnectionsEnabled").checked === Boolean(payload.new_connections_enabled)) {{
connectionsEdited = false;
}}
renderAuth(payload);
await refresh();
}} catch (error) {{
Expand Down
Loading