diff --git a/modules/hm_qc/routes.py b/modules/hm_qc/routes.py index 4f2725d..1d7bf00 100644 --- a/modules/hm_qc/routes.py +++ b/modules/hm_qc/routes.py @@ -381,6 +381,32 @@ def progress_poll(session_id): return jsonify({'error': str(e)}), 500 +@hm_qc_bp.route('/report/') +def view_report(report_id): + """View a saved QC report by database ID.""" + try: + report = QCReport.query.get(report_id) + if not report: + return render_template('hm_qc/results.html', error='Report not found'), 404 + + # Read the HTML report file + html_content = None + if report.file_path and os.path.exists(report.file_path): + with open(report.file_path, 'r', encoding='utf-8') as f: + html_content = f.read() + + return render_template( + 'hm_qc/view_report.html', + active_tab='hm-qc', + report=report, + html_content=html_content + ) + + except Exception as e: + logger.error(f"Error viewing report {report_id}: {e}") + return render_template('hm_qc/results.html', error=str(e)), 500 + + @hm_qc_bp.route('/results/') def results(session_id): """ diff --git a/modules/hm_qc/templates/hm_qc/index.html b/modules/hm_qc/templates/hm_qc/index.html index ed55ada..82fdf85 100644 --- a/modules/hm_qc/templates/hm_qc/index.html +++ b/modules/hm_qc/templates/hm_qc/index.html @@ -79,6 +79,7 @@ Score Status Date + @@ -99,6 +100,11 @@ {{ report.created_at.strftime('%Y-%m-%d %H:%M') if report.created_at }} + + + View + + {% endfor %} diff --git a/modules/hm_qc/templates/hm_qc/view_report.html b/modules/hm_qc/templates/hm_qc/view_report.html new file mode 100644 index 0000000..6a17f30 --- /dev/null +++ b/modules/hm_qc/templates/hm_qc/view_report.html @@ -0,0 +1,82 @@ +{% extends "base.html" %} + +{% block title %}QC Report - {{ report.filename }}{% endblock %} + +{% block extra_head %} + +{% endblock %} + +{% block content %} +
+
+

QC Report

+ + Back to HM QC + +
+ + +
+
+
+
+
+ {{ '%.0f' % report.score if report.score is not none else '-' }} +
+ + {{ report.status | upper }} + +
+
+
+
+
+
+ + + + + + + + + + + + + +
Filename{{ report.filename }}
Job Number{{ report.job_number or '-' }}
Date{{ report.created_at.strftime('%Y-%m-%d %H:%M:%S') if report.created_at }}
+
+
+
+
+ + + {% if html_content %} +
+
+ Detailed Report +
+
+ +
+
+ {% else %} +
+ + Report file not found on disk. The report may have been generated before the current deployment. +
+ {% endif %} +
+{% endblock %}