@@ -17,37 +17,6 @@ function initGridstack() {
1717 } ) ;
1818}
1919
20- function injectDeleteButtons ( ) {
21- document . querySelectorAll ( '.grid-stack-item' ) . forEach ( item => {
22-
23- if ( ! item . id || ! ALL_CARDS . includes ( item . id ) ) return ;
24-
25- if ( item . querySelector ( '.card-delete-btn' ) ) return ;
26-
27- const btn = document . createElement ( 'div' ) ;
28- btn . className = 'card-delete-btn' ;
29- btn . innerHTML = '🗑️' ;
30-
31- Object . assign ( btn . style , {
32- position : 'absolute' ,
33- top : '8px' ,
34- right : '8px' ,
35- cursor : 'pointer' ,
36- fontSize : '14px' ,
37- opacity : '0.7' ,
38- display : currentPw ? 'block' : 'none' ,
39- zIndex : 20
40- } ) ;
41-
42- btn . onclick = ( e ) => {
43- e . stopPropagation ( ) ;
44- removeCard ( item . id ) ;
45- } ;
46-
47- item . appendChild ( btn ) ;
48- } ) ;
49- }
50-
5120// 2. Layout speichern (Nur in DB und nur wenn PW da ist)
5221async function saveLayout ( ) {
5322 if ( ! dashboardGrid || ! currentPw || currentPw === "" ) {
@@ -116,118 +85,10 @@ async function resetDatabaseLayout() {
11685 }
11786}
11887
119- let removedCards = [ ] ;
120-
121- function removeCard ( cardId ) {
122- if ( ! currentPw ) return ;
123-
124- const el = document . getElementById ( cardId ) ;
125- if ( ! el ) return ;
126-
127- el . style . display = 'none' ;
128-
129- if ( ! removedCards . includes ( cardId ) ) {
130- removedCards . push ( cardId ) ;
131- }
132-
133- saveRemovedCards ( ) ;
134- updateAdminCardList ( ) ;
135- }
136-
137- function restoreCard ( cardId ) {
138- const el = document . getElementById ( cardId ) ;
139- if ( ! el ) return ;
140-
141- el . style . display = '' ;
142-
143- removedCards = removedCards . filter ( id => id !== cardId ) ;
144-
145- saveRemovedCards ( ) ;
146- updateAdminCardList ( ) ;
147- }
148-
149- async function loadRemovedCards ( ) {
150- const res = await fetch ( '/api/cards' ) ;
151- const data = await res . json ( ) ;
152-
153- removedCards = data . removed || [ ] ;
154-
155- removedCards . forEach ( id => {
156- const el = document . getElementById ( id ) ;
157- if ( el ) el . style . display = 'none' ;
158- } ) ;
159-
160- updateAdminCardList ( ) ;
161- }
162-
163- async function saveRemovedCards ( ) {
164- if ( ! currentPw ) return ;
165-
166- await fetch ( '/api/cards' , {
167- method : 'POST' ,
168- headers : { 'Content-Type' : 'application/json' } ,
169- body : JSON . stringify ( {
170- removed : removedCards ,
171- pw : currentPw
172- } )
173- } ) ;
174- }
175-
176- const ALL_CARDS = [
177- "card-total" ,
178- "card-live" ,
179- "card-main-chart" ,
180- "card-panel-chart" ,
181- "card-hourly-heatmap" ,
182- "card-donut-chart" ,
183- "card-records" ,
184- "card-roi" ,
185- "card-yearly-heatmap" ,
186- "card-forecast" ,
187- "card-shap-details" ,
188- "card-global-shap" ,
189- "card-feature-importance"
190- ] ;
191-
192- function updateAdminCardList ( ) {
193- const container = document . getElementById ( 'cardManagerList' ) ;
194- if ( ! container ) return ;
195-
196- container . innerHTML = '' ;
197-
198- ALL_CARDS . forEach ( id => {
199- const isRemoved = removedCards . includes ( id ) ;
200-
201- const row = document . createElement ( 'div' ) ;
202- row . style . display = 'flex' ;
203- row . style . justifyContent = 'space-between' ;
204- row . style . marginBottom = '6px' ;
205-
206- row . innerHTML = `
207- <span>${ id } </span>
208- <button onclick="${ isRemoved
209- ? `restoreCard('${ id } ')`
210- : `removeCard('${ id } ')` } ">
211- ${ isRemoved ? '➕' : '🗑️' }
212- </button>
213- ` ;
214-
215- container . appendChild ( row ) ;
216- } ) ;
217- }
218-
219- function toggleDeleteButtons ( show ) {
220- document . querySelectorAll ( '.card-delete-btn' ) . forEach ( btn => {
221- btn . style . display = show ? 'block' : 'none' ;
222- } ) ;
223- }
224-
22588document . addEventListener ( "DOMContentLoaded" , async ( ) => {
22689 // --- PHASE 1: Das Gerüst aufbauen ---
22790 initGridstack ( ) ;
22891 await loadLayout ( ) ; // Wartet, bis Boxen aus DB oder LocalStorage da sind
229- await loadRemovedCards ( ) ;
230- injectDeleteButtons ( ) ;
23192
23293 // --- PHASE 2: Startwerte für Datumsfelder setzen ---
23394 const t = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
0 commit comments