Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
2c499b363b
|
|||
39e2f2634d | |||
ffa6944e7b
|
|||
449dba1d7e
|
|||
b6d1367019
|
|||
2ff8757b74 | |||
7f06e900bb
|
|||
4c2338c34a
|
|||
5f8d49f054
|
|||
5cfba1c068 | |||
09a670727f | |||
f4a4597223
|
|||
70815f0172
|
|||
e4e8e19466 | |||
2228f0cfb5 | |||
24fb1c2941
|
|||
cc3a6381d5
|
|||
938562b9d8
|
|||
103d60764b
|
|||
8a446b8a8d
|
@ -7,7 +7,9 @@ COPY start.sh ${APP_DIR}/
|
|||||||
|
|
||||||
WORKDIR ${APP_DIR}
|
WORKDIR ${APP_DIR}
|
||||||
|
|
||||||
RUN pip install -r requirements.txt
|
RUN \
|
||||||
|
apk add --no-cache build-base libpq-dev && \
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
|
10
src/Run.py
10
src/Run.py
@ -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
|
||||||
@ -100,7 +99,7 @@ def add_lm():
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/add_nutrition', methods=['POST'])
|
@app.route('/add_nutrition', methods=['POST'])
|
||||||
@oidc.accept_token(require_token=True, scopes_required=['openid'])
|
@oidc.require_login
|
||||||
def add_nutrition():
|
def add_nutrition():
|
||||||
food = request.form.get('food')
|
food = request.form.get('food')
|
||||||
kcal = float(request.form.get('kcal'))
|
kcal = float(request.form.get('kcal'))
|
||||||
@ -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:
|
||||||
|
@ -13,6 +13,8 @@ itsdangerous==2.1.2
|
|||||||
Jinja2==3.1.3
|
Jinja2==3.1.3
|
||||||
MarkupSafe==2.1.4
|
MarkupSafe==2.1.4
|
||||||
packaging==23.2
|
packaging==23.2
|
||||||
|
psycopg==3.1.17
|
||||||
|
psycopg2==2.9.9
|
||||||
pycparser==2.21
|
pycparser==2.21
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
typing_extensions==4.9.0
|
typing_extensions==4.9.0
|
||||||
|
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,10 +4,9 @@
|
|||||||
<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>
|
||||||
|
|
||||||
// JavaScript-Funktion, um die Produkte beim Laden der Seite zu holen
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
cleanUpLocalStorage();
|
cleanUpLocalStorage();
|
||||||
restoreTableFromLocalStorage();
|
restoreTableFromLocalStorage();
|
||||||
|
@ -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');
|
||||||
@ -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