- копирую модуль upload/ из drhider (слои 1-2) - blueprint: параметр sink (drhider-сессия по умолчанию, сверка — DB+парсинг) - upload_bp: contracts_upload_sink = _store_and_parse - routes: регистрирую create_upload_refs_blueprint(cfg, sink=...) - app.py: корень репо в sys.path (для import upload) - History: план переиспользования + ревью Соннета
30 lines
1.9 KiB
JavaScript
30 lines
1.9 KiB
JavaScript
// render — рендер таблицы выбора файлов (обычная).
|
|
// Если идёт обработка (state.proc.phase === 'processing') — 3-секционная.
|
|
|
|
import { esc } from './esc.js';
|
|
import { fs } from './fs.js';
|
|
import { fmtSec } from './fmt_sec.js';
|
|
import { estForFile } from './est_for_file.js';
|
|
import { renderProcTable } from './render_proc_table.js';
|
|
|
|
export function render(state, els, cfg) {
|
|
if (state.proc && state.proc.phase === 'processing') { renderProcTable(state, els, cfg); return; }
|
|
if (state.files.length === 0) {
|
|
els.tableBody.innerHTML = '<tr class="empty-row"><td colspan="4">Нет выбранных файлов</td></tr>';
|
|
} else {
|
|
els.tableBody.innerHTML = state.files.map((f, i) => {
|
|
const over = state.overNames.has(f.name);
|
|
const rowCls = over ? ' class="row-over"' : '';
|
|
const stTxt = over ? '<span style="color:#c0392b;">🔥 не учитывается</span>'
|
|
: '<span style="color:#7d3c98;">~' + fmtSec(estForFile(f, cfg.estMbSec)) + '</span>';
|
|
return '<tr id="row-' + i + '"' + rowCls + '><td class="name-cell">' + esc(f.name) + '</td><td class="num-cell">' + fs(f.size) + '</td><td class="num-cell" id="st-' + i + '" style="font-size:12px;">' + stTxt + '</td><td><button class="remove-btn" data-idx="' + i + '">✕</button></td></tr>';
|
|
}).join('');
|
|
}
|
|
const overCount = state.files.filter(f => state.overNames.has(f.name)).length;
|
|
const totalSize = state.files.reduce((s, f) => s + (state.overNames.has(f.name) ? 0 : f.size), 0);
|
|
const cntMain = state.files.length - overCount;
|
|
const totEst = state.files.reduce((s, f) => s + (state.overNames.has(f.name) ? 0 : estForFile(f, cfg.estMbSec)), 0);
|
|
els.countEl.textContent = (overCount ? cntMain + ' учитываются + ' + overCount + ' свыше лимита' : state.files.length) + ' файлов · ' + fs(totalSize) + ' · ~' + fmtSec(totEst);
|
|
els.uploadBtnEl.disabled = cntMain === 0;
|
|
}
|