v1.0.76: фикс uppercase ключей Lucee, заголовки столбцов, красная корзина, Инфо+, столбец Текст с 2-панельной модалкой

This commit is contained in:
2026-06-21 07:21:45 +04:00
parent fa843bc367
commit e049d28515
2 changed files with 167 additions and 56 deletions
+93 -8
View File
@@ -34,14 +34,15 @@
.status-err { color: var(--destructive); }
.summary-row td { background: rgba(34,197,94,.05); font-weight: 600; }
.empty-row td { color: var(--muted); text-align: center; padding: 24px; }
.remove-btn { cursor: pointer; color: var(--muted); background: none; border: none; padding: 2px 4px; font-size: 16px; line-height: 1; }
.remove-btn:hover { color: var(--destructive); }
.remove-btn { cursor: pointer; color: #f87171; background: none; border: none; padding: 2px 4px; font-size: 16px; line-height: 1; }
.remove-btn:hover { color: #ef4444; }
.info-btn { cursor: pointer; color: var(--muted); background: none; border: none; padding: 2px 4px; font-size: 14px; display: none; }
.info-btn:hover { color: var(--brand-primary); }
.info-btn.visible { display: inline; }
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.4); z-index: 100; justify-content: center; align-items: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--background); border-radius: 12px; border: 1px solid var(--brand-gray); box-shadow: 0 4px 24px rgba(0,0,0,.15); max-width: 520px; width: 90%; max-height: 80vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 900px; }
.modal-header { padding: 14px 16px; border-bottom: 1px solid var(--brand-gray); display: flex; align-items: center; gap: 8px; font-weight: 600; flex-shrink: 0; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-body .kv { display: flex; margin-bottom: 6px; font-size: 13px; }
@@ -56,12 +57,21 @@
.diff-field-new { color: var(--green); font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
.text-panes { display: flex; gap: 0; }
.text-pane { flex: 1; min-width: 0; overflow-y: auto; max-height: 65vh; }
.text-pane:first-child { border-right: 1px solid var(--brand-gray); padding-right: 12px; }
.text-pane:last-child { padding-left: 12px; }
.text-pane pre { background: var(--brand-grey-light); padding: 10px; border-radius: 6px; font-size: 11px; white-space: pre-wrap; margin: 0; }
.text-pane table { font-size: 11px; width: 100%; }
.text-pane th { font-size: 10px; padding: 4px 6px; }
.text-pane td { padding: 3px 6px; font-size: 11px; }
.text-pane .pane-title { font-weight: 600; font-size: 12px; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; }
</style>
</head>
<body>
<div class="topbar">
<img src="/nubes-logo.svg" alt="Nubes">
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.75 — Lucee</span></span>
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.76 — Lucee</span></span>
</div>
<div class="content">
@@ -76,7 +86,7 @@
<div class="table-wrap">
<table>
<thead>
<tr><th>Имя</th><th style="width:130px;">Изменён</th><th style="width:90px;">Размер</th><th style="width:115px;">Статус</th><th style="width:30px;">Базовый</th><th style="width:30px;">View</th><th style="width:30px;"></th><th style="width:30px;"></th></tr>
<tr><th>Имя</th><th style="width:130px;">Изменён</th><th style="width:90px;">Размер</th><th style="width:115px;">Парсинг</th><th style="width:30px;">Базовый</th><th style="width:30px;">View</th><th style="width:30px;">Текст</th><th style="width:30px;">Инфо</th><th style="width:30px;">✕</th></tr>
</thead>
<tbody id="fileTable"></tbody>
</table>
@@ -183,6 +193,7 @@ function renderTable() {
'<td class="status-cell">' + (f.status || '') + '</td>' +
'<td style="text-align:center;">' + radio + '</td>' +
'<td><button class="info-btn' + (f.doc_id ? ' visible' : '') + '" onclick="showView(\'' + (f.doc_id||'') + '\')" title="Просмотр"><i data-lucide="eye" style="width:16px;height:16px;"></i></button></td>' +
'<td><button class="info-btn' + (f.doc_id ? ' visible' : '') + '" onclick="showText(\'' + (f.doc_id||'') + '\')" title="Текст / Распарсено"><i data-lucide="file-text" style="width:16px;height:16px;"></i></button></td>' +
'<td><button class="info-btn' + (f.doc_id ? ' visible' : '') + '" id="info_' + i + '" onclick="showInfo(' + i + ')" title="Инфо"><i data-lucide="info" style="width:16px;height:16px;"></i></button></td>' +
'<td><button class="remove-btn" onclick="removeFile(' + i + ')" title="Удалить"><i data-lucide="trash-2" style="width:16px;height:16px;"></i></button></td>' +
'</tr>';
@@ -568,29 +579,48 @@ function showInfo(i) {
document.getElementById('modalTitle').textContent = f.name;
var html = '<div class="kv"><span class="k">Размер</span><span class="v">' + formatSize(f.size) + '</span></div>';
html += '<div class="kv"><span class="k">Изменён</span><span class="v">' + formatDate(f.lastModified) + '</span></div>';
html += '<div class="kv"><span class="k">Тип</span><span class="v">' + (f.type || '—') + '</span></div>';
if (f.parseInfo) {
var d = f.parseInfo;
html += '<div class="kv"><span class="k">Элементов</span><span class="v">' + (d.ELEMENT_COUNT||0) + '</span></div>';
html += '<div class="kv"><span class="k">Параграфов</span><span class="v">' + (d.PARAGRAPHS||0) + '</span></div>';
html += '<div class="kv"><span class="k">Таблиц</span><span class="v">' + (d.TABLES||0) + '</span></div>';
html += '<div class="kv"><span class="k">Строк таблиц</span><span class="v">' + (d.TABLE_ROWS||0) + '</span></div>';
html += '<div class="kv"><span class="k">Страниц</span><span class="v">' + (d.PAGES||'—') + '</span></div>';
if (d.PARSE_TIME_MS) {
html += '<div class="kv"><span class="k">Время парсинга</span><span class="v">' + (d.PARSE_TIME_MS > 1000 ? (d.PARSE_TIME_MS/1000).toFixed(1) + ' с' : d.PARSE_TIME_MS + ' мс') + '</span></div>';
}
if (d.TEXT_LENGTH) {
html += '<div class="kv"><span class="k">Символов текста</span><span class="v">' + d.TEXT_LENGTH.toLocaleString() + '</span></div>';
}
if (d.TEXT_PREVIEW) {
html += '<div style="margin-top:10px;font-weight:600;font-size:13px;">Превью текста:</div>';
html += '<pre>' + d.TEXT_PREVIEW + '</pre>';
html += '<div style="margin-top:10px;font-weight:600;font-size:13px;">Превью текста (первые 3000 симв.):</div>';
html += '<pre style="max-height:200px;overflow-y:auto;">' + d.TEXT_PREVIEW.substring(0, 3000) + '</pre>';
}
if (d.TABLE_HEADERS && d.TABLE_HEADERS.length > 0) {
html += '<div style="margin-top:10px;font-weight:600;font-size:13px;">Первые строки таблиц:</div>';
html += '<div style="margin-top:10px;font-weight:600;font-size:13px;">Заголовки таблиц:</div>';
d.TABLE_HEADERS.forEach(function(hdr, ti) {
html += '<div style="margin-top:4px;font-size:11px;color:var(--muted);">Таблица ' + (ti+1) + ':</div>';
html += '<div style="margin-top:4px;font-size:11px;color:var(--muted);">Таблица ' + (ti+1) + ' (' + (hdr||[]).length + ' колонок):</div>';
html += '<pre>' + (hdr||[]).map(function(c){return c||'(пусто)';}).join(' | ') + '</pre>';
});
}
if (d.TABLE_SAMPLES && d.TABLE_SAMPLES.length > 0) {
html += '<div style="margin-top:10px;font-weight:600;font-size:13px;">Первые строки таблиц:</div>';
d.TABLE_SAMPLES.forEach(function(sample, ti) {
html += '<div style="margin-top:4px;font-size:11px;color:var(--muted);">Таблица ' + (ti+1) + ':</div>';
html += '<pre style="max-height:120px;overflow-y:auto;">' + sample.map(function(row){ return (row||[]).map(function(c){return c||'(пусто)';}).join(' | '); }).join('\n') + '</pre>';
});
}
if (d.ERRORS && d.ERRORS.length > 0) {
html += '<div style="margin-top:8px;color:var(--destructive);font-weight:600;">Ошибки:</div>';
html += '<pre>' + d.ERRORS.join('\n') + '</pre>';
}
}
html += '<div class="kv"><span class="k">doc_id</span><span class="v">' + (f.doc_id || '—') + '</span></div>';
if (f.supp_id) {
html += '<div class="kv"><span class="k">supp_id</span><span class="v">' + f.supp_id + '</span></div>';
html += '<div class="kv"><span class="k">Тип ДС</span><span class="v">' + (f.supp_type || '—') + '</span></div>';
}
document.getElementById('modalBody').innerHTML = html;
document.getElementById('modalOverlay').classList.add('open');
}
@@ -612,9 +642,64 @@ async function showView(docId) {
}
}
async function showText(docId) {
document.getElementById('modalTitle').textContent = 'Текст / Распарсено';
document.getElementById('modalBody').innerHTML = '<span style="color:var(--muted);">Загрузка...</span>';
var modal = document.querySelector('.modal');
modal.classList.add('wide');
document.getElementById('modalOverlay').classList.add('open');
try {
var resp = await fetch('/view.cfm?doc_id=' + docId);
var rawText = await resp.text();
// Clean leading whitespace from CFML
rawText = rawText.replace(/^\s+/, '');
// Fetch parsed elements via API
var qResp = await fetch('/api.cfm?action=query&sql=SELECT%20elements_json%20FROM%20documents%20WHERE%20id%3D\'' + docId + '\'');
var qData = await qResp.json();
var parsedHtml = '<span style="color:var(--muted);">Нет данных парсинга</span>';
if (qData.OK && qData.ROWS && qData.ROWS.length > 0) {
var ej = qData.ROWS[0].ELEMENTS_JSON;
if (typeof ej === 'object' && ej.Value) ej = ej.Value;
var elements = JSON.parse(ej);
if (elements.length > 0) {
var rows = '';
elements.forEach(function(el, idx) {
var etype = el.type || el.TYPE || '?';
var style = el.style || el.STYLE || '';
var content = '';
if (etype === 'paragraph') {
content = (el.text || el.TEXT || '').substring(0, 200);
} else if (etype === 'table') {
var tblRows = el.rows || el.ROWS || [];
content = tblRows.length + '×' + (tblRows[0] ? tblRows[0].length : 0) + ' ячеек';
}
rows += '<tr><td>' + (idx+1) + '</td><td>' + etype + '</td><td>' + style + '</td><td style="max-width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + (content||'').replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</td></tr>';
});
parsedHtml = '<div class="table-wrap"><table><thead><tr><th>№</th><th>Тип</th><th>Стиль</th><th>Содержание</th></tr></thead><tbody>' + rows + '</tbody></table></div>';
}
}
var html = '<div class="text-panes">' +
'<div class="text-pane"><div class="pane-title">Сырой текст</div><pre>' + rawText.replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</pre></div>' +
'<div class="text-pane"><div class="pane-title">Распарсено</div>' + parsedHtml + '</div>' +
'</div>';
document.getElementById('modalBody').innerHTML = html;
} catch(e) {
document.getElementById('modalBody').innerHTML = '<span style="color:var(--destructive);">Ошибка загрузки</span>';
}
}
// closeModal — сбросить wide при закрытии
var origCloseModal = closeModal;
closeModal = function(e) {
if (e && e.target !== document.getElementById('modalOverlay')) return;
document.querySelector('.modal').classList.remove('wide');
document.getElementById('modalOverlay').classList.remove('open');
};
window.showInfo = showInfo;
window.closeModal = closeModal;
window.showView = showView;
window.showText = showText;
// ── Промпт ───────────────────────────────────────────────────
var promptEditor = document.getElementById('promptEditor');