sync file-type support across upload/convert and fix collected_at timezone handling
This commit is contained in:
@@ -8,11 +8,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
initTabs();
|
||||
initFilters();
|
||||
loadParsersInfo();
|
||||
loadSupportedFileTypes();
|
||||
});
|
||||
|
||||
let sourceType = 'archive';
|
||||
let convertFiles = [];
|
||||
let isConvertRunning = false;
|
||||
let supportedUploadExtensions = null;
|
||||
let supportedConvertExtensions = null;
|
||||
let apiConnectPayload = null;
|
||||
let collectionJob = null;
|
||||
let collectionJobPollTimer = null;
|
||||
@@ -642,8 +645,9 @@ function renderConvertSummary() {
|
||||
return;
|
||||
}
|
||||
|
||||
const supportedFiles = convertFiles.filter(file => isSupportedConvertFileName(file.webkitRelativePath || file.name));
|
||||
const skippedCount = convertFiles.length - supportedFiles.length;
|
||||
const selectedFiles = convertFiles.filter(file => file && file.name);
|
||||
const supportedFiles = selectedFiles.filter(file => isSupportedConvertFileName(file.webkitRelativePath || file.name));
|
||||
const skippedCount = selectedFiles.length - supportedFiles.length;
|
||||
const previewCount = 5;
|
||||
const previewFiles = supportedFiles.slice(0, previewCount).map(file => escapeHtml(file.webkitRelativePath || file.name));
|
||||
const remaining = supportedFiles.length - previewFiles.length;
|
||||
@@ -664,7 +668,8 @@ async function runConvertBatch() {
|
||||
return;
|
||||
}
|
||||
|
||||
const supportedFiles = convertFiles.filter(file => isSupportedConvertFileName(file.webkitRelativePath || file.name));
|
||||
const selectedFiles = convertFiles.filter(file => file && file.name);
|
||||
const supportedFiles = selectedFiles.filter(file => isSupportedConvertFileName(file.webkitRelativePath || file.name));
|
||||
if (supportedFiles.length === 0) {
|
||||
renderConvertStatus('В выбранной папке нет файлов поддерживаемого типа', 'error');
|
||||
return;
|
||||
@@ -835,15 +840,42 @@ function isSupportedConvertFileName(filename) {
|
||||
if (!name) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
name.endsWith('.zip') ||
|
||||
name.endsWith('.tar') ||
|
||||
name.endsWith('.tar.gz') ||
|
||||
name.endsWith('.tgz') ||
|
||||
name.endsWith('.json') ||
|
||||
name.endsWith('.txt') ||
|
||||
name.endsWith('.log')
|
||||
);
|
||||
if (Array.isArray(supportedConvertExtensions) && supportedConvertExtensions.length > 0) {
|
||||
return supportedConvertExtensions.some(ext => name.endsWith(ext));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function loadSupportedFileTypes() {
|
||||
try {
|
||||
const response = await fetch('/api/file-types');
|
||||
const payload = await response.json();
|
||||
if (!response.ok) {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(payload.upload_extensions)) {
|
||||
supportedUploadExtensions = payload.upload_extensions
|
||||
.map(ext => String(ext || '').trim().toLowerCase())
|
||||
.filter(Boolean);
|
||||
}
|
||||
if (Array.isArray(payload.convert_extensions)) {
|
||||
supportedConvertExtensions = payload.convert_extensions
|
||||
.map(ext => String(ext || '').trim().toLowerCase())
|
||||
.filter(Boolean);
|
||||
}
|
||||
applyUploadAcceptExtensions();
|
||||
renderConvertSummary();
|
||||
} catch (err) {
|
||||
// Keep permissive fallback if endpoint is temporarily unavailable.
|
||||
}
|
||||
}
|
||||
|
||||
function applyUploadAcceptExtensions() {
|
||||
const fileInput = document.getElementById('file-input');
|
||||
if (!fileInput || !Array.isArray(supportedUploadExtensions) || supportedUploadExtensions.length === 0) {
|
||||
return;
|
||||
}
|
||||
fileInput.setAttribute('accept', supportedUploadExtensions.join(','));
|
||||
}
|
||||
|
||||
function renderConvertStatus(message, status) {
|
||||
|
||||
Reference in New Issue
Block a user