Skip to content

Commit 59bcab2

Browse files
SoquixximDarshanGK
andauthored
feat(frontend): add per-item delete for history and favorites (imDarshanGK#1124)
Co-authored-by: Darshan G K <122042809+imDarshanGK@users.noreply.github.com>
1 parent 5eb68cc commit 59bcab2

1 file changed

Lines changed: 98 additions & 2 deletions

File tree

frontend/index.html

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,32 @@
18091809
background: var(--bg3);
18101810
border-color: var(--border2);
18111811
}
1812-
1812+
1813+
/* Delete button */
1814+
.delete-btn {
1815+
border: none;
1816+
outline: none;
1817+
box-shadow: none;
1818+
background: transparent;
1819+
color: var(--text-3);
1820+
cursor: pointer;
1821+
padding: 4px;
1822+
margin-left: 8px;
1823+
border-radius: 6px;
1824+
display: flex;
1825+
align-items: center;
1826+
justify-content: center;
1827+
transition: all var(--transition);
1828+
}
1829+
.delete-btn:focus,
1830+
.delete-btn:focus-visible {
1831+
outline: none;
1832+
box-shadow: none;
1833+
}
1834+
.delete-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.12);
1835+
}
1836+
.delete-btn svg { width: 16px; height: 16px;
1837+
}
18131838
.history-thumb {
18141839
font-family: var(--font-mono);
18151840
font-size: 0.72rem;
@@ -3422,6 +3447,7 @@ <h1 data-i18n="hero_title">Debug. Understand.<br><em>Ship faster.</em></h1>
34223447
return { response, baseUsed: normalizedBase, fallbackUsed: false };
34233448
} catch (err) {
34243449
const fallbackBase = getApiFallbackBase(normalizedBase);
3450+
34253451
if (!fallbackBase) throw err;
34263452
const response = await fetch(`${fallbackBase}${path}`, options);
34273453
return { response, baseUsed: fallbackBase, fallbackUsed: true };
@@ -3816,7 +3842,6 @@ <h1 data-i18n="hero_title">Debug. Understand.<br><em>Ship faster.</em></h1>
38163842
const err = await res.json().catch(() => ({}));
38173843
throw new Error(err.detail || `HTTP ${res.status}`);
38183844
}
3819-
38203845
const data = await res.json();
38213846
currentResult = data;
38223847
renderZipResults(data);
@@ -3871,6 +3896,7 @@ <h1 data-i18n="hero_title">Debug. Understand.<br><em>Ship faster.</em></h1>
38713896

38723897
} catch (err) {
38733898
toast(getTranslation('toast_analysis_failed').replace('{message}', err.message), 'error');
3899+
38743900
resetResults();
38753901
} finally {
38763902
analyzeBtn.classList.remove('loading');
@@ -4498,6 +4524,22 @@ <h3>Project Health Score</h3>
44984524
loadLocalHistory();
44994525
}
45004526

4527+
async function confirmDeleteHistory(id) {
4528+
4529+
if(!confirm("Delete this history entry?")) return;
4530+
const apiBase = getApiBase();
4531+
4532+
const res = await fetch(`${apiBase}/history/${id}`,{
4533+
method: "DELETE"
4534+
});
4535+
4536+
if(res.ok) {
4537+
fetchHistory();
4538+
} else {
4539+
toast("Failed to delete entry","error");
4540+
}
4541+
}
4542+
45014543
function loadLocalHistory() {
45024544
let localHistory = JSON.parse(localStorage.getItem('qyx_history') || '[]');
45034545

@@ -4605,6 +4647,28 @@ <h3>Project Health Score</h3>
46054647
${issuesHtml}
46064648
</div>
46074649
<span class="history-meta">${displayTime}</span>
4650+
<button
4651+
class="delete-btn"
4652+
onclick="event.stopPropagation(); confirmDeleteHistory('${h.id}')"
4653+
title="Delete entry"
4654+
aria-label="Delete entry">
4655+
<svg
4656+
xmlns="http://www.w3.org/2000/svg"
4657+
width="16"
4658+
height="16"
4659+
viewBox=" 0 0 24 24"
4660+
fill="none"
4661+
stroke="currentColor"
4662+
stroke-width="2"
4663+
stroke-linecap="round"
4664+
stroke-linejoin="round">
4665+
<polyline points="3 6 5 6 21 6"></polyline>
4666+
<path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"></path>
4667+
<path d="M10 11v6"></path>
4668+
<path d="M14 11v6"></path>
4669+
<path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"></path>
4670+
</svg>
4671+
</button>
46084672
</div>`;
46094673
}).join('');
46104674
}
@@ -4840,10 +4904,42 @@ <h3>Project Health Score</h3>
48404904
${issuesHtml}
48414905
</div>
48424906
<span class="history-meta" style="opacity:0.5"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg></span>
4907+
<button class="delete-btn" onclick="event.stopPropagation(); confirmDeleteFavorite('${f.id}')"
4908+
title="Delete favorite" aria-label="Delete favorite">
4909+
<svg
4910+
xmlns="http://www.w3.org/2000/svg"
4911+
width="16"
4912+
height="16"
4913+
viewBox=" 0 0 24 24"
4914+
fill="none"
4915+
stroke="currentColor"
4916+
stroke-width="2"
4917+
stroke-linecap="round"
4918+
stroke-linejoin="round">
4919+
<polyline points="3 6 5 6 21 6"></polyline>
4920+
<path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"></path>
4921+
<path d="M10 11v6"></path>
4922+
<path d="M14 11v6"></path>
4923+
<path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"></path>
4924+
</svg>
4925+
</button>
48434926
</div>`;
48444927
}).join('');
48454928
}
48464929

4930+
async function confirmDeleteFavorite(id) {
4931+
if(!confirm("Delete this favorite?")) return;
4932+
4933+
const normalizedId = Number(id);
4934+
4935+
favorites = favorites.filter(f => f.id !== normalizedId);
4936+
localStorage.setItem("qyx_favorites",
4937+
JSON.stringify(favorites));
4938+
4939+
renderFavorites();
4940+
4941+
}
4942+
48474943
document.getElementById('clearFavsBtn').addEventListener('click', () => {
48484944
if (!confirm(getTranslation('confirm_clear_favs'))) return;
48494945

0 commit comments

Comments
 (0)