Add AI auto-check worker, share link message/link fields, and update journal/settings UI
This commit is contained in:
+25
-3
@@ -1,4 +1,8 @@
|
||||
const DIRTY_FIELDS = ['spamInterval', 'footerLeft', 'footerRight'];
|
||||
const DIRTY_FIELDS = ['spamInterval', 'footerLeft', 'footerRight', 'aiPrompt', 'aiAutoCheck'];
|
||||
|
||||
function fieldValue(el) {
|
||||
return el.type === 'checkbox' ? String(el.checked) : el.value;
|
||||
}
|
||||
|
||||
function setBtnLoading(btn, on, spinnerClass) {
|
||||
if (on) {
|
||||
@@ -14,7 +18,7 @@ function setBtnLoading(btn, on, spinnerClass) {
|
||||
function updateDirty() {
|
||||
const dirty = DIRTY_FIELDS.some(id => {
|
||||
const el = document.getElementById(id);
|
||||
return String(el.dataset.original ?? '') !== el.value;
|
||||
return String(el.dataset.original ?? '') !== fieldValue(el);
|
||||
});
|
||||
document.getElementById('saveBar').classList.toggle('show', dirty);
|
||||
}
|
||||
@@ -27,7 +31,7 @@ function bindDirty() {
|
||||
|
||||
function snapshotDirty() {
|
||||
DIRTY_FIELDS.forEach(id => {
|
||||
document.getElementById(id).dataset.original = document.getElementById(id).value;
|
||||
document.getElementById(id).dataset.original = fieldValue(document.getElementById(id));
|
||||
});
|
||||
updateDirty();
|
||||
}
|
||||
@@ -41,7 +45,10 @@ async function loadSettings() {
|
||||
if (s.spam_interval_min !== undefined) document.getElementById('spamInterval').value = s.spam_interval_min;
|
||||
document.getElementById('footerLeft').value = s.footer_left || '';
|
||||
document.getElementById('footerRight').value = s.footer_right || '';
|
||||
document.getElementById('aiPrompt').value = s.ai_prompt || '';
|
||||
document.getElementById('aiAutoCheck').checked = s.ai_autocheck_enabled !== 'false';
|
||||
snapshotDirty();
|
||||
loadAiQueue();
|
||||
if (stRes.ok) {
|
||||
const st = await stRes.json();
|
||||
document.getElementById('dataStats').innerHTML = `
|
||||
@@ -122,6 +129,19 @@ function renderSystemInfo(si) {
|
||||
`;
|
||||
}
|
||||
|
||||
async function loadAiQueue() {
|
||||
const el = document.getElementById('aiQueueInfo');
|
||||
if (!el) return;
|
||||
try {
|
||||
const res = await fetch(`${API}/api/ai/queue`, { headers: hdr() });
|
||||
if (!res.ok) { el.textContent = ''; return; }
|
||||
const q = await res.json();
|
||||
const c = q.counts || {};
|
||||
const state = q.enabled ? 'включена' : 'выключена';
|
||||
el.innerHTML = `Автопроверка: <b>${state}</b> · Модель: <b>${esc(q.model)}</b> · В очереди: <b>${c.pending || 0}</b> · Проверено: <b>${c.done || 0}</b> · Ошибок: <b>${c.error || 0}</b> · Пропущено: <b>${c.skipped || 0}</b> · <a href="worker.html">Монитор воркера →</a>`;
|
||||
} catch { el.textContent = ''; }
|
||||
}
|
||||
|
||||
async function saveSettings() {
|
||||
const v = document.getElementById('spamInterval').value;
|
||||
if (v === '' || Number(v) < 1) { alert('Введите число от 1'); return; }
|
||||
@@ -136,6 +156,8 @@ async function saveSettings() {
|
||||
spam_interval_min: String(Math.round(Number(v))),
|
||||
footer_left: document.getElementById('footerLeft').value.trim(),
|
||||
footer_right: document.getElementById('footerRight').value.trim(),
|
||||
ai_prompt: document.getElementById('aiPrompt').value.trim(),
|
||||
ai_autocheck_enabled: document.getElementById('aiAutoCheck').checked ? 'true' : 'false',
|
||||
} })
|
||||
});
|
||||
if (res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user