Skip to content

Commit 7c5a1e6

Browse files
author
wlanboy
committed
delete für einzelne history einträge
1 parent ef8b49c commit 7c5a1e6

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

src/main/resources/public/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@
6868
.diagnostic-card {
6969
border-left: 5px solid var(--istio-blue);
7070
}
71+
72+
.cursor-pointer {
73+
cursor: pointer;
74+
}
75+
76+
.delete-history-item:hover {
77+
color: #dc3545 !important;
78+
transform: scale(1.2);
79+
}
7180
</style>
7281
</head>
7382

src/main/resources/public/js/http-client.js

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,48 @@ document.addEventListener('DOMContentLoaded', () => {
181181
function renderHistory() {
182182
emptyHistoryMsg.style.display = requestHistory.length ? 'none' : 'block';
183183
historyList.innerHTML = '';
184-
requestHistory.forEach(entry => {
184+
185+
requestHistory.forEach((entry) => {
185186
const isErr = entry.status >= 400 || entry.status === 0;
186-
const item = document.createElement('button');
187-
item.className = `list-group-item list-group-item-action border-start border-4 ${isErr ? 'border-danger' : 'border-success'}`;
187+
const item = document.createElement('div');
188+
item.className = `list-group-item list-group-item-action border-start border-4 ${isErr ? 'border-danger' : 'border-success'} d-flex align-items-center p-0`;
189+
188190
item.innerHTML = `
189-
<div class="d-flex justify-content-between"><strong>${entry.payload.method}</strong><small>${entry.time}</small></div>
190-
<div class="text-truncate small">${entry.payload.url}</div>
191-
<div class="mt-1"><span class="badge ${isErr ? 'bg-danger' : 'bg-success'}">${entry.status}</span> <small>${entry.duration}ms</small></div>
192-
`;
193-
item.onclick = () => restoreEntry(entry);
191+
<div class="flex-grow-1 p-2 cursor-pointer">
192+
<div class="d-flex justify-content-between">
193+
<strong class="small">${entry.payload.method}</strong>
194+
<small class="text-muted" style="font-size: 0.7rem;">${entry.time}</small>
195+
</div>
196+
<div class="text-truncate x-small text-muted" style="max-width: 180px;">${entry.payload.url}</div>
197+
<div class="mt-1">
198+
<span class="badge ${isErr ? 'bg-danger' : 'bg-success'}" style="font-size: 0.65rem;">${entry.status}</span>
199+
<small class="x-small">${entry.duration}ms</small>
200+
</div>
201+
</div>
202+
<button class="btn btn-sm text-danger opacity-50 px-2 delete-history-item" title="Löschen">
203+
<i class="bi bi-trash"></i>✕
204+
</button>
205+
`;
206+
207+
item.querySelector('.flex-grow-1').onclick = () => restoreEntry(entry);
208+
209+
item.querySelector('.delete-history-item').onclick = (e) => {
210+
e.preventDefault();
211+
e.stopPropagation();
212+
deleteSingleHistoryItem(entry.id);
213+
};
214+
194215
historyList.appendChild(item);
195216
});
196217
}
197218

219+
function deleteSingleHistoryItem(entryId) {
220+
requestHistory = requestHistory.filter(item => item.id !== entryId);
221+
222+
saveHistoryToStorage();
223+
renderHistory();
224+
}
225+
198226
function restoreEntry(entry) {
199227
document.getElementById('url').value = entry.payload.url;
200228
document.getElementById('method').value = entry.payload.method;
@@ -228,8 +256,6 @@ document.addEventListener('DOMContentLoaded', () => {
228256
downloadAnchor.remove();
229257
}
230258

231-
// --- NEUE STORAGE FUNKTIONEN ---
232-
233259
function saveHistoryToStorage() {
234260
try {
235261
localStorage.setItem(STORAGE_KEY, JSON.stringify(requestHistory));

0 commit comments

Comments
 (0)