From 21f6008cba5a23dc8e471c82af294217952f4bd9 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 24 Mar 2026 14:58:16 +0800 Subject: [PATCH] feat(frontend): add start/stop control buttons to equipment cards --- web/js/equipment.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/web/js/equipment.js b/web/js/equipment.js index d301ab6..0f4c58c 100644 --- a/web/js/equipment.js +++ b/web/js/equipment.js @@ -210,6 +210,29 @@ export function renderEquipments() { }); actionRow.append(editBtn, deleteBtn); + + if (equipment.kind === "coal_feeder" || equipment.kind === "distributor") { + const startBtn = document.createElement("button"); + startBtn.className = "secondary"; + startBtn.textContent = "Start"; + startBtn.addEventListener("click", (e) => { + e.stopPropagation(); + apiFetch(`/api/control/equipment/${equipment.id}/start`, { method: "POST" }) + .catch(() => {}); + }); + + const stopBtn = document.createElement("button"); + stopBtn.className = "danger"; + stopBtn.textContent = "Stop"; + stopBtn.addEventListener("click", (e) => { + e.stopPropagation(); + apiFetch(`/api/control/equipment/${equipment.id}/stop`, { method: "POST" }) + .catch(() => {}); + }); + + actionRow.append(startBtn, stopBtn); + } + dom.equipmentList.appendChild(box); }); }