Surface WAIT_USER and add Confirm to the browser client
Ports show_user_message() from client/brewpi_gui.py: a plain <dialog>
pops with the step's user_message the instant WAIT_USER is newly
entered (tracked via a prevState comparison in onSudChanged()'s State
branch), and sends {"Sud": {"Confirm": true}} on the dialog's close
event - covers both the OK button and Escape dismissal.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0189FkmyJkY77HqsNomr1DwV
This commit is contained in:
+16
@@ -9,6 +9,7 @@ const CHANNELS = ['Pot', 'Sensor', 'Heater', 'Stirrer', 'TempCtrl', 'Sud', 'Syst
|
||||
// "running" - mirrors client/brewpi_gui.py's SUD_RUNNING_STATES.
|
||||
const RUNNING_STATES = new Set(['SudState.RAMPING', 'SudState.HOLDING', 'SudState.WAIT_USER']);
|
||||
const PAUSED_STATE = 'SudState.PAUSED';
|
||||
const WAIT_USER_STATE = 'SudState.WAIT_USER';
|
||||
|
||||
let ws = null;
|
||||
let connected = false;
|
||||
@@ -306,6 +307,14 @@ function updateSudActions() {
|
||||
document.getElementById('btn-sud-stop').disabled = !(running || paused);
|
||||
}
|
||||
|
||||
// Mirrors client/brewpi_gui.py's show_user_message(): the Sud is already
|
||||
// blocked in WAIT_USER server-side - dismissing this dialog (OK or Escape,
|
||||
// both fire the dialog's 'close' event) is what unblocks it.
|
||||
function showUserMessage(message) {
|
||||
document.getElementById('sud-message-text').textContent = message;
|
||||
document.getElementById('sud-message-dialog').showModal();
|
||||
}
|
||||
|
||||
function downloadJson(doc) {
|
||||
const blob = new Blob([JSON.stringify(doc, null, '\t')], {type: 'application/json'});
|
||||
const url = URL.createObjectURL(blob);
|
||||
@@ -462,6 +471,7 @@ function onSudChanged(msg) {
|
||||
}
|
||||
} else if (key === 'State') {
|
||||
const newState = msg.State;
|
||||
const prevState = sudState;
|
||||
const isRunningNow = RUNNING_STATES.has(newState);
|
||||
if (isRunningNow && !wasRunning) {
|
||||
elapsed = 0;
|
||||
@@ -470,6 +480,9 @@ function onSudChanged(msg) {
|
||||
}
|
||||
wasRunning = isRunningNow;
|
||||
sudState = newState;
|
||||
if (newState === WAIT_USER_STATE && prevState !== WAIT_USER_STATE && sudUserMessage) {
|
||||
showUserMessage(sudUserMessage);
|
||||
}
|
||||
updateStepPlates();
|
||||
updateSudActions();
|
||||
} else if (key === 'UserMessage') {
|
||||
@@ -661,6 +674,9 @@ document.getElementById('btn-sud-start').addEventListener('click', () => {
|
||||
document.getElementById('btn-sud-stop').addEventListener('click', () => {
|
||||
sendMsg('Sud', {Stop: true});
|
||||
});
|
||||
document.getElementById('sud-message-dialog').addEventListener('close', () => {
|
||||
sendMsg('Sud', {Confirm: true});
|
||||
});
|
||||
|
||||
document.querySelectorAll('.tab-btn').forEach((btn) => {
|
||||
btn.addEventListener('click', () => {
|
||||
|
||||
Reference in New Issue
Block a user