diff --git a/clavis/clavis-vault/cmd/clavitor/web/agents.html b/clavis/clavis-vault/cmd/clavitor/web/agents.html index 4f45a9b..4800f67 100644 --- a/clavis/clavis-vault/cmd/clavitor/web/agents.html +++ b/clavis/clavis-vault/cmd/clavitor/web/agents.html @@ -71,6 +71,43 @@

Loading...

+ + + @@ -139,7 +176,8 @@ '' + escapeHtml(a.last_ip) + '' + '' + a.rate_limit_minute + '/m ' + a.rate_limit_hour + '/h' + '' + escapeHtml(ips) + '' + - ''; + '' + + ' '; if (a.status === 'locked') { html += ''; @@ -257,6 +295,46 @@ loadAgents(); }); + // Edit modal functions + function openEditModal(id, name, ips, rateMin, rateHour) { + document.getElementById('editAgentId').value = id; + document.getElementById('editAgentNameDisplay').textContent = name; + document.getElementById('editAgentIPs').value = ips || ''; + document.getElementById('editRateMin').value = rateMin || 5; + document.getElementById('editRateHour').value = rateHour || 10; + document.getElementById('editModal').classList.remove('hidden'); + } + + function closeEditModal() { + document.getElementById('editModal').classList.add('hidden'); + } + + async function saveAgentSettings() { + var id = document.getElementById('editAgentId').value; + var ipsStr = document.getElementById('editAgentIPs').value.trim(); + var ips = ipsStr ? ipsStr.split(',').map(function(s) { return s.trim(); }).filter(Boolean) : []; + + var data = { + ip_whitelist: ips, + rate_limit_minute: parseInt(document.getElementById('editRateMin').value) || 5, + rate_limit_hour: parseInt(document.getElementById('editRateHour').value) || 10 + }; + + try { + await api('PUT', '/api/agents/' + id, data); + toast('Agent settings updated'); + closeEditModal(); + loadAgents(); + } catch(e) { + toast('Failed to update agent: ' + e.message, 'error'); + } + } + + // Close modal on outside click + document.getElementById('editModal').addEventListener('click', function(e) { + if (e.target === this) closeEditModal(); + }); + // Stateless: check sessionStorage for master key if (!getL1Bearer()) { window.location.href = '/app/';