Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
8e0ec494cb
|
|||
9d42a46b43
|
|||
95fa775c61
|
|||
f8b54f7bba
|
|||
9d6555af82
|
|||
3d6c071233
|
|||
6ede84955c
|
|||
b9b7c6b48d
|
|||
d1280eea7b
|
|||
c403e4f253
|
|||
d3e624b9ce
|
|||
86c8b76736 | |||
c85b68b072 | |||
c8648788d0 | |||
fe5ad6ba8d | |||
512e89205c | |||
dbb99ba47a | |||
9c42e0fc63 | |||
92508a23ae | |||
8c3155434a | |||
777ad92b22 | |||
708ce6dd3d | |||
75b66806a2 | |||
6b5c3c36ca | |||
7f90ad4c05 | |||
9dee350323 | |||
c3c3b4f83d | |||
727e2f60c4 | |||
a411f59e00 | |||
be531a7ccf | |||
6e94925fda | |||
814c5b17e3 |
@ -1,4 +1,4 @@
|
|||||||
FROM python:3.12-alpine3.19
|
FROM python:3.12-alpine3.21
|
||||||
|
|
||||||
ARG APP_DIR="/opt/app"
|
ARG APP_DIR="/opt/app"
|
||||||
ARG VERSION_ID1="x"
|
ARG VERSION_ID1="x"
|
||||||
|
47
src/Run.py
47
src/Run.py
@ -1,4 +1,6 @@
|
|||||||
from flask import Flask, request, render_template, jsonify, redirect, url_for, g
|
from flask import Flask, request, render_template, jsonify, redirect, url_for, g
|
||||||
|
from flask_session import Session
|
||||||
|
import redis
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from flask_oidc import OpenIDConnect
|
from flask_oidc import OpenIDConnect
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
@ -11,15 +13,21 @@ from math import ceil, floor
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.update({
|
app.config.update({
|
||||||
'SECRET_KEY': os.environ['SECRET'],
|
'SECRET_KEY': os.environ['SECRET'],
|
||||||
'DEBUG': False,
|
'DEBUG': True,
|
||||||
'OIDC_CLIENT_SECRETS': json.loads(os.environ['CLIENT_SECRETS']),
|
'OIDC_CLIENT_SECRETS': json.loads(os.environ['CLIENT_SECRETS']),
|
||||||
'OIDC_ID_TOKEN_COOKIE_SECURE': False,
|
'OIDC_ID_TOKEN_COOKIE_SECURE': True,
|
||||||
'OIDC_USER_INFO_ENABLED': True,
|
'OIDC_USER_INFO_ENABLED': True,
|
||||||
'OIDC_OPENID_REALM': 'hottis',
|
'OIDC_OPENID_REALM': 'hottis',
|
||||||
'OIDC_SCOPES': ['openid', 'email', 'profile']
|
'OIDC_SCOPES': ['openid', 'email'],
|
||||||
|
'SESSION_TYPE': 'redis',
|
||||||
|
'SESSION_PERMANENT': False,
|
||||||
|
'SESSION_USE_SIGNER': True,
|
||||||
|
'SESSION_KEY_PREFIX': 'nutri',
|
||||||
|
'SESSION_REDIS': redis.StrictRedis(host='redis-master.redis.svc.cluster.local', port=6379, db=4)
|
||||||
})
|
})
|
||||||
|
|
||||||
oidc = OpenIDConnect(app)
|
oidc = OpenIDConnect(app)
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
app.logger.handlers = logging.getLogger('gunicorn.error').handlers
|
app.logger.handlers = logging.getLogger('gunicorn.error').handlers
|
||||||
|
|
||||||
datapw = 'dasrtwegdffgtewrt4335wferg'
|
datapw = 'dasrtwegdffgtewrt4335wferg'
|
||||||
@ -38,7 +46,7 @@ def calculate_nutrition(food, weight):
|
|||||||
# Runden und Berechnen der Nährwerte basierend auf dem Gewicht
|
# Runden und Berechnen der Nährwerte basierend auf dem Gewicht
|
||||||
kcal, ew, fett, kh, bst, ca = result
|
kcal, ew, fett, kh, bst, ca = result
|
||||||
nutrition_values = [
|
nutrition_values = [
|
||||||
schulrunden(kcal * weight / 100), # kcal gerundet auf ganze Zahl
|
schulrunden(kcal * weight / 100, ist_kcal=True), # kcal gerundet auf ganze Zahl
|
||||||
schulrunden(ew * weight / 100, 1), # EW gerundet auf eine Dezimalstelle
|
schulrunden(ew * weight / 100, 1), # EW gerundet auf eine Dezimalstelle
|
||||||
schulrunden(fett * weight / 100, 1), # Fett gerundet auf eine Dezimalstelle
|
schulrunden(fett * weight / 100, 1), # Fett gerundet auf eine Dezimalstelle
|
||||||
schulrunden(kh * weight / 100, 1), # KH gerundet auf eine Dezimalstelle
|
schulrunden(kh * weight / 100, 1), # KH gerundet auf eine Dezimalstelle
|
||||||
@ -55,7 +63,11 @@ def calculate_nutrition(food, weight):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def schulrunden(zahl, stellen=0):
|
def schulrunden(zahl, stellen=0, ist_kcal=False):
|
||||||
|
# Wenn es sich um kcal handelt und der Wert vor der Rundung zwischen 0 und 1 liegt
|
||||||
|
if ist_kcal and 0 < zahl < 1:
|
||||||
|
return 1
|
||||||
|
|
||||||
faktor = 10 ** stellen
|
faktor = 10 ** stellen
|
||||||
zahl = zahl * faktor
|
zahl = zahl * faktor
|
||||||
basis = floor(zahl)
|
basis = floor(zahl)
|
||||||
@ -69,14 +81,14 @@ def schulrunden(zahl, stellen=0):
|
|||||||
|
|
||||||
# Index-Route
|
# Index-Route
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
@app.route('/get_products')
|
@app.route('/get_products')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def get_products():
|
def get_products():
|
||||||
try:
|
try:
|
||||||
conn = psycopg2.connect()
|
conn = psycopg2.connect()
|
||||||
@ -91,7 +103,7 @@ def get_products():
|
|||||||
|
|
||||||
# Route zum Hinzufügen und Berechnen von Lebensmitteln
|
# Route zum Hinzufügen und Berechnen von Lebensmitteln
|
||||||
@app.route('/add_lm', methods=['GET'])
|
@app.route('/add_lm', methods=['GET'])
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def add_lm():
|
def add_lm():
|
||||||
food = request.args.get('food')
|
food = request.args.get('food')
|
||||||
weight = float(request.args.get('weight'))
|
weight = float(request.args.get('weight'))
|
||||||
@ -121,7 +133,7 @@ def convert_decimal(value):
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/add_nutrition', methods=['POST'])
|
@app.route('/add_nutrition', methods=['POST'])
|
||||||
@oidc.accept_token(['openid'])
|
# @oidc.accept_token(['openid'])
|
||||||
def add_nutrition():
|
def add_nutrition():
|
||||||
app.logger.info("add_nutrition")
|
app.logger.info("add_nutrition")
|
||||||
|
|
||||||
@ -151,18 +163,18 @@ def add_nutrition():
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/nutrition')
|
@app.route('/nutrition')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def nutrition():
|
def nutrition():
|
||||||
return render_template('nutrition.html')
|
return render_template('nutrition.html')
|
||||||
|
|
||||||
@app.route('/get_token')
|
@app.route('/get_token')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def get_token():
|
def get_token():
|
||||||
return jsonify(token=oidc.get_access_token())
|
return jsonify(token=oidc.get_access_token())
|
||||||
|
|
||||||
|
|
||||||
@app.route('/get_database_entries')
|
@app.route('/get_database_entries')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def get_database_entries():
|
def get_database_entries():
|
||||||
try:
|
try:
|
||||||
# Ersetzen Sie diese Werte mit Ihren Datenbank-Verbindungsinformationen
|
# Ersetzen Sie diese Werte mit Ihren Datenbank-Verbindungsinformationen
|
||||||
@ -193,7 +205,7 @@ def get_database_entries():
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/delete_nutrition', methods=['POST'])
|
@app.route('/delete_nutrition', methods=['POST'])
|
||||||
@oidc.accept_token(['openid'])
|
# @oidc.accept_token(['openid'])
|
||||||
def delete_nutrition():
|
def delete_nutrition():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
foodNames = data['foodNames']
|
foodNames = data['foodNames']
|
||||||
@ -215,6 +227,13 @@ def delete_nutrition():
|
|||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/random')
|
||||||
|
@oidc.require_login
|
||||||
|
def random_page():
|
||||||
|
# Diese Route gibt die HTML-Seite 'random.html' zurück
|
||||||
|
return render_template('random.html')
|
||||||
|
|
||||||
|
|
||||||
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
||||||
|
|
||||||
|
#
|
||||||
|
@ -20,3 +20,6 @@ requests==2.31.0
|
|||||||
typing_extensions==4.9.0
|
typing_extensions==4.9.0
|
||||||
urllib3==2.1.0
|
urllib3==2.1.0
|
||||||
Werkzeug==3.0.1
|
Werkzeug==3.0.1
|
||||||
|
Flask-Session
|
||||||
|
redis
|
||||||
|
|
||||||
|
BIN
src/static/images/elisa.jpg
Normal file
BIN
src/static/images/elisa.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
src/static/images/elo.jpg
Normal file
BIN
src/static/images/elo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 KiB |
BIN
src/static/images/marie.jpg
Normal file
BIN
src/static/images/marie.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
BIN
src/static/images/marie2.jpg
Normal file
BIN
src/static/images/marie2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 167 KiB |
@ -241,3 +241,27 @@ button#cancel-button:not(:disabled):hover {
|
|||||||
.form-row {
|
.form-row {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
button#submit-button {
|
||||||
|
background-image: url('images/elisa.jpg'); /* Pfad zum Bild */
|
||||||
|
background-size: contain; /* Passt das Bild innerhalb des Buttons an, ohne es zu strecken */
|
||||||
|
background-repeat: no-repeat; /* Verhindert das Wiederholen des Bildes */
|
||||||
|
background-position: center; /* Zentriert das Bild im Button */
|
||||||
|
color: transparent; /* Macht den Text unsichtbar, damit nur das Bild sichtbar ist */
|
||||||
|
width: 62px; /* Setzt die Breite automatisch entsprechend des Inhalts */
|
||||||
|
height: 85px; /* Passt die Höhe an, um das Bild vollständig anzuzeigen */
|
||||||
|
padding: 10px 20px; /* Hinzufügen von etwas Platz um das Bild */
|
||||||
|
}
|
||||||
|
|
||||||
|
button#remove-button {
|
||||||
|
background-image: url('images/marie2.jpg'); /* Pfad zum Bild */
|
||||||
|
background-size: contain; /* Passt das Bild innerhalb des Buttons an, ohne es zu strecken */
|
||||||
|
background-repeat: no-repeat; /* Verhindert das Wiederholen des Bildes */
|
||||||
|
background-position: center; /* Zentriert das Bild im Button */
|
||||||
|
color: transparent; /* Macht den Text unsichtbar, damit nur das Bild sichtbar ist */
|
||||||
|
width: 78px; /* Setzt die Breite automatisch entsprechend des Inhalts */
|
||||||
|
height: 85px; /* Passt die Höhe an, um das Bild vollständig anzuzeigen */
|
||||||
|
padding: 10px 20px; /* Hinzufügen von etwas Platz um das Bild */
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -177,6 +177,17 @@ function updateRowWithNewData(row, weight, nutritionData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function schulrunden(zahl) {
|
||||||
|
// Multipliziere die Zahl mit 10, um die relevante Dezimalstelle vor das Komma zu bekommen
|
||||||
|
zahl = zahl * 10;
|
||||||
|
// Wende Math.ceil an, um auf die nächste ganze Zahl aufzurunden,
|
||||||
|
// aber nur, wenn der Dezimalteil >= 0.5 ist. Andernfalls verwende Math.floor.
|
||||||
|
zahl = (zahl - Math.floor(zahl) >= 0.5) ? Math.ceil(zahl) : Math.floor(zahl);
|
||||||
|
// Teile durch 10, um die ursprüngliche Skalierung wiederherzustellen,
|
||||||
|
// aber mit der erforderlichen Rundung
|
||||||
|
return zahl / 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function addProduct() {
|
function addProduct() {
|
||||||
const foodInput = document.getElementById('my_combobox');
|
const foodInput = document.getElementById('my_combobox');
|
||||||
@ -187,7 +198,7 @@ function updateRowWithNewData(row, weight, nutritionData) {
|
|||||||
const portions = portionsInput.value ? parseInt(portionsInput.value, 10) : 1;
|
const portions = portionsInput.value ? parseInt(portionsInput.value, 10) : 1;
|
||||||
|
|
||||||
// Teilen des Gewichts durch die Anzahl der Portionen und Aufrunden
|
// Teilen des Gewichts durch die Anzahl der Portionen und Aufrunden
|
||||||
weight = Math.ceil(weight / portions);
|
weight = schulrunden(weight / portions);
|
||||||
|
|
||||||
|
|
||||||
fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
|
fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
|
||||||
@ -270,7 +281,8 @@ function updateTotalNutrition() {
|
|||||||
<datalist id="products">
|
<datalist id="products">
|
||||||
<!-- Produkte werden hier dynamisch eingefügt -->
|
<!-- Produkte werden hier dynamisch eingefügt -->
|
||||||
</datalist>
|
</datalist>
|
||||||
<input type="number" id="weight" name="weight" placeholder="Gramm" oninput="updateButtonState()">
|
<input type="number" id="weight" name="weight" placeholder="Gramm" step="0.1" min="0" oninput="updateButtonState()">
|
||||||
|
|
||||||
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -289,7 +301,7 @@ function updateTotalNutrition() {
|
|||||||
</tr>
|
</tr>
|
||||||
<!-- Zeilen werden hier dynamisch hinzugefügt -->
|
<!-- Zeilen werden hier dynamisch hinzugefügt -->
|
||||||
</table>
|
</table>
|
||||||
<button id="remove-button" onclick="removeSelectedRow()" disabled>Entfernen</button>
|
<button id="remove-button" onclick="removeSelectedRow()" disabled></button>
|
||||||
<table id="total-nutrition-table">
|
<table id="total-nutrition-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Lebensmittel</th>
|
<th>Lebensmittel</th>
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let isEditing = false;
|
|
||||||
|
|
||||||
function updateSubmitButtonState() {
|
function updateSubmitButtonState() {
|
||||||
const inputs = document.querySelectorAll('#nutrition-form input');
|
const inputs = document.querySelectorAll('#nutrition-form input');
|
||||||
const allFilled = Array.from(inputs).every(input => input.value.trim() !== '');
|
const allFilled = Array.from(inputs).every(input => input.value.trim() !== '');
|
||||||
@ -59,95 +57,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function showPasswordPrompt(action) {
|
|
||||||
// Setze isEditing je nach Aktion
|
|
||||||
isEditing = (action === 'edit');
|
|
||||||
if (isEditing) {
|
|
||||||
// Deaktiviere Zeilenauswahl
|
|
||||||
document.getElementById('database-nutrition-table').removeEventListener('click', handleRowClick);
|
|
||||||
} else {
|
|
||||||
// Aktiviere Zeilenauswahl
|
|
||||||
document.getElementById('database-nutrition-table').addEventListener('click', handleRowClick);
|
|
||||||
}
|
|
||||||
document.getElementById('delete-row-button').style.display = action === 'edit' ? 'none' : 'block';
|
|
||||||
document.getElementById('edit-row-button').style.display = action === 'delete' ? 'none' : 'block';
|
|
||||||
document.getElementById('password-prompt').style.display = 'block';
|
|
||||||
document.getElementById('password-prompt').setAttribute('data-action', action);
|
|
||||||
// Deselektiere alle Zeilen
|
|
||||||
deselectAllRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
function deselectAllRows() {
|
|
||||||
document.querySelectorAll('#database-nutrition-table .selected').forEach(row => {
|
|
||||||
row.classList.remove('selected');
|
|
||||||
});
|
|
||||||
updateDeleteButtonState();
|
|
||||||
updateEditButtonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
function hidePasswordPrompt() {
|
|
||||||
document.getElementById('delete-row-button').style.display = 'block';
|
|
||||||
document.getElementById('edit-row-button').style.display = 'block';
|
|
||||||
document.getElementById('password-prompt').style.display = 'none';
|
|
||||||
// Setze isEditing zurück
|
|
||||||
isEditing = false;
|
|
||||||
// Deaktiviere Editierbarkeit aller Zellen und aktiviere Zeilenauswahl
|
|
||||||
setCellsEditable(false);
|
|
||||||
document.getElementById('database-nutrition-table').addEventListener('click', handleRowClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
function performActionIfPasswordCorrect() {
|
|
||||||
const password = document.getElementById('password-input').value;
|
|
||||||
if (password === 'geheim') {
|
|
||||||
const action = document.getElementById('password-prompt').getAttribute('data-action');
|
|
||||||
if (action === 'delete') {
|
|
||||||
deleteSelectedRows();
|
|
||||||
} else if (action === 'edit') {
|
|
||||||
// Mache Zellen editierbar
|
|
||||||
setCellsEditable(true);
|
|
||||||
hidePasswordPrompt();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
alert('Falsches Passwort!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCellsEditable(editable) {
|
|
||||||
document.querySelectorAll('#database-nutrition-table td').forEach(cell => {
|
|
||||||
cell.contentEditable = editable;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRowClick(event) {
|
|
||||||
if (event.target.tagName === 'TD' && !isEditing) {
|
|
||||||
event.target.parentNode.classList.toggle('selected');
|
|
||||||
updateDeleteButtonState();
|
|
||||||
updateEditButtonState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateEditButtonState() {
|
|
||||||
// Diese Funktion soll ähnlich wie updateDeleteButtonState() implementiert werden,
|
|
||||||
// um den "Bearbeiten"-Button zu aktivieren/deaktivieren
|
|
||||||
const selectedRows = document.querySelectorAll('#database-nutrition-table .selected').length;
|
|
||||||
const editButton = document.getElementById('edit-row-button');
|
|
||||||
editButton.disabled = selectedRows === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ergänze Event-Listener, um den Zustand des Bearbeiten-Buttons zu aktualisieren
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
document.getElementById('database-nutrition-table').addEventListener('click', handleRowClick);
|
|
||||||
const table = document.getElementById('database-nutrition-table');
|
const table = document.getElementById('database-nutrition-table');
|
||||||
table.addEventListener('click', function(e) {
|
table.addEventListener('click', function(e) {
|
||||||
if (e.target.tagName === 'TD') {
|
if (e.target.tagName === 'TD') {
|
||||||
e.target.parentNode.classList.toggle('selected');
|
e.target.parentNode.classList.toggle('selected');
|
||||||
updateDeleteButtonState();
|
updateDeleteButtonState();
|
||||||
updateEditButtonState();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateDeleteButtonState();
|
updateDeleteButtonState();
|
||||||
updateEditButtonState();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function deleteSelectedRows() {
|
function deleteSelectedRows() {
|
||||||
@ -180,15 +98,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// function showPasswordPrompt() {
|
function showPasswordPrompt() {
|
||||||
// document.getElementById('delete-row-button').style.display = 'none';
|
document.getElementById('delete-row-button').style.display = 'none';
|
||||||
// document.getElementById('password-prompt').style.display = 'block';
|
document.getElementById('password-prompt').style.display = 'block';
|
||||||
// }
|
}
|
||||||
|
|
||||||
// function hidePasswordPrompt() {
|
function hidePasswordPrompt() {
|
||||||
// document.getElementById('delete-row-button').style.display = 'block';
|
document.getElementById('delete-row-button').style.display = 'block';
|
||||||
// document.getElementById('password-prompt').style.display = 'none';
|
document.getElementById('password-prompt').style.display = 'none';
|
||||||
// }
|
}
|
||||||
|
|
||||||
function deleteRowsIfPasswordCorrect() {
|
function deleteRowsIfPasswordCorrect() {
|
||||||
const password = document.getElementById('password-input').value;
|
const password = document.getElementById('password-input').value;
|
||||||
@ -219,13 +137,13 @@
|
|||||||
tableBody.innerHTML = '';
|
tableBody.innerHTML = '';
|
||||||
data.forEach(entry => {
|
data.forEach(entry => {
|
||||||
const row = tableBody.insertRow();
|
const row = tableBody.insertRow();
|
||||||
row.insertCell(0).innerText = entry.food;
|
row.insertCell(0).innerHTML = entry.food;
|
||||||
row.insertCell(1).innerText = entry.kcal;
|
row.insertCell(1).innerHTML = entry.kcal;
|
||||||
row.insertCell(2).innerText = entry.ew;
|
row.insertCell(2).innerHTML = entry.ew;
|
||||||
row.insertCell(3).innerText = entry.fett;
|
row.insertCell(3).innerHTML = entry.fett;
|
||||||
row.insertCell(4).innerText = entry.kh;
|
row.insertCell(4).innerHTML = entry.kh;
|
||||||
row.insertCell(5).innerText = entry.bst;
|
row.insertCell(5).innerHTML = entry.bst;
|
||||||
row.insertCell(6).innerText = entry.ca;
|
row.insertCell(6).innerHTML = entry.ca;
|
||||||
|
|
||||||
// ... Fügen Sie weitere Zellen für die anderen Werte hinzu ...
|
// ... Fügen Sie weitere Zellen für die anderen Werte hinzu ...
|
||||||
});
|
});
|
||||||
@ -254,7 +172,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openImagePage() {
|
||||||
|
window.open('random', '_blank'); // Öffnet die neue Seite in einem neuen Tab
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -297,6 +217,10 @@
|
|||||||
|
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<input type="text" id="search-input" placeholder="Lebensmittel suchen..." oninput="filterTable()">
|
<input type="text" id="search-input" placeholder="Lebensmittel suchen..." oninput="filterTable()">
|
||||||
|
<button onclick="openImagePage()" style="background-image: url('../static/images/marie.jpg'); border: none; cursor: pointer; background-size: cover; width: 62px; height: 85px; vertical-align: middle;">
|
||||||
|
<!-- Der Text wird durch den transparenten Text ersetzt, falls nötig -->
|
||||||
|
<span style="opacity: 0;">Öffnen</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -318,12 +242,11 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<button id="delete-row-button" onclick="showPasswordPrompt('delete')">Zeilen löschen</button>
|
<button id="delete-row-button" onclick="showPasswordPrompt()">Zeilen löschen</button>
|
||||||
<button id="edit-row-button" onclick="showPasswordPrompt('edit')">Bearbeiten</button>
|
|
||||||
|
|
||||||
<div id="password-prompt" style="display: none;">
|
<div id="password-prompt" style="display: none;">
|
||||||
<input type="password" id="password-input" placeholder="Passwort">
|
<input type="password" id="password-input" placeholder="Passwort">
|
||||||
<button id="ok-button" onclick="performActionIfPasswordCorrect()">OK</button>
|
<button id="ok-button" onclick="deleteRowsIfPasswordCorrect()">OK</button>
|
||||||
<button id="cancel-button" onclick="hidePasswordPrompt()">Abbrechen</button>
|
<button id="cancel-button" onclick="hidePasswordPrompt()">Abbrechen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
10
src/templates/random.html
Normal file
10
src/templates/random.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Bildansicht</title>
|
||||||
|
</head>
|
||||||
|
<body style="margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh;">
|
||||||
|
<img src="../static/images/elo.jpg" alt="Elo Bild" style="max-width: 100%; max-height: 100%;">
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user