feat: add 'Hide upgrade failures' checkbox to history controls
Build and Push Docker Image / build (push) Successful in 36s
CI / Security audit (push) Successful in 1m27s
CI / Tests & coverage (push) Successful in 1m43s

This commit is contained in:
2026-05-17 22:52:55 +01:00
parent 55a5577f2a
commit 19b9c97e64
3 changed files with 39 additions and 3 deletions
+19 -3
View File
@@ -9,6 +9,8 @@ const SPLASH_MIN_MS = 1200; // minimum splash display time
let historyDays = parseInt(localStorage.getItem('sofarr-history-days'), 10) || 7;
let historyRefreshHandle = null;
const HISTORY_REFRESH_MS = 5 * 60 * 1000; // auto-refresh history every 5 min
let ignoreAvailable = localStorage.getItem('sofarr-ignore-available') === 'true';
let lastHistoryItems = []; // raw items from last fetch, for re-filtering without a network round-trip
// SSE stream state
let sseSource = null;
@@ -869,6 +871,7 @@ function hideLoading() {
function initHistoryControls() {
const daysInput = document.getElementById('history-days');
const refreshBtn = document.getElementById('history-refresh-btn');
const ignoreToggle = document.getElementById('ignore-available-toggle');
if (daysInput) {
daysInput.addEventListener('change', () => {
const v = parseInt(daysInput.value, 10);
@@ -882,6 +885,14 @@ function initHistoryControls() {
if (refreshBtn) {
refreshBtn.addEventListener('click', () => loadHistory(true));
}
if (ignoreToggle) {
ignoreToggle.checked = ignoreAvailable;
ignoreToggle.addEventListener('change', () => {
ignoreAvailable = ignoreToggle.checked;
localStorage.setItem('sofarr-ignore-available', ignoreAvailable);
renderHistory(lastHistoryItems);
});
}
}
function startHistoryRefresh() {
@@ -897,6 +908,7 @@ function stopHistoryRefresh() {
}
function clearHistory() {
lastHistoryItems = [];
document.getElementById('history-list').innerHTML = '';
document.getElementById('no-history').style.display = 'none';
document.getElementById('history-error').style.display = 'none';
@@ -920,7 +932,8 @@ async function loadHistory(forceRefresh = false) {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
loadingEl.style.display = 'none';
renderHistory(data.history || []);
lastHistoryItems = data.history || [];
renderHistory(lastHistoryItems);
} catch (err) {
loadingEl.style.display = 'none';
errorEl.textContent = 'Failed to load history.';
@@ -933,12 +946,15 @@ function renderHistory(items) {
const listEl = document.getElementById('history-list');
const noHistoryEl = document.getElementById('no-history');
listEl.innerHTML = '';
if (!items.length) {
const visible = ignoreAvailable
? items.filter(item => !(item.outcome === 'failed' && item.availableForUpgrade))
: items;
if (!visible.length) {
noHistoryEl.style.display = 'block';
return;
}
noHistoryEl.style.display = 'none';
items.forEach(item => listEl.appendChild(createHistoryCard(item)));
visible.forEach(item => listEl.appendChild(createHistoryCard(item)));
}
function createHistoryCard(item) {