18 Commits
0.3.1 ... 0.4.1

Author SHA1 Message Date
5e4ab261a7 change
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-04-04 13:41:43 +02:00
14227f0058 cahnge
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 13:37:36 +02:00
ed62772643 label
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 13:32:22 +02:00
43b74dc3c2 style
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 13:29:03 +02:00
1643aa65d4 change
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 13:24:33 +02:00
a44b0ecf58 bug
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 13:14:04 +02:00
0f3ff65605 local storage
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 13:09:13 +02:00
32df39efb8 bug
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 13:03:25 +02:00
b85b7957c6 change
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:53:05 +02:00
bee94df6e6 change table
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:46:24 +02:00
79cf147345 change table
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:41:41 +02:00
c9d50b6018 missing var
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:34:51 +02:00
8d853a8a43 protion option
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:30:18 +02:00
3e6d743fd4 back
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:25:51 +02:00
888f8717b5 revert
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:19:23 +02:00
eddd739c71 commented out
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:15:35 +02:00
7213cb4757 no scan
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-04 12:08:16 +02:00
204e2e4dd7 portion option
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-04-03 22:06:15 +02:00
4 changed files with 89 additions and 18 deletions

View File

@ -17,10 +17,10 @@ steps:
when:
- event: [push, tag]
scan_image:
image: aquasec/trivy
commands:
- trivy image $FORGE_NAME/$CI_REPO:$CI_COMMIT_SHA --quiet --exit-code 1
# scan_image:
# image: aquasec/trivy
# commands:
# - trivy image $FORGE_NAME/$CI_REPO:$CI_COMMIT_SHA --quiet --exit-code 1
deploytest:
image: portainer/kubectl-shell:latest

View File

@ -6,6 +6,7 @@ import os
import json
import psycopg2
import logging
from math import ceil
app = Flask(__name__)
app.config.update({

View File

@ -231,4 +231,13 @@ button#cancel-button:disabled {
button#cancel-button:not(:disabled):hover {
background-color: #490000; /* Dunkleres Rot */
}
}
.form-layout {
display: flex;
flex-direction: column;
}
.form-row {
margin-bottom: 10px;
}

View File

@ -32,6 +32,49 @@
});
});
function recalculateTableBasedOnPortions() {
const portions = parseInt(document.getElementById('portions').value, 10) || 1;
let entries = JSON.parse(localStorage.getItem('nutritionEntries')) || [];
entries.forEach((entry, index) => {
const newWeight = Math.ceil(entry.weight / portions);
// Da die Server-Anfrage möglicherweise nicht sofort antwortet, passen wir den Index an, um die korrekte Zeile zu aktualisieren.
fetchUpdatedNutrition(entry.food, newWeight, index + 1); // +1, um den Kopfzeilenindex zu überspringen
});
}
function fetchUpdatedNutrition(food, weight, rowIndex) {
fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
.then(response => response.json())
.then(data => {
// Direktes Aktualisieren der Zeile mit den neuen Daten
const table = document.getElementById('nutrition-table');
if (table.rows[rowIndex]) {
updateRowWithNewData(table.rows[rowIndex], weight, data);
}
updateTotalNutrition(); // Aktualisiert die Gesamtnährwerte
})
.catch(error => {
console.error('Fehler:', error);
// Behandlung spezifischer Fehler, z.B. Zurücksetzen der Werte oder Anzeigen einer Fehlermeldung
});
}
function updateRowWithNewData(row, weight, nutritionData) {
if (nutritionData && row.cells.length > 7) {
row.cells[1].innerText = weight; // Aktualisiere Gewicht
row.cells[2].innerText = nutritionData.kcal;
row.cells[3].innerText = nutritionData.ew;
row.cells[4].innerText = nutritionData.fett;
row.cells[5].innerText = nutritionData.kh;
row.cells[6].innerText = nutritionData.bst;
row.cells[7].innerText = nutritionData.ca;
} else {
// Fehlerbehandlung, falls die Datenstruktur nicht wie erwartet ist
console.error('Unvollständige Daten erhalten: ', nutritionData);
}
}
function restoreTableFromLocalStorage() {
let entries = JSON.parse(localStorage.getItem('nutritionEntries')) || [];
let oneHourAgo = new Date().getTime() - (60 * 60 * 1000);
@ -94,10 +137,14 @@
}
function removeEntryFromLocalStorage(rowData) {
let entries = JSON.parse(localStorage.getItem('nutritionEntries')) || [];
entries = entries.filter(entry => entry.food !== rowData.food || entry.weight !== rowData.weight);
localStorage.setItem('nutritionEntries', JSON.stringify(entries));
}
let entries = JSON.parse(localStorage.getItem('nutritionEntries')) || [];
// Konvertieren von rowData.weight in eine Zahl, um eine korrekte Vergleichsbasis zu schaffen
const weightToCompare = parseFloat(rowData.weight);
// Verwendung einer strikten Gleichheitsprüfung für beide Werte
entries = entries.filter(entry => entry.food !== rowData.food || parseFloat(entry.weight) !== weightToCompare);
localStorage.setItem('nutritionEntries', JSON.stringify(entries));
}
function updateRemoveButtonState() {
const selectedRows = document.querySelectorAll('#nutrition-table .selected').length;
@ -111,11 +158,18 @@
document.getElementById('submit-button').disabled = !(food && weight);
}
function addProduct() {
const foodInput = document.getElementById('my_combobox');
const weightInput = document.getElementById('weight');
const portionsInput = document.getElementById('portions');
const food = foodInput.value;
const weight = weightInput.value;
let weight = parseFloat(weightInput.value);
const portions = portionsInput.value ? parseInt(portionsInput.value, 10) : 1;
// Teilen des Gewichts durch die Anzahl der Portionen und Aufrunden
weight = Math.ceil(weight / portions);
fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
@ -187,15 +241,22 @@ function updateTotalNutrition() {
<div class="content">
<form onsubmit="event.preventDefault(); addProduct();" id="product-form">
<label for="my_combobox">Wählen Sie ein Lebensmittel</label>
<input list="products" name="my_combobox" id="my_combobox" placeholder="Lebensmittel" oninput="updateButtonState()" autocomplete="off">
<datalist id="products">
<!-- Produkte werden hier dynamisch eingefügt -->
</datalist>
<input type="number" id="weight" name="weight" placeholder="Gramm" oninput="updateButtonState()">
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
<form onsubmit="event.preventDefault(); addProduct();" id="product-form" class="form-layout">
<div class="form-row">
<label for="portions">Wählen Sie die Anzahl an Portionen</label>
<input type="number" id="portions" name="portions" placeholder="Portionen" min="1" value="1" oninput="recalculateTableBasedOnPortions()">
</div>
<div class="form-row">
<label for="my_combobox">Wählen Sie ein Lebensmittel</label>
<input list="products" name="my_combobox" id="my_combobox" placeholder="Lebensmittel" oninput="updateButtonState()" autocomplete="off">
<datalist id="products">
<!-- Produkte werden hier dynamisch eingefügt -->
</datalist>
<input type="number" id="weight" name="weight" placeholder="Gramm" oninput="updateButtonState()">
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
</div>
</form>
<table id="nutrition-table">
<tr>