Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
807f1de774 | |||
677874a0e1 | |||
81fc7ade5f | |||
b941819b73 | |||
dcc1336d62 | |||
99bd1841cb | |||
16f8c23c38 | |||
cb84e3cdc0 | |||
ca734fda32 | |||
4f6d3de79c | |||
bf245e215a | |||
443eb9ef00 | |||
ce38d6cf24 | |||
5c8f057843 |
@ -13,7 +13,8 @@ RUN \
|
|||||||
apk add --no-cache build-base libpq-dev && \
|
apk add --no-cache build-base libpq-dev && \
|
||||||
pip install -r requirements.txt && \
|
pip install -r requirements.txt && \
|
||||||
if [ "${VERSION_ID2}" != "" ]; then VERSION_ID=${VERSION_ID2}; else VERSION_ID=${VERSION_ID1}; fi && \
|
if [ "${VERSION_ID2}" != "" ]; then VERSION_ID=${VERSION_ID2}; else VERSION_ID=${VERSION_ID1}; fi && \
|
||||||
sed -i -e 's/VERSION_ID/'$VERSION_ID'/' ${APP_DIR}/templates/index.html
|
sed -i -e 's/VERSION_ID/'$VERSION_ID'/' ${APP_DIR}/templates/index.html && \
|
||||||
|
sed -i -e 's/VERSION_ID/'"$VERSION_ID"'/' ${APP_DIR}/templates/nutrition.html
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
|
26
src/Run.py
26
src/Run.py
@ -175,8 +175,30 @@ def get_database_entries():
|
|||||||
if conn:
|
if conn:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/delete_nutrition', methods=['POST'])
|
||||||
|
@oidc.accept_token(['openid'])
|
||||||
|
def delete_nutrition():
|
||||||
|
data = request.get_json()
|
||||||
|
foodNames = data['foodNames']
|
||||||
|
|
||||||
|
if not foodNames:
|
||||||
|
return jsonify({'error': 'Keine Lebensmittel zum Löschen angegeben'}), 400
|
||||||
|
|
||||||
|
try:
|
||||||
|
conn = psycopg2.connect()
|
||||||
|
with conn.cursor() as cursor:
|
||||||
|
query = "DELETE FROM nutrition_table WHERE name = ANY(%s)"
|
||||||
|
cursor.execute(query, (foodNames,))
|
||||||
|
conn.commit()
|
||||||
|
return jsonify({'message': 'Erfolgreich gelöscht'}), 200
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': str(e)}), 500
|
||||||
|
finally:
|
||||||
|
if conn:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,13 +46,30 @@ button#remove-button:not(:disabled):hover {
|
|||||||
background-color: #490000; /* Dunkleres Rot */
|
background-color: #490000; /* Dunkleres Rot */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: separate; /* Erlaubt die Anwendung von border-radius */
|
||||||
|
border-spacing: 0;
|
||||||
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table th:first-child {
|
||||||
|
border-top-left-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th:last-child {
|
||||||
|
border-top-right-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr:last-child td:first-child {
|
||||||
|
border-bottom-left-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr:last-child td:last-child {
|
||||||
|
border-bottom-right-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
table, th, td {
|
table, th, td {
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
@ -89,9 +106,20 @@ tr:hover:not(.selected) {
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#navbar .navbar-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
#navbar h1 {
|
#navbar h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navbar .versionid {
|
||||||
|
margin-left: 20px;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#navbar ul {
|
#navbar ul {
|
||||||
@ -113,13 +141,10 @@ tr:hover:not(.selected) {
|
|||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#navbar a:hover {
|
#navbar a:hover, #navbar a.active {
|
||||||
background-color: #007344; /* Etwas helleres Grün */
|
background-color: #007344; /* Etwas helleres Grün */
|
||||||
}
|
}
|
||||||
|
|
||||||
#navbar a.active {
|
|
||||||
background-color: #008C50; /* Mittleres Grün */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
@ -130,10 +155,8 @@ tr:hover:not(.selected) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#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 {
|
#nutrition-input-table th, #nutrition-input-table td {
|
||||||
border: 1px solid #ddd; /* Fügt Ränder hinzu */
|
border: 1px solid #ddd; /* Fügt Ränder hinzu */
|
||||||
@ -153,16 +176,17 @@ tr:hover:not(.selected) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#table-container {
|
.table-container {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
max-height: 400px; /* Passen Sie die Höhe nach Bedarf an */
|
max-height: 500px; /* Passen Sie die Höhe nach Bedarf an */
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#database-nutrition-table {
|
#database-nutrition-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: separate; /* Erlaubt die Anwendung von border-radius */
|
||||||
|
border-spacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#database-nutrition-table th, #database-nutrition-table td {
|
#database-nutrition-table th, #database-nutrition-table td {
|
||||||
@ -183,34 +207,28 @@ tr:hover:not(.selected) {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#password-prompt input[type="password"] {
|
button#delete-row-button {
|
||||||
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 */
|
background-color: #640000; /* Helles Rot */
|
||||||
}
|
}
|
||||||
|
|
||||||
#password-prompt button[type="button"]:hover {
|
button#delete-row-button:disabled {
|
||||||
|
background-color: #cccccc;
|
||||||
|
color: #666666;
|
||||||
|
}
|
||||||
|
|
||||||
|
button#delete-row-button:not(:disabled):hover {
|
||||||
|
background-color: #490000; /* Dunkleres Rot */
|
||||||
|
}
|
||||||
|
|
||||||
|
button#cancel-button {
|
||||||
|
background-color: #640000; /* Helles Rot */
|
||||||
|
}
|
||||||
|
|
||||||
|
button#cancel-button:disabled {
|
||||||
|
background-color: #cccccc;
|
||||||
|
color: #666666;
|
||||||
|
}
|
||||||
|
|
||||||
|
button#cancel-button:not(:disabled):hover {
|
||||||
background-color: #490000; /* Dunkleres Rot */
|
background-color: #490000; /* Dunkleres Rot */
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Nährwertberechnungs-App</title>
|
<title>Elo's Rezept Rechner</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">
|
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
||||||
|
|
||||||
@ -175,9 +175,11 @@ function updateTotalNutrition() {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav id="navbar">
|
<nav id="navbar">
|
||||||
|
<div class="navbar-header">
|
||||||
<h1>Elo's Rezept Rechner</h1>
|
<h1>Elo's Rezept Rechner</h1>
|
||||||
<ul>
|
|
||||||
<li class="versionid">VERSION_ID</li>
|
<li class="versionid">VERSION_ID</li>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
<li><a href="/" class="active">Rechner</a></li>
|
<li><a href="/" class="active">Rechner</a></li>
|
||||||
<li><a href="/nutrition">Neue Lebensmittel</a></li>
|
<li><a href="/nutrition">Neue Lebensmittel</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Neue Lebensmittel hinzufügen</title>
|
<title>Elo's Rezept Rechner</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">
|
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
||||||
|
|
||||||
@ -70,13 +70,33 @@
|
|||||||
|
|
||||||
function deleteSelectedRows() {
|
function deleteSelectedRows() {
|
||||||
const table = document.getElementById('database-nutrition-table');
|
const table = document.getElementById('database-nutrition-table');
|
||||||
Array.from(table.rows).forEach(row => {
|
const selectedRows = Array.from(table.querySelectorAll('tr.selected'));
|
||||||
if (row.classList.contains('selected')) {
|
const foodNames = selectedRows.map(row => row.cells[0].innerText); // Annahme, der Name des Lebensmittels befindet sich in der ersten Zelle
|
||||||
// Logik zum Löschen der Zeile aus der Datenbank
|
|
||||||
|
if (foodNames.length > 0) {
|
||||||
|
// Holen des Tokens und Senden einer Anfrage an das Backend, um die Einträge zu löschen
|
||||||
|
getBearerToken(token => {
|
||||||
|
fetch('/delete_nutrition', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer ' + token
|
||||||
|
},
|
||||||
|
body: JSON.stringify({foodNames: foodNames})
|
||||||
|
}).then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
// Erfolgreich gelöscht, entferne Zeilen aus der Tabelle
|
||||||
|
selectedRows.forEach(row => {
|
||||||
table.deleteRow(row.rowIndex);
|
table.deleteRow(row.rowIndex);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error('Fehler beim Löschen der Datenbank-Einträge');
|
||||||
}
|
}
|
||||||
|
}).catch(error => console.error('Fehler:', error));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function showPasswordPrompt() {
|
function showPasswordPrompt() {
|
||||||
document.getElementById('delete-row-button').style.display = 'none';
|
document.getElementById('delete-row-button').style.display = 'none';
|
||||||
@ -90,7 +110,7 @@
|
|||||||
|
|
||||||
function deleteRowsIfPasswordCorrect() {
|
function deleteRowsIfPasswordCorrect() {
|
||||||
const password = document.getElementById('password-input').value;
|
const password = document.getElementById('password-input').value;
|
||||||
if (password === 'wowmuchsecurity') {
|
if (password === 'geheim') {
|
||||||
deleteSelectedRows(); // Funktion, die die ausgewählten Zeilen löscht
|
deleteSelectedRows(); // Funktion, die die ausgewählten Zeilen löscht
|
||||||
hidePasswordPrompt();
|
hidePasswordPrompt();
|
||||||
} else {
|
} else {
|
||||||
@ -133,18 +153,41 @@
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', loadDatabaseEntries);
|
document.addEventListener('DOMContentLoaded', loadDatabaseEntries);
|
||||||
|
|
||||||
|
function filterTable() {
|
||||||
|
const searchInput = document.getElementById('search-input');
|
||||||
|
const filterText = searchInput.value.toUpperCase();
|
||||||
|
const table = document.getElementById('database-nutrition-table');
|
||||||
|
const rows = table.getElementsByTagName('tr');
|
||||||
|
|
||||||
|
for (let i = 1; i < rows.length; i++) { // Beginnen bei 1, um die Kopfzeile auszulassen
|
||||||
|
const cell = rows[i].getElementsByTagName('td')[0]; // Angenommen, der zu suchende Text befindet sich in der ersten Spalte
|
||||||
|
if (cell) {
|
||||||
|
const textValue = cell.textContent || cell.innerText;
|
||||||
|
if (textValue.toUpperCase().indexOf(filterText) > -1) {
|
||||||
|
rows[i].style.display = ""; // Zeile anzeigen
|
||||||
|
} else {
|
||||||
|
rows[i].style.display = "none"; // Zeile verstecken
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav id="navbar">
|
<nav id="navbar">
|
||||||
|
<div class="navbar-header">
|
||||||
<h1>Elo's Rezept Rechner</h1>
|
<h1>Elo's Rezept Rechner</h1>
|
||||||
|
<li class="versionid">VERSION_ID</li>
|
||||||
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/">Rechner</a></li>
|
<li><a href="/">Rechner</a></li>
|
||||||
<li><a href="/nutrition" class="active">Neue Lebensmittel</a></li>
|
<li><a href="/nutrition" class="active">Neue Lebensmittel</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<form onsubmit="event.preventDefault(); addNutritionEntry();" method="POST" id="nutrition-form">
|
<form onsubmit="event.preventDefault(); addNutritionEntry();" method="POST" id="nutrition-form">
|
||||||
<table id="nutrition-input-table">
|
<table id="nutrition-input-table">
|
||||||
@ -170,7 +213,12 @@ document.addEventListener('DOMContentLoaded', loadDatabaseEntries);
|
|||||||
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div id="table-container">
|
<div class="search-container">
|
||||||
|
<input type="text" id="search-input" placeholder="Lebensmittel suchen..." oninput="filterTable()">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="table-container">
|
||||||
<table id="database-nutrition-table">
|
<table id="database-nutrition-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -192,8 +240,8 @@ document.addEventListener('DOMContentLoaded', loadDatabaseEntries);
|
|||||||
|
|
||||||
<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 onclick="deleteRowsIfPasswordCorrect()">OK</button>
|
<button id="ok-button" onclick="deleteRowsIfPasswordCorrect()">OK</button>
|
||||||
<button onclick="hidePasswordPrompt()">Abbrechen</button>
|
<button id="cancel-button" onclick="hidePasswordPrompt()">Abbrechen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user