diff --git a/Dockerfile b/Dockerfile index d0a1550..8805846 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ COPY start.sh ${APP_DIR}/ WORKDIR ${APP_DIR} RUN \ - apk add --no-cache build-base libpq-dev && \ + apk add --no-cache build-base libpq-dev npm && \ pip install --upgrade pip && \ pip install -r requirements.txt && \ if [ "${VERSION_ID2}" != "" ]; then VERSION_ID=${VERSION_ID2}; else VERSION_ID=${VERSION_ID1}; fi && \ diff --git a/src/templates/nutrition.html b/src/templates/nutrition.html index 8b2c1f6..2067d3b 100644 --- a/src/templates/nutrition.html +++ b/src/templates/nutrition.html @@ -130,26 +130,24 @@ function loadDatabaseEntries() { - fetch('/get_database_entries') // Pfad zur entsprechenden Flask-Route - .then(response => response.json()) - .then(data => { - const tableBody = document.getElementById('database-nutrition-table').getElementsByTagName('tbody')[0]; - tableBody.innerHTML = ''; - data.forEach(entry => { - const row = tableBody.insertRow(); - row.insertCell(0).innerHTML = entry.food; - row.insertCell(1).innerHTML = entry.kcal; - row.insertCell(2).innerHTML = entry.ew; - row.insertCell(3).innerHTML = entry.fett; - row.insertCell(4).innerHTML = entry.kh; - row.insertCell(5).innerHTML = entry.bst; - row.insertCell(6).innerHTML = entry.ca; + fetch('/get_database_entries') // Pfad zur entsprechenden Flask-Route + .then(response => response.json()) + .then(data => { + const tableBody = document.getElementById('database-nutrition-table').getElementsByTagName('tbody')[0]; + tableBody.innerHTML = ''; // Das Löschen ist hier in Ordnung, da wir nur den Inhalt entfernen + data.forEach(entry => { + const row = tableBody.insertRow(); + Object.keys(entry).forEach((key, index) => { + const cell = row.insertCell(index); + cell.innerText = entry[key]; // Verwendung von innerText statt innerHTML + }); + + // Kein Bedarf, die Kommentare zu wiederholen – die Methode ist selbsterklärend + }); + }) + .catch(error => console.error('Fehler:', error)); +} - // ... Fügen Sie weitere Zellen für die anderen Werte hinzu ... - }); - }) - .catch(error => console.error('Fehler:', error)); - } document.addEventListener('DOMContentLoaded', loadDatabaseEntries);