From 42a4285e099f68ad3e7b612cd0b92b587c3dd77e Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Mon, 16 Mar 2026 15:37:33 -0700 Subject: [PATCH] Add clear findings button to library maintenance modal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per-job and per-status filtering — respects active toolbar filters so users can clear e.g. only track number findings or only dismissed items. Confirmation uses the app's styled modal instead of browser confirm(). --- core/repair_worker.py | 30 ++++++++++++++++++++++++++++++ web_server.py | 17 +++++++++++++++++ webui/index.html | 1 + webui/static/script.js | 41 +++++++++++++++++++++++++++++++++++++++++ webui/static/style.css | 19 ++++++++++++++++++- 5 files changed, 107 insertions(+), 1 deletion(-) diff --git a/core/repair_worker.py b/core/repair_worker.py index 6cb4eb75..facb4cdf 100644 --- a/core/repair_worker.py +++ b/core/repair_worker.py @@ -1075,6 +1075,36 @@ class RepairWorker: if conn: conn.close() + def clear_findings(self, job_id: str = None, status: str = None) -> int: + """Delete findings from the database. Optionally filter by job_id and/or status. Returns count deleted.""" + conn = None + try: + conn = self.db._get_connection() + cursor = conn.cursor() + conditions = [] + params = [] + if job_id: + conditions.append("job_id = ?") + params.append(job_id) + if status: + conditions.append("status = ?") + params.append(status) + where = f" WHERE {' AND '.join(conditions)}" if conditions else "" + cursor.execute(f"SELECT COUNT(*) FROM repair_findings{where}", params) + count = cursor.fetchone()[0] + cursor.execute(f"DELETE FROM repair_findings{where}", params) + conn.commit() + logger.info("Cleared %d findings%s%s", count, + f" for job {job_id}" if job_id else "", + f" with status {status}" if status else "") + return count + except Exception as e: + logger.error("Error clearing findings: %s", e) + return 0 + finally: + if conn: + conn.close() + def _get_findings_count(self, status: str = None) -> int: """Get count of findings by status.""" conn = None diff --git a/web_server.py b/web_server.py index 16a758be..131fa9d8 100644 --- a/web_server.py +++ b/web_server.py @@ -39031,6 +39031,23 @@ def repair_findings_bulk(): logger.error(f"Error bulk updating findings: {e}") return jsonify({'error': str(e)}), 500 +@app.route('/api/repair/findings/clear', methods=['POST']) +def repair_findings_clear(): + """Clear (delete) findings, optionally filtered by job_id and/or status""" + try: + if repair_worker is None: + return jsonify({'error': 'Repair worker not initialized'}), 400 + + data = request.get_json(silent=True) or {} + job_id = data.get('job_id') + status = data.get('status') + + count = repair_worker.clear_findings(job_id=job_id, status=status) + return jsonify({'success': True, 'deleted': count}), 200 + except Exception as e: + logger.error(f"Error clearing findings: {e}") + return jsonify({'error': str(e)}), 500 + @app.route('/api/repair/history', methods=['GET']) def repair_history(): """Get job run history""" diff --git a/webui/index.html b/webui/index.html index 5dcd17d8..e100db4f 100644 --- a/webui/index.html +++ b/webui/index.html @@ -5774,6 +5774,7 @@ +