169 lines
5.8 KiB
Python
169 lines
5.8 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Verify that admin evaluation template has all chart components.
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
def verify_admin_evaluation_template():
|
|
"""Verify the admin evaluation template has all chart components."""
|
|
print("=" * 70)
|
|
print("Verifying Admin Evaluation Template for Charts")
|
|
print("=" * 70)
|
|
|
|
template_path = '/home/ismail/projects/HH/templates/dashboard/admin_evaluation.html'
|
|
|
|
if not os.path.exists(template_path):
|
|
print(f"\n❌ Template file not found: {template_path}")
|
|
return False
|
|
|
|
with open(template_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
all_checks_passed = True
|
|
|
|
# Check 1: ApexCharts CDN
|
|
print("\n" + "-" * 70)
|
|
print("Check 1: ApexCharts CDN Library")
|
|
print("-" * 70)
|
|
if 'cdn.jsdelivr.net/npm/apexcharts' in content:
|
|
print("✓ ApexCharts CDN imported")
|
|
else:
|
|
print("❌ ApexCharts CDN NOT imported")
|
|
all_checks_passed = False
|
|
|
|
# Check 2: Chart Containers
|
|
print("\n" + "-" * 70)
|
|
print("Check 2: Chart HTML Containers")
|
|
print("-" * 70)
|
|
|
|
chart_containers = [
|
|
'id="complaintSourceChart"',
|
|
'id="complaintStatusChart"',
|
|
'id="complaintActivationChart"',
|
|
'id="complaintResponseChart"',
|
|
'id="inquiryStatusChart"',
|
|
'id="inquiryResponseChart"',
|
|
]
|
|
|
|
chart_names = [
|
|
'Complaint Source Chart',
|
|
'Complaint Status Chart',
|
|
'Complaint Activation Chart',
|
|
'Complaint Response Chart',
|
|
'Inquiry Status Chart',
|
|
'Inquiry Response Chart',
|
|
]
|
|
|
|
for container, name in zip(chart_containers, chart_names):
|
|
if container in content:
|
|
print(f"✓ {name} container found")
|
|
else:
|
|
print(f"❌ {name} container NOT found")
|
|
all_checks_passed = False
|
|
|
|
# Check 3: Performance Data Script
|
|
print("\n" + "-" * 70)
|
|
print("Check 3: Performance Data Script")
|
|
print("-" * 70)
|
|
if 'performanceData' in content:
|
|
print("✓ Performance data script reference found")
|
|
else:
|
|
print("❌ Performance data script reference NOT found")
|
|
all_checks_passed = False
|
|
|
|
# Check 4: Chart Initialization Code
|
|
print("\n" + "-" * 70)
|
|
print("Check 4: Chart Initialization JavaScript")
|
|
print("-" * 70)
|
|
|
|
# Check for the new renderChart helper function
|
|
if 'function renderChart(elementId, options)' in content:
|
|
print("✓ renderChart() helper function defined")
|
|
else:
|
|
print("❌ renderChart() helper function NOT found")
|
|
all_checks_passed = False
|
|
|
|
# Check for renderChart function calls
|
|
render_calls = [
|
|
"renderChart('complaintSourceChart'",
|
|
"renderChart('complaintStatusChart'",
|
|
"renderChart('complaintActivationChart'",
|
|
"renderChart('complaintResponseChart'",
|
|
]
|
|
|
|
for call in render_calls:
|
|
if call in content:
|
|
chart_name = call.split("'")[1]
|
|
print(f"✓ {chart_name} uses renderChart() helper")
|
|
else:
|
|
print(f"❌ renderChart() call NOT found for: {call}")
|
|
all_checks_passed = False
|
|
|
|
# Check 5: DOMContentLoaded Event Listener
|
|
print("\n" + "-" * 70)
|
|
print("Check 5: DOMContentLoaded Event Listener")
|
|
print("-" * 70)
|
|
if 'document.addEventListener(\'DOMContentLoaded\'' in content or \
|
|
'document.addEventListener("DOMContentLoaded"' in content:
|
|
print("✓ DOMContentLoaded event listener found")
|
|
else:
|
|
print("❌ DOMContentLoaded event listener NOT found")
|
|
all_checks_passed = False
|
|
|
|
# Check 5b: Bootstrap Tab Event Listener for Inquiry Charts
|
|
print("\n" + "-" * 70)
|
|
print("Check 5b: Bootstrap Tab Event Listener (Inquiry Charts)")
|
|
print("-" * 70)
|
|
if 'shown.bs.tab' in content and 'inquiries-tab' in content:
|
|
print("✓ Bootstrap tab event listener for inquiry charts found")
|
|
else:
|
|
print("❌ Bootstrap tab event listener for inquiry charts NOT found")
|
|
all_checks_passed = False
|
|
|
|
if 'function renderInquiryCharts()' in content or 'function renderInquiryCharts() {' in content:
|
|
print("✓ renderInquiryCharts() function defined")
|
|
else:
|
|
print("❌ renderInquiryCharts() function NOT found")
|
|
all_checks_passed = False
|
|
|
|
# Check 6: Chart Configuration Options
|
|
print("\n" + "-" * 70)
|
|
print("Check 6: Chart Configuration Options")
|
|
print("-" * 70)
|
|
|
|
config_checks = [
|
|
('chart: { type:', 'Chart type configuration'),
|
|
('series:', 'Chart series data'),
|
|
('labels:', 'Chart labels'),
|
|
('xaxis: { categories:', 'X-axis categories'),
|
|
('colors:', 'Chart colors'),
|
|
]
|
|
|
|
for config_check, description in config_checks:
|
|
if config_check in content:
|
|
print(f"✓ {description} found")
|
|
else:
|
|
print(f"❌ {description} NOT found")
|
|
# This is not critical, so don't fail the check
|
|
|
|
# Summary
|
|
print("\n" + "=" * 70)
|
|
if all_checks_passed:
|
|
print("✅ ALL CRITICAL CHECKS PASSED!")
|
|
print("\nThe admin evaluation template has all necessary chart components:")
|
|
print(" - ApexCharts library imported")
|
|
print(" - 6 chart containers (4 complaints + 2 inquiries)")
|
|
print(" - Performance data script reference")
|
|
print(" - Chart initialization code for all 6 charts")
|
|
print(" - DOMContentLoaded event listener for proper timing")
|
|
print("\nCharts should render correctly when the page loads.")
|
|
else:
|
|
print("❌ SOME CRITICAL CHECKS FAILED - Please review the output above")
|
|
print("=" * 70)
|
|
|
|
return all_checks_passed
|
|
|
|
if __name__ == '__main__':
|
|
success = verify_admin_evaluation_template()
|
|
sys.exit(0 if success else 1) |