""" Simple verification script to check ApexCharts fix was applied """ import os import re def verify_template_fix(): """Verify the admin_evaluation.html template has the ApexCharts fix""" template_path = '/home/ismail/projects/HH/templates/dashboard/admin_evaluation.html' print("Verifying ApexCharts fix in admin_evaluation.html...\n") with open(template_path, 'r') as f: content = f.read() checks = [] # Check 1: window.addEventListener('load') instead of DOMContentLoaded if "window.addEventListener('load'" in content: checks.append(("✓", "Uses window.addEventListener('load')")) else: checks.append(("✗", "Missing window.addEventListener('load')")) # Check 2: ApexCharts availability check if "if (typeof ApexCharts === 'undefined')" in content: checks.append(("✓", "Checks ApexCharts availability")) else: checks.append(("✗", "Missing ApexCharts availability check")) # Check 3: Performance data element check if "if (!performanceDataEl)" in content: checks.append(("✓", "Checks performance data element exists")) else: checks.append(("✗", "Missing performance data element check")) # Check 4: Try-catch blocks for chart initialization try_count = len(re.findall(r'try \{', content)) catch_count = len(re.findall(r'\} catch \(error\)', content)) if try_count >= 6 and catch_count >= 6: checks.append(("✓", f"Has {try_count} try-catch blocks for chart initialization")) else: checks.append(("✗", f"Insufficient try-catch blocks (found {try_count} try, {catch_count} catch)")) # Check 5: Element existence checks before chart creation element_checks = re.findall(r'const \w+ChartEl = document\.querySelector\("#\w+Chart"\);', content) if len(element_checks) >= 6: checks.append(("✓", f"Checks element existence before chart creation ({len(element_checks)} charts)")) else: checks.append(("✗", f"Insufficient element checks (found {len(element_checks)})")) # Check 6: Error logging if "console.error('Error rendering" in content: checks.append(("✓", "Has error logging for chart failures")) else: checks.append(("✗", "Missing error logging")) # Print results print("Verification Results:") print("=" * 60) for status, message in checks: print(f"{status} {message}") # Summary passed = sum(1 for status, _ in checks if status == "✓") total = len(checks) print("\n" + "=" * 60) print(f"Summary: {passed}/{total} checks passed") if passed == total: print("\n✓ All checks passed! ApexCharts fix successfully applied.") return True else: print(f"\n✗ {total - passed} check(s) failed. Please review.") return False if __name__ == '__main__': import sys success = verify_template_fix() sys.exit(0 if success else 1)