Skip to content

Commit 3c6489a

Browse files
author
jacquesbach
committed
Layout Reset Button
1 parent b033560 commit 3c6489a

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

static/js/layout.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ async function loadLayout() {
8080
dashboardGrid.load(savedLayout);
8181
console.log("Layout sauber neu geladen.");
8282
}
83+
84+
85+
}
86+
87+
async function resetDatabaseLayout() {
88+
if (!confirm("Möchtest du das Layout wirklich auf Standard zurücksetzen?")) return;
89+
90+
const storedPw = sessionStorage.getItem('admin_pw');
91+
if (!storedPw) return alert("Bitte erst einloggen!");
92+
93+
// Wir senden ein leeres Array oder null, damit der Server es löscht/leert
94+
await fetch('/api/layout', {
95+
method: 'POST',
96+
headers: { 'Content-Type': 'application/json' },
97+
body: JSON.stringify({
98+
layout: [], // Leeres Layout erzwingen
99+
pw: storedPw
100+
})
101+
});
102+
location.reload();
83103
}
84104

85105
document.addEventListener("DOMContentLoaded", async () => {

templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ <h1>
8181
<button class="btn-primary" onclick="savePrice()" style="padding: 8px 15px;">+</button>
8282
</div>
8383
</div>
84+
<button class="btn-secondary" id="unlockBtn" onclick="resetDatabaseLayout()"> Layout zurücksetzen </button>
8485
</div>
8586
</div>
8687

0 commit comments

Comments
 (0)