@@ -19,8 +19,10 @@ document.addEventListener('DOMContentLoaded', () => {
1919 const exportHistoryBtn = document . getElementById ( 'exportHistoryBtn' ) ;
2020
2121 let requestHistory = [ ] ;
22+ const STORAGE_KEY = 'k8s_http_client_history' ;
2223
2324 // --- INITIALISIERUNG ---
25+ loadHistoryFromStorage ( ) ;
2426 addHeaderRow ( 'Content-Type' , 'application/json' ) ;
2527
2628 // --- EVENT LISTENER ---
@@ -36,9 +38,11 @@ document.addEventListener('DOMContentLoaded', () => {
3638 }
3739
3840 clearHistoryBtn . addEventListener ( 'click' , ( ) => {
39- requestHistory = [ ] ;
40- renderHistory ( ) ;
41- emptyHistoryMsg . style . display = 'block' ;
41+ if ( confirm ( "Möchtest du die gesamte Historie wirklich löschen?" ) ) {
42+ requestHistory = [ ] ;
43+ saveHistoryToStorage ( ) ;
44+ renderHistory ( ) ;
45+ }
4246 } ) ;
4347
4448 exportHistoryBtn . addEventListener ( 'click' , exportHistoryToJson ) ;
@@ -136,7 +140,7 @@ document.addEventListener('DOMContentLoaded', () => {
136140 responseOutput . style . display = 'none' ;
137141 document . getElementById ( 'errorSummary' ) . innerText = lines [ 0 ] ;
138142 document . getElementById ( 'errorDetail' ) . innerText = lines [ 1 ] || "" ;
139-
143+
140144 stacktraceArea . innerText = stack . trim ( ) ;
141145 // Sicherstellen, dass er beim Laden des Fehlers erstmal zu ist
142146 stacktraceArea . style . display = 'none' ;
@@ -168,6 +172,9 @@ document.addEventListener('DOMContentLoaded', () => {
168172 payload, status, duration, responseData
169173 } ;
170174 requestHistory . unshift ( entry ) ;
175+ if ( requestHistory . length > 50 ) requestHistory . pop ( ) ;
176+
177+ saveHistoryToStorage ( ) ;
171178 renderHistory ( ) ;
172179 }
173180
@@ -199,7 +206,7 @@ document.addEventListener('DOMContentLoaded', () => {
199206
200207 resultArea . style . display = 'block' ;
201208 updateResponseMetadata ( entry . status , entry . duration ) ;
202-
209+
203210 const istioPanel = document . getElementById ( 'istioPanel' ) ;
204211 if ( istioPanel ) istioPanel . style . display = 'none' ;
205212
@@ -220,4 +227,27 @@ document.addEventListener('DOMContentLoaded', () => {
220227 downloadAnchor . click ( ) ;
221228 downloadAnchor . remove ( ) ;
222229 }
230+
231+ // --- NEUE STORAGE FUNKTIONEN ---
232+
233+ function saveHistoryToStorage ( ) {
234+ try {
235+ localStorage . setItem ( STORAGE_KEY , JSON . stringify ( requestHistory ) ) ;
236+ } catch ( e ) {
237+ console . error ( "Fehler beim Speichern im LocalStorage" , e ) ;
238+ }
239+ }
240+
241+ function loadHistoryFromStorage ( ) {
242+ try {
243+ const saved = localStorage . getItem ( STORAGE_KEY ) ;
244+ if ( saved ) {
245+ requestHistory = JSON . parse ( saved ) ;
246+ renderHistory ( ) ;
247+ }
248+ } catch ( e ) {
249+ console . error ( "Fehler beim Laden aus LocalStorage" , e ) ;
250+ requestHistory = [ ] ;
251+ }
252+ }
223253} ) ;
0 commit comments