feat: add region selector to monitor edit form

This commit is contained in:
M1 2026-03-18 16:15:19 +04:00
parent 93db31db3b
commit 8c39fb45c1
1 changed files with 12 additions and 0 deletions

View File

@ -182,6 +182,17 @@
</div> </div>
</div> </div>
<div>
<label class="block text-sm text-gray-400 mb-1.5">Regions <span class="text-gray-600">(leave all unselected to use all regions)</span></label>
<div class="flex flex-wrap gap-2">
<% [['eu-central','🇩🇪 EU Central'],['us-east','🇺🇸 US East'],['us-west','🇺🇸 US West'],['ap-southeast','🇸🇬 AP Southeast']].forEach(function([val, label]) { %>
<label class="flex items-center gap-2 bg-gray-800 border border-gray-700 hover:border-gray-500 rounded-lg px-3 py-2 cursor-pointer transition-colors">
<input type="checkbox" value="<%= val %>" class="edit-region-check accent-blue-500" <%= (m.regions && m.regions.includes(val)) ? 'checked' : '' %>> <span class="text-sm text-gray-300"><%- label %></span>
</label>
<% }) %>
</div>
</div>
<div> <div>
<label class="block text-sm text-gray-400 mb-1.5">Conditions <span class="text-gray-600">(optional)</span></label> <label class="block text-sm text-gray-400 mb-1.5">Conditions <span class="text-gray-600">(optional)</span></label>
<p class="text-xs text-gray-600 mb-3">Define up/down conditions. Defaults to status &lt; 400.</p> <p class="text-xs text-gray-600 mb-3">Define up/down conditions. Defaults to status &lt; 400.</p>
@ -267,6 +278,7 @@
const rb = document.getElementById('edit-request-body').value.trim(); const rb = document.getElementById('edit-request-body').value.trim();
body.request_body = rb || null; body.request_body = rb || null;
if (editQuery) body.query = editQuery; if (editQuery) body.query = editQuery;
body.regions = [...document.querySelectorAll('.edit-region-check:checked')].map(el => el.value);
await api(`/monitors/${monitorId}`, { method: 'PATCH', body }); await api(`/monitors/${monitorId}`, { method: 'PATCH', body });
location.reload(); location.reload();
} catch (err) { } catch (err) {