feat: refactor stage 1

This commit is contained in:
2026-04-08 08:58:44 +04:00
parent 8e554498f0
commit 1f01a00ad6
9 changed files with 143 additions and 17 deletions
@@ -43,6 +43,9 @@
method: document.getElementById(prefix + 'method').value,
interval_s: Number(document.getElementById(prefix + 'interval').value),
timeout_ms: Number(document.getElementById(prefix + 'timeout').value),
max_retries: Number(document.getElementById(prefix + 'max-retries').value),
retry_interval_s: Number(document.getElementById(prefix + 'retry-interval').value),
resend_interval: Number(document.getElementById(prefix + 'resend-interval').value),
};
if (Object.keys(headers).length) body.request_headers = headers;
else body.request_headers = null;
@@ -84,6 +84,36 @@
</div>
</div>
<div class="flex gap-4">
<div class="flex-1">
<label class="block text-sm text-gray-400 mb-1.5">Retries before DOWN</label>
<select id="<%= prefix %>max-retries" name="max_retries"
class="w-full <%= bg %> border <%= border %> rounded-lg px-4 py-2.5 text-gray-100 focus:outline-none focus:border-blue-500">
<% [['0','None'],['1','1'],['2','2'],['3','3'],['5','5']].forEach(function([val, label]) { %>
<option value="<%= val %>" <%= String(monitor.max_retries ?? '0') === val ? 'selected' : '' %>><%= label %></option>
<% }) %>
</select>
</div>
<div class="flex-1">
<label class="block text-sm text-gray-400 mb-1.5">Retry gap</label>
<select id="<%= prefix %>retry-interval" name="retry_interval_s"
class="w-full <%= bg %> border <%= border %> rounded-lg px-4 py-2.5 text-gray-100 focus:outline-none focus:border-blue-500">
<% [['5','5 seconds'],['15','15 seconds'],['30','30 seconds'],['60','1 minute'],['120','2 minutes']].forEach(function([val, label]) { %>
<option value="<%= val %>" <%= String(monitor.retry_interval_s ?? '30') === val ? 'selected' : '' %>><%= label %></option>
<% }) %>
</select>
</div>
<div class="flex-1">
<label class="block text-sm text-gray-400 mb-1.5">Re-alert every</label>
<select id="<%= prefix %>resend-interval" name="resend_interval"
class="w-full <%= bg %> border <%= border %> rounded-lg px-4 py-2.5 text-gray-100 focus:outline-none focus:border-blue-500">
<% [['0','Never'],['5','5 down beats'],['10','10 down beats'],['30','30 down beats'],['60','60 down beats']].forEach(function([val, label]) { %>
<option value="<%= val %>" <%= String(monitor.resend_interval ?? '0') === val ? 'selected' : '' %>><%= label %></option>
<% }) %>
</select>
</div>
</div>
<%
// Default to all regions if none selected
const selectedRegions = (monitor.regions && monitor.regions.length) ? monitor.regions : regions.map(r => r[0]);