5 Commits
0.1.5 ... 0.1.8

Author SHA1 Message Date
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
4 changed files with 29 additions and 8 deletions

View File

@ -20,6 +20,7 @@ app.config.update({
oidc = OpenIDConnect(app)
def calculate_nutrition(food, weight):
try:
conn = psycopg2.connect()
@ -104,7 +105,7 @@ def convert_decimal(value):
@app.route('/add_nutrition', methods=['POST'])
@oidc.accept_token()
@oidc.accept_token(True)
def add_nutrition():
food = request.form.get('food')
kcal = convert_decimal(request.form.get('kcal'))
@ -133,6 +134,12 @@ def add_nutrition():
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 = ProxyFix(app, x_for=1, x_host=1)

View File

@ -72,7 +72,7 @@ tr:nth-child(even) {
}
.selected, tr.selected {
background-color: #e19595; /* Hervorhebung der Auswahl */
background-color: #e5b5b5; /* Hervorhebung der Auswahl */
}
tr:hover:not(.selected) {

View File

@ -154,12 +154,12 @@ function updateTotalNutrition() {
// Durchlaufen aller Zeilen in der Haupttabelle und Addition der Werte
Array.from(document.getElementById('nutrition-table').rows).slice(1).forEach(row => {
totalKcal += parseFloat(row.cells[2].innerText);
totalEw += parseFloat(row.cells[3].innerText);
totalFett += parseFloat(row.cells[4].innerText);
totalKh += parseFloat(row.cells[5].innerText);
totalBst += parseFloat(row.cells[6].innerText);
totalCa += parseFloat(row.cells[7].innerText);
totalKcal += parseFloat(row.cells[4].innerText);
totalEw += parseFloat(row.cells[4].innerText);
totalFett += parseFloat(row.cells[5].innerText);
totalKh += parseFloat(row.cells[6].innerText);
totalBst += parseFloat(row.cells[7].innerText);
totalCa += parseFloat(row.cells[8].innerText);
});
// Rundung und Aktualisierung der Gesamtwerte

View File

@ -13,6 +13,17 @@
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() {
const form = document.getElementById('nutrition-form');
@ -20,6 +31,9 @@
fetch('/add_nutrition', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token
},
body: formData
}).then(response => {
// Behandlung der Serverantwort