<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } $cmdId = (int)($_POST['cmd_id'] ?? 0); $commands = Database::fetchAll("SELECT c.id,c.command,c.status_code,c.priority_code,c.created_at,n.hostname FROM node_commands c JOIN nodes n ON n.id=c.node_id WHERE c.status_code IN (5010,5011) ORDER BY c.created_at DESC LIMIT 20"); ?> <div id="cmd-cancel" class="panel"> <span class="section-label">Pending Commands</span><?php foreach ($commands as $c): ?> <div id="cmd-row-<?= (int)$c['id'] ?> " class="event-row"> <span class="event-action">[<?= UI::e($c['hostname']) ?> ]<?= UI::e(substr($c['command'],0,60)) ?> </span> <span class="event-time"><?= StatusCode::render((int)$c['status_code']) ?> —<?= UI::e($c['created_at']) ?> </span> <a class="btn btn-danger btn-sm cancel-cmd" href="javascript:void(0)" data-id="<?= (int)$c['id'] ?> "><span>Cancel</span></a> </div><?php endforeach; ?> <?php if (empty($commands)): ?> <div class="empty-state"><span>No pending commands.</span></div><?php endif; ?> </div> <script nonce="<?= $cspNonce ?? '' ?> "> document.querySelectorAll('.cancel-cmd').forEach(function(btn){btn.addEventListener('click',function(){ var id=btn.dataset.id; window.dashFetch('modify',{entity:'fleet_command',id:id,'data[status_code]':'5015'},function(r){if(r.ok){alert('Cancelled.');location.reload();}else{alert(r.error||'Failed');}}); });}); </script>