feat: hoster preset in folder monitor + badge color fix
- Hoster pre-selection in Ordnerüberwachung settings (only configured accounts shown) - With preset hosters: files go directly to queue without modal - Without preset: hoster modal opens as before - Fix: Aktiv badge now green on initial render Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
02f208c302
commit
22a378d36c
@ -49,7 +49,8 @@ const DEFAULTS = {
|
||||
extensions: '', // comma-separated: 'mp4,mkv,avi'
|
||||
skipDuplicates: true,
|
||||
delaySec: 3,
|
||||
autoStart: true
|
||||
autoStart: true,
|
||||
hosters: [] // pre-selected hosters, empty = ask via modal
|
||||
}
|
||||
},
|
||||
history: []
|
||||
|
||||
@ -80,9 +80,11 @@ async function init() {
|
||||
window.api.onFolderMonitorNewFiles((files) => {
|
||||
window.api.debugLog('folder-monitor: received ' + files.length + ' file(s)');
|
||||
const fm = config.globalSettings && config.globalSettings.folderMonitor;
|
||||
const hosters = getSelectedHosters();
|
||||
if (hosters.length > 0 && fm && fm.autoStart) {
|
||||
// Add files directly to queue and start upload
|
||||
const fmHosters = fm && Array.isArray(fm.hosters) && fm.hosters.length > 0 ? fm.hosters : [];
|
||||
|
||||
if (fmHosters.length > 0) {
|
||||
// Pre-selected hosters: set them as active selection and add directly to queue
|
||||
selectedUploadHosters = fmHosters.slice();
|
||||
const newFiles = [];
|
||||
for (const p of files) {
|
||||
if (!selectedFiles.find(f => f.path === p) && !_pendingFiles.find(f => f.path === p)) {
|
||||
@ -94,9 +96,10 @@ async function init() {
|
||||
selectedFiles.push(...newFiles);
|
||||
buildQueuePreview();
|
||||
updateUploadView();
|
||||
if (!uploading && !healthCheckRunning) startUpload();
|
||||
if (fm.autoStart && !uploading && !healthCheckRunning) startUpload();
|
||||
}
|
||||
} else {
|
||||
// No pre-selected hosters: open modal
|
||||
addPathsToQueue(files);
|
||||
}
|
||||
});
|
||||
@ -1784,7 +1787,7 @@ function renderSettings() {
|
||||
<div class="hoster-panel-header" data-hoster="folderMonitor">
|
||||
<span class="panel-arrow">▶</span>
|
||||
<span class="panel-title">Ordnerüberwachung</span>
|
||||
<span class="panel-status" id="folderMonitorStatusBadge">${fm.enabled && fm.folderPath ? 'Aktiv' : 'Inaktiv'}</span>
|
||||
<span class="panel-status${fm.enabled && fm.folderPath ? ' active' : ''}" id="folderMonitorStatusBadge">${fm.enabled && fm.folderPath ? 'Aktiv' : 'Inaktiv'}</span>
|
||||
</div>
|
||||
<div class="hoster-panel-body" data-panel="folderMonitor" style="display:none">
|
||||
<div class="settings-section-label">Ordner</div>
|
||||
@ -1825,6 +1828,15 @@ function renderSettings() {
|
||||
<input type="checkbox" class="settings-autosave" id="fmAutoStartInput" ${fm.autoStart !== false ? 'checked' : ''}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-section-label">Hoster-Vorauswahl</div>
|
||||
<div class="settings-grid-mini">
|
||||
${configuredAccounts.map(({ name }) => `
|
||||
<div class="settings-row checkbox-row">
|
||||
<label>${escapeHtml(name)}</label>
|
||||
<input type="checkbox" class="settings-autosave fm-hoster-checkbox" data-fm-hoster="${name}" ${(fm.hosters || []).includes(name) ? 'checked' : ''}>
|
||||
</div>`).join('')}
|
||||
</div>
|
||||
${configuredAccounts.length === 0 ? '<p class="hint" style="margin:0">Erst Accounts anlegen, dann hier auswählen.</p>' : '<p class="hint" style="margin:2px 0 0">Keine Auswahl = Hoster-Modal bei jeder Datei.</p>'}
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(folderMonitorPanel);
|
||||
@ -2023,7 +2035,8 @@ async function saveSettings(options = {}) {
|
||||
extensions: (document.getElementById('fmExtensionsInput')?.value || '').trim(),
|
||||
skipDuplicates: !!document.getElementById('fmSkipDuplicatesInput')?.checked,
|
||||
delaySec: Math.max(1, parseInt(document.getElementById('fmDelaySecInput')?.value || '3', 10) || 3),
|
||||
autoStart: !!document.getElementById('fmAutoStartInput')?.checked
|
||||
autoStart: !!document.getElementById('fmAutoStartInput')?.checked,
|
||||
hosters: Array.from(document.querySelectorAll('.fm-hoster-checkbox:checked')).map(el => el.dataset.fmHoster)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user