/** * K-hub «Мультисервер»: manual conflict resolution (orchestrator vs farm hub). */ (function (global) { const API = "/api/v1/sync/conflicts"; function escapeHtml(value) { return String(value) .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """); } function renderList(root, items, enterpriseId) { if (!items.length) { root.innerHTML = '
Нет конфликтов синхронизации.
'; return; } root.innerHTML = '| Таблица | Запись | Ферма | |
|---|---|---|---|
| ${escapeHtml(c.table_name)} | ` + `${escapeHtml(c.record_id)} | ` + `${escapeHtml(c.farm_hub_id || "—")} | ` + `` + " |
${escapeHtml(JSON.stringify(detail.orchestrator_snapshot, null, 2))}${escapeHtml(JSON.stringify(detail.hub_snapshot, null, 2))}Загрузка конфликтов…
'; fetch(`${API}?enterprise_id=${encodeURIComponent(enterpriseId)}`) .then((r) => r.json()) .then((items) => renderList(root, items || [], enterpriseId)) .catch(() => { root.innerHTML = 'Не удалось загрузить конфликты.
'; }); } global.WespMultiserverPanel = { mount(rootEl, enterpriseId) { if (!rootEl) return; load(rootEl, enterpriseId || ""); }, pendingCount(enterpriseId) { return fetch(`${API}?enterprise_id=${encodeURIComponent(enterpriseId)}`) .then((r) => r.json()) .then((items) => (Array.isArray(items) ? items.length : 0)) .catch(() => 0); }, }; })(window);