Skip to content

Commit c9c1e6d

Browse files
author
jacquesbach
committed
Changes
1 parent 3f7e537 commit c9c1e6d

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

static/js/layout.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ async function resetDatabaseLayout() {
118118
let removedCards = [];
119119

120120
function removeCard(cardId) {
121-
if (!currentPw) return alert("Nur im Admin-Modus möglich");
121+
if (!currentPw) return;
122122

123123
const el = document.getElementById(cardId);
124124
if (!el) return;
125125

126-
dashboardGrid.removeWidget(el);
126+
el.style.display = 'none';
127127

128128
if (!removedCards.includes(cardId)) {
129129
removedCards.push(cardId);
@@ -134,13 +134,10 @@ function removeCard(cardId) {
134134
}
135135

136136
function restoreCard(cardId) {
137-
if (!currentPw) return;
138-
139137
const el = document.getElementById(cardId);
138+
if (!el) return;
140139

141-
if (el) {
142-
dashboardGrid.addWidget(el);
143-
}
140+
el.style.display = '';
144141

145142
removedCards = removedCards.filter(id => id !== cardId);
146143

@@ -156,7 +153,7 @@ async function loadRemovedCards() {
156153

157154
removedCards.forEach(id => {
158155
const el = document.getElementById(id);
159-
if (el) dashboardGrid.removeWidget(el);
156+
if (el) el.style.display = 'none';
160157
});
161158

162159
updateAdminCardList();
@@ -175,25 +172,41 @@ async function saveRemovedCards() {
175172
});
176173
}
177174

175+
const ALL_CARDS = [
176+
"card-total",
177+
"card-live",
178+
"card-main-chart",
179+
"card-panel-chart",
180+
"card-hourly-heatmap",
181+
"card-donut-chart",
182+
"card-records",
183+
"card-roi",
184+
"card-yearly-heatmap",
185+
"card-forecast",
186+
"card-shap-details",
187+
"card-global-shap",
188+
"card-feature-importance"
189+
];
190+
178191
function updateAdminCardList() {
179192
const container = document.getElementById('cardManagerList');
180193
if (!container) return;
181194

182195
container.innerHTML = '';
183196

184-
document.querySelectorAll('.grid-stack-item').forEach(el => {
185-
const id = el.id;
197+
ALL_CARDS.forEach(id => {
186198
const isRemoved = removedCards.includes(id);
187199

188200
const row = document.createElement('div');
189-
190201
row.style.display = 'flex';
191202
row.style.justifyContent = 'space-between';
192203
row.style.marginBottom = '6px';
193204

194205
row.innerHTML = `
195206
<span>${id}</span>
196-
<button onclick="${isRemoved ? `restoreCard('${id}')` : `removeCard('${id}')`}">
207+
<button onclick="${isRemoved
208+
? `restoreCard('${id}')`
209+
: `removeCard('${id}')`}">
197210
${isRemoved ? '➕' : '🗑️'}
198211
</button>
199212
`;

0 commit comments

Comments
 (0)