Fix: show both schedule_enabled and state status separately in jobs table

This commit is contained in:
2026-06-11 14:31:30 +07:00
parent 4346503939
commit bcef4deaf1

View File

@@ -487,32 +487,63 @@ function renderJobsTable(inst) {
header += '</div>';
let rows = '';
for (const j of jobs) {
const isDisabled = strIsFalse(j.schedule_enabled) || strIsStopped(j.state);
const scheduleEnabled = strIsFalse(j.schedule_enabled) ? false : true;
const stateStopped = strIsStopped(j.state);
const isDisabled = !scheduleEnabled || stateStopped;
const pts = j.restore_points_to_keep != null ? j.restore_points_to_keep : (j.restorePointsToKeep != null ? j.restorePointsToKeep : null);
const actual = j.actual_restore_points != null ? j.actual_restore_points : null;
let ptsDisplay = '—';
if (pts !== null || actual !== null) {
ptsDisplay = actual !== null ? (pts !== null ? pts + ' / ' + actual : actual + ' (actual)') : (pts + ' (max)');
}
let stateBadge = stateStopped ? '<span class="badge info">' + (j.state || 'stopped') + '</span>' : '';
let scheduleBadge = '';
if (!scheduleEnabled) {
scheduleBadge = '<span class="badge danger">расписание откл</span>';
} else if (stateStopped) {
scheduleBadge = '<span class="badge warning">вкл, но stopped</span>';
} else {
scheduleBadge = '<span class="badge success">включено</span>';
}
let statusDisplay = stateStopped
? (scheduleEnabled ? '<span class="badge warning">вкл, но ' + (j.state || 'stopped') + '</span>' : '<span class="badge danger">расписание откл</span>')
: (scheduleEnabled ? '<span class="badge success">включено</span>' : '<span class="badge danger">расписание откл</span>');
rows += '<tr class="' + (isDisabled ? 'job-disabled' : '') + '">';
rows += '<td>' + esc(j.name || j.Name || '—') + '</td>';
rows += '<td>' + esc(j.type || j.jobType || '—') + '</td>';
rows += '<td>' + ptsDisplay + '</td>';
rows += '<td>' + formatDate(j.last_backup) + '</td>';
rows += '<td>' + (isDisabled ? '<span class="badge danger">выключена</span>' : '<span class="badge success">включена</span>') + '</td>';
rows += '<td>' + statusDisplay + '</td>';
rows += '</tr>';
}
let html = header + '<div class="table-wrap"><table><thead><tr><th>Имя</th><th>Тип</th><th>Точки восст.</th><th>Последний бэкап</th><th>Расписание</th></tr></thead><tbody>' + rows + '</tbody></table></div>';
let html = header + '<div class="table-wrap"><table><thead><tr><th>Имя</th><th>Тип</th><th>Точки восст.</th><th>Последний бэкап</th><th>Расписание</th><th>State</th></tr></thead><tbody>' + rows + '</tbody></table></div>';
const policies = inst.agent_policies || [];
if (policies.length) {
html += '<h4 style="margin:16px 0 8px;font-size:13px;color:var(--text-muted)">Агентские политики</h4>';
html += '<div class="table-wrap"><table><thead><tr><th>Имя</th><th>Тип</th><th>Расписание</th></tr></thead><tbody>';
for (const p of policies) {
const isDisabled = strIsFalse(p.schedule_enabled) || strIsStopped(p.state);
const scheduleEnabled = strIsFalse(p.schedule_enabled) ? false : true;
const stateStopped = strIsStopped(p.state);
const isDisabled = !scheduleEnabled || stateStopped;
let scheduleBadge = '';
if (!scheduleEnabled) {
scheduleBadge = '<span class="badge danger">расписание откл</span>';
} else if (stateStopped) {
scheduleBadge = '<span class="badge info">stopped</span>';
} else {
scheduleBadge = '<span class="badge success">включено</span>';
}
html += '<tr class="' + (isDisabled ? 'job-disabled' : '') + '">';
html += '<td>' + esc(p.name || p.Name || '—') + '</td>';
html += '<td>' + esc(p.type || p.jobType || '—') + '</td>';
html += '<td>' + (isDisabled ? '<span class="badge danger">выключена</span>' : '<span class="badge success">включена</span>') + '</td>';
html += '<td>' + scheduleBadge + '</td>';
html += '</tr>';
}
html += '</tbody></table></div>';