Separaten Output-Ordner für INVRPT → VDA 4913 Konvertierungen hinzufügen

Der eingehende Watcher nutzt denselben Input-Ordner für alle Dateitypen,
schreibt INVRPT-Konvertierungen nun aber in einen konfigurierbaren
separaten Output-Ordner. Bleibt das Feld leer, wird der Standard-
Output-Ordner als Fallback verwendet (abwärtskompatibel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
zed
2026-03-13 12:22:45 +01:00
parent 5ebcad02ed
commit 67bd64b688
4 changed files with 43 additions and 9 deletions

View File

@@ -88,9 +88,11 @@ class App {
// Disable folder buttons
const btnIn = document.getElementById('btnSelectInput');
const btnOut = document.getElementById('btnSelectOutput');
const btnInvrptOut = document.getElementById('btnSelectInvrptOutput');
const btnStart = document.getElementById('btnStartWatcher');
if (btnIn) btnIn.disabled = true;
if (btnOut) btnOut.disabled = true;
if (btnInvrptOut) btnInvrptOut.disabled = true;
if (btnStart) btnStart.disabled = true;
} else {
// Load saved settings
@@ -101,6 +103,9 @@ class App {
if (settings.outputDir) {
document.getElementById('outputDirPath').value = settings.outputDir;
}
if (settings.invrptOutputDir) {
document.getElementById('invrptOutputPath').value = settings.invrptOutputDir;
}
});
}
}
@@ -1195,18 +1200,28 @@ class App {
}
}
async selectInvrptOutputFolder() {
if (!this.watcher) return;
const folder = await this.watcher.selectFolder();
if (folder) {
document.getElementById('invrptOutputPath').value = folder;
this.watcher.saveSettings({ invrptOutputDir: folder });
}
}
// ─── Settings: Watcher Controls ──────────────────────────────────
async startWatcher() {
if (!this.watcher) return;
const inputDir = document.getElementById('inputDirPath').value;
const outputDir = document.getElementById('outputDirPath').value;
const invrptOutputDir = document.getElementById('invrptOutputPath').value;
if (!inputDir || !outputDir) {
alert('Bitte beide Ordner (Input & Output) angeben.');
return;
}
const result = await this.watcher.start(inputDir, outputDir);
const result = await this.watcher.start(inputDir, outputDir, invrptOutputDir);
if (result.error) {
alert('Watcher-Fehler: ' + result.error);
}

View File

@@ -40,7 +40,7 @@ class WatcherBridge {
}
async _processDetectedFile(data) {
const { filePath, fileName, content, outputDir } = data;
const { filePath, fileName, content, outputDir, invrptOutputDir } = data;
this._addLog('info', fileName, 'Datei erkannt, starte Konvertierung...');
let konvertierungsmodus = 'Unbekannt';
@@ -71,7 +71,9 @@ class WatcherBridge {
const baseName = fileName.replace(/\.[^.]+$/, '');
const outExt = result.format === 'vda' ? '.vda' : (result.format === 'xml' ? '.xml' : '.edi');
outFileName = baseName + '_converted' + outExt;
const outPath = outputDir + '\\' + outFileName;
const isInvrpt = result.type && result.type.includes('INVRPT');
const effectiveOutputDir = (isInvrpt && invrptOutputDir) ? invrptOutputDir : outputDir;
const outPath = effectiveOutputDir + '\\' + outFileName;
// Write converted file
const writeResult = await window.electronAPI.writeFile(outPath, result.output);
@@ -275,11 +277,11 @@ class WatcherBridge {
if (this.onLogEntry) this.onLogEntry(entry);
}
async start(inputDir, outputDir) {
async start(inputDir, outputDir, invrptOutputDir) {
if (!window.electronAPI) {
return { error: 'Electron API nicht verfügbar. App läuft im Browser-Modus.' };
}
const result = await window.electronAPI.startWatcher({ inputDir, outputDir });
const result = await window.electronAPI.startWatcher({ inputDir, outputDir, invrptOutputDir });
if (result.success) {
this.status = 'running';
this._addLog('info', '', `Watcher gestartet. Überwache: ${inputDir}`);