diff --git a/app.py b/app.py index 75afff8..689c71d 100644 --- a/app.py +++ b/app.py @@ -316,8 +316,8 @@ def init_journal(): # Default-Werte setzen falls nicht vorhanden con.execute(""" INSERT OR IGNORE INTO app_settings (key, value, updated_at) - VALUES ('app_name', 'Frankenbot', ?), ('theme', 'dark', ?) - """, (datetime.now().isoformat(), datetime.now().isoformat())) + VALUES ('app_name', 'Frankenbot', ?), ('theme', 'dark', ?), ('standup_enabled', '1', ?) + """, (datetime.now().isoformat(), datetime.now().isoformat(), datetime.now().isoformat())) con.commit() con.close() @@ -2611,7 +2611,10 @@ def daily_standup_beat(): sleep_secs = (target - now).total_seconds() logger.info("[DailyStandup] Nächstes Standup um %s (in %.0f Minuten)", target.strftime('%d.%m.%Y %H:%M'), sleep_secs / 60) time.sleep(sleep_secs) - trigger_daily_standup() + if get_app_setting('standup_enabled', '1') == '1': + trigger_daily_standup() + else: + logger.info("[DailyStandup] Standup ist deaktiviert – übersprungen.") except Exception as e: logger.error("[DailyStandup] Fehler: %s", e) time.sleep(60) @@ -2655,7 +2658,8 @@ def index(): # Hole die 5 neuesten Tasks aus DB all_tasks = get_tasks(order='desc') recent_tasks = all_tasks[:5] if all_tasks else [] - return render_template('index.html', agents=AGENTS, recent_tasks=recent_tasks) + standup_enabled = get_app_setting('standup_enabled', '1') == '1' + return render_template('index.html', agents=AGENTS, recent_tasks=recent_tasks, standup_enabled=standup_enabled) @app.route('/chat', methods=['GET', 'POST']) @login_required @@ -3820,6 +3824,34 @@ def api_trigger_standup(): return jsonify({'success': True, 'message': 'Daily Standup wurde gestartet.'}) +@app.route('/api/standup/toggle', methods=['POST']) +@login_required +def api_standup_toggle(): + """Aktiviert oder deaktiviert den täglichen Standup.""" + data = request.get_json() or {} + enabled = data.get('enabled', True) + set_app_setting('standup_enabled', '1' if enabled else '0') + state = 'aktiviert' if enabled else 'deaktiviert' + logger.info("[DailyStandup] Standup %s.", state) + return jsonify({'success': True, 'enabled': enabled, 'message': f'Daily Standup wurde {state}.'}) + + +@app.route('/api/tasks/clear', methods=['POST']) +@login_required +def api_tasks_clear(): + """Löscht alle Tasks aus der Datenbank.""" + try: + con = sqlite3.connect(EMAIL_JOURNAL_DB) + con.execute("DELETE FROM tasks") + con.commit() + con.close() + logger.info("[Tasks] Alle Tasks wurden gelöscht.") + return jsonify({'success': True, 'message': 'Alle Tasks wurden gelöscht.'}) + except Exception as e: + logger.error("[Tasks] Fehler beim Löschen aller Tasks: %s", e) + return jsonify({'success': False, 'message': str(e)}), 500 + + @app.route('/api/broadcast', methods=['POST']) @login_required def api_broadcast(): diff --git a/templates/index.html b/templates/index.html index 743b3bd..9f3aafa 100644 --- a/templates/index.html +++ b/templates/index.html @@ -76,6 +76,34 @@ {% endfor %} + +