diff options
| author | altaf-creator <dev@altafcreator.com> | 2026-01-23 22:02:56 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2026-01-23 22:02:56 +0800 |
| commit | f4d2f64e75ea782441d2512717d9ad26c8c21ecc (patch) | |
| tree | 2702df26b955133f036cd79ad0a017f3c18ffdd7 /frontend/admin | |
| parent | 17f87de3dca57dfa8ecf8dab8abc267a3f7c7cc2 (diff) | |
admin machine status
Diffstat (limited to 'frontend/admin')
| -rw-r--r-- | frontend/admin/admin.js | 33 | ||||
| -rw-r--r-- | frontend/admin/panel.html | 6 |
2 files changed, 38 insertions, 1 deletions
diff --git a/frontend/admin/admin.js b/frontend/admin/admin.js index 6f1ebce..b78b1b3 100644 --- a/frontend/admin/admin.js +++ b/frontend/admin/admin.js @@ -38,9 +38,42 @@ async function panelLoginCheck() { if (await checkLoginStatus()) { msg.style.display = "none"; authDiv.style.display = "inherit"; + return true; } else { msg.style.display = "inherit"; authDiv.style.display = "none"; + return false; + } +} + +async function syncMachineStatus() { + const response = await fetch(`${API_URL}/admin_machine_status`, { + method: "POST", + credentials: "include", + }); + const data = await response.json(); + + for (let b = 1; b <= data.length; b++) { + for (let m = 1; m <= data[b].length; m++) { + const img = document.getElementById("h"+b.toString()+"m"+m.toString()+"img"); + const dropdown = document.getElementById("h"+b.toString()+"m"+m.toString()); + + if (data[b][m] != "OUTOFSERVICE") { + if (m % 2 == 0) { + img.src = "/assets/img/washer_down.png"; + } else { + img.src = "/assets/img/dryer_down.png"; + } + dropdown.selectedIndex = 1; + } else { + if (m % 2 == 0) { + img.src = "/assets/img/washer_off.png"; + } else { + img.src = "/assets/img/dryer_off.png"; + } + dropdown.selectedIndex = 0; + } + } } } diff --git a/frontend/admin/panel.html b/frontend/admin/panel.html index 1169c30..1b0f2cf 100644 --- a/frontend/admin/panel.html +++ b/frontend/admin/panel.html @@ -77,7 +77,11 @@ </div> <script src="admin.js"></script> <script> - panelLoginCheck(); + (async () => { + if (await panelLoginCheck()) { + syncMachineStatus(); + } + })(); </script> </body> </html> |
