feat: summarize completed upload batches
Capture real batch duration and show a dedicated localized completion summary with success, failure, and skipped counts plus a direct action to open failed uploads.
This commit is contained in:
@@ -430,6 +430,7 @@ class UploadManager extends EventEmitter {
|
||||
succeeded,
|
||||
failed: total - succeeded - skipped,
|
||||
skipped,
|
||||
durationSec: Math.max(0, Math.round((Date.now() - this.startTime) / 1000)),
|
||||
files
|
||||
};
|
||||
|
||||
|
||||
@@ -2082,6 +2082,7 @@ ipcMain.handle('start-upload', async (_event, payload) => {
|
||||
succeeded: 0,
|
||||
failed: 0,
|
||||
skipped: 0,
|
||||
durationSec: 0,
|
||||
files: []
|
||||
}, skippedJobs);
|
||||
try { await configStore.appendHistory(skippedSummary); } catch (error) {
|
||||
@@ -2347,6 +2348,8 @@ ipcMain.handle('start-upload', async (_event, payload) => {
|
||||
total: tasks.length,
|
||||
succeeded: 0,
|
||||
failed: tasks.length,
|
||||
skipped: 0,
|
||||
durationSec: 0,
|
||||
files: [],
|
||||
error: err ? err.message : 'Unbekannter Fehler'
|
||||
};
|
||||
|
||||
@@ -368,6 +368,7 @@ let _updateDownloadCancelable = false;
|
||||
let _updateCancelBusy = false;
|
||||
let _updateDialogReturnFocus = null;
|
||||
let _updateDialogInertState = [];
|
||||
let _batchCompletionTimer = null;
|
||||
let _startupAutoResumeController = null;
|
||||
let _startupAutoResumeCanceled = false;
|
||||
|
||||
@@ -3405,9 +3406,62 @@ function handleBatchDone(summary) {
|
||||
lastUploadStats = { state: 'idle', globalSpeedKbs: 0, totalBytes: lastUploadStats.totalBytes, elapsed: lastUploadStats.elapsed, activeJobs: 0 };
|
||||
updateStatusBar();
|
||||
_refreshSessionFailedSnapshot();
|
||||
showBatchCompletionSummary(summary);
|
||||
_scheduleAutoRetryIfNeeded();
|
||||
}
|
||||
|
||||
function _formatBatchCompletionDuration(seconds, english) {
|
||||
const total = Math.max(0, Math.round(Number(seconds) || 0));
|
||||
if (total < 60) return english ? `${total} sec` : `${total} Sek.`;
|
||||
const minutes = Math.round(total / 60);
|
||||
if (minutes < 60) return english ? `${minutes} min` : `${minutes} Min.`;
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const remainder = minutes % 60;
|
||||
return english ? `${hours} hr ${remainder} min` : `${hours} Std. ${remainder} Min.`;
|
||||
}
|
||||
|
||||
function hideBatchCompletionSummary() {
|
||||
const toast = document.getElementById('batchCompletionToast');
|
||||
if (!toast) return;
|
||||
if (_batchCompletionTimer) clearTimeout(_batchCompletionTimer);
|
||||
_batchCompletionTimer = null;
|
||||
toast.classList.remove('show');
|
||||
setTimeout(() => {
|
||||
if (!toast.classList.contains('show')) toast.hidden = true;
|
||||
}, 240);
|
||||
}
|
||||
|
||||
function showBatchCompletionSummary(summary) {
|
||||
const toast = document.getElementById('batchCompletionToast');
|
||||
const text = document.getElementById('batchCompletionText');
|
||||
const showErrors = document.getElementById('batchCompletionShowErrors');
|
||||
if (!toast || !text || !showErrors || !summary) return;
|
||||
const total = Math.max(0, Number(summary.total) || 0);
|
||||
if (total <= 0) return;
|
||||
const succeeded = Math.max(0, Number(summary.succeeded) || 0);
|
||||
const failed = Math.max(0, Number(summary.failed) || 0);
|
||||
const skipped = Math.max(0, Number(summary.skipped) || 0);
|
||||
const english = getUiLocale() === 'en-US';
|
||||
const format = value => value.toLocaleString(getUiLocale());
|
||||
const duration = _formatBatchCompletionDuration(summary.durationSec, english);
|
||||
text.textContent = english
|
||||
? `${format(succeeded)} successful · ${format(failed)} failed · ${format(skipped)} skipped · ${duration}`
|
||||
: `${format(succeeded)} erfolgreich · ${format(failed)} fehlgeschlagen · ${format(skipped)} übersprungen · ${duration}`;
|
||||
const canShowErrors = failed > 0 && queueJobs.some(job => job.status === 'error');
|
||||
showErrors.hidden = !canShowErrors;
|
||||
toast.classList.toggle('has-failures', failed > 0);
|
||||
toast.hidden = false;
|
||||
requestAnimationFrame(() => toast.classList.add('show'));
|
||||
if (_batchCompletionTimer) clearTimeout(_batchCompletionTimer);
|
||||
_batchCompletionTimer = setTimeout(hideBatchCompletionSummary, 15000);
|
||||
}
|
||||
|
||||
function showBatchCompletionErrors() {
|
||||
document.getElementById('upload-tab')?.click();
|
||||
setUploadSidebarFilter('error');
|
||||
hideBatchCompletionSummary();
|
||||
}
|
||||
|
||||
let _sessionFailedKeys = new Set();
|
||||
|
||||
const _autoRetryState = { round: 0, timer: null };
|
||||
@@ -7285,6 +7339,8 @@ function setupListeners() {
|
||||
document.getElementById('queueStatusFilter').addEventListener('change', applyQueueDetailFilters);
|
||||
document.getElementById('queueFilterResetBtn').addEventListener('click', resetQueueFilters);
|
||||
syncQueueFilterResetAction();
|
||||
document.getElementById('batchCompletionShowErrors').addEventListener('click', showBatchCompletionErrors);
|
||||
document.getElementById('batchCompletionClose').addEventListener('click', hideBatchCompletionSummary);
|
||||
|
||||
const historyRetentionPicker = document.getElementById('historyRetentionPicker');
|
||||
const historyRetentionTrigger = document.getElementById('historyRetentionTrigger');
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
['Abbrechen', 'Cancel'],
|
||||
['Filter zurücksetzen', 'Reset filters'],
|
||||
['Filter', 'Filters'],
|
||||
['Fehler anzeigen', 'Show failures'],
|
||||
['Jetzt installieren', 'Install now'],
|
||||
['Jetzt updaten', 'Install now'],
|
||||
['Alle Dateien', 'All files'],
|
||||
|
||||
@@ -656,6 +656,11 @@
|
||||
</div>
|
||||
|
||||
<div class="copy-toast" id="copyToast" role="status" aria-live="polite" aria-atomic="true"></div>
|
||||
<div class="batch-completion-toast" id="batchCompletionToast" role="status" aria-live="polite" aria-atomic="true" hidden>
|
||||
<span id="batchCompletionText"></span>
|
||||
<button class="btn btn-xs btn-danger" id="batchCompletionShowErrors" hidden>Fehler anzeigen</button>
|
||||
<button class="batch-completion-close" id="batchCompletionClose" aria-label="Schließen">×</button>
|
||||
</div>
|
||||
<div class="startup-resume-banner" id="startupResumeBanner" role="status" aria-live="polite" hidden>
|
||||
<span id="startupResumeMessage"></span>
|
||||
<button class="btn btn-xs btn-secondary" id="cancelStartupResumeBtn">Abbrechen</button>
|
||||
|
||||
@@ -1735,6 +1735,65 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; }
|
||||
}
|
||||
.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
|
||||
|
||||
.batch-completion-toast {
|
||||
position: fixed;
|
||||
right: 14px;
|
||||
bottom: 18px;
|
||||
z-index: 2200;
|
||||
max-width: min(680px, calc(100vw - 28px));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 9px 9px 9px 13px;
|
||||
border: 1px solid var(--success);
|
||||
border-radius: 8px;
|
||||
background: rgba(35, 35, 35, .97);
|
||||
color: var(--text);
|
||||
box-shadow: 0 14px 34px rgba(0, 0, 0, .42);
|
||||
font-size: 12px;
|
||||
opacity: 0;
|
||||
transform: translateY(12px);
|
||||
transition: opacity .2s ease, transform .24s cubic-bezier(.22, 1, .36, 1);
|
||||
}
|
||||
|
||||
.batch-completion-toast[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.batch-completion-toast.show {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.batch-completion-toast.has-failures {
|
||||
border-color: var(--danger);
|
||||
}
|
||||
|
||||
#batchCompletionText {
|
||||
min-width: 0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.batch-completion-close {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 5px;
|
||||
background: transparent;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.batch-completion-close:hover {
|
||||
background: var(--bg-active);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.startup-resume-banner {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
|
||||
@@ -31,6 +31,7 @@ test('translations cover static labels and interpolated status text in both lang
|
||||
assert.equal(translateText('Alle Status', 'en'), 'Any status');
|
||||
assert.equal(translateText('Any status', 'de'), 'Alle Status');
|
||||
assert.equal(translateText('Filter', 'en'), 'Filters');
|
||||
assert.equal(translateText('Fehler anzeigen', 'en'), 'Show failures');
|
||||
});
|
||||
|
||||
test('sidebar hierarchy uses distinct English and German kicker labels', () => {
|
||||
|
||||
@@ -179,6 +179,7 @@ test('header occupies its final geometry before asynchronous initialization', ()
|
||||
assert.match(html, /class="update-progress-footer"[\s\S]*id="updateProgressDetails"[\s\S]*id="updateProgressSize"[\s\S]*id="updateProgressSpeed"[\s\S]*id="updateProgressEta"[\s\S]*id="updateProgressText"/u);
|
||||
assert.match(html, /id="queueFilterResetBtn"[^>]*disabled[^>]*>Filter zurücksetzen</u);
|
||||
assert.match(html, /class="queue-filter-summary"[\s\S]*id="queueActiveFilterCount"[^>]*>0</u);
|
||||
assert.match(html, /id="batchCompletionToast"[^>]*hidden[\s\S]*id="batchCompletionText"[\s\S]*id="batchCompletionShowErrors"/u);
|
||||
assert.doesNotMatch(html, /<\/div>\s*<div class="queue-filter-bar"/u);
|
||||
assert.match(css, /\.queue-filter-bar\s*\{[^}]*display:\s*flex;[^}]*margin-left:\s*auto;[^}]*border:\s*1px solid var\(--border\);[^}]*border-radius:\s*7px;/su);
|
||||
assert.match(css, /#updateProgressDetails\s*\{[^}]*display:\s*grid;[^}]*grid-template-columns:\s*19ch 2ch 11ch 2ch 10ch;[^}]*column-gap:\s*0;[^}]*font-variant-numeric:\s*tabular-nums;/su);
|
||||
|
||||
@@ -759,6 +759,30 @@ setTimeout(async () => {
|
||||
})()\`);
|
||||
check('Queue filter reset clears every filter and updates the stable active count', queueFilterReset.before.hidden === false && queueFilterReset.before.disabled === false && queueFilterReset.before.count === '4' && queueFilterReset.before.active === true && queueFilterReset.after.hidden === false && queueFilterReset.after.disabled === true && queueFilterReset.after.count === '0' && queueFilterReset.after.active === false && queueFilterReset.after.sidebar === 'all' && queueFilterReset.after.search === '' && queueFilterReset.after.hoster === '' && queueFilterReset.after.status === '' && queueFilterReset.after.allPressed === 'true' && queueFilterReset.after.visible === 'filter-a|filter-b');
|
||||
|
||||
const batchCompletionSummary = await wc.executeJavaScript(\`(async () => {
|
||||
setUiLanguage('en');
|
||||
queueJobs = [{ id: 'batch-error', file: 'C:/ui/error.bin', fileName: 'error.bin', hoster: 'byse.sx', status: 'error', error: 'Network failure', bytesUploaded: 0, bytesTotal: 100, progress: 0 }];
|
||||
rebuildJobIndex();
|
||||
renderQueueTable();
|
||||
showBatchCompletionSummary({ total: 1237, succeeded: 1234, failed: 1, skipped: 2, durationSec: 754 });
|
||||
await new Promise(resolve => requestAnimationFrame(resolve));
|
||||
const toast = document.getElementById('batchCompletionToast');
|
||||
const before = {
|
||||
hidden: toast.hidden,
|
||||
shown: toast.classList.contains('show'),
|
||||
text: document.getElementById('batchCompletionText').textContent,
|
||||
actionHidden: document.getElementById('batchCompletionShowErrors').hidden
|
||||
};
|
||||
document.getElementById('batchCompletionShowErrors').click();
|
||||
const after = { filter: uploadSidebarFilter, shown: toast.classList.contains('show') };
|
||||
setUiLanguage('de');
|
||||
queueJobs = [];
|
||||
rebuildJobIndex();
|
||||
setUploadSidebarFilter('all');
|
||||
return { before, after };
|
||||
})()\`);
|
||||
check('Batch completion summarizes results and opens the failed upload filter', batchCompletionSummary.before.hidden === false && batchCompletionSummary.before.shown === true && batchCompletionSummary.before.text === '1,234 successful · 1 failed · 2 skipped · 13 min' && batchCompletionSummary.before.actionHidden === false && batchCompletionSummary.after.filter === 'error' && batchCompletionSummary.after.shown === false);
|
||||
|
||||
const queueSelectionAnchor = await wc.executeJavaScript(\`(() => {
|
||||
queueJobs = ['a', 'b', 'c', 'd'].map(id => ({ id: 'anchor-' + id, file: 'C:/ui/anchor-' + id + '.bin', fileName: 'anchor-' + id + '.bin', hoster: 'byse.sx', status: 'queued', bytesUploaded: 0, bytesTotal: 100, progress: 0 }));
|
||||
selectedJobIds.clear();
|
||||
|
||||
@@ -159,6 +159,8 @@ describe('UploadManager', () => {
|
||||
assert.equal(summary.total, 2);
|
||||
assert.equal(summary.succeeded, 2);
|
||||
assert.equal(summary.failed, 0);
|
||||
assert.equal(Number.isInteger(summary.durationSec), true);
|
||||
assert.equal(summary.durationSec >= 0, true);
|
||||
assert.equal(summary.files.length, 2);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user