64 Commits

Author SHA1 Message Date
845e4ec673 logging, 2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-31 14:46:18 +01:00
d82770158c logging
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-31 13:49:14 +01:00
3852d78725 table adjusted
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-31 13:43:21 +01:00
fd057e3415 token stuff, 4
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-31 13:15:03 +01:00
e4fe5b9831 token stuff, 3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-31 13:09:26 +01:00
6a9b938ab9 token stuff, 2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-31 13:03:04 +01:00
367e76f9f1 token stuff
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-31 12:47:35 +01:00
e59b184da5 style
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-30 23:11:29 +01:00
c318cd21e0 delete button
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 22:56:22 +01:00
224e6a9147 Merge branch 'main' of gitea.hottis.de:moerp/Elo-rezept-rechner
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 22:24:51 +01:00
8f15a05a4e more table 2024-01-30 22:24:48 +01:00
f0fcbc3c56 trigger pipeline
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 20:43:17 +01:00
1e8ae0105a to many row
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-30 19:38:49 +01:00
f39c902ace fail
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-30 19:15:48 +01:00
ff26644f06 fail
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 18:51:52 +01:00
5f63092a67 f
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 18:51:02 +01:00
1fc9dd70df Merge branch 'main' of gitea.hottis.de:moerp/Elo-rezept-rechner
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 18:48:08 +01:00
794b50e041 token 2024-01-30 18:47:57 +01:00
5583bc2b60 color 2024-01-30 18:44:45 +01:00
5f34449601 token
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-30 18:26:27 +01:00
8bc3857482 Merge branch 'main' of gitea.hottis.de:moerp/elo-rezept-rechner
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 18:19:14 +01:00
5c7fe128c8 token 2024-01-30 18:19:05 +01:00
3a17338358 Merge branch 'main' of gitea.hottis.de:moerp/Elo-rezept-rechner
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 18:08:15 +01:00
4761910092 changes 2024-01-30 18:07:16 +01:00
2c499b363b Merge branch 'main' of gitea.hottis.de:moerp/elo-rezept-rechner
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 17:03:14 +01:00
39e2f2634d small
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-30 17:03:00 +01:00
ffa6944e7b fix auth for add_nut... 2024-01-30 17:02:58 +01:00
449dba1d7e Merge branch 'main' of gitea.hottis.de:moerp/elo-rezept-rechner
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 16:56:03 +01:00
b6d1367019 test 2024-01-30 16:55:44 +01:00
2ff8757b74 style 2024-01-30 16:50:15 +01:00
7f06e900bb test 2024-01-30 16:27:16 +01:00
4c2338c34a test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-30 16:24:45 +01:00
5f8d49f054 test 2024-01-30 16:19:08 +01:00
5cfba1c068 favicon
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 15:52:49 +01:00
09a670727f favicon
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-30 15:50:39 +01:00
f4a4597223 start pipeline, 2 2024-01-30 15:49:37 +01:00
70815f0172 start pipeline 2024-01-30 15:49:06 +01:00
e4e8e19466 small cahnges
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2024-01-30 15:33:54 +01:00
2228f0cfb5 db fix 2024-01-30 15:29:46 +01:00
24fb1c2941 libpq, 3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 15:00:51 +01:00
cc3a6381d5 libpq 2024-01-30 14:59:46 +01:00
938562b9d8 requirements, 3
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-01-30 14:53:47 +01:00
103d60764b requirements, 2 2024-01-30 14:53:06 +01:00
8a446b8a8d requirements 2024-01-30 14:52:32 +01:00
5948cf3840 postgres, fix 3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 14:48:31 +01:00
63dbfcc89f postgres, fix 2 2024-01-30 14:47:36 +01:00
439f6085e7 postgres 2024-01-30 14:47:07 +01:00
21479212f8 fix 2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 14:18:52 +01:00
5d8997d45e fix 2024-01-30 14:16:59 +01:00
6e6effb1bc fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 14:07:42 +01:00
00d48b4de1 roles
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 14:00:41 +01:00
fc9cd70776 Merge branch 'main' of gitea.hottis.de:moerp/elo-rezept-rechner 2024-01-30 13:59:13 +01:00
8b9654370c roles 2024-01-30 13:59:02 +01:00
4471c140c1 placeholder 2024-01-30 13:53:30 +01:00
e87675dcbd fix namespace
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 13:41:59 +01:00
dc8d6d58e1 ci
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-30 13:35:17 +01:00
46826bfe09 nothing 2024-01-30 13:29:27 +01:00
6d26cb7f2b Merge branch 'main' of gitea.hottis.de:moerp/elo-rezept-rechner
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2024-01-30 13:11:21 +01:00
19b12308d0 ci 2024-01-30 13:10:40 +01:00
fd0ad5699b more csv 2024-01-30 13:06:22 +01:00
62a5531304 fix 2024-01-30 12:28:28 +01:00
e85fdab068 oidc 2024-01-30 12:27:39 +01:00
24ac825ed7 oidc 2024-01-30 12:27:28 +01:00
3c8d842e3b oidc added 2024-01-30 12:23:48 +01:00
15 changed files with 468 additions and 187 deletions

View File

@ -2,7 +2,7 @@ steps:
build:
image: plugins/kaniko
settings:
repo: gitea.hottis.de/wn/oidc-python-example
repo: gitea.hottis.de/moerp/elo-rezept-rechner
registry:
from_secret: container_registry
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
@ -30,3 +30,4 @@ steps:
- ./deployment/deploy.sh
when:
- event: tag

View File

@ -7,7 +7,9 @@ COPY start.sh ${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

View File

@ -1,25 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: oidc-python-example
name: nutri
labels:
app: oidc-python-example
app: nutri
spec:
replicas: 1
selector:
matchLabels:
app: oidc-python-example
app: nutri
template:
metadata:
labels:
app: oidc-python-example
app: nutri
spec:
containers:
- name: oidc-python-example
- name: nutri
image: %IMAGE%
envFrom:
- secretRef:
name: secrets
name: nutri-secrets
ports:
- containerPort: 8080
protocol: TCP
@ -27,11 +27,11 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: oidc-python-example
name: nutri
spec:
type: ClusterIP
selector:
app: oidc-python-example
app: nutri
ports:
- name: http
targetPort: 8080
@ -40,23 +40,23 @@ spec:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: oidc-python-example
name: nutri
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production-http
spec:
tls:
- hosts:
- oidc-python-example.hottis.de
secretName: oidc-python-example-cert
- nutri.hottis.de
secretName: nutri-cert
rules:
- host: oidc-python-example.hottis.de
- host: nutri.hottis.de
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: oidc-python-example
name: nutri
port:
number: 80

View File

@ -6,8 +6,8 @@ if [ "$IMAGE_TAG" == "" ]; then
fi
IMAGE_NAME=gitea.hottis.de/wn/oidc-python-example
NAMESPACE=oidc-python-example
IMAGE_NAME=gitea.hottis.de/moerp/elo-rezept-rechner
NAMESPACE=moerp
DEPLOYMENT_DIR=$PWD/deployment
pushd $DEPLOYMENT_DIR > /dev/null
@ -22,7 +22,7 @@ kubectl create namespace $NAMESPACE \
-o yaml | \
kubectl -f - apply
kubectl create secret generic secrets \
kubectl create secret generic nutri-secrets \
--dry-run=client \
-o yaml \
--save-config \

View File

@ -2,10 +2,10 @@
"web": {
"issuer": "https://auth2.hottis.de/realms/hottis",
"auth_uri": "https://auth2.hottis.de/ealms/hottis/protocol/openid-connect/auth",
"client_id": "oidc-python-example",
"client_id": "nutri",
"client_secret": "%CLIENT_SECRET%",
"redirect_uris": [
"https://oidc-python-example.hottis.de/*"
"https://nutri.hottis.de/*"
],
"userinfo_uri": "https://auth2.hottis.de/realms/hottis/protocol/openid-connect/userinfo",
"token_uri": "https://auth2.hottis.de/realms/hottis/protocol/openid-connect/token"

5
deployment/secrets.enc Normal file
View File

@ -0,0 +1,5 @@
U2FsdGVkX1/th2tFCYckNPvrVu7gmXIYlGBvSx8EWLNPbWTH61+dTDg6x6f7SFi5
n17zGVWBkfY2xr6uyHrvN8udF2dN6MTPccZITuEu9z66wtEHoiRQl1drA9og39yg
KTtwsbWeO7WSjA1DXoldNZgl0KKKHopw5d9ebZh7t1TRTd1sV4+tNOqqC+Z76vGQ
zV+KU8GUd4EpUY0CdxaWttGe59Igpj6fJXEWHJ9jMM5DcSx5wJHx6g8MnBLyahD1
pD/ru5bysLlQUEjlSIIr+A==

View File

@ -1,107 +1,81 @@
from flask import Flask, request, render_template, jsonify, redirect, url_for
from flask import Flask, request, render_template, jsonify, redirect, url_for, g
import sqlite3
from flask_oidc import OpenIDConnect
from werkzeug.middleware.proxy_fix import ProxyFix
import os
import json
import psycopg2
import logging
app = Flask(__name__)
app.config.update({
'SECRET_KEY': "fdsgffdgretfsdgfsf"
'SECRET_KEY': os.environ['SECRET'],
'DEBUG': False,
'OIDC_CLIENT_SECRETS': json.loads(os.environ['CLIENT_SECRETS']),
'OIDC_ID_TOKEN_COOKIE_SECURE': False,
'OIDC_USER_INFO_ENABLED': True,
'OIDC_OPENID_REALM': 'hottis',
'OIDC_SCOPES': ['openid', 'email', 'profile']
})
# Datenbankverbindung konfigurieren
def get_db_connection():
conn = sqlite3.connect('nutrition.db') # 'nutrition.db' ist der Name der Datenbankdatei
conn.row_factory = sqlite3.Row # Ermöglicht den Zugriff auf Daten durch Spaltennamen
return conn
def init_db():
conn = get_db_connection()
cursor = conn.cursor()
# Erstellen der Tabelle
cursor.execute('''
CREATE TABLE IF NOT EXISTS nutrition_table (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
kcal REAL,
EW REAL,
Fett REAL,
KH REAL,
BST REAL,
CA REAL
)
''')
# Testdaten einfügen
test_data = [
('Apfel', 52, 0.3, 0.2, 14, 0.2, 6),
('Banane', 89, 1.1, 0.3, 23, 0.3, 5),
('Karotte', 41, 0.9, 0.2, 10, 0.2, 3),
('Tomate', 18, 0.9, 0.2, 3.9, 0.2, 4),
('Brokkoli', 34, 2.8, 0.4, 6.6, 0.4, 2),
('Spinat', 23, 2.9, 0.4, 3.6, 0.4, 99),
('Kartoffel', 77, 2, 0.1, 17, 0.1, 12),
('Huhn', 239, 27, 14, 0, 0, 2),
('Lachs', 208, 20, 13, 0, 0, 1),
('Ei', 155, 13, 11, 1.1, 1, 1)
]
cursor.executemany('INSERT INTO nutrition_table (name, kcal, EW, Fett, KH, BST, CA) VALUES (?, ?, ?, ?, ?, ?, ?)', test_data)
conn.commit()
conn.close()
oidc = OpenIDConnect(app)
def calculate_nutrition(food, weight):
conn = get_db_connection()
cursor = conn.cursor()
try:
conn = psycopg2.connect()
# Abfrage der Nährwertdaten aus der Datenbank
cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = ?', (food,))
with conn.cursor() as cursor:
# Abfrage der Nährwertdaten aus der Datenbank
cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = %s', (food,))
result = cursor.fetchone()
conn.close()
result = cursor.fetchone()
if result:
# Runden und Berechnen der Nährwerte basierend auf dem Gewicht
kcal, ew, fett, kh, bst, ca = result
nutrition_values = [
round(kcal * weight / 100), # kcal gerundet auf ganze Zahl
round(ew * weight / 100, 1), # EW gerundet auf eine Dezimalstelle
round(fett * weight / 100, 1), # Fett gerundet auf eine Dezimalstelle
round(kh * weight / 100, 1), # KH gerundet auf eine Dezimalstelle
round(bst * weight / 100, 1), # BST gerundet auf eine Dezimalstelle
round(ca * weight / 100) # CA gerundet auf ganze Zahl
]
return nutrition_values
else:
return None
finally:
if conn:
conn.close()
if result:
# Runden und Berechnen der Nährwerte basierend auf dem Gewicht
kcal, ew, fett, kh, bst, ca = result
nutrition_values = [
round(kcal * weight / 100), # kcal gerundet auf ganze Zahl
round(ew * weight / 100, 1), # EW gerundet auf eine Dezimalstelle
round(fett * weight / 100, 1), # Fett gerundet auf eine Dezimalstelle
round(kh * weight / 100, 1), # KH gerundet auf eine Dezimalstelle
round(bst * weight / 100, 1), # BST gerundet auf eine Dezimalstelle
round(ca * weight / 100) # CA gerundet auf ganze Zahl
]
return nutrition_values
else:
return None
# Index-Route
@app.route('/')
@oidc.require_login
def index():
return render_template('index.html')
# ...
@app.route('/get_products')
@oidc.require_login
def get_products():
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute('SELECT name FROM nutrition_table')
products = cursor.fetchall()
conn.close()
print("ter")
return {'products': [product[0] for product in products]}
# ...
try:
conn = psycopg2.connect()
with conn.cursor() as cursor:
cursor.execute('SELECT name FROM nutrition_table')
products = cursor.fetchall()
return {'products': [product[0] for product in products]}
finally:
if conn:
conn.close()
# Route zum Hinzufügen und Berechnen von Lebensmitteln
@app.route('/add_lm', methods=['GET'])
@oidc.require_login
def add_lm():
food = request.args.get('food')
weight = float(request.args.get('weight'))
@ -123,38 +97,86 @@ def add_lm():
return "Lebensmittel nicht gefunden.", 404
def convert_decimal(value):
try:
return float(value.replace(',', '.'))
except (ValueError, TypeError):
return 0.0 # Rückgabe eines Standardwertes im Fehlerfall
@app.route('/add_nutrition', methods=['POST'])
@oidc.accept_token(['openid'])
def add_nutrition():
app.logger.info("add_nutrition")
food = request.form.get('food')
kcal = float(request.form.get('kcal'))
ew = float(request.form.get('ew'))
fett = float(request.form.get('fett'))
kh = float(request.form.get('kh'))
bst = float(request.form.get('bst'))
ca = float(request.form.get('ca'))
kcal = convert_decimal(request.form.get('kcal'))
ew = convert_decimal(request.form.get('ew'))
fett = convert_decimal(request.form.get('fett'))
kh = convert_decimal(request.form.get('kh'))
bst = convert_decimal(request.form.get('bst'))
ca = convert_decimal(request.form.get('ca'))
print("test")
# Verbindung zur Datenbank herstellen und Daten einfügen
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (?, ?, ?, ?, ?, ?, ?)",
(food, kcal, ew, fett, kh, bst, ca))
conn.commit()
conn.close()
return redirect(url_for('nutrition'))
try:
conn = psycopg2.connect()
with conn.cursor() as cursor:
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))
conn.commit()
return redirect(url_for('nutrition'))
except Exception as e:
app.logger.warn(f"error in add_nutrition: {e}")
return jsonify({"error": str(e)}), 500
finally:
if conn:
conn.close()
@app.route('/nutrition')
@oidc.require_login
def nutrition():
return render_template('nutrition.html')
@app.route('/get_token')
@oidc.require_login
def get_token():
return jsonify(token=oidc.get_access_token())
@app.route('/get_database_entries')
@oidc.require_login
def get_database_entries():
try:
# Ersetzen Sie diese Werte mit Ihren Datenbank-Verbindungsinformationen
conn = psycopg2.connect()
cursor = conn.cursor()
with conn.cursor() as cursor:
cursor.execute("SELECT name, kcal, ew, fett, kh, bst, ca FROM nutrition_table ORDER BY name")
entries = cursor.fetchall()
# Umwandeln der Daten in ein JSON-freundliches Format
entries_list = []
for entry in entries:
entries_list.append({
"food": entry[0],
"kcal": entry[1],
"ew": entry[2],
"fett": entry[3],
"kh": entry[4],
"bst": entry[5],
"ca": entry[6]
})
return jsonify(entries_list)
except Exception as e:
return jsonify({"error": str(e)}), 500
finally:
if conn:
conn.close()
app = ProxyFix(app, x_for=1, x_host=1)
if __name__ == '__main__':
#init_db()
app.run(debug=True)

View File

@ -1,26 +1,28 @@
import csv
import sqlite3
import psycopg2
# Pfad zur Ihrer CSV-Datei
csv_file_path = 'nu.csv'
# Pfad zur Ihrer SQLite-Datenbank
sqlite_db_path = 'nutrition.db'
# Verbindung zur SQLite-Datenbank herstellen
conn = sqlite3.connect(sqlite_db_path)
conn = psycopg2.connect()
cursor = conn.cursor()
# Erstellen der Tabelle (falls noch nicht vorhanden)
cursor.execute('''
CREATE TABLE IF NOT EXISTS nutrition_table (
name TEXT,
id serial not null,
name TEXT not null,
kcal REAL,
EW REAL,
Fett REAL,
KH REAL,
BST REAL,
Ca REAL
Ca REAL,
constraint nutrition_table_pk primary key (id),
constraint nutrition_table_name_uk unique (name)
)
''')
@ -29,8 +31,9 @@ with open(csv_file_path, newline='', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile)
next(reader, None) # Überspringen der Kopfzeile
for row in reader:
cursor.execute('INSERT INTO nutrition_table (name, kcal, EW, Fett, KH, BST, Ca) VALUES (?, ?, ?, ?, ?, ?, ?)', row)
cursor.execute('INSERT INTO nutrition_table (name, kcal, EW, Fett, KH, BST, Ca) VALUES (%s, %s, %s, %s, %s, %s, %s)', row)
# Änderungen speichern und Verbindung schließen
conn.commit()
conn.close()

View File

@ -1,12 +1,11 @@
name,kcal,EW,Fett,KH,BST,Ca
Zitronensaft,38,0.4,0.5,3.8,0.1,11
Zucker,405,0.0,0.0,100.0,0.0,2
Trinkmilch3.5,65,3.4,3.6,4.7,0.0,120
Hühnerei50,137,11.9,9.3,1.5,0.0,51
Trinkmilch 3.5%,65,3.4,3.6,4.7,0.0,120
Hühnerei,137,11.9,9.3,1.5,0.0,51
Pflanzenmargarine,722,0.2,80.0,0.4,0.0,8
Sahne30,309,2.4,31.7,3.4,0.0,80
Sahne 30%,309,2.4,31.7,3.4,0.0,80
Maisstärke,353,0.4,0.1,85.9,1.0,0
Paniermehl,368,10.1,2.1,73.5,5.3,50
Weizengrieß,335,9.6,0.8,69.0,7.1,17
Mehl405,343,9.8,1.0,71.8,4.0,15
Rapsöl,884,0,100.0,0,0,0
@ -18,11 +17,11 @@ Olivenöl,884,0,99.8,0.2,0,0
Möhre,39,0.8,0.2,6.8,3.6,21
Rote linsen,350,23.9,2.2,52.3,10.8,48
Gemüsebruhe verz,7,1.6,0,1,0,12
Rindfleisch keule,148,20.0,7.6,0,0,6
Rindfleisch Keule,148,20.0,7.6,0,0,6
Rinderbouillon,4,0.2,0,1,0,5
Meerettich iD,78,2.8,0.3,11.7,7.5,105
Saure sahne10,117,3.1,10.0,3.7,0,110
Joghurt3.5, 64,3.3,3.5,4.4,0,120
Saure sahne 10%,117,3.1,10.0,3.7,0,110
Joghurt 3.5%, 64,3.3,3.5,4.4,0,120
Dill,65,3.7,0.8,8.0,5.3,230
Schnittlauch,40,3.6,0.7,1.6,6.0,129
Gartenkresse,41,4.2,0.7,2.5,3.5,214
@ -37,29 +36,27 @@ Apfel,57,0.3,0.6,11.4,2.0,7
Kiwi grün,55,0.9,0.6,9.1,3.0,28
Banane,93,1.2,0.2,20.0,1.8,8
Schweinefleisch bug,217,17.0,16.5,0.0,0.0,9
Gouda48,370,22.7,29.9,0,0,811
Gouda 48%,370,22.7,29.9,0,0,811
Blumenkohl,28,2.5,0.3,2.3,2.9,22
Knoblauch,145,6.1,0.1,28.4,1.8,38
Senf,88,6.0,4.0,6.0,1.0,124
Blattspinat roh,21,2.7,0.3,0.6,2.6,117
Buttermilch,37,3.5,0.5,4.0,0.0,109
Himbeere,37,1.3,0.3,4.8,4.7,40
Salz dill gurken,9,0.4,0.1,1.3,0.5,18
Schmand20,205,2.8,20.0,3.6,0.0,100
Schmand 20%,205,2.8,20.0,3.6,0.0,100
Aspikpulver,338,84.2,0.1,0.0,0.0,11
Lachs atlantischer,210,20.4,13.4,0.3,0.0,4
Pinienkerne,589,24.0,50.7,7.3,7.2,26
Zwieback,385,9.9,4.3,73.1,5.2,42
Speisequark,72,13.5,0.3,3.2,0.0,92
Basilikum,47,3.1,0.8,5.1,3.1,369
Mayonaise50,490,0.5,52.0,5.0,0.0,10
Mayonaise 50%,490,0.5,52.0,5.0,0.0,10
Weizenbrötchen,292,10.2,1.8,55.9,3.6,49
Seelachs köhler,81,18.3,0.9,0,0,14
Bohnen grün,21,1.7,0.1,2.0,2.3,34
Aprikosen dose,70,0.5,0.1,15.1,1.4,11
Aprikosen Dose,70,0.5,0.1,15.1,1.4,11
Orangenfilets,47,1.0,0.2,8.3,2.2,42
Mirabellen dose,66,0.7,0.2,15.0,0.9,12
Pfirsich dose,67,0.4,0.1,15.5,1.1,4
Mirabellen Dose,66,0.7,0.2,15.0,0.9,12
Pfirsich Dose,67,0.4,0.1,15.5,1.1,4
Vanillezucker,405,0.0,0.0,100.0,0,2
Vanille pp,346,0.5,0.0,86.0,1,15
Brokkoli,34,3.8,0.2,2.7,3.0,58
@ -76,11 +73,50 @@ Mais Dose,81,3.2,1.2,12.6,2.8,8
Pfefferminze,50,3.8,0.7,5.3,3.0,179
Erdbeere,36,0.8,0.4,5.5,2.0,24
Himbeere,37,1.3,0.3,4.8,4.7,40
Orange/apfelsine,47,1.0,0.2,8.3,2.2,42
Orange/Apfelsine,47,1.0,0.2,8.3,2.2,42
Orangensaft frisch,44,0.7,0.1,8.7,0.4,11
Weintraube,69,0.7,0.3,15.2,1.5,12
Naturreis,349,7.2,2.2,74.1,2.2,16
Mehl405,343,9.8,1.0,71.8,4.0,15
Mehl550,346,9.8,1.1,72.0,4.3,17
Mehl Type 405,343,9.8,1.0,71.8,4.0,15
Mehl Type 550,346,9.8,1.1,72.0,4.3,17
Milchreis,316,6.4,0.8,80.2,1.1,6
Kartoffelstärke,341,0.6,0.1,83.1,0.1,35
Hmilch fettarm 1.5%,47,3.4,1.5,4.9,0.0,123
Edamer 30%,254,26.4,16.2,0,0.0,800
Gouda alt 48%,414,24.6,33.7,0.1,0.0,871
Hackfleisch,207,20.5,14.0,0.0,0.0,6
Bockwurst,277,12.3,25.3,0.0,0.1,12
Geflügelwurst mager,108,16.2,4.8,0.0,0.0,23
Butterschmalz,897,0.3,99.5,0.0,0.0,6
Diätmargerine,722,0.2,80.0,0.2,0.0,10
Kürbiskerne,590,35.5,46.6,2.7,8.7,10
Sonnenblumenkerne geschält,593,22.5,49.0,12.3,6.3,98
Butterkeks,441,8.2,11.0,74.7,3.3,47
Zwieback,385,9.9,4.3,73.1,5.2,42
Schokolade 75% Kakaomasse,598,7.8,42.6,35.0,10.9,73
Paniermehl,368,10.1,0.1,73.5,5.3,50
Schinken geräuchert,152,20.7,7.7,0.0,0.0,2
Rinderkeule,148,20.0,7.6,0.0,0.0,6
Kirsche süß,62,0.9,0.3,13.3,1.3,17
Kirschen sauer,50,0.9,0.5,9.9,1.0,8
Eisbergsalat,16,1.0,0.2,2.0,1.1,19
Endivie,18,1.8,0.2,1.2,1.9,54
Feldsalat,18,1.8,0.4,0.8,1.5,32
Gurke,14,0.6,0.2,1.8,0.9,15
Schalotte,25,1.5,0.2,3.3,1.5,37
Gemüsebrühe verz,7,1.6,0,0,0,12
Fleischbrühe,4,0.2,0,1,0,5
Hühnerbrühe verz,10,0.4,0,1,0,10
Bohnenkaffee,2,0.0,0,0,0,10
Sojasauce,70,9.0,0,8,0,20
Rote Bete,46,1.5,0.2,8.4,2.5,29
Rote Bete Saft,37,1.0,0,8.0,0.3,20
Paprika gelb,37,1.2,0.3,5.3,3.6,8
Paprika grün,23,1.2,0.2,2.9,2.0,10
Paprika rot,43,1.3,0.5,6.4,3.6,10
Knollensellerie,27,1.6,0.3,2.3,4.2,50
Erdbeeren tiefgefroren,38,0.9,0.4,5.8,2.1,24
Himbeeren tiefgefroren,45,1.4,0.3,5.0,4.8,42
Kerbel,58,4.1,0.6,6.2,5.3,400
Majoran,52,2.1,1.1,6.9,2.9,322
Oregano,72,2.2,2.0,9.7,2.5,310
Thymian,52,1.5,1.2,7.4,3.0,307

1 name kcal EW Fett KH BST Ca
2 Zitronensaft 38 0.4 0.5 3.8 0.1 11
3 Zucker 405 0.0 0.0 100.0 0.0 2
4 Trinkmilch3.5 Trinkmilch 3.5% 65 3.4 3.6 4.7 0.0 120
5 Hühnerei50 Hühnerei 137 11.9 9.3 1.5 0.0 51
6 Pflanzenmargarine 722 0.2 80.0 0.4 0.0 8
7 Sahne30 Sahne 30% 309 2.4 31.7 3.4 0.0 80
8 Maisstärke 353 0.4 0.1 85.9 1.0 0
Paniermehl 368 10.1 2.1 73.5 5.3 50
9 Weizengrieß 335 9.6 0.8 69.0 7.1 17
10 Mehl405 343 9.8 1.0 71.8 4.0 15
11 Rapsöl 884 0 100.0 0 0 0
17 Möhre 39 0.8 0.2 6.8 3.6 21
18 Rote linsen 350 23.9 2.2 52.3 10.8 48
19 Gemüsebruhe verz 7 1.6 0 1 0 12
20 Rindfleisch keule Rindfleisch Keule 148 20.0 7.6 0 0 6
21 Rinderbouillon 4 0.2 0 1 0 5
22 Meerettich iD 78 2.8 0.3 11.7 7.5 105
23 Saure sahne10 Saure sahne 10% 117 3.1 10.0 3.7 0 110
24 Joghurt3.5 Joghurt 3.5% 64 3.3 3.5 4.4 0 120
25 Dill 65 3.7 0.8 8.0 5.3 230
26 Schnittlauch 40 3.6 0.7 1.6 6.0 129
27 Gartenkresse 41 4.2 0.7 2.5 3.5 214
36 Kiwi grün 55 0.9 0.6 9.1 3.0 28
37 Banane 93 1.2 0.2 20.0 1.8 8
38 Schweinefleisch bug 217 17.0 16.5 0.0 0.0 9
39 Gouda48 Gouda 48% 370 22.7 29.9 0 0 811
40 Blumenkohl 28 2.5 0.3 2.3 2.9 22
41 Knoblauch 145 6.1 0.1 28.4 1.8 38
42 Senf 88 6.0 4.0 6.0 1.0 124
43 Blattspinat roh 21 2.7 0.3 0.6 2.6 117
44 Buttermilch 37 3.5 0.5 4.0 0.0 109
Himbeere 37 1.3 0.3 4.8 4.7 40
45 Salz dill gurken 9 0.4 0.1 1.3 0.5 18
46 Schmand20 Schmand 20% 205 2.8 20.0 3.6 0.0 100
47 Aspikpulver 338 84.2 0.1 0.0 0.0 11
48 Lachs atlantischer 210 20.4 13.4 0.3 0.0 4
49 Pinienkerne 589 24.0 50.7 7.3 7.2 26
Zwieback 385 9.9 4.3 73.1 5.2 42
50 Speisequark 72 13.5 0.3 3.2 0.0 92
51 Basilikum 47 3.1 0.8 5.1 3.1 369
52 Mayonaise50 Mayonaise 50% 490 0.5 52.0 5.0 0.0 10
53 Weizenbrötchen 292 10.2 1.8 55.9 3.6 49
54 Seelachs köhler 81 18.3 0.9 0 0 14
55 Bohnen grün 21 1.7 0.1 2.0 2.3 34
56 Aprikosen dose Aprikosen Dose 70 0.5 0.1 15.1 1.4 11
57 Orangenfilets 47 1.0 0.2 8.3 2.2 42
58 Mirabellen dose Mirabellen Dose 66 0.7 0.2 15.0 0.9 12
59 Pfirsich dose Pfirsich Dose 67 0.4 0.1 15.5 1.1 4
60 Vanillezucker 405 0.0 0.0 100.0 0 2
61 Vanille pp 346 0.5 0.0 86.0 1 15
62 Brokkoli 34 3.8 0.2 2.7 3.0 58
73 Pfefferminze 50 3.8 0.7 5.3 3.0 179
74 Erdbeere 36 0.8 0.4 5.5 2.0 24
75 Himbeere 37 1.3 0.3 4.8 4.7 40
76 Orange/apfelsine Orange/Apfelsine 47 1.0 0.2 8.3 2.2 42
77 Orangensaft frisch 44 0.7 0.1 8.7 0.4 11
78 Weintraube 69 0.7 0.3 15.2 1.5 12
79 Naturreis 349 7.2 2.2 74.1 2.2 16
80 Mehl405 Mehl Type 405 343 9.8 1.0 71.8 4.0 15
81 Mehl550 Mehl Type 550 346 9.8 1.1 72.0 4.3 17
82 Milchreis 316 6.4 0.8 80.2 1.1 6
83 Kartoffelstärke Hmilch fettarm 1.5% 341 47 0.6 3.4 0.1 1.5 83.1 4.9 0.1 0.0 35 123
84 Edamer 30% 254 26.4 16.2 0 0.0 800
85 Gouda alt 48% 414 24.6 33.7 0.1 0.0 871
86 Hackfleisch 207 20.5 14.0 0.0 0.0 6
87 Bockwurst 277 12.3 25.3 0.0 0.1 12
88 Geflügelwurst mager 108 16.2 4.8 0.0 0.0 23
89 Butterschmalz 897 0.3 99.5 0.0 0.0 6
90 Diätmargerine 722 0.2 80.0 0.2 0.0 10
91 Kürbiskerne 590 35.5 46.6 2.7 8.7 10
92 Sonnenblumenkerne geschält 593 22.5 49.0 12.3 6.3 98
93 Butterkeks 441 8.2 11.0 74.7 3.3 47
94 Zwieback 385 9.9 4.3 73.1 5.2 42
95 Schokolade 75% Kakaomasse 598 7.8 42.6 35.0 10.9 73
96 Paniermehl 368 10.1 0.1 73.5 5.3 50
97 Schinken geräuchert 152 20.7 7.7 0.0 0.0 2
98 Rinderkeule 148 20.0 7.6 0.0 0.0 6
99 Kirsche süß 62 0.9 0.3 13.3 1.3 17
100 Kirschen sauer 50 0.9 0.5 9.9 1.0 8
101 Eisbergsalat 16 1.0 0.2 2.0 1.1 19
102 Endivie 18 1.8 0.2 1.2 1.9 54
103 Feldsalat 18 1.8 0.4 0.8 1.5 32
104 Gurke 14 0.6 0.2 1.8 0.9 15
105 Schalotte 25 1.5 0.2 3.3 1.5 37
106 Gemüsebrühe verz 7 1.6 0 0 0 12
107 Fleischbrühe 4 0.2 0 1 0 5
108 Hühnerbrühe verz 10 0.4 0 1 0 10
109 Bohnenkaffee 2 0.0 0 0 0 10
110 Sojasauce 70 9.0 0 8 0 20
111 Rote Bete 46 1.5 0.2 8.4 2.5 29
112 Rote Bete Saft 37 1.0 0 8.0 0.3 20
113 Paprika gelb 37 1.2 0.3 5.3 3.6 8
114 Paprika grün 23 1.2 0.2 2.9 2.0 10
115 Paprika rot 43 1.3 0.5 6.4 3.6 10
116 Knollensellerie 27 1.6 0.3 2.3 4.2 50
117 Erdbeeren tiefgefroren 38 0.9 0.4 5.8 2.1 24
118 Himbeeren tiefgefroren 45 1.4 0.3 5.0 4.8 42
119 Kerbel 58 4.1 0.6 6.2 5.3 400
120 Majoran 52 2.1 1.1 6.9 2.9 322
121 Oregano 72 2.2 2.0 9.7 2.5 310
122 Thymian 52 1.5 1.2 7.4 3.0 307

View File

@ -13,6 +13,8 @@ itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.4
packaging==23.2
psycopg==3.1.17
psycopg2==2.9.9
pycparser==2.21
requests==2.31.0
typing_extensions==4.9.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -34,13 +34,20 @@ button:not(:disabled):hover {
}
button#remove-button {
background-color: #f443366f; /* Helles Rot */
background-color: #640000; /* Helles Rot */
}
button#remove-button:disabled {
background-color: #cccccc;
color: #666666;
}
button#remove-button:not(:disabled):hover {
background-color: #d32f2f3d; /* Dunkleres Rot */
background-color: #490000; /* Dunkleres Rot */
}
table {
width: 100%;
border-collapse: collapse;
@ -65,7 +72,7 @@ tr:nth-child(even) {
}
.selected, tr.selected {
background-color: #ffdd99; /* Hervorhebung der Auswahl */
background-color: #e5b5b5; /* Hervorhebung der Auswahl */
}
tr:hover:not(.selected) {
@ -121,3 +128,89 @@ tr:hover:not(.selected) {
padding: 20px;
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 */
}
}
#table-container {
overflow-y: auto;
max-height: 400px; /* Passen Sie die Höhe nach Bedarf an */
border-radius: 10px;
margin-top: 20px;
}
#database-nutrition-table {
width: 100%;
border-collapse: collapse;
}
#database-nutrition-table th, #database-nutrition-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
#database-nutrition-table tr.selected {
background-color: #f0e68c;
}
#password-prompt {
margin-top: 10px;
display: flex;
align-items: center;
justify-content: center;
}
#password-prompt input[type="password"] {
padding: 8px;
margin-right: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}
#password-prompt button {
padding: 8px 15px;
margin-right: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
color: white;
}
#password-prompt button[type="submit"] {
background-color: #008C50; /* Helles Grün */
}
#password-prompt button[type="submit"]:hover {
background-color: #007344; /* Dunkleres Grün */
}
#password-prompt button[type="button"] {
background-color: #640000; /* Helles Rot */
}
#password-prompt button[type="button"]:hover {
background-color: #490000; /* Dunkleres Rot */
}

View File

@ -4,10 +4,9 @@
<meta charset="UTF-8">
<title>Nährwertberechnungs-App</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
<link rel="shortcut icon" href="../static/images/favicon.ico">
<script>
// JavaScript-Funktion, um die Produkte beim Laden der Seite zu holen
document.addEventListener('DOMContentLoaded', function() {
cleanUpLocalStorage();
restoreTableFromLocalStorage();
@ -172,20 +171,11 @@ function updateTotalNutrition() {
document.getElementById('total-ca').innerText = Math.round(totalCa);
}
// Rufen Sie diese Funktion auf, wenn sich die Haupttabelle ändert
// Diese Funktion sollte aufgerufen werden, wenn ein Produkt hinzugefügt oder entfernt wird
</script>
</head>
<body>
<nav id="navbar">
<h1>Elos Rezept Rechner</h1>
<h1>Elo's Rezept Rechner</h1>
<ul>
<li><a href="/" class="active">Rechner</a></li>
<li><a href="/nutrition">Neue Lebensmittel</a></li>
@ -196,7 +186,7 @@ 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" oninput="updateButtonState()" autocomplete="off">
<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>
@ -220,6 +210,8 @@ function updateTotalNutrition() {
<button id="remove-button" onclick="removeSelectedRow()" disabled>Entfernen</button>
<table id="total-nutrition-table">
<tr>
<th>Lebensmittel</th>
<th>Gewicht (g)</th>
<th>kcal</th>
<th>EW</th>
<th>Fett</th>
@ -228,6 +220,8 @@ function updateTotalNutrition() {
<th>CA</th>
</tr>
<tr>
<td>Gesamtwerte</td>
<td>-</td>
<td id="total-kcal">0</td>
<td id="total-ew">0</td>
<td id="total-fett">0</td>

View File

@ -4,6 +4,8 @@
<meta charset="UTF-8">
<title>Neue Lebensmittel hinzufügen</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
<link rel="shortcut icon" href="../static/images/favicon.ico">
<script>
function updateSubmitButtonState() {
const inputs = document.querySelectorAll('#nutrition-form input');
@ -11,38 +13,129 @@
document.getElementById('submit-button').disabled = !allFilled;
}
function getBearerToken(callback) {
fetch('/get_token')
.then(response => response.json())
.then(data => {
callback(data.token);
})
.catch(error => {
console.error('Fehler beim Abrufen des Tokens:', error);
});
}
function addNutritionEntry() {
getBearerToken(token => {
const form = document.getElementById('nutrition-form');
const formData = new FormData(form);
const form = document.getElementById('nutrition-form');
const formData = new FormData(form);
fetch('/add_nutrition', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token
},
body: formData
}).then(response => {
// Behandlung der Serverantwort
// Beispielsweise das Formular zurücksetzen
form.reset();
updateSubmitButtonState();
}).catch(error => {
console.error('Fehler:', error);
});
// ... Code, um den Eintrag zur Datenbank hinzuzufügen
fetch('/add_nutrition', {
method: 'POST',
body: formData
}).then(response => {
// Behandlung der Serverantwort
// Beispielsweise das Formular zurücksetzen
form.reset();
updateSubmitButtonState();
}).catch(error => {
console.error('Fehler:', error);
});
// ... Code, um den Eintrag zur Datenbank hinzuzufügen
// Nach dem Hinzufügen, setze alle Eingabefelder zurück
document.querySelectorAll('#nutrition-form input').forEach(input => {
input.value = ''; // Setzt den Wert jedes Eingabefeldes zurück
});
// Nach dem Hinzufügen, setze alle Eingabefelder zurück
document.querySelectorAll('#nutrition-form input').forEach(input => {
input.value = ''; // Setzt den Wert jedes Eingabefeldes zurück
});
// Deaktiviere den "Hinzufügen"-Button wieder
document.getElementById('submit-button').disabled = true;
});
}
document.addEventListener('DOMContentLoaded', function() {
const table = document.getElementById('database-nutrition-table');
table.addEventListener('click', function(e) {
if (e.target.tagName === 'TD') {
e.target.parentNode.classList.toggle('selected');
updateDeleteButtonState();
}
});
updateDeleteButtonState();
});
function deleteSelectedRows() {
const table = document.getElementById('database-nutrition-table');
Array.from(table.rows).forEach(row => {
if (row.classList.contains('selected')) {
// Logik zum Löschen der Zeile aus der Datenbank
table.deleteRow(row.rowIndex);
}
});
}
function showPasswordPrompt() {
document.getElementById('delete-row-button').style.display = 'none';
document.getElementById('password-prompt').style.display = 'block';
}
function hidePasswordPrompt() {
document.getElementById('delete-row-button').style.display = 'block';
document.getElementById('password-prompt').style.display = 'none';
}
function deleteRowsIfPasswordCorrect() {
const password = document.getElementById('password-input').value;
if (password === 'wowmuchsecurity') {
deleteSelectedRows(); // Funktion, die die ausgewählten Zeilen löscht
hidePasswordPrompt();
} else {
alert('Falsches Passwort!');
}
}
function updateDeleteButtonState() {
const selectedRows = document.querySelectorAll('#nutrition-table .selected').length;
const deleteButton = document.getElementById('delete-row-button');
deleteButton.disabled = selectedRows === 0;
if (selectedRows === 0) {
hidePasswordPrompt(); // Versteckt die Passwort-Eingabe, falls keine Zeile ausgewählt ist
}
}
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];
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;
// ... Fügen Sie weitere Zellen für die anderen Werte hinzu ...
});
})
.catch(error => console.error('Fehler:', error));
}
document.addEventListener('DOMContentLoaded', loadDatabaseEntries);
// Deaktiviere den "Hinzufügen"-Button wieder
document.getElementById('submit-button').disabled = true;
}
</script>
</head>
<body>
<nav id="navbar">
<h1>Elos Rezept Rechner</h1>
<h1>Elo's Rezept Rechner</h1>
<ul>
<li><a href="/">Rechner</a></li>
<li><a href="/nutrition" class="active">Neue Lebensmittel</a></li>
@ -62,17 +155,45 @@
<th>CA</th>
</tr>
<tr>
<td><input type="text" name="food" oninput="updateSubmitButtonState()"></td>
<td><input <input type="text" name="kcal" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
<td><input <input type="text" name="ew" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
<td><input <input type="text" name="fett" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
<td><input <input type="text" name="kh" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
<td><input <input type="text" name="bst" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
<td><input <input type="text" name="ca" pattern="\d+(\.\d{1,2})?" 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})?" placeholder="g" 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})?" placeholder="g" 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})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
<td><input <input type="text" name="ca" pattern="\d+([.,]\d{1,2})?" placeholder="mg" oninput="updateSubmitButtonState()"></td>
</tr>
</table>
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
</form>
<div id="table-container">
<table id="database-nutrition-table">
<thead>
<tr>
<th>Lebensmittel</th>
<th>kcal</th>
<th>EW</th>
<th>Fett</th>
<th>KH</th>
<th>BST</th>
<th>CA</th>
</tr>
</thead>
<tbody>
<!-- Die Zeilen werden dynamisch aus der Datenbank geladen -->
</tbody>
</table>
</div>
<button id="delete-row-button" onclick="showPasswordPrompt()">Zeilen löschen</button>
<div id="password-prompt" style="display: none;">
<input type="password" id="password-input" placeholder="Passwort">
<button onclick="deleteRowsIfPasswordCorrect()">OK</button>
<button onclick="hidePasswordPrompt()">Abbrechen</button>
</div>
</div>
</body>
</html>

View File

@ -1,4 +1,6 @@
#!/bin/sh
gunicorn 'Run:app' --bind 0.0.0.0:8080 --log-level=info --workers=4
gunicorn 'Run:app' --bind 0.0.0.0:8080 --log-level=debug --workers=4