fix-broker-dots-sync
This commit is contained in:
parent
5c54b1916d
commit
e2f5026591
16
api/set_blocked.php
Normal file
16
api/set_blocked.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
require __DIR__ . '/db.php';
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$uid = $data['uid'] ?? '';
|
||||
$blocked = $data['blocked'] ?? -1;
|
||||
|
||||
if (!$uid || !in_array((int)$blocked, [0, 1], true)) {
|
||||
http_response_code(400);
|
||||
echo json_encode(["error" => "invalid"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo->prepare("UPDATE contadores SET blocked=? WHERE uid=?")->execute([(int)$blocked, $uid]);
|
||||
echo json_encode(["ok" => 1]);
|
||||
@ -136,9 +136,14 @@ ob_start();
|
||||
<button class="btn btn-secondary btn-sm" data-uid="<?= h($uid) ?>" data-act="cmd" data-cmd="REBOOT">Reboot</button>
|
||||
<button class="btn btn-danger btn-sm" data-uid="<?= h($uid) ?>" data-act="delete">✕</button>
|
||||
</td>
|
||||
<td style="white-space:nowrap">
|
||||
<button class="btn btn-secondary btn-sm" data-uid="<?= h($uid) ?>" data-act="switch_pair" data-pair="0"><?= $isVps?$dot:'' ?>→ VPS</button>
|
||||
<button class="btn btn-secondary btn-sm" data-uid="<?= h($uid) ?>" data-act="switch_pair" data-pair="1"><?= $isPmx?$dot:'' ?>→ Proxmox</button>
|
||||
<td style="text-align:center">
|
||||
<div style="font-size:10px;color:var(--muted);margin-bottom:3px"><?= $isVps?'VPS':($isPmx?'PMX':'—') ?></div>
|
||||
<span title="VPS" data-uid="<?= h($uid) ?>" data-act="switch_pair" data-pair="0"
|
||||
style="cursor:pointer;display:inline-block;width:10px;height:10px;border-radius:50%;margin:0 3px;
|
||||
background:<?= $isVps?'#3fb950':'#333' ?>;<?= $isVps?'box-shadow:0 0 5px #3fb950;':'' ?>"></span>
|
||||
<span title="Proxmox" data-uid="<?= h($uid) ?>" data-act="switch_pair" data-pair="1"
|
||||
style="cursor:pointer;display:inline-block;width:10px;height:10px;border-radius:50%;margin:0 3px;
|
||||
background:<?= $isPmx?'#3fb950':'#333' ?>;<?= $isPmx?'box-shadow:0 0 5px #3fb950;':'' ?>"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
@ -156,7 +161,7 @@ function act(uid, action, extra){
|
||||
fetch('/esp_proxmox.php',{method:'POST',body:fd}).then(()=>location.reload());
|
||||
}
|
||||
document.addEventListener('click',function(e){
|
||||
const b=e.target.closest('button[data-act]'); if(!b) return;
|
||||
const b=e.target.closest('[data-act]'); if(!b) return;
|
||||
if(b.dataset.act==='delete' && !confirm('Remover '+b.dataset.uid+'?')) return;
|
||||
const extra={};
|
||||
if(b.dataset.pair!==undefined) extra.pair=b.dataset.pair;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user