Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
449dba1d7e
|
|||
b6d1367019
|
|||
2ff8757b74 | |||
7f06e900bb
|
|||
4c2338c34a
|
|||
5f8d49f054
|
|||
5cfba1c068 | |||
09a670727f | |||
f4a4597223
|
|||
70815f0172
|
|||
e4e8e19466 | |||
2228f0cfb5 |
@ -15,4 +15,3 @@ EXPOSE 8080
|
|||||||
|
|
||||||
CMD "./start.sh"
|
CMD "./start.sh"
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,15 +20,13 @@ app.config.update({
|
|||||||
oidc = OpenIDConnect(app)
|
oidc = OpenIDConnect(app)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def calculate_nutrition(food, weight):
|
def calculate_nutrition(food, weight):
|
||||||
try:
|
try:
|
||||||
conn = psycopg2.connect()
|
conn = psycopg2.connect()
|
||||||
|
|
||||||
with conn.cursor() as cursor:
|
with conn.cursor() as cursor:
|
||||||
# Abfrage der Nährwertdaten aus der Datenbank
|
# Abfrage der Nährwertdaten aus der Datenbank
|
||||||
cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = ?', (food,))
|
cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = %s', (food,))
|
||||||
|
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
|
|
||||||
@ -51,6 +49,7 @@ def calculate_nutrition(food, weight):
|
|||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Index-Route
|
# Index-Route
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@oidc.require_login
|
@oidc.require_login
|
||||||
@ -115,9 +114,10 @@ def add_nutrition():
|
|||||||
try:
|
try:
|
||||||
conn = psycopg2.connect()
|
conn = psycopg2.connect()
|
||||||
with conn.cursor() as cursor:
|
with conn.cursor() as cursor:
|
||||||
cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (%s, %s, %s, %s, %s, %s, %s)",
|
||||||
(food, kcal, ew, fett, kh, bst, ca))
|
(food, kcal, ew, fett, kh, bst, ca))
|
||||||
|
|
||||||
|
|
||||||
return redirect(url_for('nutrition'))
|
return redirect(url_for('nutrition'))
|
||||||
finally:
|
finally:
|
||||||
if conn:
|
if conn:
|
||||||
|
BIN
src/static/images/favicon.ico
Normal file
BIN
src/static/images/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -37,10 +37,17 @@ button#remove-button {
|
|||||||
background-color: #f443366f; /* Helles Rot */
|
background-color: #f443366f; /* Helles Rot */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button#remove-button:disabled {
|
||||||
|
background-color: #cccccc;
|
||||||
|
color: #666666;
|
||||||
|
}
|
||||||
|
|
||||||
button#remove-button:not(:disabled):hover {
|
button#remove-button:not(:disabled):hover {
|
||||||
background-color: #d32f2f3d; /* Dunkleres Rot */
|
background-color: #d32f2f3d; /* Dunkleres Rot */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
@ -121,3 +128,27 @@ tr:hover:not(.selected) {
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#nutrition-input-table {
|
||||||
|
width: 100%; /* Tabelle nimmt die volle Breite ein */
|
||||||
|
border-collapse: collapse; /* Entfernt doppelte Ränder */
|
||||||
|
}
|
||||||
|
|
||||||
|
#nutrition-input-table th, #nutrition-input-table td {
|
||||||
|
border: 1px solid #ddd; /* Fügt Ränder hinzu */
|
||||||
|
padding: 8px; /* Fügt Innenabstand hinzu */
|
||||||
|
text-align: left; /* Ausrichtung des Textes */
|
||||||
|
}
|
||||||
|
|
||||||
|
#nutrition-input-table input {
|
||||||
|
width: 100%; /* Eingabefelder nehmen die volle Breite der Zelle ein */
|
||||||
|
box-sizing: border-box; /* Box-Modell für die Breitenberechnung */
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
#nutrition-input-table {
|
||||||
|
display: block;
|
||||||
|
overflow-x: auto; /* Ermöglicht horizontales Scrollen auf kleinen Bildschirmen */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Nährwertberechnungs-App</title>
|
<title>Nährwertberechnungs-App</title>
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||||
|
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Neue Lebensmittel hinzufügen</title>
|
<title>Neue Lebensmittel hinzufügen</title>
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||||
|
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function updateSubmitButtonState() {
|
function updateSubmitButtonState() {
|
||||||
const inputs = document.querySelectorAll('#nutrition-form input');
|
const inputs = document.querySelectorAll('#nutrition-form input');
|
||||||
@ -36,7 +38,7 @@
|
|||||||
|
|
||||||
// Deaktiviere den "Hinzufügen"-Button wieder
|
// Deaktiviere den "Hinzufügen"-Button wieder
|
||||||
document.getElementById('submit-button').disabled = true;
|
document.getElementById('submit-button').disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@ -62,13 +64,13 @@
|
|||||||
<th>CA</th>
|
<th>CA</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="text" name="food" oninput="updateSubmitButtonState()"></td>
|
<td><input type="text" name="food" placeholder="Lebensmittel" oninput="updateSubmitButtonState()"></td>
|
||||||
<td><input <input type="text" name="kcal" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
<td><input <input type="text" name="kcal" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||||
<td><input <input type="text" name="ew" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
<td><input <input type="text" name="ew" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||||
<td><input <input type="text" name="fett" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
<td><input <input type="text" name="fett" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||||
<td><input <input type="text" name="kh" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
<td><input <input type="text" name="kh" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||||
<td><input <input type="text" name="bst" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
<td><input <input type="text" name="bst" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||||
<td><input <input type="text" name="ca" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
<td><input <input type="text" name="ca" pattern="\d+(\.\d{1,2})?" placeholder="mg" oninput="updateSubmitButtonState()"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
||||||
|
Reference in New Issue
Block a user