feat: improve uploader UI and persist queue

This commit is contained in:
Administrator 2026-03-10 22:19:42 +01:00
parent d7ddeda341
commit b4f4370041
8 changed files with 825 additions and 165 deletions

View File

@ -26,6 +26,9 @@ const DEFAULTS = {
globalSettings: { globalSettings: {
alwaysOnTop: false, alwaysOnTop: false,
shutdownAfterFinish: 'nothing', // nothing | sleep | shutdown | restart shutdownAfterFinish: 'nothing', // nothing | sleep | shutdown | restart
logFilePath: '',
resumeQueueOnLaunch: true,
pendingQueue: null,
scramble: { scramble: {
active: false, active: false,
prefix: '', prefix: '',

View File

@ -41,7 +41,7 @@ const HOSTER_CONFIGS = {
}, },
'voe.sx': { 'voe.sx': {
apiBase: 'https://voe.sx', apiBase: 'https://voe.sx',
serverEndpoints: ['/api/upload/server'], serverEndpoints: ['/api/upload/server', '/api/v1/upload/server'],
buildUploadUrl: (url, key) => appendKeyParam(url, key), buildUploadUrl: (url, key) => appendKeyParam(url, key),
formFields: () => ({}), formFields: () => ({}),
parseResult: parseVoeResult parseResult: parseVoeResult
@ -176,9 +176,15 @@ function parseDoodstreamResult(payload) {
// VOE: { file: { file_code } } // VOE: { file: { file_code } }
function parseVoeResult(payload) { function parseVoeResult(payload) {
const file_code = (payload.file && typeof payload.file === 'object') const source = payload && typeof payload === 'object' && payload.result && typeof payload.result === 'object'
? payload.file.file_code ? payload.result
: null; : payload;
const file = source && typeof source.file === 'object' ? source.file : null;
const file_code = file?.file_code
|| file?.filecode
|| source?.file_code
|| source?.filecode
|| null;
return { return {
download_url: file_code ? `https://voe.sx/${file_code}` : null, download_url: file_code ? `https://voe.sx/${file_code}` : null,
@ -353,26 +359,64 @@ async function uploadFile(hosterName, filePath, apiKey, onProgress, signal, thro
const { iterable, boundary, totalSize } = createUploadBody(filePath, formFields, onProgress, throttle, signal); const { iterable, boundary, totalSize } = createUploadBody(filePath, formFields, onProgress, throttle, signal);
const { body, statusCode } = await request(targetUrl, { const { body, statusCode, headers } = await request(targetUrl, {
method: 'POST', method: 'POST',
body: iterable, body: iterable,
signal, signal,
headers: { headers: {
'Content-Type': `multipart/form-data; boundary=${boundary}`, 'Content-Type': `multipart/form-data; boundary=${boundary}`,
'Content-Length': String(totalSize) 'Content-Length': String(totalSize),
'Accept': 'application/json, text/plain;q=0.9, */*;q=0.8',
'User-Agent': 'multi-hoster-uploader/1.1'
}, },
headersTimeout: UPLOAD_TIMEOUT, headersTimeout: UPLOAD_TIMEOUT,
bodyTimeout: UPLOAD_TIMEOUT bodyTimeout: UPLOAD_TIMEOUT
}); });
const payload = await body.json(); const rawBody = await body.text();
let payload = null;
try {
payload = rawBody ? JSON.parse(rawBody) : {};
} catch {
const snippet = rawBody ? rawBody.slice(0, 240).replace(/\s+/g, ' ').trim() : '';
throw new Error(
`Upload-Antwort von ${hosterName} war kein JSON (HTTP ${statusCode}${snippet ? `): ${snippet}` : ')'}`
);
}
if (statusCode < 200 || statusCode >= 300) {
throw new Error(
payload.msg
|| payload.message
|| `Upload fehlgeschlagen (HTTP ${statusCode}${headers?.['content-type'] ? `, ${headers['content-type']}` : ''})`
);
}
if (payload.status && [401, 403, 429, 500].includes(payload.status)) { if (payload.status && [401, 403, 429, 500].includes(payload.status)) {
throw new Error(payload.msg || payload.message || JSON.stringify(payload)); throw new Error(payload.msg || payload.message || JSON.stringify(payload));
} }
// Step 3: Parse result const result = config.parseResult(payload);
return config.parseResult(payload); if (result?.file_code || result?.download_url || result?.embed_url) {
return result;
} }
module.exports = { uploadFile, HOSTER_CONFIGS }; if (payload.success === false) {
throw new Error(payload.msg || payload.message || `Upload zu ${hosterName} wurde vom Server abgelehnt.`);
}
throw new Error(
payload.msg
|| payload.message
|| `Upload zu ${hosterName} lieferte keine verwendbaren Dateidaten zurueck.`
);
}
module.exports = {
uploadFile,
HOSTER_CONFIGS,
__test: {
extractUploadServerUrl,
parseVoeResult
}
};

77
main.js
View File

@ -58,24 +58,64 @@ function normalizeApiError(payload, fallback) {
return fallback; return fallback;
} }
function getLogFilePath() { function getDefaultLogFilePath() {
// Next to the EXE when packaged, next to project root when dev
const baseDir = app.isPackaged const baseDir = app.isPackaged
? path.dirname(process.execPath) ? path.dirname(process.execPath)
: path.join(__dirname); : path.join(__dirname);
return path.join(baseDir, 'fileuploader.log'); return path.join(baseDir, 'fileuploader.log');
} }
function getLogFilePath() {
const config = configStore.load();
const customPath = config && config.globalSettings
? String(config.globalSettings.logFilePath || '').trim()
: '';
return customPath || getDefaultLogFilePath();
}
function appendUploadLog(hoster, link, fileName) { function appendUploadLog(hoster, link, fileName) {
try { try {
const logPath = getLogFilePath();
fs.mkdirSync(path.dirname(logPath), { recursive: true });
const now = new Date(); const now = new Date();
const pad = (n) => String(n).padStart(2, '0'); const pad = (n) => String(n).padStart(2, '0');
const dateStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`; const dateStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
const line = `${dateStr}|${hoster}|${link}||${fileName}|\n`; const line = `${dateStr}|${hoster}|${link}||${fileName}|\n`;
fs.appendFileSync(getLogFilePath(), line, 'utf-8'); fs.appendFileSync(logPath, line, 'utf-8');
} catch {} } catch {}
} }
function buildUploadTasks(config, files, hosters) {
const tasks = [];
for (const file of files) {
for (const hoster of hosters) {
const hosterConfig = config.hosters[hoster];
if (!hosterConfig) {
debugLog(` skip ${hoster}: no config`);
continue;
}
if (hoster === 'vidmoly.me') {
if (!hosterConfig.username || !hosterConfig.password) {
debugLog(` skip ${hoster}: missing username/password`);
continue;
}
tasks.push({ file, hoster, username: hosterConfig.username, password: hosterConfig.password });
} else {
if (!hosterConfig.apiKey) {
debugLog(` skip ${hoster}: missing apiKey`);
continue;
}
tasks.push({ file, hoster, apiKey: hosterConfig.apiKey });
debugLog(` task: ${hoster} key=${hosterConfig.apiKey.slice(0, 6)}...`);
}
}
}
return tasks;
}
async function checkDoodstreamHealth(hosterConfig) { async function checkDoodstreamHealth(hosterConfig) {
const apiKey = hosterConfig && hosterConfig.apiKey const apiKey = hosterConfig && hosterConfig.apiKey
? String(hosterConfig.apiKey).trim() ? String(hosterConfig.apiKey).trim()
@ -216,7 +256,7 @@ function createWindow() {
height: 750, height: 750,
minWidth: 800, minWidth: 800,
minHeight: 550, minHeight: 550,
backgroundColor: '#0f0f1a', backgroundColor: '#16181c',
autoHideMenuBar: true, autoHideMenuBar: true,
webPreferences: { webPreferences: {
contextIsolation: true, contextIsolation: true,
@ -322,34 +362,7 @@ ipcMain.handle('start-upload', (_event, payload) => {
debugLog(`start-upload: files=${JSON.stringify(files)}, hosters=${JSON.stringify(hosters)}`); debugLog(`start-upload: files=${JSON.stringify(files)}, hosters=${JSON.stringify(hosters)}`);
// Build tasks with credentials const tasks = buildUploadTasks(config, files, hosters);
const tasks = [];
for (const file of files) {
for (const hoster of hosters) {
const hosterConfig = config.hosters[hoster];
if (!hosterConfig) {
debugLog(` skip ${hoster}: no config`);
continue;
}
if (hoster === 'vidmoly.me') {
// Vidmoly uses username/password login
if (!hosterConfig.username || !hosterConfig.password) {
debugLog(` skip ${hoster}: missing username/password`);
continue;
}
tasks.push({ file, hoster, username: hosterConfig.username, password: hosterConfig.password });
} else {
// Other hosters use API key
if (!hosterConfig.apiKey) {
debugLog(` skip ${hoster}: missing apiKey`);
continue;
}
tasks.push({ file, hoster, apiKey: hosterConfig.apiKey });
debugLog(` task: ${hoster} key=${hosterConfig.apiKey.slice(0, 6)}...`);
}
}
}
debugLog(` tasks built: ${tasks.length}`); debugLog(` tasks built: ${tasks.length}`);

View File

@ -2,11 +2,13 @@ const HOSTERS = ['doodstream.com', 'voe.sx', 'vidmoly.me', 'byse.sx'];
// --- State --- // --- State ---
let selectedFiles = []; // { path, name, size } let selectedFiles = []; // { path, name, size }
let selectedUploadHosters = [];
let config = { hosters: {}, hosterSettings: {}, globalSettings: {} }; let config = { hosters: {}, hosterSettings: {}, globalSettings: {} };
let hosterSettings = {}; let hosterSettings = {};
let uploading = false; let uploading = false;
let healthCheckRunning = false; let healthCheckRunning = false;
let autoHealthCheckEnabled = true; let autoHealthCheckEnabled = true;
let queuePersistTimer = null;
const AUTO_CHECK_PREF_KEY = 'autoHealthCheckBeforeUpload'; const AUTO_CHECK_PREF_KEY = 'autoHealthCheckBeforeUpload';
// Queue state // Queue state
@ -23,11 +25,21 @@ async function init() {
config = await window.api.getConfig(); config = await window.api.getConfig();
hosterSettings = config.hosterSettings || {}; hosterSettings = config.hosterSettings || {};
autoHealthCheckEnabled = loadAutoCheckPreference(); autoHealthCheckEnabled = loadAutoCheckPreference();
renderHosterChips(); syncSelectedUploadHosters();
restoreQueueStateFromConfig();
renderHosterSummary();
renderHosterModal();
renderSettings(); renderSettings();
setupListeners(); setupListeners();
setupDragDrop(); setupDragDrop();
loadHistory(); loadHistory();
updateUploadView();
if (shouldAutoResumeQueue()) {
setTimeout(() => {
if (!uploading) startUpload();
}, 350);
}
// Version display // Version display
try { try {
@ -75,37 +87,215 @@ document.querySelectorAll('.tab').forEach(tab => {
}); });
}); });
// --- Hoster chips --- // --- Hoster selection ---
function hosterHasCredentials(name, hoster) { function hosterHasCredentials(name, hoster) {
if (name === 'vidmoly.me') return !!(hoster.username && hoster.password); if (name === 'vidmoly.me') return !!(hoster.username && hoster.password);
return !!hoster.apiKey; return !!hoster.apiKey;
} }
function renderHosterChips() { function getAvailableHosters() {
const container = document.getElementById('hosterSelect'); return HOSTERS
container.innerHTML = ''; .map(name => {
for (const name of HOSTERS) {
const hoster = config.hosters[name] || {}; const hoster = config.hosters[name] || {};
const hasCreds = hosterHasCredentials(name, hoster); return { name, hoster, hasCreds: hosterHasCredentials(name, hoster) };
const chip = document.createElement('label'); })
chip.className = 'hoster-chip' + (hoster.enabled && hasCreds ? ' selected' : '') + (!hasCreds ? ' no-key' : ''); .filter(item => item.hasCreds);
chip.innerHTML = ` }
<input type="checkbox" data-hoster="${name}" ${hoster.enabled && hasCreds ? 'checked' : ''} ${!hasCreds ? 'disabled' : ''}>
<span class="hoster-dot"></span> function syncSelectedUploadHosters() {
<span>${name}</span> const available = new Set(getAvailableHosters().map(item => item.name));
`; selectedUploadHosters = selectedUploadHosters.filter(name => available.has(name));
chip.querySelector('input').addEventListener('change', (e) => { if (selectedUploadHosters.length === 0) {
chip.classList.toggle('selected', e.target.checked); selectedUploadHosters = HOSTERS.filter(name => {
if (!uploading && selectedFiles.length > 0) buildQueuePreview(); const hoster = config.hosters[name] || {};
updateStartButton(); return !!hoster.enabled && hosterHasCredentials(name, hoster);
}); });
container.appendChild(chip);
} }
} }
function getSelectedHosters() { function getSelectedHosters() {
return Array.from(document.querySelectorAll('#hosterSelect input:checked')) return selectedUploadHosters.slice();
.map(cb => cb.dataset.hoster); }
function renderHosterSummary() {
const summary = document.getElementById('hosterSummary');
if (!summary) return;
const hosters = getSelectedHosters();
if (hosters.length === 0) {
summary.textContent = 'Keine Upload-Ziele ausgewaehlt';
} else if (hosters.length === 1) {
summary.textContent = `Aktives Ziel: ${hosters[0]}`;
} else {
summary.textContent = `${hosters.length} Ziele aktiv: ${hosters.join(', ')}`;
}
}
function renderHosterModal() {
const list = document.getElementById('hosterModalList');
const hint = document.getElementById('hosterModalHint');
if (!list || !hint) return;
const available = getAvailableHosters();
if (available.length === 0) {
list.innerHTML = '';
hint.textContent = 'Keine Hoster mit Zugangsdaten vorhanden. Bitte zuerst in den Einstellungen API-Key oder Login eintragen.';
return;
}
list.innerHTML = available.map(item => {
const checked = selectedUploadHosters.includes(item.name);
const subtitle = item.name === 'vidmoly.me' ? 'Login hinterlegt' : 'API-Key hinterlegt';
return `
<label class="hoster-option${checked ? ' selected' : ''}" data-hoster-option="${item.name}">
<input type="checkbox" data-hoster-modal="${item.name}" ${checked ? 'checked' : ''}>
<div class="hoster-option-main">
<div class="hoster-option-title">${escapeHtml(item.name)}</div>
<div class="hoster-option-subtitle">${subtitle}</div>
</div>
</label>
`;
}).join('');
hint.textContent = 'Die Auswahl wird fuer neue Queue-Eintraege verwendet.';
list.querySelectorAll('input[data-hoster-modal]').forEach(input => {
input.addEventListener('change', () => {
input.closest('.hoster-option')?.classList.toggle('selected', input.checked);
});
});
}
function openHosterModal() {
syncSelectedUploadHosters();
renderHosterModal();
document.getElementById('hosterModal').style.display = 'flex';
}
function closeHosterModal() {
const modal = document.getElementById('hosterModal');
if (modal) modal.style.display = 'none';
}
function applyHosterSelection() {
selectedUploadHosters = Array.from(document.querySelectorAll('input[data-hoster-modal]:checked'))
.map(input => input.dataset.hosterModal);
renderHosterSummary();
if (!uploading && selectedFiles.length > 0) buildQueuePreview();
updateStartButton();
persistQueueStateSoon();
closeHosterModal();
}
function normalizeRestoredJobStatus(status) {
if (status === 'done' || status === 'error' || status === 'skipped' || status === 'preview') return status;
return 'queued';
}
function restoreQueueStateFromConfig() {
const pending = config?.globalSettings?.pendingQueue;
if (!pending || typeof pending !== 'object') return;
selectedUploadHosters = Array.isArray(pending.selectedUploadHosters)
? pending.selectedUploadHosters.filter(Boolean)
: selectedUploadHosters;
selectedFiles = Array.isArray(pending.selectedFiles)
? pending.selectedFiles
.filter(file => file && file.path)
.map(file => ({ path: file.path, name: file.name || file.path.split(/[\\/]/).pop(), size: file.size || 0 }))
: [];
queueJobs = Array.isArray(pending.queueJobs)
? pending.queueJobs
.filter(job => job && job.fileName && job.hoster)
.map(job => ({
id: job.id || `restored-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
uploadId: null,
file: job.file || '',
fileName: job.fileName,
hoster: job.hoster,
status: normalizeRestoredJobStatus(job.status),
bytesUploaded: job.status === 'done' ? (job.bytesTotal || 0) : 0,
bytesTotal: job.bytesTotal || 0,
speedKbs: 0,
elapsed: 0,
remaining: 0,
error: job.error || null,
result: job.result || null,
attempt: 0,
maxAttempts: job.maxAttempts || 0,
link: '',
progress: job.status === 'done' ? 1 : 0
}))
: [];
}
function buildPersistedQueueState() {
const unfinishedJobs = queueJobs.filter(job => job.status !== 'done' && job.status !== 'skipped');
const selectedFileMap = new Map(selectedFiles.map(file => [file.path, file]));
for (const job of unfinishedJobs) {
if (job.file && !selectedFileMap.has(job.file)) {
selectedFileMap.set(job.file, {
path: job.file,
name: job.fileName,
size: job.bytesTotal || 0
});
}
}
if (selectedFileMap.size === 0 && queueJobs.every(job => job.status === 'done' || job.status === 'skipped')) {
return null;
}
return {
selectedUploadHosters: getSelectedHosters(),
selectedFiles: Array.from(selectedFileMap.values()),
queueJobs: queueJobs.map(job => ({
id: job.id,
file: job.file,
fileName: job.fileName,
hoster: job.hoster,
status: job.status,
bytesTotal: job.bytesTotal || 0,
error: job.error || null,
result: job.result || null,
maxAttempts: job.maxAttempts || 0
}))
};
}
async function persistQueueStateNow() {
const globalSettings = {
...(config.globalSettings || {}),
pendingQueue: buildPersistedQueueState()
};
config.globalSettings = globalSettings;
await window.api.saveGlobalSettings(globalSettings);
}
function persistQueueStateSoon() {
clearTimeout(queuePersistTimer);
queuePersistTimer = setTimeout(() => {
persistQueueStateNow().catch(() => {});
}, 250);
}
function clearPersistedQueueStateSoon() {
clearTimeout(queuePersistTimer);
queuePersistTimer = setTimeout(() => {
const globalSettings = {
...(config.globalSettings || {}),
pendingQueue: null
};
config.globalSettings = globalSettings;
window.api.saveGlobalSettings(globalSettings).catch(() => {});
}, 0);
}
function shouldAutoResumeQueue() {
if (!config?.globalSettings?.resumeQueueOnLaunch) return false;
return queueJobs.some(job => !['done', 'skipped'].includes(job.status));
} }
// --- File selection --- // --- File selection ---
@ -132,39 +322,47 @@ function setupDragDrop() {
} }
function addDroppedFiles(fileList) { function addDroppedFiles(fileList) {
let added = 0;
const files = Array.from(fileList); const files = Array.from(fileList);
for (const file of files) { for (const file of files) {
if (!selectedFiles.find(f => f.path === file.path)) { if (!selectedFiles.find(f => f.path === file.path)) {
selectedFiles.push({ path: file.path, name: file.name, size: file.size }); selectedFiles.push({ path: file.path, name: file.name, size: file.size });
added++;
} }
} }
updateUploadView(); updateUploadView();
persistQueueStateSoon();
if (added > 0) openHosterModal();
} }
async function pickFiles() { async function pickFiles() {
const paths = await window.api.selectFiles(); const paths = await window.api.selectFiles();
if (!paths) return; if (!paths) return;
let added = 0;
for (const p of paths) { for (const p of paths) {
if (!selectedFiles.find(f => f.path === p)) { if (!selectedFiles.find(f => f.path === p)) {
const name = p.split('\\').pop().split('/').pop(); const name = p.split('\\').pop().split('/').pop();
selectedFiles.push({ path: p, name, size: null }); // size resolved by upload-manager selectedFiles.push({ path: p, name, size: null }); // size resolved by upload-manager
added++;
} }
} }
updateUploadView(); updateUploadView();
persistQueueStateSoon();
if (added > 0) openHosterModal();
} }
function updateUploadView() { function updateUploadView() {
const dropZone = document.getElementById('dropZone'); const dropZone = document.getElementById('dropZone');
const queueContainer = document.getElementById('queueContainer'); const queueShell = document.getElementById('queueShell');
const queueActions = document.getElementById('queueActions'); const queueActions = document.getElementById('queueActions');
if (selectedFiles.length === 0 && queueJobs.length === 0) { if (selectedFiles.length === 0 && queueJobs.length === 0) {
dropZone.style.display = 'flex'; dropZone.style.display = 'flex';
queueContainer.style.display = 'none'; queueShell.style.display = 'none';
queueActions.style.display = 'none'; queueActions.style.display = 'none';
} else { } else {
dropZone.style.display = 'none'; dropZone.style.display = 'none';
queueContainer.style.display = 'block'; queueShell.style.display = 'flex';
queueActions.style.display = 'flex'; queueActions.style.display = 'flex';
if (!uploading && selectedFiles.length > 0) { if (!uploading && selectedFiles.length > 0) {
buildQueuePreview(); buildQueuePreview();
@ -183,6 +381,12 @@ function updateStartButton() {
// Build preview jobs from selected files x selected hosters (before upload starts) // Build preview jobs from selected files x selected hosters (before upload starts)
function buildQueuePreview() { function buildQueuePreview() {
const hosters = getSelectedHosters(); const hosters = getSelectedHosters();
if (hosters.length === 0) {
queueJobs = queueJobs.filter(j => j.status !== 'preview');
renderQueueTable();
persistQueueStateSoon();
return;
}
// Remove old preview jobs (status 'preview') // Remove old preview jobs (status 'preview')
queueJobs = queueJobs.filter(j => j.status !== 'preview'); queueJobs = queueJobs.filter(j => j.status !== 'preview');
@ -202,6 +406,7 @@ function buildQueuePreview() {
} }
} }
renderQueueTable(); renderQueueTable();
persistQueueStateSoon();
} }
// --- Queue Table Rendering (debounced) --- // --- Queue Table Rendering (debounced) ---
@ -371,7 +576,10 @@ document.addEventListener('click', (e) => {
if (!e.target.closest('.context-menu')) hideContextMenu(); if (!e.target.closest('.context-menu')) hideContextMenu();
}); });
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') hideContextMenu(); if (e.key === 'Escape') {
hideContextMenu();
closeHosterModal();
}
}); });
document.getElementById('contextMenu').addEventListener('click', (e) => { document.getElementById('contextMenu').addEventListener('click', (e) => {
@ -394,10 +602,17 @@ async function handleContextAction(action) {
selectedJobIds.clear(); selectedJobIds.clear();
renderQueueTable(); renderQueueTable();
if (queueJobs.length === 0) { selectedFiles = []; updateUploadView(); } if (queueJobs.length === 0) { selectedFiles = []; updateUploadView(); }
persistQueueStateSoon();
} else if (action === 'copy-all-links') { } else if (action === 'copy-all-links') {
copyAllLinks(); copyAllLinks();
} else if (action === 'delete-all') { } else if (action === 'delete-all') {
if (!uploading) { queueJobs = []; selectedFiles = []; selectedJobIds.clear(); updateUploadView(); } if (!uploading) {
queueJobs = [];
selectedFiles = [];
selectedJobIds.clear();
updateUploadView();
clearPersistedQueueStateSoon();
}
} else if (action === 'always-on-top') { } else if (action === 'always-on-top') {
alwaysOnTopState = !alwaysOnTopState; alwaysOnTopState = !alwaysOnTopState;
await window.api.setAlwaysOnTop(alwaysOnTopState); await window.api.setAlwaysOnTop(alwaysOnTopState);
@ -471,6 +686,7 @@ async function startUpload() {
console.log('[startUpload] sending payload:', uploadPayload); console.log('[startUpload] sending payload:', uploadPayload);
const result = await window.api.startUpload(uploadPayload); const result = await window.api.startUpload(uploadPayload);
console.log('[startUpload] response:', result); console.log('[startUpload] response:', result);
persistQueueStateSoon();
if (result && result.error) { if (result && result.error) {
alert(result.error); alert(result.error);
@ -486,6 +702,7 @@ async function cancelUpload() {
document.getElementById('startUploadBtn').style.display = 'inline-block'; document.getElementById('startUploadBtn').style.display = 'inline-block';
document.getElementById('cancelUploadBtn').style.display = 'none'; document.getElementById('cancelUploadBtn').style.display = 'none';
updateStartButton(); updateStartButton();
persistQueueStateSoon();
} }
// --- Progress handling --- // --- Progress handling ---
@ -529,6 +746,7 @@ function handleProgress(data) {
job.progress = data.progress || 0; job.progress = data.progress || 0;
scheduleQueueRender(); scheduleQueueRender();
persistQueueStateSoon();
} }
function handleBatchDone(summary) { function handleBatchDone(summary) {
@ -539,6 +757,8 @@ function handleBatchDone(summary) {
document.getElementById('cancelUploadBtn').style.display = 'none'; document.getElementById('cancelUploadBtn').style.display = 'none';
updateStartButton(); updateStartButton();
renderQueueTable(); renderQueueTable();
loadHistory();
clearPersistedQueueStateSoon();
// Final stats update // Final stats update
document.getElementById('sbState').textContent = 'Fertig'; document.getElementById('sbState').textContent = 'Fertig';
@ -574,6 +794,7 @@ function retrySelectedJobs() {
selectedJobIds.clear(); selectedJobIds.clear();
renderQueueTable(); renderQueueTable();
updateStartButton(); updateStartButton();
persistQueueStateSoon();
} }
// --- Health Check --- // --- Health Check ---
@ -623,6 +844,29 @@ function renderSettings() {
const container = document.getElementById('settingsHosters'); const container = document.getElementById('settingsHosters');
container.innerHTML = ''; container.innerHTML = '';
const globalSettings = config.globalSettings || {};
const generalPanel = document.createElement('div');
generalPanel.className = 'hoster-settings-panel';
generalPanel.innerHTML = `
<div class="hoster-panel-header" data-hoster="global">
<span class="panel-arrow">&#9660;</span>
<span class="panel-title">Allgemein</span>
<span class="panel-status active">System</span>
</div>
<div class="hoster-panel-body" data-panel="global" style="display:block">
<div class="settings-row">
<label>FileUploader Log</label>
<input type="text" class="key-input" id="logFilePathInput" value="${escapeAttr(globalSettings.logFilePath || '')}" placeholder="Standardpfad verwenden">
<button class="btn btn-xs btn-secondary" id="chooseLogFilePathBtn">Ordner waehlen</button>
</div>
<div class="settings-row checkbox-row">
<label>Queue nach Neustart fortsetzen</label>
<input type="checkbox" id="resumeQueueOnLaunchInput" ${globalSettings.resumeQueueOnLaunch === false ? '' : 'checked'}>
</div>
</div>
`;
container.appendChild(generalPanel);
for (const name of HOSTERS) { for (const name of HOSTERS) {
const hoster = config.hosters[name] || {}; const hoster = config.hosters[name] || {};
const hs = hosterSettings[name] || {}; const hs = hosterSettings[name] || {};
@ -712,11 +956,25 @@ function renderSettings() {
}); });
}); });
} }
document.getElementById('chooseLogFilePathBtn')?.addEventListener('click', chooseLogFilePath);
}
async function chooseLogFilePath() {
const folders = await window.api.selectFolder();
if (!folders || !folders[0]) return;
const normalized = folders[0].replace(/[\\\/]+$/, '');
document.getElementById('logFilePathInput').value = `${normalized}\\fileuploader.log`;
} }
async function saveSettings() { async function saveSettings() {
const hosters = {}; const hosters = {};
const newHosterSettings = {}; const newHosterSettings = {};
const globalSettings = {
...(config.globalSettings || {}),
logFilePath: (document.getElementById('logFilePathInput')?.value || '').trim(),
resumeQueueOnLaunch: !!document.getElementById('resumeQueueOnLaunchInput')?.checked
};
for (const name of HOSTERS) { for (const name of HOSTERS) {
// Credentials // Credentials
@ -740,9 +998,12 @@ async function saveSettings() {
await window.api.saveConfig({ hosters }); await window.api.saveConfig({ hosters });
await window.api.saveHosterSettings(newHosterSettings); await window.api.saveHosterSettings(newHosterSettings);
await window.api.saveGlobalSettings(globalSettings);
config = await window.api.getConfig(); config = await window.api.getConfig();
hosterSettings = config.hosterSettings || {}; hosterSettings = config.hosterSettings || {};
renderHosterChips(); syncSelectedUploadHosters();
renderHosterSummary();
renderHosterModal();
renderSettings(); renderSettings();
renderHealthCheckResults([]); renderHealthCheckResults([]);
@ -759,6 +1020,7 @@ async function loadHistory() {
if (!history || history.length === 0) { if (!history || history.length === 0) {
historyRowsData = []; historyRowsData = [];
container.innerHTML = '<p class="empty-state">Noch keine Uploads.</p>'; container.innerHTML = '<p class="empty-state">Noch keine Uploads.</p>';
renderRecentUploadsPanel();
return; return;
} }
@ -781,6 +1043,41 @@ async function loadHistory() {
} }
renderHistoryTable(container); renderHistoryTable(container);
renderRecentUploadsPanel();
}
function renderRecentUploadsPanel() {
const tbody = document.getElementById('recentFilesBody');
if (!tbody) return;
if (!historyRowsData.length) {
tbody.innerHTML = '<tr><td colspan="4" class="empty-state">Noch keine Uploads.</td></tr>';
return;
}
const rows = historyRowsData
.slice()
.sort((a, b) => b.dateTs - a.dateTs || b.order - a.order)
.slice(0, 20);
tbody.innerHTML = rows.map(row => `
<tr class="recent-file-row${row.isError ? ' error' : ''}" data-link="${escapeAttr(row.link)}">
<td>${escapeHtml(row.date)}</td>
<td title="${escapeAttr(row.filename)}">${escapeHtml(row.filename)}</td>
<td>${escapeHtml(row.host)}</td>
<td title="${escapeAttr(row.link)}">${escapeHtml(row.link)}</td>
</tr>
`).join('');
tbody.querySelectorAll('.recent-file-row').forEach(row => {
row.addEventListener('click', () => {
if (row.classList.contains('error')) return;
const link = row.dataset.link;
if (link) {
window.api.copyToClipboard(link);
showCopyToast('Link kopiert');
}
});
});
} }
function renderHistoryTable(container) { function renderHistoryTable(container) {
@ -842,6 +1139,7 @@ function sortHistoryRows(rows) {
// --- Setup Listeners --- // --- Setup Listeners ---
function setupListeners() { function setupListeners() {
document.getElementById('addFilesBtn').addEventListener('click', pickFiles); document.getElementById('addFilesBtn').addEventListener('click', pickFiles);
document.getElementById('chooseHostersBtn').addEventListener('click', openHosterModal);
document.getElementById('startUploadBtn').addEventListener('click', startUpload); document.getElementById('startUploadBtn').addEventListener('click', startUpload);
document.getElementById('cancelUploadBtn').addEventListener('click', cancelUpload); document.getElementById('cancelUploadBtn').addEventListener('click', cancelUpload);
document.getElementById('runHealthCheckBtn').addEventListener('click', runHealthCheck); document.getElementById('runHealthCheckBtn').addEventListener('click', runHealthCheck);
@ -851,7 +1149,28 @@ function setupListeners() {
retrySelectedJobs(); retrySelectedJobs();
}); });
document.getElementById('clearQueueBtn').addEventListener('click', () => { document.getElementById('clearQueueBtn').addEventListener('click', () => {
if (!uploading) { queueJobs = []; selectedFiles = []; selectedJobIds.clear(); updateUploadView(); } if (!uploading) {
queueJobs = [];
selectedFiles = [];
selectedJobIds.clear();
updateUploadView();
clearPersistedQueueStateSoon();
}
});
document.getElementById('confirmHosterModalBtn').addEventListener('click', applyHosterSelection);
document.getElementById('cancelHosterModalBtn').addEventListener('click', closeHosterModal);
document.getElementById('closeHosterModalBtn').addEventListener('click', closeHosterModal);
document.getElementById('selectAllHostersBtn').addEventListener('click', () => {
document.querySelectorAll('input[data-hoster-modal]').forEach(input => {
input.checked = true;
input.closest('.hoster-option')?.classList.add('selected');
});
});
document.getElementById('clearHostersBtn').addEventListener('click', () => {
document.querySelectorAll('input[data-hoster-modal]').forEach(input => {
input.checked = false;
input.closest('.hoster-option')?.classList.remove('selected');
});
}); });
document.getElementById('saveSettingsBtn').addEventListener('click', saveSettings); document.getElementById('saveSettingsBtn').addEventListener('click', saveSettings);
document.getElementById('clearHistoryBtn').addEventListener('click', async () => { document.getElementById('clearHistoryBtn').addEventListener('click', async () => {
@ -893,6 +1212,10 @@ function setupListeners() {
e.preventDefault(); e.preventDefault();
showContextMenu(e.clientX, e.clientY); showContextMenu(e.clientX, e.clientY);
}); });
document.getElementById('hosterModal').addEventListener('click', (e) => {
if (e.target.id === 'hosterModal') closeHosterModal();
});
} }
// --- Update UI --- // --- Update UI ---

View File

@ -25,7 +25,8 @@
<!-- Toolbar --> <!-- Toolbar -->
<div class="upload-toolbar"> <div class="upload-toolbar">
<div class="toolbar-left"> <div class="toolbar-left">
<div class="hoster-select" id="hosterSelect"></div> <button class="btn btn-xs btn-secondary" id="chooseHostersBtn">Ziele waehlen</button>
<span class="hoster-summary" id="hosterSummary">Keine Upload-Ziele ausgewaehlt</span>
</div> </div>
<div class="toolbar-right"> <div class="toolbar-right">
<div class="health-check-inline"> <div class="health-check-inline">
@ -44,6 +45,7 @@
<!-- Health check results (collapsible) --> <!-- Health check results (collapsible) -->
<div class="health-check-results" id="healthCheckResults"></div> <div class="health-check-results" id="healthCheckResults"></div>
<div class="upload-workspace">
<!-- Drop zone (shown when no files) --> <!-- Drop zone (shown when no files) -->
<div class="drop-zone" id="dropZone"> <div class="drop-zone" id="dropZone">
<div class="drop-icon">&#128193;</div> <div class="drop-icon">&#128193;</div>
@ -51,7 +53,8 @@
</div> </div>
<!-- Queue Table --> <!-- Queue Table -->
<div class="queue-container" id="queueContainer" style="display:none"> <div class="queue-shell" id="queueShell" style="display:none">
<div class="queue-container" id="queueContainer">
<table class="queue-table" id="queueTable"> <table class="queue-table" id="queueTable">
<thead> <thead>
<tr> <tr>
@ -75,6 +78,28 @@
<button class="btn btn-xs btn-secondary" id="retryFailedBtn" style="display:none">Fehlgeschlagene erneut</button> <button class="btn btn-xs btn-secondary" id="retryFailedBtn" style="display:none">Fehlgeschlagene erneut</button>
<button class="btn btn-xs btn-secondary" id="clearQueueBtn">Queue leeren</button> <button class="btn btn-xs btn-secondary" id="clearQueueBtn">Queue leeren</button>
</div> </div>
<div class="recent-files-panel" id="recentFilesPanel">
<div class="recent-files-header">
<h3>Files</h3>
<span class="recent-files-hint">Zuletzt erzeugte Upload-Links</span>
</div>
<div class="recent-files-table-wrap">
<table class="recent-files-table">
<thead>
<tr>
<th class="col-date">Date</th>
<th class="col-filename">Filename</th>
<th class="col-host">Host</th>
<th class="col-link">Link</th>
</tr>
</thead>
<tbody id="recentFilesBody"></tbody>
</table>
</div>
</div>
</div>
</div>
</div> </div>
<!-- Settings View --> <!-- Settings View -->
@ -142,6 +167,30 @@
</div> </div>
</div> </div>
<div class="modal-overlay" id="hosterModal" style="display:none">
<div class="modal-card">
<div class="modal-header">
<div>
<h3>Upload-Ziele auswaehlen</h3>
<p>Dateien wurden hinzugefuegt. Waehle jetzt die Hoster fuer den Upload.</p>
</div>
<button class="icon-btn" id="closeHosterModalBtn" aria-label="Schliessen">&times;</button>
</div>
<div class="modal-body">
<div class="modal-actions-inline">
<button class="btn btn-xs btn-secondary" id="selectAllHostersBtn">Alle</button>
<button class="btn btn-xs btn-secondary" id="clearHostersBtn">Keine</button>
</div>
<div class="hoster-modal-list" id="hosterModalList"></div>
<p class="modal-hint" id="hosterModalHint"></p>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" id="cancelHosterModalBtn">Abbrechen</button>
<button class="btn btn-primary" id="confirmHosterModalBtn">Uebernehmen</button>
</div>
</div>
</div>
<script src="app.js"></script> <script src="app.js"></script>
</body> </body>
</html> </html>

View File

@ -1,28 +1,31 @@
:root { :root {
--bg-primary: #0f0f1a; --bg-primary: #16181c;
--bg-secondary: #1a1a2e; --bg-secondary: #20242b;
--bg-card: #1e1e2e; --bg-card: #262b33;
--bg-card-hover: #2a2a3e; --bg-card-hover: #2e3440;
--bg-input: #2a2a3e; --bg-input: #1b2027;
--border: rgba(255, 255, 255, 0.1); --border: rgba(255, 255, 255, 0.08);
--border-hover: rgba(255, 255, 255, 0.2); --border-hover: rgba(255, 255, 255, 0.18);
--text: #fff; --text: #edf1f7;
--text-muted: #888; --text-muted: #9ea7b3;
--text-dim: #666; --text-dim: #727b88;
--accent: #667eea; --accent: #3ea7ff;
--accent-end: #764ba2; --accent-end: #65d8ff;
--success: #00b894; --success: #43c788;
--success-end: #00cec9; --success-end: #89e0b0;
--danger: #e74c3c; --danger: #f06f5a;
--warning: #fdcb6e; --warning: #f0c36c;
--link-color: #00cec9; --link-color: #7edcff;
--panel-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
} }
* { margin: 0; padding: 0; box-sizing: border-box; } * { margin: 0; padding: 0; box-sizing: border-box; }
body { body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-family: 'Aptos', 'Segoe UI Variable Text', 'Bahnschrift', sans-serif;
background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, #16213e 100%); background:
radial-gradient(circle at top right, rgba(62, 167, 255, 0.08), transparent 28%),
linear-gradient(180deg, #14171b 0%, #191d23 100%);
min-height: 100vh; min-height: 100vh;
color: var(--text); color: var(--text);
user-select: none; user-select: none;
@ -36,22 +39,24 @@ body {
gap: 2px; gap: 2px;
padding: 8px 16px 0; padding: 8px 16px 0;
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
background: rgba(0, 0, 0, 0.2); background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.08));
flex-shrink: 0; flex-shrink: 0;
} }
.tab { .tab {
padding: 8px 20px; padding: 10px 18px 9px;
background: transparent; background: transparent;
border: none; border: none;
color: var(--text-muted); color: var(--text-muted);
font-size: 13px; font-size: 12px;
letter-spacing: 0.04em;
text-transform: uppercase;
cursor: pointer; cursor: pointer;
border-bottom: 2px solid transparent; border-bottom: 2px solid transparent;
transition: all 0.2s; transition: all 0.2s;
} }
.tab:hover { color: var(--text); } .tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); } .tab.active { color: var(--text); border-bottom-color: var(--accent); background: rgba(255, 255, 255, 0.03); }
.version-label { .version-label {
margin-left: auto; margin-left: auto;
@ -82,59 +87,41 @@ body {
/* Buttons */ /* Buttons */
.btn { .btn {
padding: 8px 16px; padding: 8px 16px;
border: none; border: 1px solid transparent;
border-radius: 6px; border-radius: 8px;
cursor: pointer; cursor: pointer;
font-size: 13px; font-size: 12px;
font-weight: 500; font-weight: 600;
letter-spacing: 0.02em;
transition: all 0.2s; transition: all 0.2s;
} }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 4px; } .btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 4px; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 5px; } .btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 5px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-end)); color: #fff; } .btn-primary { background: linear-gradient(180deg, var(--accent-end), var(--accent)); color: #092033; box-shadow: inset 0 1px 0 rgba(255,255,255,0.28); }
.btn-primary:hover { filter: brightness(1.1); } .btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: default; filter: none; } .btn-primary:disabled { opacity: 0.5; cursor: default; filter: none; }
.btn-secondary { background: var(--bg-input); color: var(--text-muted); border: 1px solid var(--border); } .btn-secondary { background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.08)); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text); } .btn-secondary:hover { border-color: var(--border-hover); color: var(--text); background: rgba(255,255,255,0.05); }
.btn-success { background: linear-gradient(135deg, var(--success), var(--success-end)); color: #fff; } .btn-success { background: linear-gradient(180deg, var(--success-end), var(--success)); color: #082616; box-shadow: inset 0 1px 0 rgba(255,255,255,0.22); }
.btn-success:hover { filter: brightness(1.1); } .btn-success:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-success:disabled { opacity: 0.5; cursor: default; filter: none; } .btn-success:disabled { opacity: 0.5; cursor: default; filter: none; }
.btn-danger { background: var(--danger); color: #fff; } .btn-danger { background: linear-gradient(180deg, #ff8e74, var(--danger)); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); } .btn-danger:hover { filter: brightness(1.05); transform: translateY(-1px); }
/* Upload Toolbar */ /* Upload Toolbar */
.upload-toolbar { .upload-toolbar {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
padding: 8px 16px; padding: 10px 16px;
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
background: rgba(0, 0, 0, 0.15); background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.08));
flex-shrink: 0; flex-shrink: 0;
flex-wrap: wrap; flex-wrap: wrap;
} }
.toolbar-left { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 200px; } .toolbar-left { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 200px; }
.toolbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; } .toolbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.hoster-summary { font-size: 12px; color: var(--text-muted); }
/* Hoster Chips */
.hoster-select { display: flex; gap: 4px; flex-wrap: wrap; }
.hoster-chip {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 3px 8px;
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 4px;
cursor: pointer;
font-size: 11px;
transition: all 0.2s;
}
.hoster-chip input { display: none; }
.hoster-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); }
.hoster-chip.selected { border-color: var(--accent); background: rgba(102, 126, 234, 0.15); }
.hoster-chip.selected .hoster-dot { background: var(--accent); }
.hoster-chip.no-key { opacity: 0.4; cursor: default; }
/* Health check */ /* Health check */
.health-check-inline { display: flex; align-items: center; gap: 4px; } .health-check-inline { display: flex; align-items: center; gap: 4px; }
@ -153,6 +140,12 @@ body {
.health-tag { font-weight: 600; } .health-tag { font-weight: 600; }
/* Drop Zone */ /* Drop Zone */
.upload-workspace {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
.drop-zone { .drop-zone {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -160,21 +153,33 @@ body {
justify-content: center; justify-content: center;
flex: 1; flex: 1;
margin: 16px; margin: 16px;
border: 2px dashed var(--border); border: 1px dashed rgba(126, 220, 255, 0.28);
border-radius: 12px; border-radius: 18px;
cursor: pointer; cursor: pointer;
transition: all 0.3s; transition: all 0.3s;
color: var(--text-muted); color: var(--text-muted);
min-height: 200px; min-height: 200px;
background:
linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.08)),
repeating-linear-gradient(135deg, rgba(255,255,255,0.015), rgba(255,255,255,0.015) 12px, transparent 12px, transparent 24px);
box-shadow: var(--panel-shadow);
} }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: rgba(102, 126, 234, 0.05); } .drop-zone:hover, .drop-zone.drag-over { border-color: rgba(126, 220, 255, 0.6); background-color: rgba(62, 167, 255, 0.06); }
.drop-icon { font-size: 40px; margin-bottom: 8px; } .drop-icon { font-size: 40px; margin-bottom: 8px; }
/* Queue Container */ /* Queue Container */
.queue-shell {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
.queue-container { .queue-container {
flex: 1; flex: 1;
min-height: 220px;
overflow: auto; overflow: auto;
padding: 0; padding: 0;
background: rgba(255, 255, 255, 0.02);
} }
/* Queue Table */ /* Queue Table */
@ -192,7 +197,7 @@ body {
.queue-table th { .queue-table th {
padding: 5px 8px; padding: 5px 8px;
text-align: left; text-align: left;
background: #12121f; background: linear-gradient(180deg, #2a313b, #20252d);
color: var(--text-muted); color: var(--text-muted);
font-weight: 600; font-weight: 600;
font-size: 10px; font-size: 10px;
@ -216,7 +221,7 @@ body {
.queue-table td { .queue-table td {
padding: 4px 8px; padding: 4px 8px;
border-bottom: 1px solid rgba(255, 255, 255, 0.03); border-bottom: 1px solid rgba(255, 255, 255, 0.035);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
@ -224,7 +229,7 @@ body {
/* Queue Row States */ /* Queue Row States */
.queue-row { transition: background 0.15s; cursor: pointer; } .queue-row { transition: background 0.15s; cursor: pointer; }
.queue-row:hover { background: rgba(255, 255, 255, 0.03); } .queue-row:hover { background: rgba(255, 255, 255, 0.04); }
.queue-row.selected { background: rgba(102, 126, 234, 0.12) !important; } .queue-row.selected { background: rgba(102, 126, 234, 0.12) !important; }
.queue-row.status-uploading { background: rgba(102, 126, 234, 0.08); } .queue-row.status-uploading { background: rgba(102, 126, 234, 0.08); }
@ -278,10 +283,180 @@ body {
gap: 6px; gap: 6px;
padding: 6px 16px; padding: 6px 16px;
border-top: 1px solid var(--border); border-top: 1px solid var(--border);
background: rgba(0, 0, 0, 0.1); background: rgba(0, 0, 0, 0.14);
flex-shrink: 0; flex-shrink: 0;
} }
.recent-files-panel {
min-height: 220px;
max-height: 280px;
display: flex;
flex-direction: column;
border-top: 1px solid var(--border);
background: linear-gradient(180deg, rgba(255,255,255,0.015), rgba(0,0,0,0.12));
}
.recent-files-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 8px 16px;
border-bottom: 1px solid var(--border);
background: rgba(0, 0, 0, 0.12);
}
.recent-files-header h3 {
font-size: 13px;
font-weight: 600;
}
.recent-files-hint {
font-size: 11px;
color: var(--text-dim);
}
.recent-files-table-wrap {
flex: 1;
min-height: 0;
overflow: auto;
}
.recent-files-table {
width: 100%;
border-collapse: collapse;
font-size: 11px;
table-layout: fixed;
}
.recent-files-table th {
position: sticky;
top: 0;
z-index: 2;
padding: 6px 8px;
text-align: left;
background: linear-gradient(180deg, #2a313b, #20252d);
color: var(--text-muted);
font-weight: 600;
font-size: 10px;
text-transform: uppercase;
border-bottom: 1px solid var(--border);
}
.recent-files-table td {
padding: 5px 8px;
border-bottom: 1px solid rgba(255, 255, 255, 0.03);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.recent-file-row {
cursor: pointer;
transition: background 0.15s;
}
.recent-file-row:hover {
background: rgba(255, 255, 255, 0.03);
}
.recent-file-row.error {
color: var(--danger);
opacity: 0.75;
}
.modal-overlay {
position: fixed;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background: rgba(5, 7, 16, 0.72);
z-index: 2500;
padding: 24px;
}
.modal-card {
width: min(560px, 100%);
max-height: min(80vh, 700px);
display: flex;
flex-direction: column;
background: linear-gradient(180deg, rgba(30, 30, 46, 0.98), rgba(20, 20, 32, 0.98));
border: 1px solid var(--border-hover);
border-radius: 16px;
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
overflow: hidden;
}
.modal-header,
.modal-footer {
padding: 14px 16px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.modal-header {
border-bottom: 1px solid var(--border);
}
.modal-header h3 {
font-size: 18px;
margin-bottom: 4px;
}
.modal-header p,
.modal-hint {
font-size: 12px;
color: var(--text-muted);
}
.modal-body {
padding: 14px 16px 10px;
overflow: auto;
}
.modal-actions-inline {
display: flex;
gap: 8px;
margin-bottom: 12px;
}
.hoster-modal-list {
display: grid;
gap: 10px;
}
.hoster-option {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: 10px;
background: rgba(255, 255, 255, 0.02);
}
.hoster-option.selected {
border-color: rgba(102, 126, 234, 0.65);
background: rgba(102, 126, 234, 0.12);
}
.hoster-option.disabled {
opacity: 0.45;
}
.hoster-option input {
width: 16px;
height: 16px;
}
.hoster-option-main {
flex: 1;
}
.hoster-option-title {
font-size: 13px;
font-weight: 600;
}
.hoster-option-subtitle {
font-size: 11px;
color: var(--text-muted);
margin-top: 2px;
}
.icon-btn {
border: 1px solid var(--border);
background: transparent;
color: var(--text-muted);
width: 32px;
height: 32px;
border-radius: 8px;
cursor: pointer;
font-size: 20px;
line-height: 1;
}
.icon-btn:hover {
color: var(--text);
border-color: var(--border-hover);
}
/* Context Menu */ /* Context Menu */
.context-menu { .context-menu {
position: fixed; position: fixed;
@ -323,6 +498,7 @@ body {
/* Settings View */ /* Settings View */
.settings-container { padding: 16px; overflow: auto; flex: 1; } .settings-container { padding: 16px; overflow: auto; flex: 1; }
.settings-container { background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 24%); }
.settings-container h2 { margin-bottom: 4px; font-size: 18px; } .settings-container h2 { margin-bottom: 4px; font-size: 18px; }
.settings-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; } .settings-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
@ -358,6 +534,10 @@ body {
gap: 8px; gap: 8px;
margin-bottom: 6px; margin-bottom: 6px;
} }
.checkbox-row input[type="checkbox"] {
width: 16px;
height: 16px;
}
.settings-row label { .settings-row label {
font-size: 12px; font-size: 12px;
color: var(--text-muted); color: var(--text-muted);
@ -398,7 +578,7 @@ body {
} }
/* History View */ /* History View */
.history-container { padding: 16px; overflow: auto; flex: 1; } .history-container { padding: 16px; overflow: auto; flex: 1; background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 24%); }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; } .history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-header h2 { font-size: 18px; } .history-header h2 { font-size: 18px; }
@ -494,6 +674,15 @@ body {
} }
.shutdown-box p { margin-bottom: 16px; font-size: 16px; } .shutdown-box p { margin-bottom: 16px; font-size: 16px; }
@media (max-width: 900px) {
.recent-files-panel {
max-height: 220px;
}
.modal-overlay {
padding: 12px;
}
}
/* Scrollbars */ /* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-track { background: transparent; }

View File

@ -42,6 +42,9 @@ describe('ConfigStore', () => {
assert.equal(config.hosterSettings['doodstream.com'].parallelCount, 2); assert.equal(config.hosterSettings['doodstream.com'].parallelCount, 2);
assert.equal(config.globalSettings.alwaysOnTop, false); assert.equal(config.globalSettings.alwaysOnTop, false);
assert.equal(config.globalSettings.shutdownAfterFinish, 'nothing'); assert.equal(config.globalSettings.shutdownAfterFinish, 'nothing');
assert.equal(config.globalSettings.logFilePath, '');
assert.equal(config.globalSettings.resumeQueueOnLaunch, true);
assert.equal(config.globalSettings.pendingQueue, null);
assert.deepEqual(config.history, []); assert.deepEqual(config.history, []);
}); });
@ -119,5 +122,7 @@ describe('ConfigStore', () => {
const config = store.load(); const config = store.load();
assert.equal(config.globalSettings.alwaysOnTop, true); assert.equal(config.globalSettings.alwaysOnTop, true);
assert.equal(config.globalSettings.shutdownAfterFinish, 'nothing'); // default assert.equal(config.globalSettings.shutdownAfterFinish, 'nothing'); // default
assert.equal(config.globalSettings.resumeQueueOnLaunch, true);
assert.equal(config.globalSettings.logFilePath, '');
}); });
}); });

34
tests/hosters.test.js Normal file
View File

@ -0,0 +1,34 @@
const { describe, it } = require('node:test');
const assert = require('node:assert/strict');
const { __test } = require('../lib/hosters');
describe('hosters helpers', () => {
it('extracts VOE file_code from nested result payloads', () => {
assert.deepEqual(__test.parseVoeResult({ result: { file: { file_code: 'abc123' } } }), {
download_url: 'https://voe.sx/abc123',
embed_url: 'https://voe.sx/e/abc123',
file_code: 'abc123'
});
});
it('extracts VOE file_code from flat fallback payloads', () => {
assert.deepEqual(__test.parseVoeResult({ file_code: 'xyz789' }), {
download_url: 'https://voe.sx/xyz789',
embed_url: 'https://voe.sx/e/xyz789',
file_code: 'xyz789'
});
});
it('extracts upload server URLs from nested API responses', () => {
const url = __test.extractUploadServerUrl({
result: {
server: {
upload_url: 'https://delivery-hydra.voe-network.net/upload/01'
}
}
}, 'https://voe.sx');
assert.equal(url, 'https://delivery-hydra.voe-network.net/upload/01');
});
});