Navigate before initializing page state

This commit is contained in:
2026-08-03 00:21:55 +03:30
parent 66c8c19e0c
commit e6ee587bf0
5 changed files with 119 additions and 36 deletions
+12 -3
View File
@@ -183,7 +183,7 @@
<div class="fg">
<label>Target URL</label>
<input id="cfg-target-url" type="url" placeholder="https://example.com" />
<input id="cfg-target-url" type="url" placeholder="https://example.com" required />
</div>
<div class="fg" style="display:flex;align-items:center;gap:10px;margin-bottom:14px">
@@ -1189,6 +1189,7 @@ document.getElementById('cfg-digipay-match').addEventListener('change', e => {
document.getElementById('form-save').addEventListener('click', async () => {
const body = collectForm();
if (!body.name) { alert('Config name is required.'); return; }
if (!body.target_url) { alert('Target URL is required.'); return; }
const cfgId = document.getElementById('cfg-id').value;
const isEdit = !!cfgId;
@@ -1408,6 +1409,11 @@ function startBatchPoll() {
document.getElementById('batch-start-btn').addEventListener('click', async () => {
const configId = parseInt(document.getElementById('batch-config-select').value);
if (!configId) { alert('Please select a flow config.'); return; }
const selectedConfig = _configs.find(c => c.id === configId);
if (!selectedConfig?.target_url) {
alert('The selected flow config has no Target URL. Edit and save it first.');
return;
}
const workers = parseInt(document.getElementById('batch-workers').value) || 3;
const runs = parseInt(document.getElementById('batch-runs').value) || 10;
const stagger = parseInt(document.getElementById('batch-stagger').value) || 0;
@@ -1420,8 +1426,11 @@ document.getElementById('batch-start-btn').addEventListener('click', async () =>
});
if (!res) return;
if (res.status === 404) { const d = await res.json(); alert(d.detail || 'Flow config not found.'); return; }
if (!res.ok) { alert('Failed to add task.'); return; }
if (!res.ok) {
const d = await res.json().catch(() => ({}));
alert(d.detail || 'Failed to add task.');
return;
}
const data = await res.json();
await pollBatchStatus();