diff --git a/web/src/routes/modules/+page.svelte b/web/src/routes/modules/+page.svelte index 5422751..2037a70 100644 --- a/web/src/routes/modules/+page.svelte +++ b/web/src/routes/modules/+page.svelte @@ -120,6 +120,14 @@ } } + function moduleIntervalLabel(moduleRow: ModuleRow): string { + const cron = typeof moduleRow.cron_expr === 'string' ? moduleRow.cron_expr.trim() : moduleRow.cron_expr; + if (cron) return cron; + return moduleRow.refresh_interval_sec !== null && moduleRow.refresh_interval_sec !== undefined + ? `${moduleRow.refresh_interval_sec}с` + : '—'; + } + function toggleModuleSelection(id: string) { const next = new Set(selectedModuleIds); if (next.has(id)) next.delete(id); @@ -237,9 +245,7 @@ {m.priority} - {m.cron_expr ?? (m.refresh_interval_sec !== null && m.refresh_interval_sec !== undefined - ? `${m.refresh_interval_sec}с` - : '—')} + {moduleIntervalLabel(m)} {#if m.enabled} @@ -286,7 +292,7 @@ {moduleTypes.find((t) => t.value === form.type)?.label ?? 'Выберите тип'} - {#each moduleTypes as t} + {#each moduleTypes as t (t.value)} {t.label} {/each} diff --git a/web/src/routes/modules/[moduleId]/+page.svelte b/web/src/routes/modules/[moduleId]/+page.svelte index 4bdffb4..e30b640 100644 --- a/web/src/routes/modules/[moduleId]/+page.svelte +++ b/web/src/routes/modules/[moduleId]/+page.svelte @@ -146,6 +146,8 @@ // Module edit let editDialog = $state(false); let editForm = $state({}); + let editDefaultCommunitySelect = $state('__none__'); + let editDohProfileSelect = $state('__none__'); let editSaving = $state(false); let deleteModDialog = $state(false); let deletingMod = $state(false); @@ -265,13 +267,28 @@ default_community_id: mod.default_community_id, doh_profile_id: mod.doh_profile_id }; + editDefaultCommunitySelect = nullableSelectValue(mod.default_community_id); + editDohProfileSelect = nullableSelectValue(mod.doh_profile_id); editDialog = true; } async function saveMod() { editSaving = true; try { - await apiMutate(`/v1/modules/${moduleId}`, 'PATCH', editForm); + const cron = typeof editForm.cron_expr === 'string' ? editForm.cron_expr.trim() : editForm.cron_expr; + const intervalRaw = editForm.refresh_interval_sec; + const interval = + intervalRaw === null || intervalRaw === undefined + ? null + : Number(intervalRaw); + const payload: ModulePatch = { + ...editForm, + cron_expr: cron ? cron : null, + refresh_interval_sec: Number.isFinite(interval) ? interval : null, + default_community_id: fromNullableSelect(editDefaultCommunitySelect), + doh_profile_id: fromNullableSelect(editDohProfileSelect) + }; + await apiMutate(`/v1/modules/${moduleId}`, 'PATCH', payload); await loadMod(); toast.success('Модуль обновлён'); editDialog = false; @@ -733,6 +750,14 @@ return value; } + function moduleIntervalLabel(moduleRow: ModuleRow): string { + const cron = typeof moduleRow.cron_expr === 'string' ? moduleRow.cron_expr.trim() : moduleRow.cron_expr; + if (cron) return cron; + return moduleRow.refresh_interval_sec !== null && moduleRow.refresh_interval_sec !== undefined + ? `${moduleRow.refresh_interval_sec}с` + : '—'; + } + const activeTab = $derived.by(() => { if (!mod) return 'entries'; switch (mod.type) { @@ -810,7 +835,7 @@ Интервал - {mod.cron_expr ?? (mod.refresh_interval_sec !== null && mod.refresh_interval_sec !== undefined ? `${mod.refresh_interval_sec}с` : '—')} + {moduleIntervalLabel(mod)} @@ -1281,8 +1306,9 @@ Community по умолчанию { + editDefaultCommunitySelect = nullableSelectValue(v); editForm.default_community_id = fromNullableSelect(v); }} > @@ -1301,8 +1327,9 @@ DoH профиль { + editDohProfileSelect = nullableSelectValue(v); editForm.doh_profile_id = fromNullableSelect(v); }} >
Интервал
- {mod.cron_expr ?? (mod.refresh_interval_sec !== null && mod.refresh_interval_sec !== undefined ? `${mod.refresh_interval_sec}с` : '—')} + {moduleIntervalLabel(mod)}