This commit is contained in:
1 parent
0cef0dd3a1
commit
f2e400c89e
6 files changed
+140
-31
No files matched your search
+69
-22
@@ -658,11 +658,24 @@ function createAutomationStatusSnapshot() {
|
||||
return freezeAutomationValue(snapshot);
|
||||
}
|
||||
|
||||
function automationErrorDetail(error) {
|
||||
const message = String(error?.message || error || 'Unbekannter Fehler');
|
||||
if (/(?:token|password|cookie|authorization|api[_-]?key|session)\s*[:=]/i.test(message)) return localizeUiText('Fehlerdetails enthalten geschützte Daten.');
|
||||
return _sanitizeFailureClipboardValue(message, 700);
|
||||
}
|
||||
|
||||
async function loadAutomationEvidenceSnapshot() {
|
||||
const readEvidence = async (label, read) => {
|
||||
try {
|
||||
return await read();
|
||||
} catch (error) {
|
||||
throw new Error(`${localizeUiText(label)}: ${automationErrorDetail(error)}`);
|
||||
}
|
||||
};
|
||||
const [history, uploadLog, automationCompletions] = await Promise.all([
|
||||
window.api.getHistory(),
|
||||
window.api.readOwnUploadLog(),
|
||||
typeof window.api.getAutomationCompletions === 'function' ? window.api.getAutomationCompletions() : Promise.resolve([])
|
||||
readEvidence('Verlauf konnte nicht gelesen werden', () => window.api.getHistory()),
|
||||
readEvidence('Upload-Log konnte nicht gelesen werden', () => window.api.readOwnUploadLog()),
|
||||
readEvidence('Abschlussnachweis konnte nicht gelesen werden', () => typeof window.api.getAutomationCompletions === 'function' ? window.api.getAutomationCompletions() : Promise.resolve([]))
|
||||
]);
|
||||
return { history, uploadLog, automationCompletions };
|
||||
}
|
||||
@@ -716,7 +729,7 @@ async function evaluateAutomationCandidates(files, options = {}) {
|
||||
uploadLogRows: uploadLog
|
||||
});
|
||||
const processedPaths = new Set(processed.processedPaths.map(normalizeAutomationPath));
|
||||
for (const path of processedPaths) reasons.set(path, 'processed');
|
||||
for (const path of processedPaths) reasons.set(path, processed.reasons[path] || 'processed');
|
||||
const unprocessed = matched.filter(candidate => !processedPaths.has(normalizeAutomationPath(candidate.path)));
|
||||
const inspection = await window.api.inspectImportFiles(
|
||||
unprocessed,
|
||||
@@ -750,7 +763,7 @@ async function evaluateAutomationCandidates(files, options = {}) {
|
||||
const completedHostersByPath = new Map(completionState.completedByPath.map(entry => [normalizeAutomationPath(entry.path), new Set(entry.hosters)]));
|
||||
for (const path of ledgerProcessedPaths) {
|
||||
processedPaths.add(path);
|
||||
reasons.set(path, 'processed');
|
||||
reasons.set(path, 'completion');
|
||||
}
|
||||
const plannedCandidates = initialPlannedCandidates
|
||||
.filter(candidate => !ledgerProcessedPaths.has(normalizeAutomationPath(candidate.path)))
|
||||
@@ -791,11 +804,16 @@ async function evaluateAutomationCandidates(files, options = {}) {
|
||||
name: candidate.name,
|
||||
reason: reasons.get(normalizeAutomationPath(candidate.path)) || 'unavailable'
|
||||
}));
|
||||
const skippedReasons = new Set(['filter-rejected', 'processed', 'inspection-duplicate', 'unavailable', 'size-limited']);
|
||||
const skippedReasons = new Set(['filter-rejected', 'processed', 'completion', 'history', 'upload-log', 'in-queue', 'inspection-duplicate', 'unavailable', 'size-limited']);
|
||||
const summary = {
|
||||
found: candidates.length,
|
||||
filterMatched: matched.length,
|
||||
alreadyProcessed: processed.processedPaths.length + inspectionDuplicatePaths.size + ledgerProcessedPaths.size,
|
||||
processedByCompletion: ledgerProcessedPaths.size,
|
||||
processedByHistory: classifications.filter(entry => entry.reason === 'history').length,
|
||||
processedByUploadLog: classifications.filter(entry => entry.reason === 'upload-log').length,
|
||||
inQueue: classifications.filter(entry => entry.reason === 'in-queue' || entry.reason === 'inspection-duplicate').length,
|
||||
filterRejected: classifications.filter(entry => entry.reason === 'filter-rejected').length,
|
||||
unavailable: unavailablePaths.size,
|
||||
sizeLimitedJobs,
|
||||
acceptedFiles: selectedHosters.length === 0 ? plannedCandidates.length : actionableCandidates.length,
|
||||
@@ -804,6 +822,7 @@ async function evaluateAutomationCandidates(files, options = {}) {
|
||||
availableSlots,
|
||||
deferredFiles: deferredFiles.length
|
||||
};
|
||||
if (options.dryRun !== true) window.api.debugLog(`automation-eval trigger=${String(options.trigger || 'watcher')} found=${summary.found} admitted=${admittedFiles.length} completion=${summary.processedByCompletion} history=${summary.processedByHistory} log=${summary.processedByUploadLog} queue=${summary.inQueue} filter=${summary.filterRejected} unavailable=${summary.unavailable} sizeLimitedJobs=${summary.sizeLimitedJobs} deferred=${summary.deferredFiles}`);
|
||||
return freezeAutomationValue({
|
||||
dryRun: options.dryRun === true,
|
||||
trigger: String(options.trigger || 'watcher'),
|
||||
@@ -941,13 +960,14 @@ async function applyAutomationEvaluation(evaluation) {
|
||||
const classifications = (evaluation.classifications || []).map(entry => dynamicPaths.has(normalizeAutomationPath(entry.path))
|
||||
? { ...entry, reason: dynamicReasons.get(normalizeAutomationPath(entry.path)) }
|
||||
: entry);
|
||||
const skippedReasons = new Set(['filter-rejected', 'processed', 'inspection-duplicate', 'unavailable', 'size-limited']);
|
||||
const skippedReasons = new Set(['filter-rejected', 'processed', 'completion', 'history', 'upload-log', 'in-queue', 'inspection-duplicate', 'unavailable', 'size-limited']);
|
||||
const telemetryDelta = {
|
||||
detected: classifications.length,
|
||||
queued: admittedFiles.length,
|
||||
skipped: classifications.filter(entry => skippedReasons.has(entry.reason)).length,
|
||||
deferred: deferredFiles.length,
|
||||
lastDetectedName: evaluation.telemetryDelta?.lastDetectedName || ''
|
||||
lastDetectedName: evaluation.telemetryDelta?.lastDetectedName || '',
|
||||
lastError: ''
|
||||
};
|
||||
if (admittedFiles.length === 0) {
|
||||
const telemetryResult = await persistAutomationTelemetry(telemetryDelta);
|
||||
@@ -1028,8 +1048,7 @@ async function applyAutomationEvaluation(evaluation) {
|
||||
async function runFolderMonitorTestScan() {
|
||||
const result = await window.api.folderMonitorTestScan();
|
||||
if (result?.error) {
|
||||
const knownErrors = ['Kein Ordnerpfad angegeben', 'Ordner nicht erreichbar', 'Ordnerscan fehlgeschlagen'];
|
||||
throw new Error(knownErrors.includes(result.error) ? result.error : 'Ordnerüberwachung konnte nicht getestet werden.');
|
||||
throw new Error(localizeUiText(result.error) + (result.errorCode ? ` (${result.errorCode})` : ''));
|
||||
}
|
||||
return evaluateAutomationCandidates(result?.files || [], { dryRun: true, trigger: result?.trigger || 'test' });
|
||||
}
|
||||
@@ -1047,6 +1066,11 @@ const automationTestMetricDefinitions = Object.freeze([
|
||||
Object.freeze(['found', 'Gefundene Dateien']),
|
||||
Object.freeze(['filterMatched', 'Passend zum Dateifilter']),
|
||||
Object.freeze(['alreadyProcessed', 'Bereits verarbeitet']),
|
||||
Object.freeze(['processedByCompletion', 'Bereits hochgeladen laut Abschlussnachweis']),
|
||||
Object.freeze(['processedByHistory', 'Bereits im Verlauf']),
|
||||
Object.freeze(['processedByUploadLog', 'Bereits im Upload-Log']),
|
||||
Object.freeze(['inQueue', 'Bereits in Warteschlange oder Auswahl']),
|
||||
Object.freeze(['filterRejected', 'Vom Dateifilter ausgeschlossen']),
|
||||
Object.freeze(['unavailable', 'Fehlend, leer oder nicht lesbar']),
|
||||
Object.freeze(['sizeLimitedJobs', 'Durch Größenlimits ausgeschlossen']),
|
||||
Object.freeze(['acceptedFiles', 'Akzeptierte Dateien']),
|
||||
@@ -1127,6 +1151,11 @@ function renderAutomationStatusSnapshot(snapshot) {
|
||||
const errorText = String(snapshot.error || telemetry.lastError || '');
|
||||
if (errorRow) errorRow.hidden = errorText.length === 0;
|
||||
setAutomationText('automationLastError', errorText ? localizeUiText(errorText) : '');
|
||||
const pauseNotice = document.getElementById('automationPauseNotice');
|
||||
if (pauseNotice) {
|
||||
pauseNotice.hidden = !snapshot.paused;
|
||||
pauseNotice.textContent = snapshot.paused ? `${localizeUiText('Automatik pausiert seit')} ${formatAutomationDateTime(snapshot.pausedAt)}. ${localizeUiText('Fortsetzen aktiviert die Ordnerüberwachung und die Warteschlange. Aktive Uploads werden beim Pausieren noch abgeschlossen.')}` : '';
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
@@ -1147,7 +1176,7 @@ function ensureAutomationPauseResumeButton() {
|
||||
function syncAutomationPauseResumeButton(snapshot) {
|
||||
const button = ensureAutomationPauseResumeButton();
|
||||
if (!button || !snapshot) return;
|
||||
const label = snapshot.paused === true ? 'Fortsetzen' : 'Abschließen und pausieren';
|
||||
const label = snapshot.paused === true ? 'Automatik fortsetzen' : 'Automatik pausieren';
|
||||
const localized = localizeUiText(label);
|
||||
const text = button.querySelector('.automation-pause-resume-label');
|
||||
if (text) text.textContent = localized;
|
||||
@@ -1155,6 +1184,12 @@ function syncAutomationPauseResumeButton(snapshot) {
|
||||
button.setAttribute('aria-label', localized);
|
||||
button.classList.toggle('automation-resume', snapshot.paused === true);
|
||||
button.disabled = automationPauseResumeBusy;
|
||||
const settingsButton = document.getElementById('automationSettingsPauseResumeBtn');
|
||||
if (settingsButton) {
|
||||
settingsButton.textContent = localized;
|
||||
settingsButton.disabled = automationPauseResumeBusy || snapshot.statusAvailable !== true;
|
||||
settingsButton.title = localizeUiText('Fortsetzen aktiviert die Ordnerüberwachung und die Warteschlange. Aktive Uploads werden beim Pausieren noch abgeschlossen.');
|
||||
}
|
||||
}
|
||||
|
||||
function syncAutomationContextStartControls(blocked) {
|
||||
@@ -1330,9 +1365,10 @@ async function runAutomationTestOverlay() {
|
||||
if (generation !== automationTestGeneration) return;
|
||||
renderAutomationTestViewState({ loading: false, summary: evaluation.summary, error: '' });
|
||||
} catch (error) {
|
||||
const detail = automationErrorDetail(error);
|
||||
window.api.debugLog(`automation-test failed: ${detail}`);
|
||||
if (generation !== automationTestGeneration) return;
|
||||
const knownErrors = ['Kein Ordnerpfad angegeben', 'Ordner nicht erreichbar', 'Ordnerscan fehlgeschlagen'];
|
||||
renderAutomationTestViewState({ loading: false, summary: null, error: knownErrors.includes(error?.message) ? error.message : 'Ordnerüberwachung konnte nicht getestet werden.' });
|
||||
renderAutomationTestViewState({ loading: false, summary: null, error: `${localizeUiText('Ordnerüberwachung konnte nicht getestet werden.')} ${localizeUiText(detail)}` });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1374,6 +1410,7 @@ async function toggleAutomationPauseResume() {
|
||||
lastUploadStats.state = 'stopping';
|
||||
updateStatusBar();
|
||||
}
|
||||
showCopyToast(localizeUiText('Automatik und Warteschlange pausiert. Fortsetzen ist unter Einstellungen → Automatik jederzeit möglich.'), 6500);
|
||||
}
|
||||
} catch {
|
||||
showCopyToast(localizeUiText(resume ? 'Automatik konnte nicht fortgesetzt werden.' : 'Automatik konnte nicht pausiert werden.'), 6000, 'error');
|
||||
@@ -1539,7 +1576,11 @@ async function init() {
|
||||
});
|
||||
|
||||
window.api.onFolderMonitorNewFiles(files => {
|
||||
handleFolderMonitorFiles(files).catch(error => window.api.debugLog(`folder-monitor renderer evaluation failed: ${error.message || String(error)}`));
|
||||
handleFolderMonitorFiles(files).catch(error => {
|
||||
const message = automationErrorDetail(error);
|
||||
window.api.debugLog(`folder-monitor renderer evaluation failed: ${message}`);
|
||||
persistAutomationTelemetry({ lastError: message }).then(refreshAutomationControlCenter);
|
||||
});
|
||||
});
|
||||
window.api.signalFolderMonitorReady();
|
||||
if (typeof window.api.onAutomationStatus === 'function') {
|
||||
@@ -6482,7 +6523,10 @@ function renderSettings() {
|
||||
${pageHeader('Automatik', 'Wiederholungen und überwachte Ordner für unbeaufsichtigte Uploads.')}
|
||||
<section class="automation-status-card" id="automationStatusCard" aria-live="polite">
|
||||
<div class="automation-status-header">
|
||||
<span class="automation-state-badge state-inactive" id="automationStateBadge">Inaktiv</span>
|
||||
<div class="automation-status-controls">
|
||||
<span class="automation-state-badge state-inactive" id="automationStateBadge">Inaktiv</span>
|
||||
<button class="btn btn-secondary" id="automationSettingsPauseResumeBtn" type="button">Automatik pausieren</button>
|
||||
</div>
|
||||
<div class="automation-queue-summary">
|
||||
<span class="automation-queue-label">Aktuelle Queue-Auslastung</span>
|
||||
<strong class="automation-status-value automation-queue-value" id="automationQueueMeter">0 / 15.000</strong>
|
||||
@@ -6491,14 +6535,16 @@ function renderSettings() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="automation-pause-notice" id="automationPauseNotice" hidden></p>
|
||||
<p class="hint">Die Tageszähler zählen Prüfungen und Aufnahmen. Wiederholte Abgleiche derselben Datei werden erneut gezählt.</p>
|
||||
<div class="automation-status-metrics">
|
||||
<div class="automation-status-metric"><span>Überwachung läuft seit</span><strong class="automation-status-value" id="automationMonitoringSince">Nie</strong></div>
|
||||
<div class="automation-status-metric"><span>Ordner erreichbar</span><strong class="automation-status-value" id="automationFolderReachable">—</strong></div>
|
||||
<div class="automation-status-metric"><span>Letzte erkannte Datei</span><strong class="automation-status-value" id="automationLastDetectedFile">Keine Datei erkannt</strong></div>
|
||||
<div class="automation-status-metric"><span>Heute erkannt</span><strong class="automation-status-value" id="automationDetectedToday">0</strong></div>
|
||||
<div class="automation-status-metric"><span>Dateiprüfungen heute</span><strong class="automation-status-value" id="automationDetectedToday">0</strong></div>
|
||||
<div class="automation-status-metric"><span>Heute eingereiht</span><strong class="automation-status-value" id="automationQueuedToday">0</strong></div>
|
||||
<div class="automation-status-metric"><span>Heute übersprungen</span><strong class="automation-status-value" id="automationSkippedToday">0</strong></div>
|
||||
<div class="automation-status-metric"><span>Wegen Queue-Limit zurückgestellt</span><strong class="automation-status-value" id="automationDeferredToday">0</strong></div>
|
||||
<div class="automation-status-metric"><span>Übersprungene Prüfungen heute</span><strong class="automation-status-value" id="automationSkippedToday">0</strong></div>
|
||||
<div class="automation-status-metric"><span>Zurückstellungen wegen Queue-Limit heute</span><strong class="automation-status-value" id="automationDeferredToday">0</strong></div>
|
||||
<div class="automation-status-metric"><span>Letzter Abgleich</span><strong class="automation-status-value" id="automationLastReconcile">Nie</strong></div>
|
||||
<div class="automation-status-metric"><span>Nächster Abgleich</span><strong class="automation-status-value" id="automationNextReconcile">Nie</strong></div>
|
||||
</div>
|
||||
@@ -6581,7 +6627,7 @@ function renderSettings() {
|
||||
<div class="settings-row checkbox-row folder-monitor-help-row">
|
||||
<label>Vorhandene Dateien einmalig einlesen</label>
|
||||
<input type="checkbox" class="settings-autosave" id="fmIncludeExistingInput" ${fm.includeExisting ? 'checked' : ''}>
|
||||
${folderMonitorHelp('existing', 'Fügt beim nächsten Start der Überwachung alle bereits vorhandenen passenden Dateien hinzu. Die Option wird danach automatisch deaktiviert.')}
|
||||
${folderMonitorHelp('existing', 'Bezieht beim Start bereits vorhandene Dateien ein. Bereits hochgeladene Dateien werden weiterhin übersprungen. Regelmäßige Abgleiche prüfen den gesamten Ordner erneut.')}
|
||||
</div>
|
||||
<div class="settings-row checkbox-row folder-monitor-help-row">
|
||||
<label>Duplikate überspringen</label>
|
||||
@@ -7108,6 +7154,7 @@ function renderSettings() {
|
||||
}
|
||||
});
|
||||
document.getElementById('automationTestBtn')?.addEventListener('click', runAutomationTestOverlay);
|
||||
document.getElementById('automationSettingsPauseResumeBtn')?.addEventListener('click', toggleAutomationPauseResume);
|
||||
ensureAutomationTestOverlay();
|
||||
refreshAutomationControlCenter();
|
||||
|
||||
@@ -7323,9 +7370,9 @@ function syncLanguagePicker(value) {
|
||||
}
|
||||
|
||||
async function chooseLogFilePath() {
|
||||
const folders = await window.api.selectFolder();
|
||||
if (!folders || !folders[0]) return;
|
||||
const normalized = folders[0].replace(/[\\\/]+$/, '');
|
||||
const folder = await window.api.folderMonitorSelectFolder();
|
||||
if (!folder) return;
|
||||
const normalized = folder.replace(/[\\\/]+$/, '');
|
||||
document.getElementById('logFilePathInput').value = `${normalized}\\fileuploader.log`;
|
||||
markSettingsDirty();
|
||||
}
|
||||
|
||||
@@ -266,6 +266,22 @@
|
||||
['Abgleichintervall', 'Reconciliation interval'],
|
||||
['Abschließen und pausieren', 'Finish and pause'],
|
||||
['Fortsetzen', 'Resume'],
|
||||
['Automatik fortsetzen', 'Resume automation'],
|
||||
['Automatik pausieren', 'Pause automation'],
|
||||
['Automatik pausiert seit', 'Automation paused since'],
|
||||
['Verlauf konnte nicht gelesen werden', 'History could not be read'],
|
||||
['Upload-Log konnte nicht gelesen werden', 'Upload log could not be read'],
|
||||
['Abschlussnachweis konnte nicht gelesen werden', 'Completion records could not be read'],
|
||||
['Fehlerdetails enthalten geschützte Daten.', 'Error details contain protected data.'],
|
||||
['Fortsetzen aktiviert die Ordnerüberwachung und die Warteschlange. Aktive Uploads werden beim Pausieren noch abgeschlossen.', 'Resuming enables folder monitoring and the queue. Active uploads are allowed to finish when pausing.'],
|
||||
['Automatik und Warteschlange pausiert. Fortsetzen ist unter Einstellungen → Automatik jederzeit möglich.', 'Automation and queue paused. Resume at any time under Settings → Automation.'],
|
||||
['Die Tageszähler zählen Prüfungen und Aufnahmen. Wiederholte Abgleiche derselben Datei werden erneut gezählt.', 'Daily counters count checks and admissions. Repeated checks of the same file are counted again.'],
|
||||
['Bereits hochgeladen laut Abschlussnachweis', 'Already uploaded according to completion records'],
|
||||
['Bereits im Verlauf', 'Already in history'],
|
||||
['Bereits im Upload-Log', 'Already in upload log'],
|
||||
['Bereits in Warteschlange oder Auswahl', 'Already queued or selected'],
|
||||
['Vom Dateifilter ausgeschlossen', 'Excluded by file filter'],
|
||||
['Bezieht beim Start bereits vorhandene Dateien ein. Bereits hochgeladene Dateien werden weiterhin übersprungen. Regelmäßige Abgleiche prüfen den gesamten Ordner erneut.', 'Includes existing files at startup. Already uploaded files are still skipped. Periodic reconciliation checks the entire folder again.'],
|
||||
['Pausiert', 'Paused'],
|
||||
['Queue-Limit erreicht', 'Queue limit reached'],
|
||||
['Ordner getrennt', 'Folder disconnected'],
|
||||
@@ -273,6 +289,9 @@
|
||||
['Ordner erreichbar', 'Folder reachable'],
|
||||
['Letzte erkannte Datei', 'Last detected file'],
|
||||
['Heute erkannt', 'Detected today'],
|
||||
['Dateiprüfungen heute', 'File checks today'],
|
||||
['Übersprungene Prüfungen heute', 'Skipped checks today'],
|
||||
['Zurückstellungen wegen Queue-Limit heute', 'Queue-limit deferrals today'],
|
||||
['Heute eingereiht', 'Queued today'],
|
||||
['Heute übersprungen', 'Skipped today'],
|
||||
['Wegen Queue-Limit zurückgestellt', 'Deferred by queue limit'],
|
||||
|
||||
@@ -1271,6 +1271,9 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; }
|
||||
box-shadow: 0 14px 32px rgba(0, 0, 0, .14);
|
||||
}
|
||||
.automation-status-card * { min-width: 0; }
|
||||
.automation-status-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
|
||||
.automation-status-controls .btn { white-space: normal; font-size: 12px; }
|
||||
.automation-pause-notice { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
|
||||
.automation-status-header {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(240px, 1fr);
|
||||
|
||||
Reference in new issue
Block a user