Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
e4fe5b9831
|
|||
6a9b938ab9
|
|||
367e76f9f1
|
|||
e59b184da5 |
@ -5,6 +5,7 @@ from werkzeug.middleware.proxy_fix import ProxyFix
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
import logging
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.update({
|
app.config.update({
|
||||||
@ -18,6 +19,7 @@ app.config.update({
|
|||||||
})
|
})
|
||||||
|
|
||||||
oidc = OpenIDConnect(app)
|
oidc = OpenIDConnect(app)
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -105,8 +107,10 @@ def convert_decimal(value):
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/add_nutrition', methods=['POST'])
|
@app.route('/add_nutrition', methods=['POST'])
|
||||||
@oidc.accept_token(True)
|
@oidc.accept_token(['openid'])
|
||||||
def add_nutrition():
|
def add_nutrition():
|
||||||
|
logger.info("add_nutrition")
|
||||||
|
|
||||||
food = request.form.get('food')
|
food = request.form.get('food')
|
||||||
kcal = convert_decimal(request.form.get('kcal'))
|
kcal = convert_decimal(request.form.get('kcal'))
|
||||||
ew = convert_decimal(request.form.get('ew'))
|
ew = convert_decimal(request.form.get('ew'))
|
||||||
@ -132,6 +136,7 @@ def add_nutrition():
|
|||||||
@app.route('/nutrition')
|
@app.route('/nutrition')
|
||||||
@oidc.require_login
|
@oidc.require_login
|
||||||
def nutrition():
|
def nutrition():
|
||||||
|
logger.info("nutrition")
|
||||||
return render_template('nutrition.html')
|
return render_template('nutrition.html')
|
||||||
|
|
||||||
@app.route('/get_token')
|
@app.route('/get_token')
|
||||||
|
@ -174,3 +174,43 @@ tr:hover:not(.selected) {
|
|||||||
#database-nutrition-table tr.selected {
|
#database-nutrition-table tr.selected {
|
||||||
background-color: #f0e68c;
|
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 */
|
||||||
|
}
|
||||||
|
@ -61,8 +61,10 @@
|
|||||||
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();
|
||||||
});
|
});
|
||||||
|
|
||||||
function deleteSelectedRows() {
|
function deleteSelectedRows() {
|
||||||
@ -95,6 +97,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
function loadDatabaseEntries() {
|
||||||
fetch('/get_database_entries') // Pfad zur entsprechenden Flask-Route
|
fetch('/get_database_entries') // Pfad zur entsprechenden Flask-Route
|
||||||
|
Reference in New Issue
Block a user