From 4eb2c9e71d2c63d4e1ee48d0c8e0a2a5f7291519 Mon Sep 17 00:00:00 2001 From: Erik Thiele Date: Thu, 2 Jul 2026 14:29:03 +0200 Subject: [PATCH] =?UTF-8?q?Einstellungen=20ausgelagert:=20eigene=20Seite?= =?UTF-8?q?=20f=C3=BCr=20Druckerabschreibung,=20Arbeitskosten,=20Gewinnmar?= =?UTF-8?q?ge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Neue /settings-Route mit eigener Seite (Einstellungen für Drucker, Arbeit, Marge) - Settings-Cards aus index.html entfernt - /save_config merged mit bestehenden Werten (kein Überschreiben) - Navigation im Header: Kalkulation ↔ Einstellungen (alle Seiten) - Port auf 5001 geändert (macOS AirPlay blockiert 5000) --- app.py | 27 +++++++-- templates/index.html | 47 ++-------------- templates/invoice.html | 5 ++ templates/settings.html | 118 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 48 deletions(-) create mode 100644 templates/settings.html diff --git a/app.py b/app.py index a59b588..f586255 100644 --- a/app.py +++ b/app.py @@ -124,19 +124,32 @@ def index(): return render_template('index.html', config=config, calc=calc) +@app.route('/settings') +def settings(): + """Einstellungsseite fuer Druckerabschreibung, Arbeitskosten und Marge.""" + config = load_config() + return render_template('settings.html', config=config) + + @app.route('/calculate', methods=['POST']) def calc_json(): - """AJAX-Endpunkt: Nimmt Formular-JSON entgegen, gibt Berechnung zurueck.""" + """AJAX-Endpunkt: Nimmt Formular-JSON entgegen, gibt Berechnung zurueck. + Fehlende Werte werden aus der gespeicherten Config ergaenzt.""" data = request.get_json() - calc = calculate(data) + config = load_config() + merged = {**config, **data} + calc = calculate(merged) return jsonify(calc) @app.route('/save_config', methods=['POST']) def save_config_route(): - """AJAX-Endpunkt: Speichert aktuelle Formularwerte in YAML.""" + """AJAX-Endpunkt: Speichert aktuelle Formularwerte in YAML. + Vorhandene Werte (z.B. aus Einstellungen) werden nicht ueberschrieben.""" data = request.get_json() - save_config(data) + existing = load_config() + existing.update(data) + save_config(existing) return jsonify({'status': 'ok'}) @@ -210,7 +223,9 @@ def invoice_pdf(): def export(): """Exportiert die Kalkulation als TXT-Datei.""" data = request.get_json() - calc = calculate(data) + config = load_config() + merged = {**config, **data} + calc = calculate(merged) lines = [ "3D-DRUCK KOSTENKALKULATION", @@ -239,4 +254,4 @@ def export(): if __name__ == '__main__': - app.run(host='0.0.0.0', debug=True) + app.run(host='0.0.0.0', port=5001, debug=True) diff --git a/templates/index.html b/templates/index.html index 531b3a7..0e024f5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -22,6 +22,11 @@ 3D Druck Kostenkalkulator -
-
Drucker Abschreibung
-
-
- - -
-
- - -
-
- - -
-
-
- -
-
Arbeitskosten
-
-
- - -
-
- - -
-
-
- -
-
Gewinnmarge
-
-
- - -
-
-
- diff --git a/templates/invoice.html b/templates/invoice.html index 70cead7..8ad5e72 100644 --- a/templates/invoice.html +++ b/templates/invoice.html @@ -22,6 +22,11 @@ Rechnung erstellen