From aa78f601d5690f2de113130170dbc8e34255a558 Mon Sep 17 00:00:00 2001 From: deploy Date: Tue, 7 Jul 2026 12:57:50 +0100 Subject: [PATCH] esp_proxmox: brilho dropdown niveis + relogio estilo/tema global e por-uid Co-Authored-By: Claude Fable 5 --- esp_proxmox.php | 82 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 12 deletions(-) diff --git a/esp_proxmox.php b/esp_proxmox.php index 417b05e..ca508ee 100644 --- a/esp_proxmox.php +++ b/esp_proxmox.php @@ -32,6 +32,16 @@ function pmx_post(array $data): array { $msg = ''; $msgOk = true; if ($_SERVER['REQUEST_METHOD'] === 'POST') { + // ações de frota (broadcast) — não precisam de uid válido + $action0 = $_POST['action'] ?? ''; + if ($action0 === 'clock_style' || $action0 === 'clock_theme') { + $res = pmx_post($_POST); + $who = ($_POST['uid'] ?? '') === 'all' ? 'frota toda' : ($_POST['uid'] ?? '?'); + if (!empty($res['ok'])) { $msg = "Relógio atualizado ($who)."; $msgOk = true; } + else { $msg = $res['error'] ?? 'Erro'; $msgOk = false; } + $qs = $msgOk ? '?ok='.urlencode($msg) : '?err='.urlencode($msg); + header("Location: /esp_proxmox.php$qs"); exit; + } $uid = preg_replace('/[^0-9A-Fa-f]/', '', $_POST['uid'] ?? ''); if (!$uid) { $msg = 'UID invalido.'; $msgOk = false; } else { @@ -94,6 +104,28 @@ ob_start();
+
+ Relógio: + $lbl): ?> +
+ + + + +
+ + + Tema: + ['Âmbar','#EF9F27'],'verde'=>['Verde','#3fb950'],'branco'=>['Branco','#d7dde4'],'noite'=>['Noite','#da3633']] as $tk => [$tlbl,$tcol]): ?> +
+ + + + +
+ +
+

Sem dispositivos ou erro a ligar ao broker Proxmox.

@@ -103,7 +135,7 @@ ob_start();
- +
- + +
UIDVersãoUltimo contactoOnlineEstadoBrilhoAçõesBroker
UIDVersãoUltimo contactoOnlineEstadoBrilhoRelógioAçõesBroker
onlineoffline bloqueadoaprovado
- > - -
+ + + + + + @@ -165,13 +221,15 @@ document.addEventListener('click',function(e){ act(b.dataset.uid,b.dataset.act,extra); }); function setBri(uid,val){ - document.getElementById('brival_'+uid).textContent=val; - clearTimeout(_bt[uid]); - _bt[uid]=setTimeout(()=>{ - const fd=new FormData(); - fd.append('action','brightness');fd.append('uid',uid);fd.append('value',val); - fetch('/esp_proxmox.php',{method:'POST',headers:{'X-Requested-With':'XMLHttpRequest'},body:fd}); - },400); + const fd=new FormData(); + fd.append('action','brightness');fd.append('uid',uid);fd.append('value',val); + fetch('/esp_proxmox.php',{method:'POST',headers:{'X-Requested-With':'XMLHttpRequest'},body:fd}); +} +function clockCmd(uid,action,val){ + if(val==='') return; + const fd=new FormData(); + fd.append('action',action);fd.append('uid',uid);fd.append('value',val); + fetch('/esp_proxmox.php',{method:'POST',headers:{'X-Requested-With':'XMLHttpRequest'},body:fd}).catch(console.error); }