Rework radar system
This commit is contained in:
@@ -102,7 +102,8 @@ async function changeDisplayCombo(path, body) {
|
||||
} catch (err) {
|
||||
toast(err.message, true);
|
||||
} finally {
|
||||
displayComboSelect.disabled = btnNextCombo.disabled = false;
|
||||
displayComboSelect.disabled = displayComboSelect.options.length === 0;
|
||||
btnNextCombo.disabled = displayComboSelect.options.length < 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +268,8 @@ function buildSettingsForm(schema) {
|
||||
function collectFields() {
|
||||
const out = {};
|
||||
for (const key in fieldInputs) {
|
||||
const { el, kind } = fieldInputs[key];
|
||||
const { el, kind, dirty } = fieldInputs[key];
|
||||
if (!dirty) continue; // unchanged browser values must not overwrite newer desktop edits
|
||||
if (kind === "geometry") out[key] = el.getRecords();
|
||||
else if (kind === "bool") out[key] = el.checked;
|
||||
else if (kind === "int" || kind === "float") {
|
||||
@@ -296,7 +298,9 @@ function clearDirty() {
|
||||
|
||||
async function applyOne(field, value) {
|
||||
try {
|
||||
await api("/api/live_settings", { [field]: value });
|
||||
const schema = await api("/api/live_settings", { [field]: value });
|
||||
if (fieldInputs[field]) fieldInputs[field].dirty = false;
|
||||
applySettings(schema);
|
||||
} catch (err) {
|
||||
toast(err.message, true);
|
||||
}
|
||||
@@ -321,8 +325,9 @@ function applySettings(schema) {
|
||||
btnApply.addEventListener("click", async () => {
|
||||
btnApply.disabled = true;
|
||||
try {
|
||||
await api("/api/live_settings", collectFields());
|
||||
const schema = await api("/api/live_settings", collectFields());
|
||||
clearDirty(); // applied; let live pushes update the form again
|
||||
applySettings(schema);
|
||||
settingsNote.textContent = "Applied.";
|
||||
} catch (err) {
|
||||
settingsNote.textContent = err.message;
|
||||
@@ -335,7 +340,7 @@ btnApply.addEventListener("click", async () => {
|
||||
btnResetHistory.addEventListener("click", async () => {
|
||||
btnResetHistory.disabled = true;
|
||||
try {
|
||||
await api("/api/live_settings", { history_command: "clear_all" });
|
||||
await api("/api/clear_history");
|
||||
settingsNote.textContent = "History reset requested.";
|
||||
} catch (err) {
|
||||
settingsNote.textContent = err.message;
|
||||
@@ -464,6 +469,8 @@ function applyStatus(s) {
|
||||
comboOptionsSignature = signature;
|
||||
}
|
||||
displayComboSelect.value = `${combo.input}:${combo.output}`;
|
||||
displayComboSelect.disabled = options.length === 0;
|
||||
btnNextCombo.disabled = options.length < 2;
|
||||
}
|
||||
if ("running" in s) {
|
||||
setStat(runningEl, "running", s.running ? "yes" : "no", s.running ? "ok" : "off");
|
||||
|
||||
Reference in New Issue
Block a user